From 44cdba785f4db6c1a15eef93af0922a2c91cf1dc Mon Sep 17 00:00:00 2001 From: fengzhe ding <76160279+Mitse1n@users.noreply.github.com> Date: Wed, 18 Sep 2024 15:14:23 +0800 Subject: [PATCH] [Release] sdk/resourcemanager/billing/armbilling/1.0.0 (#23450) * billing release 2024-04-01 * add files * delete unused imported packages --------- Co-authored-by: fz --- .../billing/armbilling/CHANGELOG.md | 705 + .../billing/armbilling/accounts_client.go | 364 +- .../accounts_client_example_test.go | 1386 +- .../billing/armbilling/address_client.go | 18 +- .../armbilling/address_client_example_test.go | 22 +- .../billing/armbilling/agreements_client.go | 20 +- .../agreements_client_example_test.go | 117 +- .../armbilling/associatedtenants_client.go | 332 + .../associatedtenants_client_example_test.go | 172 + .../billing/armbilling/autorest.md | 7 +- .../armbilling/availablebalances_client.go | 106 +- .../availablebalances_client_example_test.go | 87 +- .../billing/armbilling/client_factory.go | 198 +- .../billing/armbilling/constants.go | 1724 ++- .../billing/armbilling/customers_client.go | 140 +- .../customers_client_example_test.go | 287 +- .../billing/armbilling/date_type.go | 6 +- .../billing/armbilling/departments_client.go | 175 + .../departments_client_example_test.go | 101 + .../armbilling/enrollmentaccounts_client.go | 247 +- .../enrollmentaccounts_client_example_test.go | 199 +- .../armbilling/fake/accounts_server.go | 328 +- .../billing/armbilling/fake/address_server.go | 7 +- .../armbilling/fake/agreements_server.go | 23 +- .../fake/associatedtenants_server.go | 330 + .../fake/availablebalances_server.go | 58 +- .../armbilling/fake/customers_server.go | 189 +- .../billing/armbilling/fake/date_type.go | 6 +- .../armbilling/fake/departments_server.go | 204 + .../fake/enrollmentaccounts_server.go | 294 +- .../armbilling/fake/instructions_server.go | 203 - .../billing/armbilling/fake/internal.go | 11 +- .../armbilling/fake/invoices_server.go | 597 +- .../armbilling/fake/invoicesections_server.go | 187 +- .../armbilling/fake/operations_server.go | 3 +- .../fake/partnertransfers_server.go | 263 + .../armbilling/fake/paymentmethods_server.go | 346 + .../billing/armbilling/fake/periods_server.go | 174 - .../armbilling/fake/permissions_server.go | 483 +- .../armbilling/fake/policies_server.go | 356 +- .../armbilling/fake/products_server.go | 350 +- .../armbilling/fake/profiles_server.go | 187 +- .../armbilling/fake/property_server.go | 33 +- .../fake/recipienttransfers_server.go | 248 + .../armbilling/fake/requests_server.go | 703 + .../fake/reservationorders_server.go | 195 + .../armbilling/fake/reservations_server.go | 265 +- .../armbilling/fake/roleassignments_server.go | 1339 +- .../armbilling/fake/roledefinition_server.go | 625 + .../armbilling/fake/roledefinitions_server.go | 340 - .../fake/savingsplanorders_server.go | 195 + .../armbilling/fake/savingsplans_server.go | 382 + .../billing/armbilling/fake/server_factory.go | 170 +- .../armbilling/fake/subscriptions_server.go | 1089 +- .../fake/subscriptionsaliases_server.go | 278 + .../billing/armbilling/fake/time_rfc3339.go | 45 +- .../armbilling/fake/transactions_server.go | 614 +- .../armbilling/fake/transfers_server.go | 263 + .../billing/armbilling/instructions_client.go | 236 - .../instructions_client_example_test.go | 135 - .../billing/armbilling/invoices_client.go | 543 +- .../invoices_client_example_test.go | 1602 +-- .../armbilling/invoicesections_client.go | 197 +- .../invoicesections_client_example_test.go | 237 +- .../billing/armbilling/models.go | 5320 ++++++-- .../billing/armbilling/models_serde.go | 11260 +++++++++++++--- .../billing/armbilling/operations_client.go | 9 +- .../operations_client_example_test.go | 54 + .../billing/armbilling/options.go | 1813 ++- .../armbilling/partnertransfers_client.go | 328 + .../partnertransfers_client_example_test.go | 190 + .../armbilling/paymentmethods_client.go | 444 + .../paymentmethods_client_example_test.go | 316 + .../billing/armbilling/periods_client.go | 171 - .../armbilling/periods_client_example_test.go | 93 - .../billing/armbilling/permissions_client.go | 655 +- .../permissions_client_example_test.go | 394 +- .../billing/armbilling/policies_client.go | 525 +- .../policies_client_example_test.go | 252 +- .../billing/armbilling/products_client.go | 228 +- .../products_client_example_test.go | 624 +- .../billing/armbilling/profiles_client.go | 200 +- .../profiles_client_example_test.go | 762 +- .../billing/armbilling/property_client.go | 34 +- .../property_client_example_test.go | 239 +- .../armbilling/recipienttransfers_client.go | 325 + .../recipienttransfers_client_example_test.go | 255 + .../billing/armbilling/requests_client.go | 560 + .../requests_client_example_test.go | 557 + .../armbilling/reservationorders_client.go | 172 + .../reservationorders_client_example_test.go | 540 + .../billing/armbilling/reservations_client.go | 254 +- .../reservations_client_example_test.go | 788 +- .../billing/armbilling/response_types.go | 489 - .../billing/armbilling/responses.go | 1125 ++ .../armbilling/roleassignments_client.go | 1937 ++- .../roleassignments_client_example_test.go | 1090 +- .../armbilling/roledefinition_client.go | 827 ++ .../roledefinition_client_example_test.go | 986 ++ .../armbilling/roledefinitions_client.go | 428 - .../roledefinitions_client_example_test.go | 508 - .../armbilling/savingsplanorders_client.go | 172 + .../savingsplanorders_client_example_test.go | 495 + .../billing/armbilling/savingsplans_client.go | 399 + .../savingsplans_client_example_test.go | 707 + .../armbilling/subscriptions_client.go | 883 +- .../subscriptions_client_example_test.go | 1086 +- .../armbilling/subscriptionsaliases_client.go | 261 + ...ubscriptionsaliases_client_example_test.go | 286 + .../billing/armbilling/time_rfc3339.go | 45 +- .../billing/armbilling/transactions_client.go | 445 +- .../transactions_client_example_test.go | 596 +- .../billing/armbilling/transfers_client.go | 326 + .../transfers_client_example_test.go | 186 + 114 files changed, 50364 insertions(+), 11021 deletions(-) create mode 100644 sdk/resourcemanager/billing/armbilling/associatedtenants_client.go create mode 100644 sdk/resourcemanager/billing/armbilling/associatedtenants_client_example_test.go create mode 100644 sdk/resourcemanager/billing/armbilling/departments_client.go create mode 100644 sdk/resourcemanager/billing/armbilling/departments_client_example_test.go create mode 100644 sdk/resourcemanager/billing/armbilling/fake/associatedtenants_server.go create mode 100644 sdk/resourcemanager/billing/armbilling/fake/departments_server.go delete mode 100644 sdk/resourcemanager/billing/armbilling/fake/instructions_server.go create mode 100644 sdk/resourcemanager/billing/armbilling/fake/partnertransfers_server.go create mode 100644 sdk/resourcemanager/billing/armbilling/fake/paymentmethods_server.go delete mode 100644 sdk/resourcemanager/billing/armbilling/fake/periods_server.go create mode 100644 sdk/resourcemanager/billing/armbilling/fake/recipienttransfers_server.go create mode 100644 sdk/resourcemanager/billing/armbilling/fake/requests_server.go create mode 100644 sdk/resourcemanager/billing/armbilling/fake/reservationorders_server.go create mode 100644 sdk/resourcemanager/billing/armbilling/fake/roledefinition_server.go delete mode 100644 sdk/resourcemanager/billing/armbilling/fake/roledefinitions_server.go create mode 100644 sdk/resourcemanager/billing/armbilling/fake/savingsplanorders_server.go create mode 100644 sdk/resourcemanager/billing/armbilling/fake/savingsplans_server.go create mode 100644 sdk/resourcemanager/billing/armbilling/fake/subscriptionsaliases_server.go create mode 100644 sdk/resourcemanager/billing/armbilling/fake/transfers_server.go delete mode 100644 sdk/resourcemanager/billing/armbilling/instructions_client.go delete mode 100644 sdk/resourcemanager/billing/armbilling/instructions_client_example_test.go create mode 100644 sdk/resourcemanager/billing/armbilling/operations_client_example_test.go create mode 100644 sdk/resourcemanager/billing/armbilling/partnertransfers_client.go create mode 100644 sdk/resourcemanager/billing/armbilling/partnertransfers_client_example_test.go create mode 100644 sdk/resourcemanager/billing/armbilling/paymentmethods_client.go create mode 100644 sdk/resourcemanager/billing/armbilling/paymentmethods_client_example_test.go delete mode 100644 sdk/resourcemanager/billing/armbilling/periods_client.go delete mode 100644 sdk/resourcemanager/billing/armbilling/periods_client_example_test.go create mode 100644 sdk/resourcemanager/billing/armbilling/recipienttransfers_client.go create mode 100644 sdk/resourcemanager/billing/armbilling/recipienttransfers_client_example_test.go create mode 100644 sdk/resourcemanager/billing/armbilling/requests_client.go create mode 100644 sdk/resourcemanager/billing/armbilling/requests_client_example_test.go create mode 100644 sdk/resourcemanager/billing/armbilling/reservationorders_client.go create mode 100644 sdk/resourcemanager/billing/armbilling/reservationorders_client_example_test.go delete mode 100644 sdk/resourcemanager/billing/armbilling/response_types.go create mode 100644 sdk/resourcemanager/billing/armbilling/responses.go create mode 100644 sdk/resourcemanager/billing/armbilling/roledefinition_client.go create mode 100644 sdk/resourcemanager/billing/armbilling/roledefinition_client_example_test.go delete mode 100644 sdk/resourcemanager/billing/armbilling/roledefinitions_client.go delete mode 100644 sdk/resourcemanager/billing/armbilling/roledefinitions_client_example_test.go create mode 100644 sdk/resourcemanager/billing/armbilling/savingsplanorders_client.go create mode 100644 sdk/resourcemanager/billing/armbilling/savingsplanorders_client_example_test.go create mode 100644 sdk/resourcemanager/billing/armbilling/savingsplans_client.go create mode 100644 sdk/resourcemanager/billing/armbilling/savingsplans_client_example_test.go create mode 100644 sdk/resourcemanager/billing/armbilling/subscriptionsaliases_client.go create mode 100644 sdk/resourcemanager/billing/armbilling/subscriptionsaliases_client_example_test.go create mode 100644 sdk/resourcemanager/billing/armbilling/transfers_client.go create mode 100644 sdk/resourcemanager/billing/armbilling/transfers_client_example_test.go diff --git a/sdk/resourcemanager/billing/armbilling/CHANGELOG.md b/sdk/resourcemanager/billing/armbilling/CHANGELOG.md index 81ee2fd4f63c..9cee70e4140c 100644 --- a/sdk/resourcemanager/billing/armbilling/CHANGELOG.md +++ b/sdk/resourcemanager/billing/armbilling/CHANGELOG.md @@ -1,5 +1,710 @@ # Release History +## 1.0.0 (2024-09-09) +### Breaking Changes + +- Function `*AccountsClient.BeginUpdate` parameter(s) have been changed from `(context.Context, string, AccountUpdateRequest, *AccountsClientBeginUpdateOptions)` to `(context.Context, string, AccountPatch, *AccountsClientBeginUpdateOptions)` +- Function `*CustomersClient.Get` parameter(s) have been changed from `(context.Context, string, string, *CustomersClientGetOptions)` to `(context.Context, string, string, string, *CustomersClientGetOptions)` +- Function `*EnrollmentAccountsClient.Get` parameter(s) have been changed from `(context.Context, string, *EnrollmentAccountsClientGetOptions)` to `(context.Context, string, string, *EnrollmentAccountsClientGetOptions)` +- Function `*InvoicesClient.Get` parameter(s) have been changed from `(context.Context, string, string, *InvoicesClientGetOptions)` to `(context.Context, string, *InvoicesClientGetOptions)` +- Function `*InvoicesClient.NewListByBillingAccountPager` parameter(s) have been changed from `(string, string, string, *InvoicesClientListByBillingAccountOptions)` to `(string, *InvoicesClientListByBillingAccountOptions)` +- Function `*InvoicesClient.NewListByBillingProfilePager` parameter(s) have been changed from `(string, string, string, string, *InvoicesClientListByBillingProfileOptions)` to `(string, string, *InvoicesClientListByBillingProfileOptions)` +- Function `*InvoicesClient.NewListByBillingSubscriptionPager` parameter(s) have been changed from `(string, string, *InvoicesClientListByBillingSubscriptionOptions)` to `(*InvoicesClientListByBillingSubscriptionOptions)` +- Function `*PermissionsClient.NewListByCustomerPager` parameter(s) have been changed from `(string, string, *PermissionsClientListByCustomerOptions)` to `(string, string, string, *PermissionsClientListByCustomerOptions)` +- Function `NewPoliciesClient` parameter(s) have been changed from `(azcore.TokenCredential, *arm.ClientOptions)` to `(string, azcore.TokenCredential, *arm.ClientOptions)` +- Function `*PoliciesClient.GetByCustomer` parameter(s) have been changed from `(context.Context, string, string, *PoliciesClientGetByCustomerOptions)` to `(context.Context, string, string, string, ServiceDefinedResourceName, *PoliciesClientGetByCustomerOptions)` +- Function `*ProductsClient.Update` parameter(s) have been changed from `(context.Context, string, string, Product, *ProductsClientUpdateOptions)` to `(context.Context, string, string, ProductPatch, *ProductsClientUpdateOptions)` +- Function `NewSubscriptionsClient` parameter(s) have been changed from `(string, azcore.TokenCredential, *arm.ClientOptions)` to `(azcore.TokenCredential, *arm.ClientOptions)` +- Function `*SubscriptionsClient.BeginMove` parameter(s) have been changed from `(context.Context, string, TransferBillingSubscriptionRequestProperties, *SubscriptionsClientBeginMoveOptions)` to `(context.Context, string, string, MoveBillingSubscriptionRequest, *SubscriptionsClientBeginMoveOptions)` +- Function `*SubscriptionsClient.Get` parameter(s) have been changed from `(context.Context, string, *SubscriptionsClientGetOptions)` to `(context.Context, string, string, *SubscriptionsClientGetOptions)` +- Function `*SubscriptionsClient.NewListByCustomerPager` parameter(s) have been changed from `(string, string, *SubscriptionsClientListByCustomerOptions)` to `(string, string, string, *SubscriptionsClientListByCustomerOptions)` +- Type of `AccountProperties.EnrollmentDetails` has been changed from `*Enrollment` to `*AccountPropertiesEnrollmentDetails` +- Type of `AccountProperties.SoldTo` has been changed from `*AddressDetails` to `*AccountPropertiesSoldTo` +- Type of `AgreementProperties.BillingProfileInfo` has been changed from `*ProfileInfo` to `[]*ProfileInfo` +- Type of `AgreementProperties.Participants` has been changed from `[]*Participants` to `[]*Participant` +- Type of `AvailableBalanceProperties.Amount` has been changed from `*Amount` to `*AvailableBalancePropertiesAmount` +- Type of `CustomerPolicyProperties.ViewCharges` has been changed from `*ViewCharges` to `*ViewChargesPolicy` +- Type of `EnrollmentAccountListResult.Value` has been changed from `[]*EnrollmentAccountSummary` to `[]*EnrollmentAccount` +- Type of `ErrorResponse.Error` has been changed from `*ErrorDetails` to `*ErrorDetail` +- Type of `InvoiceProperties.AmountDue` has been changed from `*Amount` to `*InvoicePropertiesAmountDue` +- Type of `InvoiceProperties.AzurePrepaymentApplied` has been changed from `*Amount` to `*InvoicePropertiesAzurePrepaymentApplied` +- Type of `InvoiceProperties.BilledAmount` has been changed from `*Amount` to `*InvoicePropertiesBilledAmount` +- Type of `InvoiceProperties.CreditAmount` has been changed from `*Amount` to `*InvoicePropertiesCreditAmount` +- Type of `InvoiceProperties.Documents` has been changed from `[]*Document` to `[]*InvoiceDocument` +- Type of `InvoiceProperties.FreeAzureCreditApplied` has been changed from `*Amount` to `*InvoicePropertiesFreeAzureCreditApplied` +- Type of `InvoiceProperties.Payments` has been changed from `[]*PaymentProperties` to `[]*Payment` +- Type of `InvoiceProperties.RebillDetails` has been changed from `map[string]*RebillDetails` to `*InvoicePropertiesRebillDetails` +- Type of `InvoiceProperties.SubTotal` has been changed from `*Amount` to `*InvoicePropertiesSubTotal` +- Type of `InvoiceProperties.TaxAmount` has been changed from `*Amount` to `*InvoicePropertiesTaxAmount` +- Type of `InvoiceProperties.TotalAmount` has been changed from `*Amount` to `*InvoicePropertiesTotalAmount` +- Type of `InvoiceSectionProperties.TargetCloud` has been changed from `*TargetCloud` to `*string` +- Type of `InvoiceSectionWithCreateSubPermission.BillingProfileSpendingLimit` has been changed from `*SpendingLimitForBillingProfile` to `*SpendingLimit` +- Type of `InvoiceSectionWithCreateSubPermission.BillingProfileStatusReasonCode` has been changed from `*StatusReasonCodeForBillingProfile` to `*BillingProfileStatusReasonCode` +- Type of `ProductProperties.BillingFrequency` has been changed from `*BillingFrequency` to `*string` +- Type of `ProductProperties.EndDate` has been changed from `*time.Time` to `*string` +- Type of `ProductProperties.LastCharge` has been changed from `*Amount` to `*ProductPropertiesLastCharge` +- Type of `ProductProperties.LastChargeDate` has been changed from `*time.Time` to `*string` +- Type of `ProductProperties.PurchaseDate` has been changed from `*time.Time` to `*string` +- Type of `ProductProperties.Quantity` has been changed from `*float32` to `*int64` +- Type of `ProductProperties.Reseller` has been changed from `*Reseller` to `*ProductPropertiesReseller` +- Type of `ProductProperties.Status` has been changed from `*ProductStatusType` to `*ProductStatus` +- Type of `ProfileProperties.BillTo` has been changed from `*AddressDetails` to `*ProfilePropertiesBillTo` +- Type of `ProfileProperties.IndirectRelationshipInfo` has been changed from `*IndirectRelationshipInfo` to `*ProfilePropertiesIndirectRelationshipInfo` +- Type of `ProfileProperties.StatusReasonCode` has been changed from `*StatusReasonCode` to `*BillingProfileStatusReasonCode` +- Type of `ProfileProperties.TargetClouds` has been changed from `[]*TargetCloud` to `[]*string` +- Type of `PropertyProperties.BillingProfileSpendingLimit` has been changed from `*BillingProfileSpendingLimit` to `*SpendingLimit` +- Type of `RebillDetails.RebillDetails` has been changed from `map[string]*RebillDetails` to `*RebillDetails` +- Type of `ReservationProperty.EffectiveDateTime` has been changed from `*string` to `*time.Time` +- Type of `RoleAssignmentProperties.CreatedOn` has been changed from `*string` to `*time.Time` +- Type of `RoleDefinitionProperties.Permissions` has been changed from `[]*PermissionsProperties` to `[]*Permission` +- Type of `TransactionProperties.AzureCreditApplied` has been changed from `*Amount` to `*TransactionPropertiesAzureCreditApplied` +- Type of `TransactionProperties.EffectivePrice` has been changed from `*Amount` to `*TransactionPropertiesEffectivePrice` +- Type of `TransactionProperties.Kind` has been changed from `*TransactionTypeKind` to `*TransactionKind` +- Type of `TransactionProperties.MarketPrice` has been changed from `*Amount` to `*TransactionPropertiesMarketPrice` +- Type of `TransactionProperties.SubTotal` has been changed from `*Amount` to `*TransactionPropertiesSubTotal` +- Type of `TransactionProperties.Tax` has been changed from `*Amount` to `*TransactionPropertiesTax` +- Type of `TransactionProperties.TransactionAmount` has been changed from `*Amount` to `*TransactionPropertiesTransactionAmount` +- Type of `TransactionProperties.TransactionType` has been changed from `*ReservationType` to `*string` +- `InvoiceTypeAzureService` from enum `InvoiceType` has been removed +- `SubscriptionTransferValidationErrorCodeNotAvailableForDestinationMarket` from enum `SubscriptionTransferValidationErrorCode` has been removed +- Enum `BillingFrequency` has been removed +- Enum `BillingProfileSpendingLimit` has been removed +- Enum `BillingSubscriptionStatusType` has been removed +- Enum `DocumentType` has been removed +- Enum `ProductStatusType` has been removed +- Enum `ProductTransferValidationErrorCode` has been removed +- Enum `ReservationType` has been removed +- Enum `SpendingLimitForBillingProfile` has been removed +- Enum `StatusReasonCode` has been removed +- Enum `StatusReasonCodeForBillingProfile` has been removed +- Enum `TargetCloud` has been removed +- Enum `TransactionTypeKind` has been removed +- Enum `ViewCharges` has been removed +- Function `*AvailableBalancesClient.Get` has been removed +- Function `*ClientFactory.NewInstructionsClient` has been removed +- Function `*ClientFactory.NewPeriodsClient` has been removed +- Function `*ClientFactory.NewRoleDefinitionsClient` has been removed +- Function `*EnrollmentAccountsClient.NewListPager` has been removed +- Function `NewInstructionsClient` has been removed +- Function `*InstructionsClient.Get` has been removed +- Function `*InstructionsClient.NewListByBillingProfilePager` has been removed +- Function `*InstructionsClient.Put` has been removed +- Function `*InvoicesClient.BeginDownloadBillingSubscriptionInvoice` has been removed +- Function `*InvoicesClient.BeginDownloadInvoice` has been removed +- Function `*InvoicesClient.BeginDownloadMultipleBillingProfileInvoices` has been removed +- Function `*InvoicesClient.BeginDownloadMultipleBillingSubscriptionInvoices` has been removed +- Function `*InvoicesClient.GetByID` has been removed +- Function `*InvoicesClient.GetBySubscriptionAndInvoiceID` has been removed +- Function `NewPeriodsClient` has been removed +- Function `*PeriodsClient.Get` has been removed +- Function `*PeriodsClient.NewListPager` has been removed +- Function `*PermissionsClient.NewListByInvoiceSectionsPager` has been removed +- Function `*PoliciesClient.Update` has been removed +- Function `*PoliciesClient.UpdateCustomer` has been removed +- Function `*ProductsClient.ValidateMove` has been removed +- Function `NewRoleDefinitionsClient` has been removed +- Function `*RoleDefinitionsClient.GetByBillingAccount` has been removed +- Function `*RoleDefinitionsClient.GetByBillingProfile` has been removed +- Function `*RoleDefinitionsClient.GetByInvoiceSection` has been removed +- Function `*RoleDefinitionsClient.NewListByBillingAccountPager` has been removed +- Function `*RoleDefinitionsClient.NewListByBillingProfilePager` has been removed +- Function `*RoleDefinitionsClient.NewListByInvoiceSectionPager` has been removed +- Function `*SubscriptionsClient.ValidateMove` has been removed +- Operation `*ProductsClient.Move` has been changed to LRO, use `*ProductsClient.BeginMove` instead. +- Operation `*SubscriptionsClient.Update` has been changed to LRO, use `*SubscriptionsClient.BeginUpdate` instead. +- Struct `AccountUpdateRequest` has been removed +- Struct `Document` has been removed +- Struct `DownloadURL` has been removed +- Struct `Enrollment` has been removed +- Struct `EnrollmentAccountContext` has been removed +- Struct `EnrollmentAccountSummary` has been removed +- Struct `EnrollmentAccountSummaryProperties` has been removed +- Struct `EnrollmentPolicies` has been removed +- Struct `ErrorDetails` has been removed +- Struct `ErrorSubDetailsItem` has been removed +- Struct `Instruction` has been removed +- Struct `InstructionListResult` has been removed +- Struct `InstructionProperties` has been removed +- Struct `InvoiceSectionCreationRequest` has been removed +- Struct `InvoiceSectionListWithCreateSubPermissionResult` has been removed +- Struct `InvoiceSectionsOnExpand` has been removed +- Struct `OperationsErrorDetails` has been removed +- Struct `OperationsErrorResponse` has been removed +- Struct `Participants` has been removed +- Struct `PaymentProperties` has been removed +- Struct `Period` has been removed +- Struct `PeriodProperties` has been removed +- Struct `PeriodsListResult` has been removed +- Struct `PermissionsListResult` has been removed +- Struct `PermissionsProperties` has been removed +- Struct `Policy` has been removed +- Struct `PolicyProperties` has been removed +- Struct `ProductsListResult` has been removed +- Struct `ProfileCreationRequest` has been removed +- Struct `ProfilesOnExpand` has been removed +- Struct `SubscriptionsListResult` has been removed +- Struct `TransferBillingSubscriptionRequestProperties` has been removed +- Struct `TransferProductRequestProperties` has been removed +- Struct `ValidateAddressResponse` has been removed +- Struct `ValidateProductTransferEligibilityError` has been removed +- Struct `ValidateProductTransferEligibilityResult` has been removed +- Struct `ValidateSubscriptionTransferEligibilityError` has been removed +- Struct `ValidateSubscriptionTransferEligibilityResult` has been removed +- Field `BillingProfiles`, `Departments`, `EnrollmentAccounts` of struct `AccountProperties` has been removed +- Field `Expand` of struct `AccountsClientGetOptions` has been removed +- Field `InvoiceSectionListWithCreateSubPermissionResult` of struct `AccountsClientListInvoiceSectionsByCreateSubscriptionPermissionResponse` has been removed +- Field `ValidateAddressResponse` of struct `AddressClientValidateResponse` has been removed +- Field `Expand` of struct `AgreementsClientGetOptions` has been removed +- Field `TotalCount` of struct `CustomerListResult` has been removed +- Field `Expand` of struct `CustomersClientGetOptions` has been removed +- Field `DepartmentName`, `EnrollmentAccounts` of struct `DepartmentProperties` has been removed +- Field `AccountName`, `AccountOwnerEmail`, `Department` of struct `EnrollmentAccountProperties` has been removed +- Field `EnrollmentAccountSummary` of struct `EnrollmentAccountsClientGetResponse` has been removed +- Field `TotalCount` of struct `InvoiceListResult` has been removed +- Field `TotalCount` of struct `InvoiceSectionListResult` has been removed +- Field `Labels` of struct `InvoiceSectionProperties` has been removed +- Field `PermissionsListResult` of struct `PermissionsClientListByBillingAccountResponse` has been removed +- Field `PermissionsListResult` of struct `PermissionsClientListByBillingProfileResponse` has been removed +- Field `PermissionsListResult` of struct `PermissionsClientListByCustomerResponse` has been removed +- Field `Policy` of struct `PoliciesClientGetByBillingProfileResponse` has been removed +- Field `ProductsListResult` of struct `ProductsClientListByBillingAccountResponse` has been removed +- Field `ProductsListResult` of struct `ProductsClientListByBillingProfileResponse` has been removed +- Field `ProductsListResult` of struct `ProductsClientListByCustomerResponse` has been removed +- Field `ProductsListResult` of struct `ProductsClientListByInvoiceSectionResponse` has been removed +- Field `TotalCount` of struct `ProfileListResult` has been removed +- Field `InvoiceSections` of struct `ProfileProperties` has been removed +- Field `Expand` of struct `ProfilesClientGetOptions` has been removed +- Field `Expand` of struct `ProfilesClientListByBillingAccountOptions` has been removed +- Field `Orderby` of struct `ReservationsClientListByBillingAccountOptions` has been removed +- Field `Orderby` of struct `ReservationsClientListByBillingProfileOptions` has been removed +- Field `RoleAssignment` of struct `RoleAssignmentsClientDeleteByBillingAccountResponse` has been removed +- Field `RoleAssignment` of struct `RoleAssignmentsClientDeleteByBillingProfileResponse` has been removed +- Field `RoleAssignment` of struct `RoleAssignmentsClientDeleteByInvoiceSectionResponse` has been removed +- Field `CostCenter`, `SubscriptionBillingStatus` of struct `SubscriptionProperties` has been removed +- Field `SubscriptionsListResult` of struct `SubscriptionsClientListByBillingAccountResponse` has been removed +- Field `SubscriptionsListResult` of struct `SubscriptionsClientListByBillingProfileResponse` has been removed +- Field `SubscriptionsListResult` of struct `SubscriptionsClientListByCustomerResponse` has been removed +- Field `SubscriptionsListResult` of struct `SubscriptionsClientListByInvoiceSectionResponse` has been removed +- Field `TotalCount` of struct `TransactionListResult` has been removed +- Field `OrderID`, `OrderName`, `SubscriptionID`, `SubscriptionName` of struct `TransactionProperties` has been removed + +### Features Added + +- Type of `TransactionProperties.BillingProfileDisplayName` has been changed from `*string` to `any` +- New value `AcceptanceModeImplicit`, `AcceptanceModeOffline`, `AcceptanceModeOther`, `AcceptanceModePhysicalSign` added to enum type `AcceptanceMode` +- New value `AccountStatusNew`, `AccountStatusOther`, `AccountStatusPending`, `AccountStatusUnderReview` added to enum type `AccountStatus` +- New value `AccountTypeBusiness`, `AccountTypeClassicPartner`, `AccountTypeInternal`, `AccountTypeOther`, `AccountTypeReseller`, `AccountTypeTenant` added to enum type `AccountType` +- New value `AddressValidationStatusOther` added to enum type `AddressValidationStatus` +- New value `AgreementTypeOther` added to enum type `AgreementType` +- New value `BillingProfileStatusDeleted`, `BillingProfileStatusOther`, `BillingProfileStatusUnderReview` added to enum type `BillingProfileStatus` +- New value `BillingProfileStatusReasonCodeOther`, `BillingProfileStatusReasonCodeUnusualActivity` added to enum type `BillingProfileStatusReasonCode` +- New value `BillingRelationshipTypeCSPCustomer`, `BillingRelationshipTypeOther` added to enum type `BillingRelationshipType` +- New value `CategoryIndirectForGovernmentAgreement`, `CategoryMicrosoftPartnerAgreement`, `CategoryUKCloudComputeFramework` added to enum type `Category` +- New value `DocumentSourceOther` added to enum type `DocumentSource` +- New value `InvoiceDocumentTypeOther`, `InvoiceDocumentTypeSummary`, `InvoiceDocumentTypeTaxReceipt`, `InvoiceDocumentTypeTransactions`, `InvoiceDocumentTypeVoidNote` added to enum type `InvoiceDocumentType` +- New value `InvoiceSectionStateDeleted`, `InvoiceSectionStateDisabled`, `InvoiceSectionStateOther`, `InvoiceSectionStateUnderReview`, `InvoiceSectionStateWarned` added to enum type `InvoiceSectionState` +- New value `InvoiceStatusLocked`, `InvoiceStatusOther` added to enum type `InvoiceStatus` +- New value `InvoiceTypeAzureServices`, `InvoiceTypeOther` added to enum type `InvoiceType` +- New value `MarketplacePurchasesPolicyDisabled`, `MarketplacePurchasesPolicyOther` added to enum type `MarketplacePurchasesPolicy` +- New value `PaymentMethodFamilyDirectDebit`, `PaymentMethodFamilyEWallet`, `PaymentMethodFamilyOther`, `PaymentMethodFamilyTaskOrder` added to enum type `PaymentMethodFamily` +- New value `ReservationPurchasesPolicyDisabled`, `ReservationPurchasesPolicyOther` added to enum type `ReservationPurchasesPolicy` +- New value `SubscriptionTransferValidationErrorCodeAccountIsLocked`, `SubscriptionTransferValidationErrorCodeAssetHasCap`, `SubscriptionTransferValidationErrorCodeAssetNotActive`, `SubscriptionTransferValidationErrorCodeBillingProfilePastDue`, `SubscriptionTransferValidationErrorCodeInvoiceSectionIsRestricted`, `SubscriptionTransferValidationErrorCodeNoActiveAzurePlan`, `SubscriptionTransferValidationErrorCodeNone`, `SubscriptionTransferValidationErrorCodeOther`, `SubscriptionTransferValidationErrorCodeSubscriptionHasReservations` added to enum type `SubscriptionTransferValidationErrorCode` +- New value `ViewChargesPolicyOther` added to enum type `ViewChargesPolicy` +- New enum type `AccessDecision` with values `AccessDecisionAllowed`, `AccessDecisionNotAllowed`, `AccessDecisionOther` +- New enum type `AccountSubType` with values `AccountSubTypeEnterprise`, `AccountSubTypeIndividual`, `AccountSubTypeNone`, `AccountSubTypeOther`, `AccountSubTypeProfessional` +- New enum type `AppliedScopeType` with values `AppliedScopeTypeManagementGroup`, `AppliedScopeTypeShared`, `AppliedScopeTypeSingle` +- New enum type `BillingAccountStatusReasonCode` with values `BillingAccountStatusReasonCodeExpired`, `BillingAccountStatusReasonCodeManuallyTerminated`, `BillingAccountStatusReasonCodeOther`, `BillingAccountStatusReasonCodeTerminateProcessing`, `BillingAccountStatusReasonCodeTransferred`, `BillingAccountStatusReasonCodeUnusualActivity` +- New enum type `BillingManagementTenantState` with values `BillingManagementTenantStateActive`, `BillingManagementTenantStateNotAllowed`, `BillingManagementTenantStateOther`, `BillingManagementTenantStateRevoked` +- New enum type `BillingPlan` with values `BillingPlanP1M` +- New enum type `BillingRequestStatus` with values `BillingRequestStatusApproved`, `BillingRequestStatusCancelled`, `BillingRequestStatusCompleted`, `BillingRequestStatusDeclined`, `BillingRequestStatusExpired`, `BillingRequestStatusOther`, `BillingRequestStatusPending` +- New enum type `BillingRequestType` with values `BillingRequestTypeInvoiceAccess`, `BillingRequestTypeOther`, `BillingRequestTypeProvisioningAccess`, `BillingRequestTypeRoleAssignment`, `BillingRequestTypeUpdateBillingPolicy` +- New enum type `BillingSubscriptionOperationStatus` with values `BillingSubscriptionOperationStatusLockedForUpdate`, `BillingSubscriptionOperationStatusNone`, `BillingSubscriptionOperationStatusOther` +- New enum type `BillingSubscriptionStatus` with values `BillingSubscriptionStatusActive`, `BillingSubscriptionStatusAutoRenew`, `BillingSubscriptionStatusCancelled`, `BillingSubscriptionStatusDeleted`, `BillingSubscriptionStatusDisabled`, `BillingSubscriptionStatusExpired`, `BillingSubscriptionStatusExpiring`, `BillingSubscriptionStatusFailed`, `BillingSubscriptionStatusOther`, `BillingSubscriptionStatusSuspended`, `BillingSubscriptionStatusUnknown`, `BillingSubscriptionStatusWarned` +- New enum type `Cancellation` with values `CancellationAllowed`, `CancellationNotAllowed` +- New enum type `CancellationReason` with values `CancellationReasonCompromise`, `CancellationReasonDispute`, `CancellationReasonOther` +- New enum type `CommitmentGrain` with values `CommitmentGrainHourly` +- New enum type `CreatedByType` with values `CreatedByTypeApplication`, `CreatedByTypeKey`, `CreatedByTypeManagedIdentity`, `CreatedByTypeUser` +- New enum type `CreditType` with values `CreditTypeAzureCreditOffer`, `CreditTypeAzureFreeCredit`, `CreditTypeOther`, `CreditTypeRefund`, `CreditTypeServiceInterruption` +- New enum type `CustomerStatus` with values `CustomerStatusActive`, `CustomerStatusDeleted`, `CustomerStatusDisabled`, `CustomerStatusOther`, `CustomerStatusPending`, `CustomerStatusUnderReview`, `CustomerStatusWarned` +- New enum type `DeleteBillingProfileEligibilityCode` with values `DeleteBillingProfileEligibilityCodeActiveBillingSubscriptions`, `DeleteBillingProfileEligibilityCodeActiveCreditCard`, `DeleteBillingProfileEligibilityCodeActiveCredits`, `DeleteBillingProfileEligibilityCodeLastBillingProfile`, `DeleteBillingProfileEligibilityCodeNone`, `DeleteBillingProfileEligibilityCodeNotSupported`, `DeleteBillingProfileEligibilityCodeOutstandingCharges`, `DeleteBillingProfileEligibilityCodePendingCharges`, `DeleteBillingProfileEligibilityCodeReservedInstances` +- New enum type `DeleteBillingProfileEligibilityStatus` with values `DeleteBillingProfileEligibilityStatusAllowed`, `DeleteBillingProfileEligibilityStatusNotAllowed` +- New enum type `DeleteInvoiceSectionEligibilityCode` with values `DeleteInvoiceSectionEligibilityCodeActiveAzurePlans`, `DeleteInvoiceSectionEligibilityCodeActiveBillingSubscriptions`, `DeleteInvoiceSectionEligibilityCodeLastInvoiceSection`, `DeleteInvoiceSectionEligibilityCodeOther`, `DeleteInvoiceSectionEligibilityCodeReservedInstances` +- New enum type `DeleteInvoiceSectionEligibilityStatus` with values `DeleteInvoiceSectionEligibilityStatusAllowed`, `DeleteInvoiceSectionEligibilityStatusNotAllowed` +- New enum type `EligibleProductType` with values `EligibleProductTypeAzureReservation`, `EligibleProductTypeDevTestAzureSubscription`, `EligibleProductTypeStandardAzureSubscription` +- New enum type `EnrollmentAccountOwnerViewCharges` with values `EnrollmentAccountOwnerViewChargesAllowed`, `EnrollmentAccountOwnerViewChargesDisabled`, `EnrollmentAccountOwnerViewChargesNotAllowed`, `EnrollmentAccountOwnerViewChargesOther` +- New enum type `EnrollmentAuthLevelState` with values `EnrollmentAuthLevelStateMicrosoftAccountOnly`, `EnrollmentAuthLevelStateMixedAccount`, `EnrollmentAuthLevelStateOrganizationalAccountCrossTenant`, `EnrollmentAuthLevelStateOrganizationalAccountOnly`, `EnrollmentAuthLevelStateOther` +- New enum type `EnrollmentDepartmentAdminViewCharges` with values `EnrollmentDepartmentAdminViewChargesAllowed`, `EnrollmentDepartmentAdminViewChargesDisabled`, `EnrollmentDepartmentAdminViewChargesNotAllowed`, `EnrollmentDepartmentAdminViewChargesOther` +- New enum type `ExtendedTermOption` with values `ExtendedTermOptionOptedIn`, `ExtendedTermOptionOptedOut`, `ExtendedTermOptionOther` +- New enum type `FailedPaymentReason` with values `FailedPaymentReasonBankDeclined`, `FailedPaymentReasonCardExpired`, `FailedPaymentReasonIncorrectCardDetails`, `FailedPaymentReasonOther` +- New enum type `InitiatorCustomerType` with values `InitiatorCustomerTypeEA`, `InitiatorCustomerTypePartner` +- New enum type `InstanceFlexibility` with values `InstanceFlexibilityOff`, `InstanceFlexibilityOn` +- New enum type `InvoiceSectionLabelManagementPolicy` with values `InvoiceSectionLabelManagementPolicyAllowed`, `InvoiceSectionLabelManagementPolicyNotAllowed`, `InvoiceSectionLabelManagementPolicyOther` +- New enum type `InvoiceSectionStateReasonCode` with values `InvoiceSectionStateReasonCodeOther`, `InvoiceSectionStateReasonCodePastDue`, `InvoiceSectionStateReasonCodeSpendingLimitExpired`, `InvoiceSectionStateReasonCodeSpendingLimitReached`, `InvoiceSectionStateReasonCodeUnusualActivity` +- New enum type `MarkupStatus` with values `MarkupStatusDisabled`, `MarkupStatusLocked`, `MarkupStatusOther`, `MarkupStatusPreview`, `MarkupStatusPublished` +- New enum type `MoveValidationErrorCode` with values `MoveValidationErrorCodeBillingAccountInactive`, `MoveValidationErrorCodeDestinationBillingProfileInactive`, `MoveValidationErrorCodeDestinationBillingProfileNotFound`, `MoveValidationErrorCodeDestinationBillingProfilePastDue`, `MoveValidationErrorCodeDestinationInvoiceSectionInactive`, `MoveValidationErrorCodeDestinationInvoiceSectionNotFound`, `MoveValidationErrorCodeInsufficientPermissionOnDestination`, `MoveValidationErrorCodeInsufficientPermissionOnSource`, `MoveValidationErrorCodeInvalidDestination`, `MoveValidationErrorCodeInvalidSource`, `MoveValidationErrorCodeMarketplaceNotEnabledOnDestination`, `MoveValidationErrorCodeOther`, `MoveValidationErrorCodeProductInactive`, `MoveValidationErrorCodeProductNotFound`, `MoveValidationErrorCodeProductTypeNotSupported`, `MoveValidationErrorCodeSourceBillingProfilePastDue`, `MoveValidationErrorCodeSourceInvoiceSectionInactive` +- New enum type `PaymentMethodStatus` with values `PaymentMethodStatusActive`, `PaymentMethodStatusInactive` +- New enum type `PaymentStatus` with values `PaymentStatusCancelled`, `PaymentStatusCompleted`, `PaymentStatusFailed`, `PaymentStatusPending`, `PaymentStatusScheduled`, `PaymentStatusSucceeded` +- New enum type `PaymentTermsEligibilityCode` with values `PaymentTermsEligibilityCodeBillingAccountNotFound`, `PaymentTermsEligibilityCodeInactiveBillingAccount`, `PaymentTermsEligibilityCodeIneligibleBillingAccountStatus`, `PaymentTermsEligibilityCodeInvalidBillingAccountType`, `PaymentTermsEligibilityCodeInvalidDateFormat`, `PaymentTermsEligibilityCodeInvalidDateRange`, `PaymentTermsEligibilityCodeInvalidTerms`, `PaymentTermsEligibilityCodeNullOrEmptyPaymentTerms`, `PaymentTermsEligibilityCodeOther`, `PaymentTermsEligibilityCodeOverlappingPaymentTerms` +- New enum type `PaymentTermsEligibilityStatus` with values `PaymentTermsEligibilityStatusInvalid`, `PaymentTermsEligibilityStatusOther`, `PaymentTermsEligibilityStatusValid` +- New enum type `PolicyType` with values `PolicyTypeOther`, `PolicyTypeSystemControlled`, `PolicyTypeUserControlled` +- New enum type `PrincipalType` with values `PrincipalTypeDirectoryRole`, `PrincipalTypeEveryone`, `PrincipalTypeGroup`, `PrincipalTypeNone`, `PrincipalTypeServicePrincipal`, `PrincipalTypeUnknown`, `PrincipalTypeUser` +- New enum type `ProductStatus` with values `ProductStatusActive`, `ProductStatusAutoRenew`, `ProductStatusCanceled`, `ProductStatusDeleted`, `ProductStatusDisabled`, `ProductStatusExpired`, `ProductStatusExpiring`, `ProductStatusOther`, `ProductStatusPastDue`, `ProductStatusSuspended` +- New enum type `ProductTransferStatus` with values `ProductTransferStatusCompleted`, `ProductTransferStatusFailed`, `ProductTransferStatusInProgress`, `ProductTransferStatusNotStarted` +- New enum type `ProductType` with values `ProductTypeAzureReservation`, `ProductTypeAzureSubscription`, `ProductTypeDepartment`, `ProductTypeSAAS`, `ProductTypeSavingsPlan` +- New enum type `ProvisioningState` with values `ProvisioningStateCanceled`, `ProvisioningStateConfirmedBilling`, `ProvisioningStateCreated`, `ProvisioningStateCreating`, `ProvisioningStateExpired`, `ProvisioningStateFailed`, `ProvisioningStateNew`, `ProvisioningStatePending`, `ProvisioningStatePendingBilling`, `ProvisioningStateProvisioning`, `ProvisioningStateSucceeded` +- New enum type `ProvisioningTenantState` with values `ProvisioningTenantStateActive`, `ProvisioningTenantStateBillingRequestDeclined`, `ProvisioningTenantStateBillingRequestExpired`, `ProvisioningTenantStateNotRequested`, `ProvisioningTenantStateOther`, `ProvisioningTenantStatePending`, `ProvisioningTenantStateRevoked` +- New enum type `RefundReasonCode` with values `RefundReasonCodeAccidentalConversion`, `RefundReasonCodeAccidentalPurchase`, `RefundReasonCodeForgotToCancel`, `RefundReasonCodeOther`, `RefundReasonCodeUnclearDocumentation`, `RefundReasonCodeUnclearPricing` +- New enum type `RefundStatus` with values `RefundStatusApproved`, `RefundStatusCancelled`, `RefundStatusCompleted`, `RefundStatusDeclined`, `RefundStatusExpired`, `RefundStatusOther`, `RefundStatusPending` +- New enum type `ReservationBillingPlan` with values `ReservationBillingPlanMonthly`, `ReservationBillingPlanUpfront` +- New enum type `ReservationStatusCode` with values `ReservationStatusCodeActive`, `ReservationStatusCodeCapacityError`, `ReservationStatusCodeCapacityRestricted`, `ReservationStatusCodeCreditLineCheckFailed`, `ReservationStatusCodeExchanged`, `ReservationStatusCodeExpired`, `ReservationStatusCodeMerged`, `ReservationStatusCodeNoBenefit`, `ReservationStatusCodeNoBenefitDueToSubscriptionDeletion`, `ReservationStatusCodeNoBenefitDueToSubscriptionTransfer`, `ReservationStatusCodeNone`, `ReservationStatusCodePaymentInstrumentError`, `ReservationStatusCodePending`, `ReservationStatusCodeProcessing`, `ReservationStatusCodePurchaseError`, `ReservationStatusCodeRiskCheckFailed`, `ReservationStatusCodeSplit`, `ReservationStatusCodeSucceeded`, `ReservationStatusCodeUnknownError`, `ReservationStatusCodeWarning` +- New enum type `SavingsPlanPurchasesPolicy` with values `SavingsPlanPurchasesPolicyAllowed`, `SavingsPlanPurchasesPolicyDisabled`, `SavingsPlanPurchasesPolicyNotAllowed`, `SavingsPlanPurchasesPolicyOther` +- New enum type `SavingsPlanTerm` with values `SavingsPlanTermP1Y`, `SavingsPlanTermP3Y`, `SavingsPlanTermP5Y` +- New enum type `ServiceDefinedResourceName` with values `ServiceDefinedResourceNameDefault` +- New enum type `SpecialTaxationType` with values `SpecialTaxationTypeInvoiceLevel`, `SpecialTaxationTypeSubtotalLevel` +- New enum type `SpendingLimitStatus` with values `SpendingLimitStatusActive`, `SpendingLimitStatusExpired`, `SpendingLimitStatusLimitReached`, `SpendingLimitStatusLimitRemoved`, `SpendingLimitStatusNone`, `SpendingLimitStatusOther` +- New enum type `SpendingLimitType` with values `SpendingLimitTypeAcademicSponsorship`, `SpendingLimitTypeAzureConsumptionCredit`, `SpendingLimitTypeAzureForStudents`, `SpendingLimitTypeAzureForStudentsStarter`, `SpendingLimitTypeAzurePassSponsorship`, `SpendingLimitTypeFreeAccount`, `SpendingLimitTypeMSDN`, `SpendingLimitTypeMpnSponsorship`, `SpendingLimitTypeNonProfitSponsorship`, `SpendingLimitTypeNone`, `SpendingLimitTypeOther`, `SpendingLimitTypeSandbox`, `SpendingLimitTypeSponsorship`, `SpendingLimitTypeStartupSponsorship`, `SpendingLimitTypeVisualStudio` +- New enum type `SubscriptionBillingType` with values `SubscriptionBillingTypeBenefit`, `SubscriptionBillingTypeFree`, `SubscriptionBillingTypeNone`, `SubscriptionBillingTypePaid`, `SubscriptionBillingTypePrePaid` +- New enum type `SubscriptionEnrollmentAccountStatus` with values `SubscriptionEnrollmentAccountStatusActive`, `SubscriptionEnrollmentAccountStatusCancelled`, `SubscriptionEnrollmentAccountStatusDeleted`, `SubscriptionEnrollmentAccountStatusExpired`, `SubscriptionEnrollmentAccountStatusInactive`, `SubscriptionEnrollmentAccountStatusTransferredOut`, `SubscriptionEnrollmentAccountStatusTransferring` +- New enum type `SubscriptionStatusReason` with values `SubscriptionStatusReasonCancelled`, `SubscriptionStatusReasonExpired`, `SubscriptionStatusReasonNone`, `SubscriptionStatusReasonOther`, `SubscriptionStatusReasonPastDue`, `SubscriptionStatusReasonPolicyViolation`, `SubscriptionStatusReasonSpendingLimitReached`, `SubscriptionStatusReasonSuspiciousActivity`, `SubscriptionStatusReasonTransferred` +- New enum type `SubscriptionWorkloadType` with values `SubscriptionWorkloadTypeDevTest`, `SubscriptionWorkloadTypeInternal`, `SubscriptionWorkloadTypeNone`, `SubscriptionWorkloadTypeProduction` +- New enum type `SupportLevel` with values `SupportLevelDeveloper`, `SupportLevelOther`, `SupportLevelProDirect`, `SupportLevelStandard` +- New enum type `SupportedAccountType` with values `SupportedAccountTypeEnterprise`, `SupportedAccountTypeIndividual`, `SupportedAccountTypeNone`, `SupportedAccountTypePartner` +- New enum type `TaxIdentifierStatus` with values `TaxIdentifierStatusInvalid`, `TaxIdentifierStatusOther`, `TaxIdentifierStatusValid` +- New enum type `TaxIdentifierType` with values `TaxIdentifierTypeBrazilCcmID`, `TaxIdentifierTypeBrazilCnpjID`, `TaxIdentifierTypeBrazilCpfID`, `TaxIdentifierTypeCanadianFederalExempt`, `TaxIdentifierTypeCanadianProvinceExempt`, `TaxIdentifierTypeExternalTaxation`, `TaxIdentifierTypeIndiaFederalServiceTaxID`, `TaxIdentifierTypeIndiaFederalTanID`, `TaxIdentifierTypeIndiaPanID`, `TaxIdentifierTypeIndiaStateCstID`, `TaxIdentifierTypeIndiaStateGstINID`, `TaxIdentifierTypeIndiaStateVatID`, `TaxIdentifierTypeIntlExempt`, `TaxIdentifierTypeLoveCode`, `TaxIdentifierTypeMobileBarCode`, `TaxIdentifierTypeNationalIdentificationNumber`, `TaxIdentifierTypeOther`, `TaxIdentifierTypePublicSectorID`, `TaxIdentifierTypeUSExempt`, `TaxIdentifierTypeVatID` +- New enum type `TransactionKind` with values `TransactionKindAll`, `TransactionKindOther`, `TransactionKindReservation` +- New enum type `TransactionType` with values `TransactionTypeBilled`, `TransactionTypeOther`, `TransactionTypeUnbilled` +- New enum type `TransferStatus` with values `TransferStatusCanceled`, `TransferStatusCompleted`, `TransferStatusCompletedWithErrors`, `TransferStatusDeclined`, `TransferStatusExpired`, `TransferStatusFailed`, `TransferStatusInProgress`, `TransferStatusPending` +- New function `*AccountsClient.BeginAddPaymentTerms(context.Context, string, []*PaymentTerm, *AccountsClientBeginAddPaymentTermsOptions) (*runtime.Poller[AccountsClientAddPaymentTermsResponse], error)` +- New function `*AccountsClient.BeginCancelPaymentTerms(context.Context, string, time.Time, *AccountsClientBeginCancelPaymentTermsOptions) (*runtime.Poller[AccountsClientCancelPaymentTermsResponse], error)` +- New function `*AccountsClient.ConfirmTransition(context.Context, string, *AccountsClientConfirmTransitionOptions) (AccountsClientConfirmTransitionResponse, error)` +- New function `*AccountsClient.ValidatePaymentTerms(context.Context, string, []*PaymentTerm, *AccountsClientValidatePaymentTermsOptions) (AccountsClientValidatePaymentTermsResponse, error)` +- New function `NewAssociatedTenantsClient(azcore.TokenCredential, *arm.ClientOptions) (*AssociatedTenantsClient, error)` +- New function `*AssociatedTenantsClient.BeginCreateOrUpdate(context.Context, string, string, AssociatedTenant, *AssociatedTenantsClientBeginCreateOrUpdateOptions) (*runtime.Poller[AssociatedTenantsClientCreateOrUpdateResponse], error)` +- New function `*AssociatedTenantsClient.BeginDelete(context.Context, string, string, *AssociatedTenantsClientBeginDeleteOptions) (*runtime.Poller[AssociatedTenantsClientDeleteResponse], error)` +- New function `*AssociatedTenantsClient.Get(context.Context, string, string, *AssociatedTenantsClientGetOptions) (AssociatedTenantsClientGetResponse, error)` +- New function `*AssociatedTenantsClient.NewListByBillingAccountPager(string, *AssociatedTenantsClientListByBillingAccountOptions) *runtime.Pager[AssociatedTenantsClientListByBillingAccountResponse]` +- New function `*AvailableBalancesClient.GetByBillingAccount(context.Context, string, *AvailableBalancesClientGetByBillingAccountOptions) (AvailableBalancesClientGetByBillingAccountResponse, error)` +- New function `*AvailableBalancesClient.GetByBillingProfile(context.Context, string, string, *AvailableBalancesClientGetByBillingProfileOptions) (AvailableBalancesClientGetByBillingProfileResponse, error)` +- New function `*ClientFactory.NewAssociatedTenantsClient() *AssociatedTenantsClient` +- New function `*ClientFactory.NewDepartmentsClient() *DepartmentsClient` +- New function `*ClientFactory.NewPartnerTransfersClient() *PartnerTransfersClient` +- New function `*ClientFactory.NewPaymentMethodsClient() *PaymentMethodsClient` +- New function `*ClientFactory.NewRecipientTransfersClient() *RecipientTransfersClient` +- New function `*ClientFactory.NewRequestsClient() *RequestsClient` +- New function `*ClientFactory.NewReservationOrdersClient() *ReservationOrdersClient` +- New function `*ClientFactory.NewRoleDefinitionClient() *RoleDefinitionClient` +- New function `*ClientFactory.NewSavingsPlanOrdersClient() *SavingsPlanOrdersClient` +- New function `*ClientFactory.NewSavingsPlansClient() *SavingsPlansClient` +- New function `*ClientFactory.NewSubscriptionsAliasesClient() *SubscriptionsAliasesClient` +- New function `*ClientFactory.NewTransfersClient() *TransfersClient` +- New function `*CustomersClient.GetByBillingAccount(context.Context, string, string, *CustomersClientGetByBillingAccountOptions) (CustomersClientGetByBillingAccountResponse, error)` +- New function `NewDepartmentsClient(azcore.TokenCredential, *arm.ClientOptions) (*DepartmentsClient, error)` +- New function `*DepartmentsClient.Get(context.Context, string, string, *DepartmentsClientGetOptions) (DepartmentsClientGetResponse, error)` +- New function `*DepartmentsClient.NewListByBillingAccountPager(string, *DepartmentsClientListByBillingAccountOptions) *runtime.Pager[DepartmentsClientListByBillingAccountResponse]` +- New function `*EnrollmentAccountsClient.GetByDepartment(context.Context, string, string, string, *EnrollmentAccountsClientGetByDepartmentOptions) (EnrollmentAccountsClientGetByDepartmentResponse, error)` +- New function `*EnrollmentAccountsClient.NewListByBillingAccountPager(string, *EnrollmentAccountsClientListByBillingAccountOptions) *runtime.Pager[EnrollmentAccountsClientListByBillingAccountResponse]` +- New function `*EnrollmentAccountsClient.NewListByDepartmentPager(string, string, *EnrollmentAccountsClientListByDepartmentOptions) *runtime.Pager[EnrollmentAccountsClientListByDepartmentResponse]` +- New function `*InvoiceSectionsClient.BeginDelete(context.Context, string, string, string, *InvoiceSectionsClientBeginDeleteOptions) (*runtime.Poller[InvoiceSectionsClientDeleteResponse], error)` +- New function `*InvoiceSectionsClient.ValidateDeleteEligibility(context.Context, string, string, string, *InvoiceSectionsClientValidateDeleteEligibilityOptions) (InvoiceSectionsClientValidateDeleteEligibilityResponse, error)` +- New function `*InvoicesClient.BeginAmend(context.Context, string, string, *InvoicesClientBeginAmendOptions) (*runtime.Poller[InvoicesClientAmendResponse], error)` +- New function `*InvoicesClient.BeginDownloadByBillingAccount(context.Context, string, string, *InvoicesClientBeginDownloadByBillingAccountOptions) (*runtime.Poller[InvoicesClientDownloadByBillingAccountResponse], error)` +- New function `*InvoicesClient.BeginDownloadByBillingSubscription(context.Context, string, *InvoicesClientBeginDownloadByBillingSubscriptionOptions) (*runtime.Poller[InvoicesClientDownloadByBillingSubscriptionResponse], error)` +- New function `*InvoicesClient.BeginDownloadDocumentsByBillingAccount(context.Context, string, []*DocumentDownloadRequest, *InvoicesClientBeginDownloadDocumentsByBillingAccountOptions) (*runtime.Poller[InvoicesClientDownloadDocumentsByBillingAccountResponse], error)` +- New function `*InvoicesClient.BeginDownloadDocumentsByBillingSubscription(context.Context, []*DocumentDownloadRequest, *InvoicesClientBeginDownloadDocumentsByBillingSubscriptionOptions) (*runtime.Poller[InvoicesClientDownloadDocumentsByBillingSubscriptionResponse], error)` +- New function `*InvoicesClient.BeginDownloadSummaryByBillingAccount(context.Context, string, string, *InvoicesClientBeginDownloadSummaryByBillingAccountOptions) (*runtime.Poller[InvoicesClientDownloadSummaryByBillingAccountResponse], error)` +- New function `*InvoicesClient.GetByBillingAccount(context.Context, string, string, *InvoicesClientGetByBillingAccountOptions) (InvoicesClientGetByBillingAccountResponse, error)` +- New function `*InvoicesClient.GetByBillingSubscription(context.Context, string, *InvoicesClientGetByBillingSubscriptionOptions) (InvoicesClientGetByBillingSubscriptionResponse, error)` +- New function `NewPartnerTransfersClient(azcore.TokenCredential, *arm.ClientOptions) (*PartnerTransfersClient, error)` +- New function `*PartnerTransfersClient.Cancel(context.Context, string, string, string, string, *PartnerTransfersClientCancelOptions) (PartnerTransfersClientCancelResponse, error)` +- New function `*PartnerTransfersClient.Get(context.Context, string, string, string, string, *PartnerTransfersClientGetOptions) (PartnerTransfersClientGetResponse, error)` +- New function `*PartnerTransfersClient.Initiate(context.Context, string, string, string, string, PartnerInitiateTransferRequest, *PartnerTransfersClientInitiateOptions) (PartnerTransfersClientInitiateResponse, error)` +- New function `*PartnerTransfersClient.NewListPager(string, string, string, *PartnerTransfersClientListOptions) *runtime.Pager[PartnerTransfersClientListResponse]` +- New function `NewPaymentMethodsClient(azcore.TokenCredential, *arm.ClientOptions) (*PaymentMethodsClient, error)` +- New function `*PaymentMethodsClient.DeleteByUser(context.Context, string, *PaymentMethodsClientDeleteByUserOptions) (PaymentMethodsClientDeleteByUserResponse, error)` +- New function `*PaymentMethodsClient.GetByBillingAccount(context.Context, string, string, *PaymentMethodsClientGetByBillingAccountOptions) (PaymentMethodsClientGetByBillingAccountResponse, error)` +- New function `*PaymentMethodsClient.GetByBillingProfile(context.Context, string, string, string, *PaymentMethodsClientGetByBillingProfileOptions) (PaymentMethodsClientGetByBillingProfileResponse, error)` +- New function `*PaymentMethodsClient.GetByUser(context.Context, string, *PaymentMethodsClientGetByUserOptions) (PaymentMethodsClientGetByUserResponse, error)` +- New function `*PaymentMethodsClient.NewListByBillingAccountPager(string, *PaymentMethodsClientListByBillingAccountOptions) *runtime.Pager[PaymentMethodsClientListByBillingAccountResponse]` +- New function `*PaymentMethodsClient.NewListByBillingProfilePager(string, string, *PaymentMethodsClientListByBillingProfileOptions) *runtime.Pager[PaymentMethodsClientListByBillingProfileResponse]` +- New function `*PaymentMethodsClient.NewListByUserPager(*PaymentMethodsClientListByUserOptions) *runtime.Pager[PaymentMethodsClientListByUserResponse]` +- New function `*PermissionsClient.CheckAccessByBillingAccount(context.Context, string, CheckAccessRequest, *PermissionsClientCheckAccessByBillingAccountOptions) (PermissionsClientCheckAccessByBillingAccountResponse, error)` +- New function `*PermissionsClient.CheckAccessByBillingProfile(context.Context, string, string, CheckAccessRequest, *PermissionsClientCheckAccessByBillingProfileOptions) (PermissionsClientCheckAccessByBillingProfileResponse, error)` +- New function `*PermissionsClient.CheckAccessByCustomer(context.Context, string, string, string, CheckAccessRequest, *PermissionsClientCheckAccessByCustomerOptions) (PermissionsClientCheckAccessByCustomerResponse, error)` +- New function `*PermissionsClient.CheckAccessByDepartment(context.Context, string, string, CheckAccessRequest, *PermissionsClientCheckAccessByDepartmentOptions) (PermissionsClientCheckAccessByDepartmentResponse, error)` +- New function `*PermissionsClient.CheckAccessByEnrollmentAccount(context.Context, string, string, CheckAccessRequest, *PermissionsClientCheckAccessByEnrollmentAccountOptions) (PermissionsClientCheckAccessByEnrollmentAccountResponse, error)` +- New function `*PermissionsClient.CheckAccessByInvoiceSection(context.Context, string, string, string, CheckAccessRequest, *PermissionsClientCheckAccessByInvoiceSectionOptions) (PermissionsClientCheckAccessByInvoiceSectionResponse, error)` +- New function `*PermissionsClient.NewListByCustomerAtBillingAccountPager(string, string, *PermissionsClientListByCustomerAtBillingAccountOptions) *runtime.Pager[PermissionsClientListByCustomerAtBillingAccountResponse]` +- New function `*PermissionsClient.NewListByDepartmentPager(string, string, *PermissionsClientListByDepartmentOptions) *runtime.Pager[PermissionsClientListByDepartmentResponse]` +- New function `*PermissionsClient.NewListByEnrollmentAccountPager(string, string, *PermissionsClientListByEnrollmentAccountOptions) *runtime.Pager[PermissionsClientListByEnrollmentAccountResponse]` +- New function `*PermissionsClient.NewListByInvoiceSectionPager(string, string, string, *PermissionsClientListByInvoiceSectionOptions) *runtime.Pager[PermissionsClientListByInvoiceSectionResponse]` +- New function `*PoliciesClient.BeginCreateOrUpdateByBillingAccount(context.Context, string, AccountPolicy, *PoliciesClientBeginCreateOrUpdateByBillingAccountOptions) (*runtime.Poller[PoliciesClientCreateOrUpdateByBillingAccountResponse], error)` +- New function `*PoliciesClient.BeginCreateOrUpdateByBillingProfile(context.Context, string, string, ProfilePolicy, *PoliciesClientBeginCreateOrUpdateByBillingProfileOptions) (*runtime.Poller[PoliciesClientCreateOrUpdateByBillingProfileResponse], error)` +- New function `*PoliciesClient.BeginCreateOrUpdateByCustomer(context.Context, string, string, string, CustomerPolicy, *PoliciesClientBeginCreateOrUpdateByCustomerOptions) (*runtime.Poller[PoliciesClientCreateOrUpdateByCustomerResponse], error)` +- New function `*PoliciesClient.BeginCreateOrUpdateByCustomerAtBillingAccount(context.Context, string, string, CustomerPolicy, *PoliciesClientBeginCreateOrUpdateByCustomerAtBillingAccountOptions) (*runtime.Poller[PoliciesClientCreateOrUpdateByCustomerAtBillingAccountResponse], error)` +- New function `*PoliciesClient.GetByBillingAccount(context.Context, string, *PoliciesClientGetByBillingAccountOptions) (PoliciesClientGetByBillingAccountResponse, error)` +- New function `*PoliciesClient.GetByCustomerAtBillingAccount(context.Context, string, string, *PoliciesClientGetByCustomerAtBillingAccountOptions) (PoliciesClientGetByCustomerAtBillingAccountResponse, error)` +- New function `*PoliciesClient.GetBySubscription(context.Context, *PoliciesClientGetBySubscriptionOptions) (PoliciesClientGetBySubscriptionResponse, error)` +- New function `*ProductsClient.ValidateMoveEligibility(context.Context, string, string, MoveProductRequest, *ProductsClientValidateMoveEligibilityOptions) (ProductsClientValidateMoveEligibilityResponse, error)` +- New function `*ProfilesClient.BeginDelete(context.Context, string, string, *ProfilesClientBeginDeleteOptions) (*runtime.Poller[ProfilesClientDeleteResponse], error)` +- New function `*ProfilesClient.ValidateDeleteEligibility(context.Context, string, string, *ProfilesClientValidateDeleteEligibilityOptions) (ProfilesClientValidateDeleteEligibilityResponse, error)` +- New function `NewRecipientTransfersClient(azcore.TokenCredential, *arm.ClientOptions) (*RecipientTransfersClient, error)` +- New function `*RecipientTransfersClient.Accept(context.Context, string, AcceptTransferRequest, *RecipientTransfersClientAcceptOptions) (RecipientTransfersClientAcceptResponse, error)` +- New function `*RecipientTransfersClient.Decline(context.Context, string, *RecipientTransfersClientDeclineOptions) (RecipientTransfersClientDeclineResponse, error)` +- New function `*RecipientTransfersClient.Get(context.Context, string, *RecipientTransfersClientGetOptions) (RecipientTransfersClientGetResponse, error)` +- New function `*RecipientTransfersClient.NewListPager(*RecipientTransfersClientListOptions) *runtime.Pager[RecipientTransfersClientListResponse]` +- New function `*RecipientTransfersClient.Validate(context.Context, string, AcceptTransferRequest, *RecipientTransfersClientValidateOptions) (RecipientTransfersClientValidateResponse, error)` +- New function `NewRequestsClient(azcore.TokenCredential, *arm.ClientOptions) (*RequestsClient, error)` +- New function `*RequestsClient.BeginCreateOrUpdate(context.Context, string, Request, *RequestsClientBeginCreateOrUpdateOptions) (*runtime.Poller[RequestsClientCreateOrUpdateResponse], error)` +- New function `*RequestsClient.Get(context.Context, string, *RequestsClientGetOptions) (RequestsClientGetResponse, error)` +- New function `*RequestsClient.NewListByBillingAccountPager(string, *RequestsClientListByBillingAccountOptions) *runtime.Pager[RequestsClientListByBillingAccountResponse]` +- New function `*RequestsClient.NewListByBillingProfilePager(string, string, *RequestsClientListByBillingProfileOptions) *runtime.Pager[RequestsClientListByBillingProfileResponse]` +- New function `*RequestsClient.NewListByCustomerPager(string, string, string, *RequestsClientListByCustomerOptions) *runtime.Pager[RequestsClientListByCustomerResponse]` +- New function `*RequestsClient.NewListByInvoiceSectionPager(string, string, string, *RequestsClientListByInvoiceSectionOptions) *runtime.Pager[RequestsClientListByInvoiceSectionResponse]` +- New function `*RequestsClient.NewListByUserPager(*RequestsClientListByUserOptions) *runtime.Pager[RequestsClientListByUserResponse]` +- New function `NewReservationOrdersClient(azcore.TokenCredential, *arm.ClientOptions) (*ReservationOrdersClient, error)` +- New function `*ReservationOrdersClient.GetByBillingAccount(context.Context, string, string, *ReservationOrdersClientGetByBillingAccountOptions) (ReservationOrdersClientGetByBillingAccountResponse, error)` +- New function `*ReservationOrdersClient.NewListByBillingAccountPager(string, *ReservationOrdersClientListByBillingAccountOptions) *runtime.Pager[ReservationOrdersClientListByBillingAccountResponse]` +- New function `*ReservationsClient.GetByReservationOrder(context.Context, string, string, string, *ReservationsClientGetByReservationOrderOptions) (ReservationsClientGetByReservationOrderResponse, error)` +- New function `*ReservationsClient.NewListByReservationOrderPager(string, string, *ReservationsClientListByReservationOrderOptions) *runtime.Pager[ReservationsClientListByReservationOrderResponse]` +- New function `*ReservationsClient.BeginUpdateByBillingAccount(context.Context, string, string, string, Patch, *ReservationsClientBeginUpdateByBillingAccountOptions) (*runtime.Poller[ReservationsClientUpdateByBillingAccountResponse], error)` +- New function `*RoleAssignmentsClient.BeginCreateByBillingAccount(context.Context, string, RoleAssignmentProperties, *RoleAssignmentsClientBeginCreateByBillingAccountOptions) (*runtime.Poller[RoleAssignmentsClientCreateByBillingAccountResponse], error)` +- New function `*RoleAssignmentsClient.BeginCreateByBillingProfile(context.Context, string, string, RoleAssignmentProperties, *RoleAssignmentsClientBeginCreateByBillingProfileOptions) (*runtime.Poller[RoleAssignmentsClientCreateByBillingProfileResponse], error)` +- New function `*RoleAssignmentsClient.BeginCreateByCustomer(context.Context, string, string, string, RoleAssignmentProperties, *RoleAssignmentsClientBeginCreateByCustomerOptions) (*runtime.Poller[RoleAssignmentsClientCreateByCustomerResponse], error)` +- New function `*RoleAssignmentsClient.BeginCreateByInvoiceSection(context.Context, string, string, string, RoleAssignmentProperties, *RoleAssignmentsClientBeginCreateByInvoiceSectionOptions) (*runtime.Poller[RoleAssignmentsClientCreateByInvoiceSectionResponse], error)` +- New function `*RoleAssignmentsClient.BeginCreateOrUpdateByBillingAccount(context.Context, string, string, RoleAssignment, *RoleAssignmentsClientBeginCreateOrUpdateByBillingAccountOptions) (*runtime.Poller[RoleAssignmentsClientCreateOrUpdateByBillingAccountResponse], error)` +- New function `*RoleAssignmentsClient.BeginCreateOrUpdateByDepartment(context.Context, string, string, string, RoleAssignment, *RoleAssignmentsClientBeginCreateOrUpdateByDepartmentOptions) (*runtime.Poller[RoleAssignmentsClientCreateOrUpdateByDepartmentResponse], error)` +- New function `*RoleAssignmentsClient.BeginCreateOrUpdateByEnrollmentAccount(context.Context, string, string, string, RoleAssignment, *RoleAssignmentsClientBeginCreateOrUpdateByEnrollmentAccountOptions) (*runtime.Poller[RoleAssignmentsClientCreateOrUpdateByEnrollmentAccountResponse], error)` +- New function `*RoleAssignmentsClient.DeleteByCustomer(context.Context, string, string, string, string, *RoleAssignmentsClientDeleteByCustomerOptions) (RoleAssignmentsClientDeleteByCustomerResponse, error)` +- New function `*RoleAssignmentsClient.DeleteByDepartment(context.Context, string, string, string, *RoleAssignmentsClientDeleteByDepartmentOptions) (RoleAssignmentsClientDeleteByDepartmentResponse, error)` +- New function `*RoleAssignmentsClient.DeleteByEnrollmentAccount(context.Context, string, string, string, *RoleAssignmentsClientDeleteByEnrollmentAccountOptions) (RoleAssignmentsClientDeleteByEnrollmentAccountResponse, error)` +- New function `*RoleAssignmentsClient.GetByCustomer(context.Context, string, string, string, string, *RoleAssignmentsClientGetByCustomerOptions) (RoleAssignmentsClientGetByCustomerResponse, error)` +- New function `*RoleAssignmentsClient.GetByDepartment(context.Context, string, string, string, *RoleAssignmentsClientGetByDepartmentOptions) (RoleAssignmentsClientGetByDepartmentResponse, error)` +- New function `*RoleAssignmentsClient.GetByEnrollmentAccount(context.Context, string, string, string, *RoleAssignmentsClientGetByEnrollmentAccountOptions) (RoleAssignmentsClientGetByEnrollmentAccountResponse, error)` +- New function `*RoleAssignmentsClient.NewListByCustomerPager(string, string, string, *RoleAssignmentsClientListByCustomerOptions) *runtime.Pager[RoleAssignmentsClientListByCustomerResponse]` +- New function `*RoleAssignmentsClient.NewListByDepartmentPager(string, string, *RoleAssignmentsClientListByDepartmentOptions) *runtime.Pager[RoleAssignmentsClientListByDepartmentResponse]` +- New function `*RoleAssignmentsClient.NewListByEnrollmentAccountPager(string, string, *RoleAssignmentsClientListByEnrollmentAccountOptions) *runtime.Pager[RoleAssignmentsClientListByEnrollmentAccountResponse]` +- New function `*RoleAssignmentsClient.BeginResolveByBillingAccount(context.Context, string, *RoleAssignmentsClientBeginResolveByBillingAccountOptions) (*runtime.Poller[RoleAssignmentsClientResolveByBillingAccountResponse], error)` +- New function `*RoleAssignmentsClient.BeginResolveByBillingProfile(context.Context, string, string, *RoleAssignmentsClientBeginResolveByBillingProfileOptions) (*runtime.Poller[RoleAssignmentsClientResolveByBillingProfileResponse], error)` +- New function `*RoleAssignmentsClient.BeginResolveByCustomer(context.Context, string, string, string, *RoleAssignmentsClientBeginResolveByCustomerOptions) (*runtime.Poller[RoleAssignmentsClientResolveByCustomerResponse], error)` +- New function `*RoleAssignmentsClient.BeginResolveByInvoiceSection(context.Context, string, string, string, *RoleAssignmentsClientBeginResolveByInvoiceSectionOptions) (*runtime.Poller[RoleAssignmentsClientResolveByInvoiceSectionResponse], error)` +- New function `NewRoleDefinitionClient(azcore.TokenCredential, *arm.ClientOptions) (*RoleDefinitionClient, error)` +- New function `*RoleDefinitionClient.GetByBillingAccount(context.Context, string, string, *RoleDefinitionClientGetByBillingAccountOptions) (RoleDefinitionClientGetByBillingAccountResponse, error)` +- New function `*RoleDefinitionClient.GetByBillingProfile(context.Context, string, string, string, *RoleDefinitionClientGetByBillingProfileOptions) (RoleDefinitionClientGetByBillingProfileResponse, error)` +- New function `*RoleDefinitionClient.GetByCustomer(context.Context, string, string, string, string, *RoleDefinitionClientGetByCustomerOptions) (RoleDefinitionClientGetByCustomerResponse, error)` +- New function `*RoleDefinitionClient.GetByDepartment(context.Context, string, string, string, *RoleDefinitionClientGetByDepartmentOptions) (RoleDefinitionClientGetByDepartmentResponse, error)` +- New function `*RoleDefinitionClient.GetByEnrollmentAccount(context.Context, string, string, string, *RoleDefinitionClientGetByEnrollmentAccountOptions) (RoleDefinitionClientGetByEnrollmentAccountResponse, error)` +- New function `*RoleDefinitionClient.GetByInvoiceSection(context.Context, string, string, string, string, *RoleDefinitionClientGetByInvoiceSectionOptions) (RoleDefinitionClientGetByInvoiceSectionResponse, error)` +- New function `*RoleDefinitionClient.NewListByBillingAccountPager(string, *RoleDefinitionClientListByBillingAccountOptions) *runtime.Pager[RoleDefinitionClientListByBillingAccountResponse]` +- New function `*RoleDefinitionClient.NewListByBillingProfilePager(string, string, *RoleDefinitionClientListByBillingProfileOptions) *runtime.Pager[RoleDefinitionClientListByBillingProfileResponse]` +- New function `*RoleDefinitionClient.NewListByCustomerPager(string, string, string, *RoleDefinitionClientListByCustomerOptions) *runtime.Pager[RoleDefinitionClientListByCustomerResponse]` +- New function `*RoleDefinitionClient.NewListByDepartmentPager(string, string, *RoleDefinitionClientListByDepartmentOptions) *runtime.Pager[RoleDefinitionClientListByDepartmentResponse]` +- New function `*RoleDefinitionClient.NewListByEnrollmentAccountPager(string, string, *RoleDefinitionClientListByEnrollmentAccountOptions) *runtime.Pager[RoleDefinitionClientListByEnrollmentAccountResponse]` +- New function `*RoleDefinitionClient.NewListByInvoiceSectionPager(string, string, string, *RoleDefinitionClientListByInvoiceSectionOptions) *runtime.Pager[RoleDefinitionClientListByInvoiceSectionResponse]` +- New function `NewSavingsPlanOrdersClient(azcore.TokenCredential, *arm.ClientOptions) (*SavingsPlanOrdersClient, error)` +- New function `*SavingsPlanOrdersClient.GetByBillingAccount(context.Context, string, string, *SavingsPlanOrdersClientGetByBillingAccountOptions) (SavingsPlanOrdersClientGetByBillingAccountResponse, error)` +- New function `*SavingsPlanOrdersClient.NewListByBillingAccountPager(string, *SavingsPlanOrdersClientListByBillingAccountOptions) *runtime.Pager[SavingsPlanOrdersClientListByBillingAccountResponse]` +- New function `NewSavingsPlansClient(azcore.TokenCredential, *arm.ClientOptions) (*SavingsPlansClient, error)` +- New function `*SavingsPlansClient.GetByBillingAccount(context.Context, string, string, string, *SavingsPlansClientGetByBillingAccountOptions) (SavingsPlansClientGetByBillingAccountResponse, error)` +- New function `*SavingsPlansClient.NewListByBillingAccountPager(string, *SavingsPlansClientListByBillingAccountOptions) *runtime.Pager[SavingsPlansClientListByBillingAccountResponse]` +- New function `*SavingsPlansClient.NewListBySavingsPlanOrderPager(string, string, *SavingsPlansClientListBySavingsPlanOrderOptions) *runtime.Pager[SavingsPlansClientListBySavingsPlanOrderResponse]` +- New function `*SavingsPlansClient.BeginUpdateByBillingAccount(context.Context, string, string, string, SavingsPlanUpdateRequest, *SavingsPlansClientBeginUpdateByBillingAccountOptions) (*runtime.Poller[SavingsPlansClientUpdateByBillingAccountResponse], error)` +- New function `*SavingsPlansClient.ValidateUpdateByBillingAccount(context.Context, string, string, string, SavingsPlanUpdateValidateRequest, *SavingsPlansClientValidateUpdateByBillingAccountOptions) (SavingsPlansClientValidateUpdateByBillingAccountResponse, error)` +- New function `NewSubscriptionsAliasesClient(azcore.TokenCredential, *arm.ClientOptions) (*SubscriptionsAliasesClient, error)` +- New function `*SubscriptionsAliasesClient.BeginCreateOrUpdate(context.Context, string, string, SubscriptionAlias, *SubscriptionsAliasesClientBeginCreateOrUpdateOptions) (*runtime.Poller[SubscriptionsAliasesClientCreateOrUpdateResponse], error)` +- New function `*SubscriptionsAliasesClient.Get(context.Context, string, string, *SubscriptionsAliasesClientGetOptions) (SubscriptionsAliasesClientGetResponse, error)` +- New function `*SubscriptionsAliasesClient.NewListByBillingAccountPager(string, *SubscriptionsAliasesClientListByBillingAccountOptions) *runtime.Pager[SubscriptionsAliasesClientListByBillingAccountResponse]` +- New function `*SubscriptionsClient.BeginCancel(context.Context, string, string, CancelSubscriptionRequest, *SubscriptionsClientBeginCancelOptions) (*runtime.Poller[SubscriptionsClientCancelResponse], error)` +- New function `*SubscriptionsClient.BeginDelete(context.Context, string, string, *SubscriptionsClientBeginDeleteOptions) (*runtime.Poller[SubscriptionsClientDeleteResponse], error)` +- New function `*SubscriptionsClient.GetByBillingProfile(context.Context, string, string, string, *SubscriptionsClientGetByBillingProfileOptions) (SubscriptionsClientGetByBillingProfileResponse, error)` +- New function `*SubscriptionsClient.NewListByCustomerAtBillingAccountPager(string, string, *SubscriptionsClientListByCustomerAtBillingAccountOptions) *runtime.Pager[SubscriptionsClientListByCustomerAtBillingAccountResponse]` +- New function `*SubscriptionsClient.NewListByEnrollmentAccountPager(string, string, *SubscriptionsClientListByEnrollmentAccountOptions) *runtime.Pager[SubscriptionsClientListByEnrollmentAccountResponse]` +- New function `*SubscriptionsClient.BeginMerge(context.Context, string, string, SubscriptionMergeRequest, *SubscriptionsClientBeginMergeOptions) (*runtime.Poller[SubscriptionsClientMergeResponse], error)` +- New function `*SubscriptionsClient.BeginSplit(context.Context, string, string, SubscriptionSplitRequest, *SubscriptionsClientBeginSplitOptions) (*runtime.Poller[SubscriptionsClientSplitResponse], error)` +- New function `*SubscriptionsClient.ValidateMoveEligibility(context.Context, string, string, MoveBillingSubscriptionRequest, *SubscriptionsClientValidateMoveEligibilityOptions) (SubscriptionsClientValidateMoveEligibilityResponse, error)` +- New function `*TransactionsClient.GetTransactionSummaryByInvoice(context.Context, string, string, *TransactionsClientGetTransactionSummaryByInvoiceOptions) (TransactionsClientGetTransactionSummaryByInvoiceResponse, error)` +- New function `*TransactionsClient.NewListByBillingProfilePager(string, string, time.Time, time.Time, TransactionType, *TransactionsClientListByBillingProfileOptions) *runtime.Pager[TransactionsClientListByBillingProfileResponse]` +- New function `*TransactionsClient.NewListByCustomerPager(string, string, string, time.Time, time.Time, TransactionType, *TransactionsClientListByCustomerOptions) *runtime.Pager[TransactionsClientListByCustomerResponse]` +- New function `*TransactionsClient.NewListByInvoiceSectionPager(string, string, string, time.Time, time.Time, TransactionType, *TransactionsClientListByInvoiceSectionOptions) *runtime.Pager[TransactionsClientListByInvoiceSectionResponse]` +- New function `*TransactionsClient.BeginTransactionsDownloadByInvoice(context.Context, string, string, *TransactionsClientBeginTransactionsDownloadByInvoiceOptions) (*runtime.Poller[TransactionsClientTransactionsDownloadByInvoiceResponse], error)` +- New function `NewTransfersClient(azcore.TokenCredential, *arm.ClientOptions) (*TransfersClient, error)` +- New function `*TransfersClient.Cancel(context.Context, string, string, string, string, *TransfersClientCancelOptions) (TransfersClientCancelResponse, error)` +- New function `*TransfersClient.Get(context.Context, string, string, string, string, *TransfersClientGetOptions) (TransfersClientGetResponse, error)` +- New function `*TransfersClient.Initiate(context.Context, string, string, string, string, InitiateTransferRequest, *TransfersClientInitiateOptions) (TransfersClientInitiateResponse, error)` +- New function `*TransfersClient.NewListPager(string, string, string, *TransfersClientListOptions) *runtime.Pager[TransfersClientListResponse]` +- New struct `AcceptTransferProperties` +- New struct `AcceptTransferRequest` +- New struct `AccountPatch` +- New struct `AccountPolicy` +- New struct `AccountPolicyProperties` +- New struct `AccountPolicyPropertiesEnterpriseAgreementPolicies` +- New struct `AccountPropertiesEnrollmentDetails` +- New struct `AccountPropertiesRegistrationNumber` +- New struct `AccountPropertiesSoldTo` +- New struct `AddressValidationResponse` +- New struct `AppliedScopeProperties` +- New struct `AssociatedTenant` +- New struct `AssociatedTenantListResult` +- New struct `AssociatedTenantProperties` +- New struct `AvailableBalancePropertiesAmount` +- New struct `AvailableBalancePropertiesTotalPaymentsOnAccount` +- New struct `Beneficiary` +- New struct `CancelSubscriptionRequest` +- New struct `CheckAccessRequest` +- New struct `CheckAccessResponse` +- New struct `Commitment` +- New struct `DeleteBillingProfileEligibilityDetail` +- New struct `DeleteBillingProfileEligibilityResult` +- New struct `DeleteInvoiceSectionEligibilityDetail` +- New struct `DeleteInvoiceSectionEligibilityResult` +- New struct `DepartmentListResult` +- New struct `DetailedTransferStatus` +- New struct `DocumentDownloadRequest` +- New struct `DocumentDownloadResult` +- New struct `EnrollmentAccountSubscriptionDetails` +- New struct `EnrollmentDetails` +- New struct `EnrollmentDetailsIndirectRelationshipInfo` +- New struct `EnterpriseAgreementPolicies` +- New struct `ErrorAdditionalInfo` +- New struct `ErrorDetail` +- New struct `ExtendedStatusDefinitionProperties` +- New struct `ExtendedStatusInfo` +- New struct `ExtendedStatusInfoProperties` +- New struct `ExternalReference` +- New struct `FailedPayment` +- New struct `InitiateTransferProperties` +- New struct `InitiateTransferRequest` +- New struct `InvoiceDocument` +- New struct `InvoicePropertiesAmountDue` +- New struct `InvoicePropertiesAzurePrepaymentApplied` +- New struct `InvoicePropertiesBilledAmount` +- New struct `InvoicePropertiesCreditAmount` +- New struct `InvoicePropertiesFreeAzureCreditApplied` +- New struct `InvoicePropertiesRebillDetails` +- New struct `InvoicePropertiesRefundDetails` +- New struct `InvoicePropertiesSubTotal` +- New struct `InvoicePropertiesTaxAmount` +- New struct `InvoicePropertiesTotalAmount` +- New struct `InvoiceSectionWithCreateSubPermissionListResult` +- New struct `MoveBillingSubscriptionEligibilityResult` +- New struct `MoveBillingSubscriptionErrorDetails` +- New struct `MoveBillingSubscriptionRequest` +- New struct `MoveProductEligibilityResult` +- New struct `MoveProductEligibilityResultErrorDetails` +- New struct `MoveProductErrorDetails` +- New struct `MoveProductRequest` +- New struct `NextBillingCycleDetails` +- New struct `Participant` +- New struct `PartnerInitiateTransferProperties` +- New struct `PartnerInitiateTransferRequest` +- New struct `PartnerTransferDetails` +- New struct `PartnerTransferDetailsListResult` +- New struct `PartnerTransferProperties` +- New struct `Patch` +- New struct `PatchProperties` +- New struct `PatchPropertiesRenewProperties` +- New struct `Payment` +- New struct `PaymentAmount` +- New struct `PaymentDetail` +- New struct `PaymentMethod` +- New struct `PaymentMethodLink` +- New struct `PaymentMethodLinkProperties` +- New struct `PaymentMethodLinksListResult` +- New struct `PaymentMethodLogo` +- New struct `PaymentMethodProperties` +- New struct `PaymentMethodsListResult` +- New struct `PaymentOnAccount` +- New struct `PaymentOnAccountAmount` +- New struct `PaymentTerm` +- New struct `PaymentTermsEligibilityDetail` +- New struct `PaymentTermsEligibilityResult` +- New struct `Permission` +- New struct `PermissionListResult` +- New struct `PlanInformation` +- New struct `PolicySummary` +- New struct `Price` +- New struct `Principal` +- New struct `ProductDetails` +- New struct `ProductListResult` +- New struct `ProductPatch` +- New struct `ProductPropertiesLastCharge` +- New struct `ProductPropertiesReseller` +- New struct `ProfilePolicy` +- New struct `ProfilePolicyProperties` +- New struct `ProfilePolicyPropertiesEnterpriseAgreementPolicies` +- New struct `ProfilePropertiesBillTo` +- New struct `ProfilePropertiesCurrentPaymentTerm` +- New struct `ProfilePropertiesIndirectRelationshipInfo` +- New struct `ProfilePropertiesShipTo` +- New struct `ProfilePropertiesSoldTo` +- New struct `PropertyPropertiesEnrollmentDetails` +- New struct `PropertyPropertiesSubscriptionServiceUsageAddress` +- New struct `ProxyResource` +- New struct `ProxyResourceWithTags` +- New struct `PurchaseRequest` +- New struct `PurchaseRequestProperties` +- New struct `RecipientTransferDetails` +- New struct `RecipientTransferDetailsListResult` +- New struct `RecipientTransferProperties` +- New struct `RefundDetailsSummary` +- New struct `RefundDetailsSummaryAmountRefunded` +- New struct `RefundDetailsSummaryAmountRequested` +- New struct `RefundTransactionDetails` +- New struct `RefundTransactionDetailsAmountRefunded` +- New struct `RefundTransactionDetailsAmountRequested` +- New struct `RegistrationNumber` +- New struct `RenewProperties` +- New struct `RenewPropertiesResponse` +- New struct `RenewalTermDetails` +- New struct `Request` +- New struct `RequestListResult` +- New struct `RequestProperties` +- New struct `RequestPropertiesCreatedBy` +- New struct `RequestPropertiesLastUpdatedBy` +- New struct `RequestPropertiesReviewedBy` +- New struct `ReservationAppliedScopeProperties` +- New struct `ReservationExtendedStatusInfo` +- New struct `ReservationList` +- New struct `ReservationMergeProperties` +- New struct `ReservationOrder` +- New struct `ReservationOrderBillingPlanInformation` +- New struct `ReservationOrderList` +- New struct `ReservationOrderProperty` +- New struct `ReservationPaymentDetail` +- New struct `ReservationPurchaseRequest` +- New struct `ReservationPurchaseRequestProperties` +- New struct `ReservationPurchaseRequestPropertiesReservedResourceProperties` +- New struct `ReservationSplitProperties` +- New struct `ReservationSwapProperties` +- New struct `SKU` +- New struct `SKUName` +- New struct `SavingsPlanModel` +- New struct `SavingsPlanModelList` +- New struct `SavingsPlanModelListResult` +- New struct `SavingsPlanModelProperties` +- New struct `SavingsPlanOrderModel` +- New struct `SavingsPlanOrderModelList` +- New struct `SavingsPlanOrderModelProperties` +- New struct `SavingsPlanSummaryCount` +- New struct `SavingsPlanUpdateRequest` +- New struct `SavingsPlanUpdateRequestProperties` +- New struct `SavingsPlanUpdateValidateRequest` +- New struct `SavingsPlanValidResponseProperty` +- New struct `SavingsPlanValidateResponse` +- New struct `SpendingLimitDetails` +- New struct `SubscriptionAlias` +- New struct `SubscriptionAliasListResult` +- New struct `SubscriptionAliasProperties` +- New struct `SubscriptionEnrollmentDetails` +- New struct `SubscriptionListResult` +- New struct `SubscriptionMergeRequest` +- New struct `SubscriptionPatch` +- New struct `SubscriptionPolicy` +- New struct `SubscriptionPolicyProperties` +- New struct `SubscriptionSplitRequest` +- New struct `SubscriptionStatusDetails` +- New struct `SystemData` +- New struct `SystemOverrides` +- New struct `TaxIdentifier` +- New struct `TransactionPropertiesAzureCreditApplied` +- New struct `TransactionPropertiesConsumptionCommitmentDecremented` +- New struct `TransactionPropertiesEffectivePrice` +- New struct `TransactionPropertiesMarketPrice` +- New struct `TransactionPropertiesRefundTransactionDetails` +- New struct `TransactionPropertiesSubTotal` +- New struct `TransactionPropertiesTax` +- New struct `TransactionPropertiesTransactionAmount` +- New struct `TransactionSummary` +- New struct `TransferDetails` +- New struct `TransferDetailsListResult` +- New struct `TransferError` +- New struct `TransferItemQueryParameter` +- New struct `TransferProperties` +- New struct `TransitionDetails` +- New struct `Utilization` +- New struct `UtilizationAggregates` +- New struct `ValidateTransferListResponse` +- New struct `ValidateTransferResponse` +- New struct `ValidateTransferResponseProperties` +- New struct `ValidationResultProperties` +- New field `SystemData`, `Tags` in struct `Account` +- New field `AccountStatusReasonCode`, `AccountSubType`, `BillingRelationshipTypes`, `HasNoBillingProfiles`, `PrimaryBillingTenantID`, `ProvisioningState`, `Qualifications`, `RegistrationNumber`, `TaxIDs` in struct `AccountProperties` +- New field `Filter` in struct `AccountsClientListInvoiceSectionsByCreateSubscriptionPermissionOptions` +- New anonymous field `InvoiceSectionWithCreateSubPermissionListResult` in struct `AccountsClientListInvoiceSectionsByCreateSubscriptionPermissionResponse` +- New field `Filter`, `IncludeAll`, `IncludeAllWithoutBillingProfiles`, `IncludeDeleted`, `IncludePendingAgreement`, `IncludeResellee`, `LegalOwnerOID`, `LegalOwnerTID`, `Search`, `Skip`, `Top` in struct `AccountsClientListOptions` +- New anonymous field `AddressValidationResponse` in struct `AddressClientValidateResponse` +- New field `IsValidAddress` in struct `AddressDetails` +- New field `SystemData`, `Tags` in struct `Agreement` +- New field `DisplayName`, `LeadBillingAccountName` in struct `AgreementProperties` +- New field `SystemData`, `Tags` in struct `AvailableBalance` +- New field `PaymentsOnAccount`, `TotalPaymentsOnAccount` in struct `AvailableBalanceProperties` +- New field `ProductID` in struct `AzurePlan` +- New field `SystemData`, `Tags` in struct `Customer` +- New field `SystemData`, `Tags` in struct `CustomerPolicy` +- New field `Policies`, `ProvisioningState` in struct `CustomerPolicyProperties` +- New field `Status`, `SystemID`, `Tags` in struct `CustomerProperties` +- New field `Count`, `Expand`, `OrderBy`, `Skip`, `Top` in struct `CustomersClientListByBillingAccountOptions` +- New field `Count`, `Expand`, `OrderBy`, `Skip`, `Top` in struct `CustomersClientListByBillingProfileOptions` +- New field `SystemData`, `Tags` in struct `Department` +- New field `DisplayName`, `ID` in struct `DepartmentProperties` +- New field `SystemData`, `Tags` in struct `EnrollmentAccount` +- New field `AuthType`, `DepartmentDisplayName`, `DepartmentID`, `DisplayName`, `IsDevTestEnabled` in struct `EnrollmentAccountProperties` +- New anonymous field `EnrollmentAccount` in struct `EnrollmentAccountsClientGetResponse` +- New field `SystemData`, `Tags` in struct `Invoice` +- New field `FailedPayments`, `RefundDetails`, `SpecialTaxationType`, `SubscriptionDisplayName` in struct `InvoiceProperties` +- New field `SystemData`, `Tags` in struct `InvoiceSection` +- New field `ProvisioningState`, `ReasonCode` in struct `InvoiceSectionProperties` +- New field `Count`, `Filter`, `IncludeDeleted`, `OrderBy`, `Search`, `Skip`, `Top` in struct `InvoiceSectionsClientListByBillingProfileOptions` +- New field `Count`, `Filter`, `OrderBy`, `PeriodEndDate`, `PeriodStartDate`, `Search`, `Skip`, `Top` in struct `InvoicesClientListByBillingAccountOptions` +- New field `Count`, `Filter`, `OrderBy`, `PeriodEndDate`, `PeriodStartDate`, `Search`, `Skip`, `Top` in struct `InvoicesClientListByBillingProfileOptions` +- New field `Count`, `Filter`, `OrderBy`, `PeriodEndDate`, `PeriodStartDate`, `Search`, `Skip`, `Top` in struct `InvoicesClientListByBillingSubscriptionOptions` +- New anonymous field `PermissionListResult` in struct `PermissionsClientListByBillingAccountResponse` +- New anonymous field `PermissionListResult` in struct `PermissionsClientListByBillingProfileResponse` +- New anonymous field `PermissionListResult` in struct `PermissionsClientListByCustomerResponse` +- New anonymous field `ProfilePolicy` in struct `PoliciesClientGetByBillingProfileResponse` +- New field `SystemData`, `Tags` in struct `Product` +- New field `Count`, `OrderBy`, `Search`, `Skip`, `Top` in struct `ProductsClientListByBillingAccountOptions` +- New anonymous field `ProductListResult` in struct `ProductsClientListByBillingAccountResponse` +- New field `Count`, `OrderBy`, `Search`, `Skip`, `Top` in struct `ProductsClientListByBillingProfileOptions` +- New anonymous field `ProductListResult` in struct `ProductsClientListByBillingProfileResponse` +- New field `Count`, `Filter`, `OrderBy`, `Search`, `Skip`, `Top` in struct `ProductsClientListByCustomerOptions` +- New anonymous field `ProductListResult` in struct `ProductsClientListByCustomerResponse` +- New field `Count`, `OrderBy`, `Search`, `Skip`, `Top` in struct `ProductsClientListByInvoiceSectionOptions` +- New anonymous field `ProductListResult` in struct `ProductsClientListByInvoiceSectionResponse` +- New field `SystemData`, `Tags` in struct `Profile` +- New field `BillingAccountID`, `BillingProfileSystemID` in struct `ProfileInfo` +- New field `CurrentPaymentTerm`, `InvoiceRecipients`, `OtherPaymentTerms`, `ProvisioningState`, `ShipTo`, `SoldTo`, `SpendingLimitDetails` in struct `ProfileProperties` +- New field `Count`, `Filter`, `IncludeDeleted`, `OrderBy`, `Search`, `Skip`, `Top` in struct `ProfilesClientListByBillingAccountOptions` +- New field `SystemData`, `Tags` in struct `Property` +- New field `IncludeBillingCountry`, `IncludeTransitionStatus` in struct `PropertyClientGetOptions` +- New field `BillingAccountAgreementType`, `BillingAccountSoldToCountry`, `BillingAccountStatus`, `BillingAccountStatusReasonCode`, `BillingAccountSubType`, `BillingAccountType`, `BillingCurrency`, `BillingProfilePaymentMethodFamily`, `BillingProfilePaymentMethodType`, `BillingProfileSpendingLimitDetails`, `CustomerDisplayName`, `CustomerID`, `CustomerStatus`, `EnrollmentDetails`, `InvoiceSectionStatus`, `InvoiceSectionStatusReasonCode`, `IsTransitionedBillingAccount`, `SubscriptionBillingStatus`, `SubscriptionBillingStatusDetails`, `SubscriptionBillingType`, `SubscriptionServiceUsageAddress`, `SubscriptionWorkloadType` in struct `PropertyProperties` +- New field `Etag`, `SystemData`, `Tags` in struct `Reservation` +- New field `AppliedScopeProperties`, `Archived`, `BenefitStartTime`, `BillingPlan`, `BillingScopeID`, `Capabilities`, `ExpiryDateTime`, `ExtendedStatusInfo`, `InstanceFlexibility`, `LastUpdatedDateTime`, `MergeProperties`, `ProductCode`, `PurchaseDate`, `PurchaseDateTime`, `RenewDestination`, `RenewProperties`, `ReviewDateTime`, `SplitProperties`, `SwapProperties` in struct `ReservationProperty` +- New field `NoBenefitCount`, `ProcessingCount`, `WarningCount` in struct `ReservationSummary` +- New field `OrderBy`, `Skiptoken`, `Take` in struct `ReservationsClientListByBillingAccountOptions` +- New field `OrderBy`, `Skiptoken`, `Take` in struct `ReservationsClientListByBillingProfileOptions` +- New field `SystemData` in struct `Resource` +- New field `SystemData`, `Tags` in struct `RoleAssignment` +- New field `BillingAccountDisplayName`, `BillingAccountID`, `BillingProfileDisplayName`, `BillingProfileID`, `BillingRequestID`, `CreatedByPrincipalPuid`, `CustomerDisplayName`, `CustomerID`, `InvoiceSectionDisplayName`, `InvoiceSectionID`, `ModifiedByPrincipalID`, `ModifiedByPrincipalPuid`, `ModifiedByPrincipalTenantID`, `ModifiedByUserEmailAddress`, `ModifiedOn`, `PrincipalDisplayName`, `PrincipalPuid`, `PrincipalTenantName`, `PrincipalType`, `ProvisioningState` in struct `RoleAssignmentProperties` +- New field `Filter`, `Skip`, `Top` in struct `RoleAssignmentsClientListByBillingAccountOptions` +- New field `Filter`, `Skip`, `Top` in struct `RoleAssignmentsClientListByBillingProfileOptions` +- New field `Filter`, `Skip`, `Top` in struct `RoleAssignmentsClientListByInvoiceSectionOptions` +- New field `SystemData`, `Tags` in struct `RoleDefinition` +- New field `SystemData`, `Tags` in struct `Subscription` +- New field `AutoRenew`, `Beneficiary`, `BeneficiaryTenantID`, `BillingFrequency`, `BillingPolicies`, `BillingProfileName`, `ConsumptionCostCenter`, `CustomerName`, `EnrollmentAccountDisplayName`, `EnrollmentAccountID`, `EnrollmentAccountSubscriptionDetails`, `InvoiceSectionName`, `NextBillingCycleDetails`, `OfferID`, `OperationStatus`, `ProductCategory`, `ProductType`, `ProductTypeID`, `ProvisioningState`, `ProvisioningTenantID`, `PurchaseDate`, `Quantity`, `RenewalTermDetails`, `ResourceURI`, `Status`, `SuspensionReasonDetails`, `SystemOverrides`, `TermDuration`, `TermEndDate`, `TermStartDate` in struct `SubscriptionProperties` +- New field `Expand` in struct `SubscriptionsClientGetOptions` +- New field `Count`, `Expand`, `Filter`, `IncludeDeleted`, `IncludeFailed`, `IncludeTenantSubscriptions`, `OrderBy`, `Search`, `Skip`, `Top` in struct `SubscriptionsClientListByBillingAccountOptions` +- New anonymous field `SubscriptionListResult` in struct `SubscriptionsClientListByBillingAccountResponse` +- New field `Count`, `Expand`, `Filter`, `IncludeDeleted`, `OrderBy`, `Search`, `Skip`, `Top` in struct `SubscriptionsClientListByBillingProfileOptions` +- New anonymous field `SubscriptionListResult` in struct `SubscriptionsClientListByBillingProfileResponse` +- New field `Count`, `Expand`, `Filter`, `IncludeDeleted`, `OrderBy`, `Search`, `Skip`, `Top` in struct `SubscriptionsClientListByCustomerOptions` +- New anonymous field `SubscriptionListResult` in struct `SubscriptionsClientListByCustomerResponse` +- New field `Count`, `Expand`, `Filter`, `IncludeDeleted`, `OrderBy`, `Search`, `Skip`, `Top` in struct `SubscriptionsClientListByInvoiceSectionOptions` +- New anonymous field `SubscriptionListResult` in struct `SubscriptionsClientListByInvoiceSectionResponse` +- New field `SystemData`, `Tags` in struct `Transaction` +- New field `ConsumptionCommitmentDecremented`, `CreditType`, `IsThirdParty`, `PartNumber`, `ReasonCode`, `RefundTransactionDetails`, `SpecialTaxationType` in struct `TransactionProperties` +- New field `Count`, `Filter`, `OrderBy`, `Search`, `Skip`, `Top` in struct `TransactionsClientListByInvoiceOptions` + + ## 0.7.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/billing/armbilling/accounts_client.go b/sdk/resourcemanager/billing/armbilling/accounts_client.go index 3c26825d3cc7..c611e02c908b 100644 --- a/sdk/resourcemanager/billing/armbilling/accounts_client.go +++ b/sdk/resourcemanager/billing/armbilling/accounts_client.go @@ -11,13 +11,16 @@ package armbilling import ( "context" "errors" + "net/http" + "net/url" + "strconv" + "strings" + "time" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" ) // AccountsClient contains the methods for the BillingAccounts group. @@ -40,10 +43,219 @@ func NewAccountsClient(credential azcore.TokenCredential, options *arm.ClientOpt return client, nil } +// BeginAddPaymentTerms - Adds payment terms to all the billing profiles under the billing account. Currently, payment terms +// can be added only on billing accounts that have Agreement Type as 'Microsoft Customer Agreement' and +// AccountType as 'Enterprise'. This action needs pre-authorization and only Field Sellers are authorized to add the payment +// terms and is not a self-serve action. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - parameters - The properties of payment term. +// - options - AccountsClientBeginAddPaymentTermsOptions contains the optional parameters for the AccountsClient.BeginAddPaymentTerms +// method. +func (client *AccountsClient) BeginAddPaymentTerms(ctx context.Context, billingAccountName string, parameters []*PaymentTerm, options *AccountsClientBeginAddPaymentTermsOptions) (*runtime.Poller[AccountsClientAddPaymentTermsResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.addPaymentTerms(ctx, billingAccountName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AccountsClientAddPaymentTermsResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AccountsClientAddPaymentTermsResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// AddPaymentTerms - Adds payment terms to all the billing profiles under the billing account. Currently, payment terms can +// be added only on billing accounts that have Agreement Type as 'Microsoft Customer Agreement' and +// AccountType as 'Enterprise'. This action needs pre-authorization and only Field Sellers are authorized to add the payment +// terms and is not a self-serve action. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *AccountsClient) addPaymentTerms(ctx context.Context, billingAccountName string, parameters []*PaymentTerm, options *AccountsClientBeginAddPaymentTermsOptions) (*http.Response, error) { + var err error + const operationName = "AccountsClient.BeginAddPaymentTerms" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.addPaymentTermsCreateRequest(ctx, billingAccountName, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// addPaymentTermsCreateRequest creates the AddPaymentTerms request. +func (client *AccountsClient) addPaymentTermsCreateRequest(ctx context.Context, billingAccountName string, parameters []*PaymentTerm, options *AccountsClientBeginAddPaymentTermsOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/addPaymentTerms" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// BeginCancelPaymentTerms - Cancels all the payment terms on billing account that falls after the cancellation date in the +// request. Currently, cancel payment terms is only served by admin actions and is not a self-serve action. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - parameters - Date after which any payment terms that needs to be cancelled. +// - options - AccountsClientBeginCancelPaymentTermsOptions contains the optional parameters for the AccountsClient.BeginCancelPaymentTerms +// method. +func (client *AccountsClient) BeginCancelPaymentTerms(ctx context.Context, billingAccountName string, parameters time.Time, options *AccountsClientBeginCancelPaymentTermsOptions) (*runtime.Poller[AccountsClientCancelPaymentTermsResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.cancelPaymentTerms(ctx, billingAccountName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AccountsClientCancelPaymentTermsResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AccountsClientCancelPaymentTermsResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CancelPaymentTerms - Cancels all the payment terms on billing account that falls after the cancellation date in the request. +// Currently, cancel payment terms is only served by admin actions and is not a self-serve action. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *AccountsClient) cancelPaymentTerms(ctx context.Context, billingAccountName string, parameters time.Time, options *AccountsClientBeginCancelPaymentTermsOptions) (*http.Response, error) { + var err error + const operationName = "AccountsClient.BeginCancelPaymentTerms" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.cancelPaymentTermsCreateRequest(ctx, billingAccountName, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// cancelPaymentTermsCreateRequest creates the CancelPaymentTerms request. +func (client *AccountsClient) cancelPaymentTermsCreateRequest(ctx context.Context, billingAccountName string, parameters time.Time, options *AccountsClientBeginCancelPaymentTermsOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/cancelPaymentTerms" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// ConfirmTransition - Gets the transition details for a billing account that has transitioned from agreement type Microsoft +// Online Services Program to agreement type Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - options - AccountsClientConfirmTransitionOptions contains the optional parameters for the AccountsClient.ConfirmTransition +// method. +func (client *AccountsClient) ConfirmTransition(ctx context.Context, billingAccountName string, options *AccountsClientConfirmTransitionOptions) (AccountsClientConfirmTransitionResponse, error) { + var err error + const operationName = "AccountsClient.ConfirmTransition" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.confirmTransitionCreateRequest(ctx, billingAccountName, options) + if err != nil { + return AccountsClientConfirmTransitionResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AccountsClientConfirmTransitionResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AccountsClientConfirmTransitionResponse{}, err + } + resp, err := client.confirmTransitionHandleResponse(httpResp) + return resp, err +} + +// confirmTransitionCreateRequest creates the ConfirmTransition request. +func (client *AccountsClient) confirmTransitionCreateRequest(ctx context.Context, billingAccountName string, options *AccountsClientConfirmTransitionOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/confirmTransition" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// confirmTransitionHandleResponse handles the ConfirmTransition response. +func (client *AccountsClient) confirmTransitionHandleResponse(resp *http.Response) (AccountsClientConfirmTransitionResponse, error) { + result := AccountsClientConfirmTransitionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TransitionDetails); err != nil { + return AccountsClientConfirmTransitionResponse{}, err + } + return result, nil +} + // Get - Gets a billing account by its ID. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - options - AccountsClientGetOptions contains the optional parameters for the AccountsClient.Get method. func (client *AccountsClient) Get(ctx context.Context, billingAccountName string, options *AccountsClientGetOptions) (AccountsClientGetResponse, error) { @@ -80,10 +292,7 @@ func (client *AccountsClient) getCreateRequest(ctx context.Context, billingAccou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") - if options != nil && options.Expand != nil { - reqQP.Set("$expand", *options.Expand) - } + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -100,7 +309,7 @@ func (client *AccountsClient) getHandleResponse(resp *http.Response) (AccountsCl // NewListPager - Lists the billing accounts that a user has access to. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - options - AccountsClientListOptions contains the optional parameters for the AccountsClient.NewListPager method. func (client *AccountsClient) NewListPager(options *AccountsClientListOptions) *runtime.Pager[AccountsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AccountsClientListResponse]{ @@ -133,9 +342,42 @@ func (client *AccountsClient) listCreateRequest(ctx context.Context, options *Ac return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") if options != nil && options.Expand != nil { - reqQP.Set("$expand", *options.Expand) + reqQP.Set("expand", *options.Expand) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.IncludeAll != nil { + reqQP.Set("includeAll", strconv.FormatBool(*options.IncludeAll)) + } + if options != nil && options.IncludeAllWithoutBillingProfiles != nil { + reqQP.Set("includeAllWithoutBillingProfiles", strconv.FormatBool(*options.IncludeAllWithoutBillingProfiles)) + } + if options != nil && options.IncludeDeleted != nil { + reqQP.Set("includeDeleted", strconv.FormatBool(*options.IncludeDeleted)) + } + if options != nil && options.IncludePendingAgreement != nil { + reqQP.Set("includePendingAgreement", strconv.FormatBool(*options.IncludePendingAgreement)) + } + if options != nil && options.IncludeResellee != nil { + reqQP.Set("includeResellee", strconv.FormatBool(*options.IncludeResellee)) + } + if options != nil && options.LegalOwnerOID != nil { + reqQP.Set("legalOwnerOID", *options.LegalOwnerOID) + } + if options != nil && options.LegalOwnerTID != nil { + reqQP.Set("legalOwnerTID", *options.LegalOwnerTID) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} @@ -155,7 +397,7 @@ func (client *AccountsClient) listHandleResponse(resp *http.Response) (AccountsC // to create Azure subscriptions. The operation is supported only for billing accounts with agreement type Microsoft Customer // Agreement. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - options - AccountsClientListInvoiceSectionsByCreateSubscriptionPermissionOptions contains the optional parameters for the // AccountsClient.NewListInvoiceSectionsByCreateSubscriptionPermissionPager method. @@ -194,7 +436,10 @@ func (client *AccountsClient) listInvoiceSectionsByCreateSubscriptionPermissionC return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -203,28 +448,31 @@ func (client *AccountsClient) listInvoiceSectionsByCreateSubscriptionPermissionC // listInvoiceSectionsByCreateSubscriptionPermissionHandleResponse handles the ListInvoiceSectionsByCreateSubscriptionPermission response. func (client *AccountsClient) listInvoiceSectionsByCreateSubscriptionPermissionHandleResponse(resp *http.Response) (AccountsClientListInvoiceSectionsByCreateSubscriptionPermissionResponse, error) { result := AccountsClientListInvoiceSectionsByCreateSubscriptionPermissionResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.InvoiceSectionListWithCreateSubPermissionResult); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.InvoiceSectionWithCreateSubPermissionListResult); err != nil { return AccountsClientListInvoiceSectionsByCreateSubscriptionPermissionResponse{}, err } return result, nil } -// BeginUpdate - Updates the properties of a billing account. Currently, displayName and address can be updated. The operation -// is supported only for billing accounts with agreement type Microsoft Customer Agreement. +// BeginUpdate - Updates the properties of a billing account. Currently, displayName and address can be updated for billing +// accounts with agreement type Microsoft Customer Agreement. Currently address and notification +// email address can be updated for billing accounts with agreement type Microsoft Online Services Agreement. Currently, purchase +// order number can be edited for billing accounts with agreement type +// Enterprise Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. -// - parameters - Request parameters that are provided to the update billing account operation. +// - parameters - A billing account. // - options - AccountsClientBeginUpdateOptions contains the optional parameters for the AccountsClient.BeginUpdate method. -func (client *AccountsClient) BeginUpdate(ctx context.Context, billingAccountName string, parameters AccountUpdateRequest, options *AccountsClientBeginUpdateOptions) (*runtime.Poller[AccountsClientUpdateResponse], error) { +func (client *AccountsClient) BeginUpdate(ctx context.Context, billingAccountName string, parameters AccountPatch, options *AccountsClientBeginUpdateOptions) (*runtime.Poller[AccountsClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, billingAccountName, parameters, options) if err != nil { return nil, err } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AccountsClientUpdateResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + FinalStateVia: runtime.FinalStateViaLocation, Tracer: client.internal.Tracer(), }) return poller, err @@ -235,12 +483,15 @@ func (client *AccountsClient) BeginUpdate(ctx context.Context, billingAccountNam } } -// Update - Updates the properties of a billing account. Currently, displayName and address can be updated. The operation -// is supported only for billing accounts with agreement type Microsoft Customer Agreement. +// Update - Updates the properties of a billing account. Currently, displayName and address can be updated for billing accounts +// with agreement type Microsoft Customer Agreement. Currently address and notification +// email address can be updated for billing accounts with agreement type Microsoft Online Services Agreement. Currently, purchase +// order number can be edited for billing accounts with agreement type +// Enterprise Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 -func (client *AccountsClient) update(ctx context.Context, billingAccountName string, parameters AccountUpdateRequest, options *AccountsClientBeginUpdateOptions) (*http.Response, error) { +// Generated from API version 2024-04-01 +func (client *AccountsClient) update(ctx context.Context, billingAccountName string, parameters AccountPatch, options *AccountsClientBeginUpdateOptions) (*http.Response, error) { var err error const operationName = "AccountsClient.BeginUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) @@ -262,7 +513,7 @@ func (client *AccountsClient) update(ctx context.Context, billingAccountName str } // updateCreateRequest creates the Update request. -func (client *AccountsClient) updateCreateRequest(ctx context.Context, billingAccountName string, parameters AccountUpdateRequest, options *AccountsClientBeginUpdateOptions) (*policy.Request, error) { +func (client *AccountsClient) updateCreateRequest(ctx context.Context, billingAccountName string, parameters AccountPatch, options *AccountsClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") @@ -273,7 +524,59 @@ func (client *AccountsClient) updateCreateRequest(ctx context.Context, billingAc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// ValidatePaymentTerms - Validates payment terms on a billing account with agreement type 'Microsoft Customer Agreement' +// and account type 'Enterprise'. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - parameters - The properties of payment term. +// - options - AccountsClientValidatePaymentTermsOptions contains the optional parameters for the AccountsClient.ValidatePaymentTerms +// method. +func (client *AccountsClient) ValidatePaymentTerms(ctx context.Context, billingAccountName string, parameters []*PaymentTerm, options *AccountsClientValidatePaymentTermsOptions) (AccountsClientValidatePaymentTermsResponse, error) { + var err error + const operationName = "AccountsClient.ValidatePaymentTerms" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.validatePaymentTermsCreateRequest(ctx, billingAccountName, parameters, options) + if err != nil { + return AccountsClientValidatePaymentTermsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AccountsClientValidatePaymentTermsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AccountsClientValidatePaymentTermsResponse{}, err + } + resp, err := client.validatePaymentTermsHandleResponse(httpResp) + return resp, err +} + +// validatePaymentTermsCreateRequest creates the ValidatePaymentTerms request. +func (client *AccountsClient) validatePaymentTermsCreateRequest(ctx context.Context, billingAccountName string, parameters []*PaymentTerm, options *AccountsClientValidatePaymentTermsOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/validatePaymentTerms" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -281,3 +584,12 @@ func (client *AccountsClient) updateCreateRequest(ctx context.Context, billingAc } return req, nil } + +// validatePaymentTermsHandleResponse handles the ValidatePaymentTerms response. +func (client *AccountsClient) validatePaymentTermsHandleResponse(resp *http.Response) (AccountsClientValidatePaymentTermsResponse, error) { + result := AccountsClientValidatePaymentTermsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PaymentTermsEligibilityResult); err != nil { + return AccountsClientValidatePaymentTermsResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/accounts_client_example_test.go b/sdk/resourcemanager/billing/armbilling/accounts_client_example_test.go index 8afe2b5ffef1..6b4ff246f1a2 100644 --- a/sdk/resourcemanager/billing/armbilling/accounts_client_example_test.go +++ b/sdk/resourcemanager/billing/armbilling/accounts_client_example_test.go @@ -13,13 +13,15 @@ import ( "context" "log" + "time" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingAccountsList.json -func ExampleAccountsClient_NewListPager_billingAccountsList() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentTermsAdd.json +func ExampleAccountsClient_BeginAddPaymentTerms() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -29,61 +31,44 @@ func ExampleAccountsClient_NewListPager_billingAccountsList() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewAccountsClient().NewListPager(&armbilling.AccountsClientListOptions{Expand: nil}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.AccountListResult = armbilling.AccountListResult{ - // Value: []*armbilling.Account{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000"), - // Properties: &armbilling.AccountProperties{ - // AccountStatus: to.Ptr(armbilling.AccountStatusActive), - // AccountType: to.Ptr(armbilling.AccountTypeEnterprise), - // AgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftCustomerAgreement), - // DisplayName: to.Ptr("Test Account 1"), - // HasReadAccess: to.Ptr(true), - // }, - // }, - // { - // Name: to.Ptr("10000000-0000-0000-0000-000000000001_00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000001_00000000-0000-0000-0000-000000000000"), - // Properties: &armbilling.AccountProperties{ - // AccountStatus: to.Ptr(armbilling.AccountStatusActive), - // AccountType: to.Ptr(armbilling.AccountTypeEnterprise), - // AgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftCustomerAgreement), - // DisplayName: to.Ptr("Test Account 2"), - // HasReadAccess: to.Ptr(true), - // }, - // }, - // { - // Name: to.Ptr("20000000-0000-0000-0000-000000000002_00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-0000-0000-0000-000000000002_00000000-0000-0000-0000-000000000000"), - // Properties: &armbilling.AccountProperties{ - // AccountStatus: to.Ptr(armbilling.AccountStatusActive), - // AccountType: to.Ptr(armbilling.AccountTypeEnterprise), - // AgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftCustomerAgreement), - // DisplayName: to.Ptr("Test Account 3"), - // HasReadAccess: to.Ptr(true), - // }, - // }}, - // } + poller, err := clientFactory.NewAccountsClient().BeginAddPaymentTerms(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", []*armbilling.PaymentTerm{ + { + EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-25T22:39:34.260Z"); return t }()), + StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t }()), + Term: to.Ptr("net10"), + }}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Account = armbilling.Account{ + // Name: to.Ptr("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/010000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // }, + // Properties: &armbilling.AccountProperties{ + // AccountStatus: to.Ptr(armbilling.AccountStatusActive), + // AccountSubType: to.Ptr(armbilling.AccountSubTypeEnterprise), + // AccountType: to.Ptr(armbilling.AccountTypeBusiness), + // AgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftCustomerAgreement), + // DisplayName: to.Ptr("Premier Business Account"), + // HasReadAccess: to.Ptr(true), + // PrimaryBillingTenantID: to.Ptr("20000000-0000-0000-0000-000000000001"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingAccountsListWithExpand.json -func ExampleAccountsClient_NewListPager_billingAccountsListWithExpand() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentTermsCancel.json +func ExampleAccountsClient_BeginCancelPaymentTerms() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -93,366 +78,39 @@ func ExampleAccountsClient_NewListPager_billingAccountsListWithExpand() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewAccountsClient().NewListPager(&armbilling.AccountsClientListOptions{Expand: to.Ptr("soldTo,billingProfiles,billingProfiles/invoiceSections")}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.AccountListResult = armbilling.AccountListResult{ - // Value: []*armbilling.Account{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000"), - // Properties: &armbilling.AccountProperties{ - // AccountStatus: to.Ptr(armbilling.AccountStatusActive), - // AccountType: to.Ptr(armbilling.AccountTypeEnterprise), - // AgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftCustomerAgreement), - // BillingProfiles: &armbilling.ProfilesOnExpand{ - // HasMoreResults: to.Ptr(true), - // Value: []*armbilling.Profile{ - // { - // Name: to.Ptr("11000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000/billingProfiles/11000000-0000-0000-0000-000000000000"), - // Properties: &armbilling.ProfileProperties{ - // BillTo: &armbilling.AddressDetails{ - // AddressLine1: to.Ptr("Test Address1"), - // AddressLine2: to.Ptr("Test Address2"), - // AddressLine3: to.Ptr("Test Address3"), - // City: to.Ptr("City"), - // CompanyName: to.Ptr("Contoso"), - // Country: to.Ptr("US"), - // Email: to.Ptr("abc@contoso.com"), - // FirstName: to.Ptr("Test"), - // LastName: to.Ptr("User"), - // PhoneNumber: to.Ptr("000-000-0000"), - // PostalCode: to.Ptr("00000"), - // Region: to.Ptr("WA"), - // }, - // BillingRelationshipType: to.Ptr(armbilling.BillingRelationshipTypeDirect), - // Currency: to.Ptr("USD"), - // DisplayName: to.Ptr("BillingProfile1"), - // EnabledAzurePlans: []*armbilling.AzurePlan{ - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan"), - // SKUID: to.Ptr("0001"), - // }, - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), - // SKUID: to.Ptr("0002"), - // }}, - // HasReadAccess: to.Ptr(true), - // InvoiceDay: to.Ptr[int32](5), - // InvoiceEmailOptIn: to.Ptr(true), - // InvoiceSections: &armbilling.InvoiceSectionsOnExpand{ - // HasMoreResults: to.Ptr(false), - // Value: []*armbilling.InvoiceSection{ - // { - // Name: to.Ptr("invoiceSectionId1"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000/billingProfiles/11000000-0000-0000-0000-000000000000/invoiceSections/invoiceSectionId1"), - // Properties: &armbilling.InvoiceSectionProperties{ - // DisplayName: to.Ptr("invoiceSectionName1"), - // Labels: map[string]*string{ - // "costCategory": to.Ptr("Support"), - // "pcCode": to.Ptr("A123456"), - // }, - // State: to.Ptr(armbilling.InvoiceSectionStateActive), - // SystemID: to.Ptr("9XXX-11XX-XX1-XXXX-XXX"), - // }, - // }, - // { - // Name: to.Ptr("invoiceSectionId2"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000/billingProfiles/11000000-0000-0000-0000-000000000000/invoiceSections/invoiceSectionId2"), - // Properties: &armbilling.InvoiceSectionProperties{ - // DisplayName: to.Ptr("invoiceSectionName2"), - // Labels: map[string]*string{ - // "costCategory": to.Ptr("Finance"), - // "pcCode": to.Ptr("B223456"), - // }, - // State: to.Ptr(armbilling.InvoiceSectionStateActive), - // SystemID: to.Ptr("9XXX-22XX-XX1-XXXX-XXX"), - // }, - // }}, - // }, - // PoNumber: to.Ptr("ABC12345"), - // SpendingLimit: to.Ptr(armbilling.SpendingLimitOn), - // Status: to.Ptr(armbilling.BillingProfileStatusWarned), - // StatusReasonCode: to.Ptr(armbilling.StatusReasonCodePastDue), - // SystemID: to.Ptr("1XXX-11XX-XX1-XXXX-XXX"), - // }, - // }, - // { - // Name: to.Ptr("11000000-0000-0000-0000-000000000001"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000/billingProfiles/11000000-0000-0000-0000-000000000001"), - // Properties: &armbilling.ProfileProperties{ - // BillTo: &armbilling.AddressDetails{ - // AddressLine1: to.Ptr("Test Address1"), - // AddressLine2: to.Ptr("Test Address2"), - // AddressLine3: to.Ptr("Test Address3"), - // City: to.Ptr("City"), - // CompanyName: to.Ptr("Contoso"), - // Country: to.Ptr("US"), - // Email: to.Ptr("abc@contoso.com"), - // FirstName: to.Ptr("Test"), - // LastName: to.Ptr("User"), - // PhoneNumber: to.Ptr("000-000-0000"), - // PostalCode: to.Ptr("00000"), - // Region: to.Ptr("WA"), - // }, - // BillingRelationshipType: to.Ptr(armbilling.BillingRelationshipTypeCSPPartner), - // Currency: to.Ptr("USD"), - // DisplayName: to.Ptr("BillingProfile2"), - // EnabledAzurePlans: []*armbilling.AzurePlan{ - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan"), - // SKUID: to.Ptr("0001"), - // }, - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), - // SKUID: to.Ptr("0002"), - // }}, - // HasReadAccess: to.Ptr(true), - // InvoiceDay: to.Ptr[int32](5), - // InvoiceEmailOptIn: to.Ptr(true), - // InvoiceSections: &armbilling.InvoiceSectionsOnExpand{ - // HasMoreResults: to.Ptr(false), - // Value: []*armbilling.InvoiceSection{ - // { - // Name: to.Ptr("invoiceSectionId11"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000/billingProfiles/11000000-0000-0000-0000-000000000001/invoiceSections/invoiceSectionId11"), - // Properties: &armbilling.InvoiceSectionProperties{ - // DisplayName: to.Ptr("invoiceSectionName11"), - // Labels: map[string]*string{ - // "costCategory": to.Ptr("Marketing"), - // "pcCode": to.Ptr("Z223456"), - // }, - // State: to.Ptr(armbilling.InvoiceSectionStateActive), - // SystemID: to.Ptr("9XXX-33XX-XX1-XXXX-XXX"), - // }, - // }}, - // }, - // PoNumber: to.Ptr("ABC12345"), - // SpendingLimit: to.Ptr(armbilling.SpendingLimitOff), - // Status: to.Ptr(armbilling.BillingProfileStatusActive), - // SystemID: to.Ptr("2XXX-22XX-XX1-XXXX-XXX"), - // }, - // }}, - // }, - // DisplayName: to.Ptr("Test Account 1"), - // HasReadAccess: to.Ptr(true), - // SoldTo: &armbilling.AddressDetails{ - // AddressLine1: to.Ptr("Test Address"), - // AddressLine2: to.Ptr("Test Address"), - // AddressLine3: to.Ptr("Test Address"), - // City: to.Ptr("City"), - // CompanyName: to.Ptr("Contoso"), - // Country: to.Ptr("US"), - // Email: to.Ptr("abc@contoso.com"), - // FirstName: to.Ptr("Test"), - // LastName: to.Ptr("User"), - // PhoneNumber: to.Ptr("000-000-0000"), - // PostalCode: to.Ptr("00000"), - // Region: to.Ptr("WA"), - // }, - // }, - // }, - // { - // Name: to.Ptr("10000000-0000-0000-0000-000000000001_00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000001_00000000-0000-0000-0000-000000000000"), - // Properties: &armbilling.AccountProperties{ - // AccountStatus: to.Ptr(armbilling.AccountStatusActive), - // AccountType: to.Ptr(armbilling.AccountTypeEnterprise), - // AgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftCustomerAgreement), - // BillingProfiles: &armbilling.ProfilesOnExpand{ - // HasMoreResults: to.Ptr(true), - // Value: []*armbilling.Profile{ - // { - // Name: to.Ptr("11000000-0000-0000-0000-000000000004"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000001_00000000-0000-0000-0000-000000000000/billingProfiles/11000000-0000-0000-0000-000000000004"), - // Properties: &armbilling.ProfileProperties{ - // BillTo: &armbilling.AddressDetails{ - // AddressLine1: to.Ptr("Test Address1"), - // AddressLine2: to.Ptr("Test Address2"), - // AddressLine3: to.Ptr("Test Address3"), - // City: to.Ptr("City"), - // CompanyName: to.Ptr("Contoso Test"), - // Country: to.Ptr("US"), - // Email: to.Ptr("abc@contoso.com"), - // FirstName: to.Ptr("Test"), - // LastName: to.Ptr("User"), - // PhoneNumber: to.Ptr("000-000-0000"), - // PostalCode: to.Ptr("00000"), - // Region: to.Ptr("WA"), - // }, - // BillingRelationshipType: to.Ptr(armbilling.BillingRelationshipTypeIndirectPartner), - // Currency: to.Ptr("USD"), - // DisplayName: to.Ptr("BillingProfile3"), - // EnabledAzurePlans: []*armbilling.AzurePlan{ - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan"), - // SKUID: to.Ptr("0001"), - // }, - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), - // SKUID: to.Ptr("0002"), - // }}, - // HasReadAccess: to.Ptr(true), - // IndirectRelationshipInfo: &armbilling.IndirectRelationshipInfo{ - // BillingAccountName: to.Ptr("20000000-0000-0000-0000-000000000001_00000000-0000-0000-0000-000000000000"), - // BillingProfileName: to.Ptr("22000000-0000-0000-0000-000000000001"), - // DisplayName: to.Ptr("Customer1"), - // }, - // InvoiceDay: to.Ptr[int32](5), - // InvoiceEmailOptIn: to.Ptr(true), - // InvoiceSections: &armbilling.InvoiceSectionsOnExpand{ - // HasMoreResults: to.Ptr(true), - // Value: []*armbilling.InvoiceSection{ - // { - // Name: to.Ptr("invoiceSectionId3"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000001_00000000-0000-0000-0000-000000000000/billingProfiles/11000000-0000-0000-0000-000000000004/invoiceSections/invoiceSectionId3"), - // Properties: &armbilling.InvoiceSectionProperties{ - // DisplayName: to.Ptr("invoiceSectionName3"), - // Labels: map[string]*string{ - // "costCategory": to.Ptr("Support"), - // "pcCode": to.Ptr("C123456"), - // }, - // State: to.Ptr(armbilling.InvoiceSectionStateRestricted), - // SystemID: to.Ptr("9XXX-44XX-XX1-XXXX-XXX"), - // TargetCloud: to.Ptr(armbilling.TargetCloudUSNat), - // }, - // }, - // { - // Name: to.Ptr("invoiceSectionId4"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000001_00000000-0000-0000-0000-000000000000/billingProfiles/11000000-0000-0000-0000-000000000004/invoiceSections/invoiceSectionId4"), - // Properties: &armbilling.InvoiceSectionProperties{ - // DisplayName: to.Ptr("invoiceSectionName4"), - // Labels: map[string]*string{ - // "costCategory": to.Ptr("Marketing"), - // "pcCode": to.Ptr("D123456"), - // }, - // State: to.Ptr(armbilling.InvoiceSectionStateRestricted), - // SystemID: to.Ptr("9XXX-55XX-XX1-XXXX-XXX"), - // TargetCloud: to.Ptr(armbilling.TargetCloudUSSec), - // }, - // }}, - // }, - // PoNumber: to.Ptr("ABC12345"), - // SpendingLimit: to.Ptr(armbilling.SpendingLimitOn), - // Status: to.Ptr(armbilling.BillingProfileStatusWarned), - // StatusReasonCode: to.Ptr(armbilling.StatusReasonCodePastDue), - // SystemID: to.Ptr("3XXX-33XX-XX1-XXXX-XXX"), - // TargetClouds: []*armbilling.TargetCloud{ - // to.Ptr(armbilling.TargetCloudUSNat), - // to.Ptr(armbilling.TargetCloudUSSec)}, - // }, - // }, - // { - // Name: to.Ptr("11000000-0000-0000-0000-000000000005"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000001_00000000-0000-0000-0000-000000000000/billingProfiles/11000000-0000-0000-0000-000000000005"), - // Properties: &armbilling.ProfileProperties{ - // BillTo: &armbilling.AddressDetails{ - // AddressLine1: to.Ptr("Test Address1"), - // AddressLine2: to.Ptr("Test Address2"), - // AddressLine3: to.Ptr("Test Address3"), - // City: to.Ptr("City"), - // CompanyName: to.Ptr("Contoso Test"), - // Country: to.Ptr("US"), - // Email: to.Ptr("abc@contoso.com"), - // FirstName: to.Ptr("Test"), - // LastName: to.Ptr("User"), - // PhoneNumber: to.Ptr("000-000-0000"), - // PostalCode: to.Ptr("00000"), - // Region: to.Ptr("WA"), - // }, - // BillingRelationshipType: to.Ptr(armbilling.BillingRelationshipTypeIndirectCustomer), - // Currency: to.Ptr("USD"), - // DisplayName: to.Ptr("BillingProfile4"), - // EnabledAzurePlans: []*armbilling.AzurePlan{ - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan"), - // SKUID: to.Ptr("0001"), - // }, - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), - // SKUID: to.Ptr("0002"), - // }}, - // HasReadAccess: to.Ptr(true), - // IndirectRelationshipInfo: &armbilling.IndirectRelationshipInfo{ - // BillingAccountName: to.Ptr("30000000-0000-0000-0000-000000000001_00000000-0000-0000-0000-000000000000"), - // BillingProfileName: to.Ptr("33000000-0000-0000-0000-000000000001"), - // DisplayName: to.Ptr("Partner1"), - // }, - // InvoiceDay: to.Ptr[int32](5), - // InvoiceEmailOptIn: to.Ptr(true), - // InvoiceSections: &armbilling.InvoiceSectionsOnExpand{ - // HasMoreResults: to.Ptr(true), - // Value: []*armbilling.InvoiceSection{ - // { - // Name: to.Ptr("invoiceSectionId5"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000001_00000000-0000-0000-0000-000000000000/billingProfiles/11000000-0000-0000-0000-000000000005/invoiceSections/invoiceSectionId5"), - // Properties: &armbilling.InvoiceSectionProperties{ - // DisplayName: to.Ptr("invoiceSectionName5"), - // Labels: map[string]*string{ - // "costCategory": to.Ptr("Finance"), - // "pcCode": to.Ptr("E123456"), - // }, - // State: to.Ptr(armbilling.InvoiceSectionStateActive), - // SystemID: to.Ptr("9XXX-66XX-XX1-XXXX-XXX"), - // }, - // }, - // { - // Name: to.Ptr("invoiceSectionId6"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000001_00000000-0000-0000-0000-000000000000/billingProfiles/11000000-0000-0000-0000-000000000005/invoiceSections/invoiceSectionId6"), - // Properties: &armbilling.InvoiceSectionProperties{ - // DisplayName: to.Ptr("invoiceSectionName6"), - // Labels: map[string]*string{ - // "costCategory": to.Ptr("Support"), - // "pcCode": to.Ptr("O123456"), - // }, - // State: to.Ptr(armbilling.InvoiceSectionStateRestricted), - // SystemID: to.Ptr("9XXX-77XX-XX1-XXXX-XXX"), - // TargetCloud: to.Ptr(armbilling.TargetCloudUSSec), - // }, - // }}, - // }, - // PoNumber: to.Ptr("ABC12345"), - // SpendingLimit: to.Ptr(armbilling.SpendingLimitOn), - // Status: to.Ptr(armbilling.BillingProfileStatusWarned), - // StatusReasonCode: to.Ptr(armbilling.StatusReasonCodePastDue), - // SystemID: to.Ptr("4XXX-44XX-XX1-XXXX-XXX"), - // TargetClouds: []*armbilling.TargetCloud{ - // to.Ptr(armbilling.TargetCloudUSSec)}, - // }, - // }}, - // }, - // DisplayName: to.Ptr("Test Account 2"), - // HasReadAccess: to.Ptr(true), - // }, - // }}, - // } + poller, err := clientFactory.NewAccountsClient().BeginCancelPaymentTerms(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t }(), nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Account = armbilling.Account{ + // Name: to.Ptr("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/010000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // }, + // Properties: &armbilling.AccountProperties{ + // AccountStatus: to.Ptr(armbilling.AccountStatusActive), + // AccountSubType: to.Ptr(armbilling.AccountSubTypeEnterprise), + // AccountType: to.Ptr(armbilling.AccountTypeBusiness), + // AgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftCustomerAgreement), + // DisplayName: to.Ptr("Premier Business Account"), + // HasReadAccess: to.Ptr(true), + // PrimaryBillingTenantID: to.Ptr("20000000-0000-0000-0000-000000000001"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingAccountsListWithExpandForEnrollmentDetails.json -func ExampleAccountsClient_NewListPager_billingAccountsListWithExpandForEnrollmentDetails() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsConfirmTransition.json +func ExampleAccountsClient_ConfirmTransition() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -462,7 +120,31 @@ func ExampleAccountsClient_NewListPager_billingAccountsListWithExpandForEnrollme if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewAccountsClient().NewListPager(&armbilling.AccountsClientListOptions{Expand: to.Ptr("enrollmentDetails,departments,enrollmentAccounts")}) + res, err := clientFactory.NewAccountsClient().ConfirmTransition(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.TransitionDetails = armbilling.TransitionDetails{ + // AnniversaryDay: to.Ptr[int32](12), + // TransitionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-17T00:00:00.000Z"); return t}()), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsWithCreateSubscriptionPermissionList.json +func ExampleAccountsClient_NewListInvoiceSectionsByCreateSubscriptionPermissionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAccountsClient().NewListInvoiceSectionsByCreateSubscriptionPermissionPager("10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", &armbilling.AccountsClientListInvoiceSectionsByCreateSubscriptionPermissionOptions{Filter: nil}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -473,105 +155,95 @@ func ExampleAccountsClient_NewListPager_billingAccountsListWithExpandForEnrollme _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.AccountListResult = armbilling.AccountListResult{ - // Value: []*armbilling.Account{ + // page.InvoiceSectionWithCreateSubPermissionListResult = armbilling.InvoiceSectionWithCreateSubPermissionListResult{ + // Value: []*armbilling.InvoiceSectionWithCreateSubPermission{ // { - // Name: to.Ptr("7645820"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/7645820"), - // Properties: &armbilling.AccountProperties{ - // AgreementType: to.Ptr(armbilling.AgreementTypeEnterpriseAgreement), - // Departments: []*armbilling.Department{ - // { - // Name: to.Ptr("departmentId1"), - // Type: to.Ptr("Microsoft.Billing/departments"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/departmentId1"), - // Properties: &armbilling.DepartmentProperties{ - // CostCenter: to.Ptr("C1"), - // DepartmentName: to.Ptr("departmentName1"), - // Status: to.Ptr("Active"), - // }, - // }, - // { - // Name: to.Ptr("departmentId2"), - // Type: to.Ptr("Microsoft.Billing/departments"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/departmentId2"), - // Properties: &armbilling.DepartmentProperties{ - // CostCenter: to.Ptr("C4"), - // DepartmentName: to.Ptr("departmentName2"), - // Status: to.Ptr("Active"), - // }, - // }}, - // EnrollmentAccounts: []*armbilling.EnrollmentAccount{ - // { - // Name: to.Ptr("accountId0"), - // Type: to.Ptr("Microsoft.Billing/enrollmentAccounts"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/accountId0"), - // Properties: &armbilling.EnrollmentAccountProperties{ - // AccountName: to.Ptr("AccountName0"), - // CostCenter: to.Ptr("C0"), - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-31T17:32:28.000Z"); return t}()), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T17:32:28.000Z"); return t}()), - // Status: to.Ptr("Active"), - // }, - // }, - // { - // Name: to.Ptr("accountId1"), - // Type: to.Ptr("Microsoft.Billing/enrollmentAccounts"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/accountId1"), - // Properties: &armbilling.EnrollmentAccountProperties{ - // AccountName: to.Ptr("AccountName1"), - // CostCenter: to.Ptr("C4"), - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-31T17:32:28.000Z"); return t}()), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T17:32:28.000Z"); return t}()), - // Status: to.Ptr("Active"), - // }, - // }, - // { - // Name: to.Ptr("accountId2"), - // Type: to.Ptr("Microsoft.Billing/enrollmentAccounts"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/accountId2"), - // Properties: &armbilling.EnrollmentAccountProperties{ - // AccountName: to.Ptr("AccountName2"), - // CostCenter: to.Ptr("C4"), - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-31T17:32:28.000Z"); return t}()), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T17:32:28.000Z"); return t}()), - // Status: to.Ptr("Active"), - // }, - // }}, - // EnrollmentDetails: &armbilling.Enrollment{ - // BillingCycle: to.Ptr("Monthly"), - // Channel: to.Ptr("EaDirect"), - // CountryCode: to.Ptr("US"), - // Currency: to.Ptr("USD"), - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-31T17:32:28.000Z"); return t}()), - // Policies: &armbilling.EnrollmentPolicies{ - // AccountOwnerViewCharges: to.Ptr(true), - // DepartmentAdminViewCharges: to.Ptr(true), - // MarketplaceEnabled: to.Ptr(true), - // ReservedInstancesEnabled: to.Ptr(true), - // }, - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T17:32:28.000Z"); return t}()), - // Status: to.Ptr("Active"), - // Language: to.Ptr("en"), - // }, - // SoldTo: &armbilling.AddressDetails{ - // AddressLine1: to.Ptr("Test Address"), - // AddressLine2: to.Ptr("Test Address"), - // AddressLine3: to.Ptr("Test Address"), - // City: to.Ptr("City"), - // Country: to.Ptr("US"), - // PostalCode: to.Ptr("00000"), - // Region: to.Ptr("WA"), + // BillingProfileDisplayName: to.Ptr("Billing Profile Display Name"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileSpendingLimit: to.Ptr(armbilling.SpendingLimitOn), + // BillingProfileStatus: to.Ptr(armbilling.BillingProfileStatusWarned), + // BillingProfileStatusReasonCode: to.Ptr(armbilling.BillingProfileStatusReasonCodePastDue), + // BillingProfileSystemID: to.Ptr("33000000-0000-0000-0000-000000000000"), + // EnabledAzurePlans: []*armbilling.AzurePlan{ + // { + // SKUDescription: to.Ptr("Microsoft Azure Plan"), + // SKUID: to.Ptr("0001"), // }, - // }, + // { + // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), + // SKUID: to.Ptr("0002"), + // }}, + // InvoiceSectionDisplayName: to.Ptr("Invoice Section Display Name"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy"), + // InvoiceSectionSystemID: to.Ptr("22000000-0000-0000-0000-000000000000"), // }}, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingAccountWithExpand.json -func ExampleAccountsClient_Get_billingAccountWithExpand() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentTermInvalid.json +func ExampleAccountsClient_ValidatePaymentTerms_paymentTermInvalid() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccountsClient().ValidatePaymentTerms(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", []*armbilling.PaymentTerm{ + { + EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-25T22:39:34.260Z"); return t }()), + StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-05T22:39:34.260Z"); return t }()), + Term: to.Ptr("net10"), + }}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PaymentTermsEligibilityResult = armbilling.PaymentTermsEligibilityResult{ + // EligibilityDetails: []*armbilling.PaymentTermsEligibilityDetail{ + // { + // Code: to.Ptr(armbilling.PaymentTermsEligibilityCodeInvalidDateRange), + // Message: to.Ptr("The date range is invalid. The start date must be before the end date."), + // }}, + // EligibilityStatus: to.Ptr(armbilling.PaymentTermsEligibilityStatusInvalid), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentTermValid.json +func ExampleAccountsClient_ValidatePaymentTerms_paymentTermValid() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccountsClient().ValidatePaymentTerms(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", []*armbilling.PaymentTerm{ + { + EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-25T22:39:34.260Z"); return t }()), + StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t }()), + Term: to.Ptr("net10"), + }}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PaymentTermsEligibilityResult = armbilling.PaymentTermsEligibilityResult{ + // EligibilityStatus: to.Ptr(armbilling.PaymentTermsEligibilityStatusValid), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithExpandForPONumber.json +func ExampleAccountsClient_Get_billingAccountWithExpandForPoNumber() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -581,7 +253,7 @@ func ExampleAccountsClient_Get_billingAccountWithExpand() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewAccountsClient().Get(ctx, "{billingAccountName}", &armbilling.AccountsClientGetOptions{Expand: to.Ptr("soldTo,billingProfiles,billingProfiles/invoiceSections")}) + res, err := clientFactory.NewAccountsClient().Get(ctx, "8608480", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -589,152 +261,212 @@ func ExampleAccountsClient_Get_billingAccountWithExpand() { _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Account = armbilling.Account{ - // Name: to.Ptr("{billingAccountName}"), + // Name: to.Ptr("6564892"), // Type: to.Ptr("Microsoft.Billing/billingAccounts"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/6564892"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // }, // Properties: &armbilling.AccountProperties{ // AccountStatus: to.Ptr(armbilling.AccountStatusActive), // AccountType: to.Ptr(armbilling.AccountTypeEnterprise), + // AgreementType: to.Ptr(armbilling.AgreementTypeEnterpriseAgreement), + // DisplayName: to.Ptr("Enterprise Account"), + // EnrollmentDetails: &armbilling.AccountPropertiesEnrollmentDetails{ + // BillingCycle: to.Ptr("Monthly"), + // Channel: to.Ptr("EaDirect"), + // Cloud: to.Ptr("Azure Commercial"), + // CountryCode: to.Ptr("US"), + // Currency: to.Ptr("USD"), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-31T17:32:28.000Z"); return t}()), + // ExtendedTermOption: to.Ptr(armbilling.ExtendedTermOptionOptedOut), + // PoNumber: to.Ptr("poNumber123"), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T17:32:28.000Z"); return t}()), + // SupportCoverage: to.Ptr("1/26/2021 - 6/30/2021"), + // SupportLevel: to.Ptr(armbilling.SupportLevelStandard), + // Language: to.Ptr("en"), + // }, + // HasReadAccess: to.Ptr(true), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithRegistrationNumberWithDefaultType.json +func ExampleAccountsClient_Get_billingAccountWithRegistrationNumberWithDefaultType() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccountsClient().Get(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Account = armbilling.Account{ + // Name: to.Ptr("10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // }, + // Properties: &armbilling.AccountProperties{ + // AccountStatus: to.Ptr(armbilling.AccountStatusActive), + // AccountSubType: to.Ptr(armbilling.AccountSubTypeEnterprise), + // AccountType: to.Ptr(armbilling.AccountTypeBusiness), // AgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftCustomerAgreement), - // BillingProfiles: &armbilling.ProfilesOnExpand{ - // HasMoreResults: to.Ptr(true), - // Value: []*armbilling.Profile{ - // { - // Name: to.Ptr("11000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // Properties: &armbilling.ProfileProperties{ - // BillTo: &armbilling.AddressDetails{ - // AddressLine1: to.Ptr("Test Address1"), - // AddressLine2: to.Ptr("Test Address2"), - // AddressLine3: to.Ptr("Test Address3"), - // City: to.Ptr("City"), - // CompanyName: to.Ptr("Contoso"), - // Country: to.Ptr("US"), - // Email: to.Ptr("abc@contoso.com"), - // FirstName: to.Ptr("Test"), - // LastName: to.Ptr("User"), - // PhoneNumber: to.Ptr("000-000-0000"), - // PostalCode: to.Ptr("00000"), - // Region: to.Ptr("WA"), - // }, - // BillingRelationshipType: to.Ptr(armbilling.BillingRelationshipTypeDirect), - // Currency: to.Ptr("USD"), - // DisplayName: to.Ptr("BillingProfile1"), - // EnabledAzurePlans: []*armbilling.AzurePlan{ - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan"), - // SKUID: to.Ptr("0001"), - // }, - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), - // SKUID: to.Ptr("0002"), - // }}, - // HasReadAccess: to.Ptr(true), - // InvoiceDay: to.Ptr[int32](5), - // InvoiceEmailOptIn: to.Ptr(true), - // InvoiceSections: &armbilling.InvoiceSectionsOnExpand{ - // HasMoreResults: to.Ptr(true), - // Value: []*armbilling.InvoiceSection{ - // { - // Name: to.Ptr("invoiceSectionId1"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000/invoiceSections/invoiceSectionId1"), - // Properties: &armbilling.InvoiceSectionProperties{ - // DisplayName: to.Ptr("invoiceSectionName1"), - // Labels: map[string]*string{ - // "costCategory": to.Ptr("Support"), - // "pcCode": to.Ptr("A123456"), - // }, - // State: to.Ptr(armbilling.InvoiceSectionStateActive), - // SystemID: to.Ptr("9XXX-11XX-XX1-XXXX-XXX"), - // }, - // }}, - // }, - // PoNumber: to.Ptr("ABC12345"), - // SpendingLimit: to.Ptr(armbilling.SpendingLimitOn), - // Status: to.Ptr(armbilling.BillingProfileStatusWarned), - // StatusReasonCode: to.Ptr(armbilling.StatusReasonCodePastDue), - // SystemID: to.Ptr("1XXX-11XX-XX1-XXXX-XXX"), - // }, - // }, - // { - // Name: to.Ptr("11000000-0000-0000-0000-000000000001"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000001"), - // Properties: &armbilling.ProfileProperties{ - // BillTo: &armbilling.AddressDetails{ - // AddressLine1: to.Ptr("Test Address1"), - // AddressLine2: to.Ptr("Test Address2"), - // AddressLine3: to.Ptr("Test Address3"), - // City: to.Ptr("City"), - // CompanyName: to.Ptr("Contoso"), - // Country: to.Ptr("US"), - // Email: to.Ptr("abc@contoso.com"), - // FirstName: to.Ptr("Test"), - // LastName: to.Ptr("User"), - // PhoneNumber: to.Ptr("000-000-0000"), - // PostalCode: to.Ptr("00000"), - // Region: to.Ptr("WA"), - // }, - // BillingRelationshipType: to.Ptr(armbilling.BillingRelationshipTypeIndirectCustomer), - // Currency: to.Ptr("USD"), - // DisplayName: to.Ptr("BillingProfile2"), - // EnabledAzurePlans: []*armbilling.AzurePlan{ - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan"), - // SKUID: to.Ptr("0001"), - // }, - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), - // SKUID: to.Ptr("0002"), - // }}, - // HasReadAccess: to.Ptr(true), - // IndirectRelationshipInfo: &armbilling.IndirectRelationshipInfo{ - // BillingAccountName: to.Ptr("30000000-0000-0000-0000-000000000001_00000000-0000-0000-0000-000000000000"), - // BillingProfileName: to.Ptr("33000000-0000-0000-0000-000000000001"), - // DisplayName: to.Ptr("Partner1"), - // }, - // InvoiceDay: to.Ptr[int32](5), - // InvoiceEmailOptIn: to.Ptr(true), - // InvoiceSections: &armbilling.InvoiceSectionsOnExpand{ - // HasMoreResults: to.Ptr(true), - // Value: []*armbilling.InvoiceSection{ - // { - // Name: to.Ptr("invoiceSectionId2"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000001/invoiceSections/invoiceSectionId2"), - // Properties: &armbilling.InvoiceSectionProperties{ - // DisplayName: to.Ptr("invoiceSectionName2"), - // Labels: map[string]*string{ - // "costCategory": to.Ptr("Marketing"), - // "pcCode": to.Ptr("Z223456"), - // }, - // State: to.Ptr(armbilling.InvoiceSectionStateActive), - // SystemID: to.Ptr("9XXX-22XX-XX1-XXXX-XXX"), - // }, - // }}, - // }, - // PoNumber: to.Ptr("ABC12345"), - // SpendingLimit: to.Ptr(armbilling.SpendingLimitOff), - // Status: to.Ptr(armbilling.BillingProfileStatusActive), - // SystemID: to.Ptr("2XXX-22XX-XX1-XXXX-XXX"), - // }, - // }}, + // DisplayName: to.Ptr("Premier Business Account"), + // HasReadAccess: to.Ptr(true), + // PrimaryBillingTenantID: to.Ptr("20000000-0000-0000-0000-000000000001"), + // RegistrationNumber: &armbilling.AccountPropertiesRegistrationNumber{ + // Type: []*string{ + // to.Ptr("RegistrationNumber")}, + // ID: to.Ptr("RegistrationId"), + // }, // }, - // DisplayName: to.Ptr("Test Account 1"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithRegistrationNumberWithType.json +func ExampleAccountsClient_Get_billingAccountWithRegistrationNumberWithType() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccountsClient().Get(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Account = armbilling.Account{ + // Name: to.Ptr("10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // }, + // Properties: &armbilling.AccountProperties{ + // AccountStatus: to.Ptr(armbilling.AccountStatusActive), + // AccountSubType: to.Ptr(armbilling.AccountSubTypeEnterprise), + // AccountType: to.Ptr(armbilling.AccountTypeBusiness), + // AgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftCustomerAgreement), + // DisplayName: to.Ptr("Premier Business Account"), // HasReadAccess: to.Ptr(true), - // SoldTo: &armbilling.AddressDetails{ + // PrimaryBillingTenantID: to.Ptr("20000000-0000-0000-0000-000000000001"), + // RegistrationNumber: &armbilling.AccountPropertiesRegistrationNumber{ + // Type: []*string{ + // to.Ptr("TIN")}, + // ID: to.Ptr("SomeRegistrationId"), + // Required: to.Ptr(true), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGet.json +func ExampleAccountsClient_Get_billingAccountsGet() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccountsClient().Get(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Account = armbilling.Account{ + // Name: to.Ptr("10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // }, + // Properties: &armbilling.AccountProperties{ + // AccountStatus: to.Ptr(armbilling.AccountStatusActive), + // AccountSubType: to.Ptr(armbilling.AccountSubTypeEnterprise), + // AccountType: to.Ptr(armbilling.AccountTypeBusiness), + // AgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftCustomerAgreement), + // DisplayName: to.Ptr("Premier Business Account"), + // HasReadAccess: to.Ptr(true), + // PrimaryBillingTenantID: to.Ptr("20000000-0000-0000-0000-000000000001"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGetEA.json +func ExampleAccountsClient_Get_billingAccountsGetEa() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccountsClient().Get(ctx, "6575495", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Account = armbilling.Account{ + // Name: to.Ptr("6575495"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/6575495"), + // Properties: &armbilling.AccountProperties{ + // AgreementType: to.Ptr(armbilling.AgreementTypeEnterpriseAgreement), + // EnrollmentDetails: &armbilling.AccountPropertiesEnrollmentDetails{ + // BillingCycle: to.Ptr("Monthly"), + // Channel: to.Ptr("EaDirect"), + // Cloud: to.Ptr("Azure Commercial"), + // CountryCode: to.Ptr("US"), + // Currency: to.Ptr("USD"), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-31T17:32:28.000Z"); return t}()), + // ExtendedTermOption: to.Ptr(armbilling.ExtendedTermOptionOptedOut), + // IndirectRelationshipInfo: &armbilling.EnrollmentDetailsIndirectRelationshipInfo{ + // BillingAccountName: to.Ptr("pcn.12345"), + // BillingProfileName: to.Ptr(""), + // DisplayName: to.Ptr("Test partner"), + // }, + // InvoiceRecipient: to.Ptr("abc@contoso.com"), + // MarkupStatus: to.Ptr(armbilling.MarkupStatusPublished), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T17:32:28.000Z"); return t}()), + // SupportCoverage: to.Ptr("1/26/2021 - 6/30/2021"), + // SupportLevel: to.Ptr(armbilling.SupportLevelStandard), + // Language: to.Ptr("en"), + // }, + // SoldTo: &armbilling.AccountPropertiesSoldTo{ // AddressLine1: to.Ptr("Test Address"), // AddressLine2: to.Ptr("Test Address"), // AddressLine3: to.Ptr("Test Address"), // City: to.Ptr("City"), - // CompanyName: to.Ptr("Contoso"), // Country: to.Ptr("US"), - // Email: to.Ptr("abc@contoso.com"), - // FirstName: to.Ptr("Test"), - // LastName: to.Ptr("User"), - // PhoneNumber: to.Ptr("000-000-0000"), // PostalCode: to.Ptr("00000"), // Region: to.Ptr("WA"), // }, @@ -742,8 +474,55 @@ func ExampleAccountsClient_Get_billingAccountWithExpand() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingAccount.json -func ExampleAccountsClient_Get_billingAccounts() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGetWithExpand.json +func ExampleAccountsClient_Get_billingAccountsGetWithExpand() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccountsClient().Get(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Account = armbilling.Account{ + // Name: to.Ptr("10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // }, + // Properties: &armbilling.AccountProperties{ + // AccountStatus: to.Ptr(armbilling.AccountStatusActive), + // AccountSubType: to.Ptr(armbilling.AccountSubTypeEnterprise), + // AccountType: to.Ptr(armbilling.AccountTypeBusiness), + // AgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftCustomerAgreement), + // DisplayName: to.Ptr("Premier Business Account"), + // HasReadAccess: to.Ptr(true), + // PrimaryBillingTenantID: to.Ptr("20000000-0000-0000-0000-000000000001"), + // SoldTo: &armbilling.AccountPropertiesSoldTo{ + // AddressLine1: to.Ptr("1 Microsoft Way"), + // City: to.Ptr("Redmond"), + // CompanyName: to.Ptr("Contoso"), + // Country: to.Ptr("US"), + // IsValidAddress: to.Ptr(true), + // PostalCode: to.Ptr("98052-8300"), + // Region: to.Ptr("WA"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountUpdateWithPONumber.json +func ExampleAccountsClient_BeginUpdate_billingAccountUpdateWithPoNumber() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -753,29 +532,67 @@ func ExampleAccountsClient_Get_billingAccounts() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewAccountsClient().Get(ctx, "{billingAccountName}", &armbilling.AccountsClientGetOptions{Expand: nil}) + poller, err := clientFactory.NewAccountsClient().BeginUpdate(ctx, "6575495", armbilling.AccountPatch{ + Properties: &armbilling.AccountProperties{ + EnrollmentDetails: &armbilling.AccountPropertiesEnrollmentDetails{ + PoNumber: to.Ptr("poNumber123"), + }, + }, + }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Account = armbilling.Account{ - // Name: to.Ptr("{billingAccountName}"), + // Name: to.Ptr("6575495"), // Type: to.Ptr("Microsoft.Billing/billingAccounts"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/6575495"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // }, // Properties: &armbilling.AccountProperties{ // AccountStatus: to.Ptr(armbilling.AccountStatusActive), + // AccountSubType: to.Ptr(armbilling.AccountSubTypeNone), // AccountType: to.Ptr(armbilling.AccountTypeEnterprise), - // AgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftCustomerAgreement), - // DisplayName: to.Ptr("Test Account"), + // AgreementType: to.Ptr(armbilling.AgreementTypeEnterpriseAgreement), + // DisplayName: to.Ptr("Enterprise Account"), + // EnrollmentDetails: &armbilling.AccountPropertiesEnrollmentDetails{ + // BillingCycle: to.Ptr("Monthly"), + // Channel: to.Ptr("EaDirect"), + // Cloud: to.Ptr("Azure Commercial"), + // CountryCode: to.Ptr("US"), + // Currency: to.Ptr("USD"), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-31T17:32:28.000Z"); return t}()), + // ExtendedTermOption: to.Ptr(armbilling.ExtendedTermOptionOptedOut), + // PoNumber: to.Ptr("poNumber123"), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T17:32:28.000Z"); return t}()), + // SupportCoverage: to.Ptr("1/26/2021 - 6/30/2021"), + // SupportLevel: to.Ptr(armbilling.SupportLevelStandard), + // Language: to.Ptr("en"), + // }, // HasReadAccess: to.Ptr(true), + // SoldTo: &armbilling.AccountPropertiesSoldTo{ + // AddressLine1: to.Ptr("Test Address"), + // AddressLine2: to.Ptr("Test Address"), + // AddressLine3: to.Ptr("Test Address"), + // City: to.Ptr("City"), + // Country: to.Ptr("US"), + // PostalCode: to.Ptr("00000"), + // Region: to.Ptr("WA"), + // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/UpdateBillingAccount.json -func ExampleAccountsClient_BeginUpdate() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsUpdate.json +func ExampleAccountsClient_BeginUpdate_billingAccountsUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -785,17 +602,15 @@ func ExampleAccountsClient_BeginUpdate() { if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := clientFactory.NewAccountsClient().BeginUpdate(ctx, "{billingAccountName}", armbilling.AccountUpdateRequest{ + poller, err := clientFactory.NewAccountsClient().BeginUpdate(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", armbilling.AccountPatch{ Properties: &armbilling.AccountProperties{ DisplayName: to.Ptr("Test Account"), - SoldTo: &armbilling.AddressDetails{ - AddressLine1: to.Ptr("Test Address 1"), + SoldTo: &armbilling.AccountPropertiesSoldTo{ + AddressLine1: to.Ptr("1 Microsoft Way"), City: to.Ptr("Redmond"), CompanyName: to.Ptr("Contoso"), Country: to.Ptr("US"), - FirstName: to.Ptr("Test"), - LastName: to.Ptr("User"), - PostalCode: to.Ptr("12345"), + PostalCode: to.Ptr("98052-8300"), Region: to.Ptr("WA"), }, }, @@ -811,31 +626,36 @@ func ExampleAccountsClient_BeginUpdate() { _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Account = armbilling.Account{ - // Name: to.Ptr("{billingAccountName}"), + // Name: to.Ptr("10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), // Type: to.Ptr("Microsoft.Billing/billingAccounts"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // }, // Properties: &armbilling.AccountProperties{ // AccountStatus: to.Ptr(armbilling.AccountStatusActive), - // AccountType: to.Ptr(armbilling.AccountTypeEnterprise), + // AccountSubType: to.Ptr(armbilling.AccountSubTypeEnterprise), + // AccountType: to.Ptr(armbilling.AccountTypeBusiness), // AgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftCustomerAgreement), - // DisplayName: to.Ptr("Test Account"), + // DisplayName: to.Ptr("Premier Business Account"), // HasReadAccess: to.Ptr(true), - // SoldTo: &armbilling.AddressDetails{ - // AddressLine1: to.Ptr("Test Address 1"), + // PrimaryBillingTenantID: to.Ptr("20000000-0000-0000-0000-000000000001"), + // SoldTo: &armbilling.AccountPropertiesSoldTo{ + // AddressLine1: to.Ptr("1 Microsoft Way"), // City: to.Ptr("Redmond"), // CompanyName: to.Ptr("Contoso"), // Country: to.Ptr("US"), - // FirstName: to.Ptr("Test"), - // LastName: to.Ptr("User"), - // PostalCode: to.Ptr("12345"), + // IsValidAddress: to.Ptr(true), + // PostalCode: to.Ptr("98052-8300"), // Region: to.Ptr("WA"), // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/InvoiceSectionsListWithCreateSubPermission.json -func ExampleAccountsClient_NewListInvoiceSectionsByCreateSubscriptionPermissionPager() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountForLegacyAccountDetails.json +func ExampleAccountsClient_NewListPager_billingAccountForLegacyAccountDetails() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -845,7 +665,19 @@ func ExampleAccountsClient_NewListInvoiceSectionsByCreateSubscriptionPermissionP if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewAccountsClient().NewListInvoiceSectionsByCreateSubscriptionPermissionPager("{billingAccountName}", nil) + pager := clientFactory.NewAccountsClient().NewListPager(&armbilling.AccountsClientListOptions{IncludeAll: nil, + IncludeAllWithoutBillingProfiles: nil, + IncludeDeleted: nil, + IncludePendingAgreement: nil, + IncludeResellee: nil, + LegalOwnerTID: nil, + LegalOwnerOID: nil, + Filter: nil, + Expand: nil, + Top: nil, + Skip: nil, + Search: nil, + }) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -856,27 +688,211 @@ func ExampleAccountsClient_NewListInvoiceSectionsByCreateSubscriptionPermissionP _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.InvoiceSectionListWithCreateSubPermissionResult = armbilling.InvoiceSectionListWithCreateSubPermissionResult{ - // Value: []*armbilling.InvoiceSectionWithCreateSubPermission{ + // page.AccountListResult = armbilling.AccountListResult{ + // Value: []*armbilling.Account{ // { - // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // BillingProfileSpendingLimit: to.Ptr(armbilling.SpendingLimitForBillingProfileOn), - // BillingProfileStatus: to.Ptr(armbilling.BillingProfileStatusWarned), - // BillingProfileStatusReasonCode: to.Ptr(armbilling.StatusReasonCodeForBillingProfilePastDue), - // BillingProfileSystemID: to.Ptr("1XXX-11XX-XX1-XXXX-XXX"), - // EnabledAzurePlans: []*armbilling.AzurePlan{ - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan"), - // SKUID: to.Ptr("0001"), + // Name: to.Ptr("20000000-0000-0000-0000-000000000001"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-0000-0000-0000-000000000001"), + // Properties: &armbilling.AccountProperties{ + // AccountStatus: to.Ptr(armbilling.AccountStatusActive), + // AccountType: to.Ptr(armbilling.AccountTypeIndividual), + // AgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftOnlineServicesProgram), + // DisplayName: to.Ptr("Individual Account 2"), + // HasReadAccess: to.Ptr(true), + // NotificationEmailAddress: to.Ptr("individual@domain.com"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsList.json +func ExampleAccountsClient_NewListPager_billingAccountsList() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAccountsClient().NewListPager(&armbilling.AccountsClientListOptions{IncludeAll: nil, + IncludeAllWithoutBillingProfiles: nil, + IncludeDeleted: nil, + IncludePendingAgreement: nil, + IncludeResellee: nil, + LegalOwnerTID: nil, + LegalOwnerOID: nil, + Filter: nil, + Expand: nil, + Top: nil, + Skip: nil, + Search: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AccountListResult = armbilling.AccountListResult{ + // Value: []*armbilling.Account{ + // { + // Name: to.Ptr("10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // }, + // Properties: &armbilling.AccountProperties{ + // AccountStatus: to.Ptr(armbilling.AccountStatusActive), + // AccountSubType: to.Ptr(armbilling.AccountSubTypeEnterprise), + // AccountType: to.Ptr(armbilling.AccountTypeBusiness), + // AgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftCustomerAgreement), + // DisplayName: to.Ptr("Premier Business Account"), + // HasReadAccess: to.Ptr(true), + // PrimaryBillingTenantID: to.Ptr("20000000-0000-0000-0000-000000000001"), + // }, + // }, + // { + // Name: to.Ptr("20000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // }, + // Properties: &armbilling.AccountProperties{ + // AccountStatus: to.Ptr(armbilling.AccountStatusActive), + // AccountSubType: to.Ptr(armbilling.AccountSubTypeProfessional), + // AccountType: to.Ptr(armbilling.AccountTypeBusiness), + // AgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftCustomerAgreement), + // DisplayName: to.Ptr("Standard Business Account"), + // HasReadAccess: to.Ptr(true), + // PrimaryBillingTenantID: to.Ptr("20000000-0000-0000-0000-000000000001"), + // }, + // }, + // { + // Name: to.Ptr("30000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/30000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // }, + // Properties: &armbilling.AccountProperties{ + // AccountStatus: to.Ptr(armbilling.AccountStatusActive), + // AccountSubType: to.Ptr(armbilling.AccountSubTypeIndividual), + // AccountType: to.Ptr(armbilling.AccountTypeIndividual), + // AgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftCustomerAgreement), + // DisplayName: to.Ptr("Individual Account"), + // HasReadAccess: to.Ptr(true), + // PrimaryBillingTenantID: to.Ptr("20000000-0000-0000-0000-000000000001"), + // }, + // }, + // { + // Name: to.Ptr("40000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/40000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // }, + // Properties: &armbilling.AccountProperties{ + // AccountStatus: to.Ptr(armbilling.AccountStatusActive), + // AccountSubType: to.Ptr(armbilling.AccountSubTypeEnterprise), + // AccountType: to.Ptr(armbilling.AccountTypeBusiness), + // AgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftPartnerAgreement), + // DisplayName: to.Ptr("Premier Business Account"), + // HasReadAccess: to.Ptr(true), + // PrimaryBillingTenantID: to.Ptr("20000000-0000-0000-0000-000000000001"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsListWithExpandForPONumber.json +func ExampleAccountsClient_NewListPager_billingAccountsListWithExpandForPoNumber() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAccountsClient().NewListPager(&armbilling.AccountsClientListOptions{IncludeAll: nil, + IncludeAllWithoutBillingProfiles: nil, + IncludeDeleted: nil, + IncludePendingAgreement: nil, + IncludeResellee: nil, + LegalOwnerTID: nil, + LegalOwnerOID: nil, + Filter: nil, + Expand: to.Ptr("soldTo,enrollmentDetails/poNumber"), + Top: nil, + Skip: nil, + Search: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AccountListResult = armbilling.AccountListResult{ + // Value: []*armbilling.Account{ + // { + // Name: to.Ptr("6564892"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/6564892"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // }, + // Properties: &armbilling.AccountProperties{ + // AccountStatus: to.Ptr(armbilling.AccountStatusActive), + // AccountSubType: to.Ptr(armbilling.AccountSubTypeNone), + // AccountType: to.Ptr(armbilling.AccountTypeEnterprise), + // AgreementType: to.Ptr(armbilling.AgreementTypeEnterpriseAgreement), + // DisplayName: to.Ptr("Enterprise Account"), + // EnrollmentDetails: &armbilling.AccountPropertiesEnrollmentDetails{ + // BillingCycle: to.Ptr("Monthly"), + // Channel: to.Ptr("EaDirect"), + // Cloud: to.Ptr("Azure Commercial"), + // CountryCode: to.Ptr("US"), + // Currency: to.Ptr("USD"), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-31T17:32:28.000Z"); return t}()), + // ExtendedTermOption: to.Ptr(armbilling.ExtendedTermOptionOptedOut), + // PoNumber: to.Ptr("poNumber123"), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T17:32:28.000Z"); return t}()), + // SupportCoverage: to.Ptr("1/26/2021 - 6/30/2021"), + // SupportLevel: to.Ptr(armbilling.SupportLevelStandard), + // Language: to.Ptr("en"), // }, - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), - // SKUID: to.Ptr("0002"), - // }}, - // InvoiceSectionDisplayName: to.Ptr("invoiceSection1"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000/invoiceSections/22000000-0000-0000-0000-000000000000"), - // InvoiceSectionSystemID: to.Ptr("9XXX-11XX-XX1-XXXX-XXX"), + // HasReadAccess: to.Ptr(true), + // SoldTo: &armbilling.AccountPropertiesSoldTo{ + // AddressLine1: to.Ptr("Test Address"), + // City: to.Ptr("City"), + // CompanyName: to.Ptr("Enterprise Company"), + // Country: to.Ptr("US"), + // PostalCode: to.Ptr("00000-1111"), + // Region: to.Ptr("WA"), + // }, + // }, // }}, // } } diff --git a/sdk/resourcemanager/billing/armbilling/address_client.go b/sdk/resourcemanager/billing/armbilling/address_client.go index 8e6cbacb4d3c..39f3c7d85696 100644 --- a/sdk/resourcemanager/billing/armbilling/address_client.go +++ b/sdk/resourcemanager/billing/armbilling/address_client.go @@ -10,11 +10,12 @@ package armbilling import ( "context" + "net/http" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" ) // AddressClient contains the methods for the Address group. @@ -40,15 +41,16 @@ func NewAddressClient(credential azcore.TokenCredential, options *arm.ClientOpti // Validate - Validates an address. Use the operation to validate an address before using it as soldTo or a billTo address. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 +// - parameters - Address details. // - options - AddressClientValidateOptions contains the optional parameters for the AddressClient.Validate method. -func (client *AddressClient) Validate(ctx context.Context, address AddressDetails, options *AddressClientValidateOptions) (AddressClientValidateResponse, error) { +func (client *AddressClient) Validate(ctx context.Context, parameters AddressDetails, options *AddressClientValidateOptions) (AddressClientValidateResponse, error) { var err error const operationName = "AddressClient.Validate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.validateCreateRequest(ctx, address, options) + req, err := client.validateCreateRequest(ctx, parameters, options) if err != nil { return AddressClientValidateResponse{}, err } @@ -65,17 +67,17 @@ func (client *AddressClient) Validate(ctx context.Context, address AddressDetail } // validateCreateRequest creates the Validate request. -func (client *AddressClient) validateCreateRequest(ctx context.Context, address AddressDetails, options *AddressClientValidateOptions) (*policy.Request, error) { +func (client *AddressClient) validateCreateRequest(ctx context.Context, parameters AddressDetails, options *AddressClientValidateOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Billing/validateAddress" req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, address); err != nil { + if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } return req, nil @@ -84,7 +86,7 @@ func (client *AddressClient) validateCreateRequest(ctx context.Context, address // validateHandleResponse handles the Validate response. func (client *AddressClient) validateHandleResponse(resp *http.Response) (AddressClientValidateResponse, error) { result := AddressClientValidateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ValidateAddressResponse); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.AddressValidationResponse); err != nil { return AddressClientValidateResponse{}, err } return result, nil diff --git a/sdk/resourcemanager/billing/armbilling/address_client_example_test.go b/sdk/resourcemanager/billing/armbilling/address_client_example_test.go index daf018534c50..b7c01f319609 100644 --- a/sdk/resourcemanager/billing/armbilling/address_client_example_test.go +++ b/sdk/resourcemanager/billing/armbilling/address_client_example_test.go @@ -18,8 +18,8 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/AddressInvalid.json -func ExampleAddressClient_Validate_addressInvalid() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/addressValidateInvalid.json +func ExampleAddressClient_Validate_addressValidateInvalid() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -42,7 +42,7 @@ func ExampleAddressClient_Validate_addressInvalid() { // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ValidateAddressResponse = armbilling.ValidateAddressResponse{ + // res.AddressValidationResponse = armbilling.AddressValidationResponse{ // Status: to.Ptr(armbilling.AddressValidationStatusInvalid), // SuggestedAddresses: []*armbilling.AddressDetails{ // { @@ -63,8 +63,8 @@ func ExampleAddressClient_Validate_addressInvalid() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/AddressValid.json -func ExampleAddressClient_Validate_addressValid() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/addressValidateValid.json +func ExampleAddressClient_Validate_addressValidateValid() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -75,7 +75,7 @@ func ExampleAddressClient_Validate_addressValid() { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewAddressClient().Validate(ctx, armbilling.AddressDetails{ - AddressLine1: to.Ptr("1 Test Address"), + AddressLine1: to.Ptr("1 Test"), City: to.Ptr("bellevue"), Country: to.Ptr("us"), PostalCode: to.Ptr("12345"), @@ -87,15 +87,7 @@ func ExampleAddressClient_Validate_addressValid() { // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ValidateAddressResponse = armbilling.ValidateAddressResponse{ + // res.AddressValidationResponse = armbilling.AddressValidationResponse{ // Status: to.Ptr(armbilling.AddressValidationStatusValid), - // SuggestedAddresses: []*armbilling.AddressDetails{ - // { - // AddressLine1: to.Ptr("1 Test Address"), - // City: to.Ptr("Bellevue"), - // Country: to.Ptr("US"), - // PostalCode: to.Ptr("12345-0000"), - // Region: to.Ptr("WA"), - // }}, // } } diff --git a/sdk/resourcemanager/billing/armbilling/agreements_client.go b/sdk/resourcemanager/billing/armbilling/agreements_client.go index 6519a2bccd20..b81674cdd025 100644 --- a/sdk/resourcemanager/billing/armbilling/agreements_client.go +++ b/sdk/resourcemanager/billing/armbilling/agreements_client.go @@ -11,13 +11,14 @@ package armbilling import ( "context" "errors" + "net/http" + "net/url" + "strings" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" ) // AgreementsClient contains the methods for the Agreements group. @@ -43,7 +44,7 @@ func NewAgreementsClient(credential azcore.TokenCredential, options *arm.ClientO // Get - Gets an agreement by ID. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - agreementName - The ID that uniquely identifies an agreement. // - options - AgreementsClientGetOptions contains the optional parameters for the AgreementsClient.Get method. @@ -85,10 +86,7 @@ func (client *AgreementsClient) getCreateRequest(ctx context.Context, billingAcc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") - if options != nil && options.Expand != nil { - reqQP.Set("$expand", *options.Expand) - } + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -105,7 +103,7 @@ func (client *AgreementsClient) getHandleResponse(resp *http.Response) (Agreemen // NewListByBillingAccountPager - Lists the agreements for a billing account. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - options - AgreementsClientListByBillingAccountOptions contains the optional parameters for the AgreementsClient.NewListByBillingAccountPager // method. @@ -144,9 +142,9 @@ func (client *AgreementsClient) listByBillingAccountCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") if options != nil && options.Expand != nil { - reqQP.Set("$expand", *options.Expand) + reqQP.Set("expand", *options.Expand) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} diff --git a/sdk/resourcemanager/billing/armbilling/agreements_client_example_test.go b/sdk/resourcemanager/billing/armbilling/agreements_client_example_test.go index c1b1ac3ddab8..0a657aba7158 100644 --- a/sdk/resourcemanager/billing/armbilling/agreements_client_example_test.go +++ b/sdk/resourcemanager/billing/armbilling/agreements_client_example_test.go @@ -13,11 +13,46 @@ import ( "context" "log" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/AgreementsListByBillingAccount.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/agreementByName.json +func ExampleAgreementsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAgreementsClient().Get(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "ABC123", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Agreement = armbilling.Agreement{ + // Name: to.Ptr("ABC123"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/agreements"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/agreements/ABC123"), + // Properties: &armbilling.AgreementProperties{ + // AcceptanceMode: to.Ptr(armbilling.AcceptanceModeClickToAccept), + // AgreementLink: to.Ptr("https://contoso.com"), + // DisplayName: to.Ptr("Microsoft Customer Agreement"), + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-01T00:00:00.000Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-11-01T00:00:00.000Z"); return t}()), + // LeadBillingAccountName: to.Ptr("20000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // Status: to.Ptr("Active"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/agreementsListByBillingAccount.json func ExampleAgreementsClient_NewListByBillingAccountPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -28,7 +63,7 @@ func ExampleAgreementsClient_NewListByBillingAccountPager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewAgreementsClient().NewListByBillingAccountPager("{billingAccountName}", &armbilling.AgreementsClientListByBillingAccountOptions{Expand: nil}) + pager := clientFactory.NewAgreementsClient().NewListByBillingAccountPager("10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", &armbilling.AgreementsClientListByBillingAccountOptions{Expand: to.Ptr("Participants")}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -42,16 +77,17 @@ func ExampleAgreementsClient_NewListByBillingAccountPager() { // page.AgreementListResult = armbilling.AgreementListResult{ // Value: []*armbilling.Agreement{ // { - // Name: to.Ptr("Agreement1"), + // Name: to.Ptr("ABC123"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/agreements"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/agreements/Agreement1"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/agreements/ABC123"), // Properties: &armbilling.AgreementProperties{ // AcceptanceMode: to.Ptr(armbilling.AcceptanceModeClickToAccept), - // AgreementLink: to.Ptr("https://agreementuri1.com"), - // Category: to.Ptr(armbilling.CategoryMicrosoftCustomerAgreement), - // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-12-05T00:00:00.000Z"); return t}()), - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-12-05T00:00:00.000Z"); return t}()), - // Participants: []*armbilling.Participants{ + // AgreementLink: to.Ptr("https://contoso.com"), + // DisplayName: to.Ptr("Microsoft Customer Agreement"), + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-01T00:00:00.000Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-11-01T00:00:00.000Z"); return t}()), + // LeadBillingAccountName: to.Ptr("20000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // Participants: []*armbilling.Participant{ // { // Email: to.Ptr("abc@contoso.com"), // Status: to.Ptr("Accepted"), @@ -62,24 +98,25 @@ func ExampleAgreementsClient_NewListByBillingAccountPager() { // Status: to.Ptr("Declined"), // StatusDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-02T00:00:00.000Z"); return t}()), // }}, - // Status: to.Ptr("Published"), + // Status: to.Ptr("Active"), // }, // }, // { - // Name: to.Ptr("Agreement2"), + // Name: to.Ptr("DEF456"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/agreements"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/agreements/Agreement2"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/agreements/DEF456"), // Properties: &armbilling.AgreementProperties{ // AcceptanceMode: to.Ptr(armbilling.AcceptanceModeESignEmbedded), - // AgreementLink: to.Ptr("https://agreementuri2.com"), - // Category: to.Ptr(armbilling.CategoryMicrosoftCustomerAgreement), + // AgreementLink: to.Ptr("https://contoso.com"), + // DisplayName: to.Ptr("Microsoft Customer Agreement"), // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-12-05T00:00:00.000Z"); return t}()), - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-12-05T00:00:00.000Z"); return t}()), - // Participants: []*armbilling.Participants{ + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-05T00:00:00.000Z"); return t}()), + // LeadBillingAccountName: to.Ptr("20000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // Participants: []*armbilling.Participant{ // { // Email: to.Ptr("abc@contoso.com"), - // Status: to.Ptr("Unknown"), - // StatusDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-01T00:00:00.000Z"); return t}()), + // Status: to.Ptr("Pending"), + // StatusDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-12-05T00:00:00.000Z"); return t}()), // }}, // Status: to.Ptr("PendingSignature"), // }, @@ -87,47 +124,3 @@ func ExampleAgreementsClient_NewListByBillingAccountPager() { // } } } - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/AgreementByName.json -func ExampleAgreementsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbilling.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAgreementsClient().Get(ctx, "{billingAccountName}", "{agreementName}", &armbilling.AgreementsClientGetOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Agreement = armbilling.Agreement{ - // Name: to.Ptr("{agreementName}"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/agreements"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/agreements/{agreementName}"), - // Properties: &armbilling.AgreementProperties{ - // AcceptanceMode: to.Ptr(armbilling.AcceptanceModeClickToAccept), - // AgreementLink: to.Ptr("https://agreementuri1.com"), - // Category: to.Ptr(armbilling.CategoryMicrosoftCustomerAgreement), - // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-12-05T00:00:00.000Z"); return t}()), - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-12-05T00:00:00.000Z"); return t}()), - // Participants: []*armbilling.Participants{ - // { - // Email: to.Ptr("abc@contoso.com"), - // Status: to.Ptr("Accepted"), - // StatusDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-01T00:00:00.000Z"); return t}()), - // }, - // { - // Email: to.Ptr("xyz@contoso.com"), - // Status: to.Ptr("Declined"), - // StatusDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-02T00:00:00.000Z"); return t}()), - // }}, - // Status: to.Ptr("Published"), - // }, - // } -} diff --git a/sdk/resourcemanager/billing/armbilling/associatedtenants_client.go b/sdk/resourcemanager/billing/armbilling/associatedtenants_client.go new file mode 100644 index 000000000000..72c24f2bc363 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/associatedtenants_client.go @@ -0,0 +1,332 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armbilling + +import ( + "context" + "errors" + "net/http" + "net/url" + "strconv" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// AssociatedTenantsClient contains the methods for the AssociatedTenants group. +// Don't use this type directly, use NewAssociatedTenantsClient() instead. +type AssociatedTenantsClient struct { + internal *arm.Client +} + +// NewAssociatedTenantsClient creates a new instance of AssociatedTenantsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewAssociatedTenantsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*AssociatedTenantsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &AssociatedTenantsClient{ + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create or update an associated tenant for the billing account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - associatedTenantName - The ID that uniquely identifies a tenant. +// - parameters - An associated tenant. +// - options - AssociatedTenantsClientBeginCreateOrUpdateOptions contains the optional parameters for the AssociatedTenantsClient.BeginCreateOrUpdate +// method. +func (client *AssociatedTenantsClient) BeginCreateOrUpdate(ctx context.Context, billingAccountName string, associatedTenantName string, parameters AssociatedTenant, options *AssociatedTenantsClientBeginCreateOrUpdateOptions) (*runtime.Poller[AssociatedTenantsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, billingAccountName, associatedTenantName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AssociatedTenantsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AssociatedTenantsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create or update an associated tenant for the billing account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *AssociatedTenantsClient) createOrUpdate(ctx context.Context, billingAccountName string, associatedTenantName string, parameters AssociatedTenant, options *AssociatedTenantsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "AssociatedTenantsClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, billingAccountName, associatedTenantName, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *AssociatedTenantsClient) createOrUpdateCreateRequest(ctx context.Context, billingAccountName string, associatedTenantName string, parameters AssociatedTenant, options *AssociatedTenantsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/associatedTenants/{associatedTenantName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if associatedTenantName == "" { + return nil, errors.New("parameter associatedTenantName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{associatedTenantName}", url.PathEscape(associatedTenantName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Deletes an associated tenant for a billing account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - associatedTenantName - The ID that uniquely identifies a tenant. +// - options - AssociatedTenantsClientBeginDeleteOptions contains the optional parameters for the AssociatedTenantsClient.BeginDelete +// method. +func (client *AssociatedTenantsClient) BeginDelete(ctx context.Context, billingAccountName string, associatedTenantName string, options *AssociatedTenantsClientBeginDeleteOptions) (*runtime.Poller[AssociatedTenantsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, billingAccountName, associatedTenantName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AssociatedTenantsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AssociatedTenantsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Deletes an associated tenant for a billing account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *AssociatedTenantsClient) deleteOperation(ctx context.Context, billingAccountName string, associatedTenantName string, options *AssociatedTenantsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "AssociatedTenantsClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, billingAccountName, associatedTenantName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *AssociatedTenantsClient) deleteCreateRequest(ctx context.Context, billingAccountName string, associatedTenantName string, options *AssociatedTenantsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/associatedTenants/{associatedTenantName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if associatedTenantName == "" { + return nil, errors.New("parameter associatedTenantName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{associatedTenantName}", url.PathEscape(associatedTenantName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets an associated tenant by ID. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - associatedTenantName - The ID that uniquely identifies a tenant. +// - options - AssociatedTenantsClientGetOptions contains the optional parameters for the AssociatedTenantsClient.Get method. +func (client *AssociatedTenantsClient) Get(ctx context.Context, billingAccountName string, associatedTenantName string, options *AssociatedTenantsClientGetOptions) (AssociatedTenantsClientGetResponse, error) { + var err error + const operationName = "AssociatedTenantsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, billingAccountName, associatedTenantName, options) + if err != nil { + return AssociatedTenantsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AssociatedTenantsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AssociatedTenantsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *AssociatedTenantsClient) getCreateRequest(ctx context.Context, billingAccountName string, associatedTenantName string, options *AssociatedTenantsClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/associatedTenants/{associatedTenantName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if associatedTenantName == "" { + return nil, errors.New("parameter associatedTenantName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{associatedTenantName}", url.PathEscape(associatedTenantName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AssociatedTenantsClient) getHandleResponse(resp *http.Response) (AssociatedTenantsClientGetResponse, error) { + result := AssociatedTenantsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AssociatedTenant); err != nil { + return AssociatedTenantsClientGetResponse{}, err + } + return result, nil +} + +// NewListByBillingAccountPager - Lists the associated tenants that can collaborate with the billing account on commerce activities +// like viewing and downloading invoices, managing payments, making purchases, and managing or +// provisioning licenses. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - options - AssociatedTenantsClientListByBillingAccountOptions contains the optional parameters for the AssociatedTenantsClient.NewListByBillingAccountPager +// method. +func (client *AssociatedTenantsClient) NewListByBillingAccountPager(billingAccountName string, options *AssociatedTenantsClientListByBillingAccountOptions) *runtime.Pager[AssociatedTenantsClientListByBillingAccountResponse] { + return runtime.NewPager(runtime.PagingHandler[AssociatedTenantsClientListByBillingAccountResponse]{ + More: func(page AssociatedTenantsClientListByBillingAccountResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AssociatedTenantsClientListByBillingAccountResponse) (AssociatedTenantsClientListByBillingAccountResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AssociatedTenantsClient.NewListByBillingAccountPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByBillingAccountCreateRequest(ctx, billingAccountName, options) + }, nil) + if err != nil { + return AssociatedTenantsClientListByBillingAccountResponse{}, err + } + return client.listByBillingAccountHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByBillingAccountCreateRequest creates the ListByBillingAccount request. +func (client *AssociatedTenantsClient) listByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, options *AssociatedTenantsClientListByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/associatedTenants" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.IncludeRevoked != nil { + reqQP.Set("includeRevoked", strconv.FormatBool(*options.IncludeRevoked)) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByBillingAccountHandleResponse handles the ListByBillingAccount response. +func (client *AssociatedTenantsClient) listByBillingAccountHandleResponse(resp *http.Response) (AssociatedTenantsClientListByBillingAccountResponse, error) { + result := AssociatedTenantsClientListByBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AssociatedTenantListResult); err != nil { + return AssociatedTenantsClientListByBillingAccountResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/associatedtenants_client_example_test.go b/sdk/resourcemanager/billing/armbilling/associatedtenants_client_example_test.go new file mode 100644 index 000000000000..86c73cfe3c38 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/associatedtenants_client_example_test.go @@ -0,0 +1,172 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armbilling_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/associatedTenantsDelete.json +func ExampleAssociatedTenantsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAssociatedTenantsClient().BeginDelete(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "11111111-1111-1111-1111-111111111111", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/associatedTenantsGet.json +func ExampleAssociatedTenantsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAssociatedTenantsClient().Get(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "11111111-1111-1111-1111-111111111111", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AssociatedTenant = armbilling.AssociatedTenant{ + // Name: to.Ptr("11111111-1111-1111-1111-111111111111"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/associatedTenants"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/associatedTenants/11111111-1111-1111-1111-111111111111"), + // Properties: &armbilling.AssociatedTenantProperties{ + // BillingManagementState: to.Ptr(armbilling.BillingManagementTenantStateActive), + // DisplayName: to.Ptr("Contoso Finance"), + // ProvisioningBillingRequestID: to.Ptr("/providers/Microsoft.Billing/billingRequests/22222222-2222-2222-2222-222222222222"), + // ProvisioningManagementState: to.Ptr(armbilling.ProvisioningTenantStatePending), + // TenantID: to.Ptr("11111111-1111-1111-1111-111111111111"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/associatedTenantsCreateOrUpdate.json +func ExampleAssociatedTenantsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAssociatedTenantsClient().BeginCreateOrUpdate(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "11111111-1111-1111-1111-111111111111", armbilling.AssociatedTenant{ + Properties: &armbilling.AssociatedTenantProperties{ + BillingManagementState: to.Ptr(armbilling.BillingManagementTenantStateActive), + DisplayName: to.Ptr("Contoso Finance"), + ProvisioningManagementState: to.Ptr(armbilling.ProvisioningTenantStatePending), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AssociatedTenant = armbilling.AssociatedTenant{ + // Name: to.Ptr("11111111-1111-1111-1111-111111111111"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/associatedTenants"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/associatedTenants/11111111-1111-1111-1111-111111111111"), + // Properties: &armbilling.AssociatedTenantProperties{ + // BillingManagementState: to.Ptr(armbilling.BillingManagementTenantStateActive), + // DisplayName: to.Ptr("Contoso Finance"), + // ProvisioningBillingRequestID: to.Ptr("/providers/Microsoft.Billing/billingRequests/22222222-2222-2222-2222-222222222222"), + // ProvisioningManagementState: to.Ptr(armbilling.ProvisioningTenantStatePending), + // TenantID: to.Ptr("11111111-1111-1111-1111-111111111111"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/associatedTenantsListByBillingAccount.json +func ExampleAssociatedTenantsClient_NewListByBillingAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAssociatedTenantsClient().NewListByBillingAccountPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", &armbilling.AssociatedTenantsClientListByBillingAccountOptions{IncludeRevoked: nil, + Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AssociatedTenantListResult = armbilling.AssociatedTenantListResult{ + // Value: []*armbilling.AssociatedTenant{ + // { + // Name: to.Ptr("11111111-1111-1111-1111-111111111111"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/associatedTenants"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-000000000000:00000000-0000-0000-000000000000_2019-05-31/associatedTenants/11111111-1111-1111-1111-111111111111"), + // Properties: &armbilling.AssociatedTenantProperties{ + // BillingManagementState: to.Ptr(armbilling.BillingManagementTenantStateActive), + // DisplayName: to.Ptr("Contoso Finance"), + // ProvisioningManagementState: to.Ptr(armbilling.ProvisioningTenantStateNotRequested), + // TenantID: to.Ptr("11111111-1111-1111-1111-111111111111"), + // }, + // }, + // { + // Name: to.Ptr("22222222-2222-2222-2222-222222222222"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/associatedTenants"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-000000000000:00000000-0000-0000-000000000000_2019-05-31/associatedTenants/22222222-2222-2222-2222-222222222222"), + // Properties: &armbilling.AssociatedTenantProperties{ + // BillingManagementState: to.Ptr(armbilling.BillingManagementTenantStateNotAllowed), + // DisplayName: to.Ptr("Contoso Engineering"), + // ProvisioningBillingRequestID: to.Ptr("/providers/Microsoft.Billing/billingRequests/22222222-2222-2222-2222-222222222222"), + // ProvisioningManagementState: to.Ptr(armbilling.ProvisioningTenantStatePending), + // TenantID: to.Ptr("22222222-2222-2222-2222-222222222222"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/billing/armbilling/autorest.md b/sdk/resourcemanager/billing/armbilling/autorest.md index 692d3dc7eae8..5b958d2c3b8e 100644 --- a/sdk/resourcemanager/billing/armbilling/autorest.md +++ b/sdk/resourcemanager/billing/armbilling/autorest.md @@ -5,8 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/readme.go.md +- https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.7.0 +module-version: 1.0.0 +tag: package-2024-04 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/billing/armbilling/availablebalances_client.go b/sdk/resourcemanager/billing/armbilling/availablebalances_client.go index d8670b7efe88..9db0e6571d36 100644 --- a/sdk/resourcemanager/billing/armbilling/availablebalances_client.go +++ b/sdk/resourcemanager/billing/armbilling/availablebalances_client.go @@ -11,13 +11,14 @@ package armbilling import ( "context" "errors" + "net/http" + "net/url" + "strings" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" ) // AvailableBalancesClient contains the methods for the AvailableBalances group. @@ -40,39 +41,100 @@ func NewAvailableBalancesClient(credential azcore.TokenCredential, options *arm. return client, nil } -// Get - The available credit balance for a billing profile. This is the balance that can be used for pay now to settle due -// or past due invoices. The operation is supported only for billing accounts with -// agreement type Microsoft Customer Agreement. +// GetByBillingAccount - The Available Credit or Payment on Account Balance for a billing account. The credit balance can +// be used to settle due or past due invoices and is supported for billing accounts with agreement type +// Microsoft Customer Agreement. The payment on account balance is supported for billing accounts with agreement type Microsoft +// Customer Agreement or Microsoft Online Services Program. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - options - AvailableBalancesClientGetByBillingAccountOptions contains the optional parameters for the AvailableBalancesClient.GetByBillingAccount +// method. +func (client *AvailableBalancesClient) GetByBillingAccount(ctx context.Context, billingAccountName string, options *AvailableBalancesClientGetByBillingAccountOptions) (AvailableBalancesClientGetByBillingAccountResponse, error) { + var err error + const operationName = "AvailableBalancesClient.GetByBillingAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByBillingAccountCreateRequest(ctx, billingAccountName, options) + if err != nil { + return AvailableBalancesClientGetByBillingAccountResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AvailableBalancesClientGetByBillingAccountResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AvailableBalancesClientGetByBillingAccountResponse{}, err + } + resp, err := client.getByBillingAccountHandleResponse(httpResp) + return resp, err +} + +// getByBillingAccountCreateRequest creates the GetByBillingAccount request. +func (client *AvailableBalancesClient) getByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, options *AvailableBalancesClientGetByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/availableBalance/default" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByBillingAccountHandleResponse handles the GetByBillingAccount response. +func (client *AvailableBalancesClient) getByBillingAccountHandleResponse(resp *http.Response) (AvailableBalancesClientGetByBillingAccountResponse, error) { + result := AvailableBalancesClientGetByBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AvailableBalance); err != nil { + return AvailableBalancesClientGetByBillingAccountResponse{}, err + } + return result, nil +} + +// GetByBillingProfile - The Available Credit or Payment on Account Balance for a billing profile. The credit balance can +// be used to settle due or past due invoices and is supported for billing accounts with agreement type +// Microsoft Customer Agreement. The payment on account balance is supported for billing accounts with agreement type Microsoft +// Customer Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingProfileName - The ID that uniquely identifies a billing profile. -// - options - AvailableBalancesClientGetOptions contains the optional parameters for the AvailableBalancesClient.Get method. -func (client *AvailableBalancesClient) Get(ctx context.Context, billingAccountName string, billingProfileName string, options *AvailableBalancesClientGetOptions) (AvailableBalancesClientGetResponse, error) { +// - options - AvailableBalancesClientGetByBillingProfileOptions contains the optional parameters for the AvailableBalancesClient.GetByBillingProfile +// method. +func (client *AvailableBalancesClient) GetByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, options *AvailableBalancesClientGetByBillingProfileOptions) (AvailableBalancesClientGetByBillingProfileResponse, error) { var err error - const operationName = "AvailableBalancesClient.Get" + const operationName = "AvailableBalancesClient.GetByBillingProfile" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, billingAccountName, billingProfileName, options) + req, err := client.getByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, options) if err != nil { - return AvailableBalancesClientGetResponse{}, err + return AvailableBalancesClientGetByBillingProfileResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return AvailableBalancesClientGetResponse{}, err + return AvailableBalancesClientGetByBillingProfileResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return AvailableBalancesClientGetResponse{}, err + return AvailableBalancesClientGetByBillingProfileResponse{}, err } - resp, err := client.getHandleResponse(httpResp) + resp, err := client.getByBillingProfileHandleResponse(httpResp) return resp, err } -// getCreateRequest creates the Get request. -func (client *AvailableBalancesClient) getCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, options *AvailableBalancesClientGetOptions) (*policy.Request, error) { +// getByBillingProfileCreateRequest creates the GetByBillingProfile request. +func (client *AvailableBalancesClient) getByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, options *AvailableBalancesClientGetByBillingProfileOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/availableBalance/default" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") @@ -87,17 +149,17 @@ func (client *AvailableBalancesClient) getCreateRequest(ctx context.Context, bil return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } -// getHandleResponse handles the Get response. -func (client *AvailableBalancesClient) getHandleResponse(resp *http.Response) (AvailableBalancesClientGetResponse, error) { - result := AvailableBalancesClientGetResponse{} +// getByBillingProfileHandleResponse handles the GetByBillingProfile response. +func (client *AvailableBalancesClient) getByBillingProfileHandleResponse(resp *http.Response) (AvailableBalancesClientGetByBillingProfileResponse, error) { + result := AvailableBalancesClientGetByBillingProfileResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.AvailableBalance); err != nil { - return AvailableBalancesClientGetResponse{}, err + return AvailableBalancesClientGetByBillingProfileResponse{}, err } return result, nil } diff --git a/sdk/resourcemanager/billing/armbilling/availablebalances_client_example_test.go b/sdk/resourcemanager/billing/armbilling/availablebalances_client_example_test.go index 9ddd3339d033..2af4ce8de594 100644 --- a/sdk/resourcemanager/billing/armbilling/availablebalances_client_example_test.go +++ b/sdk/resourcemanager/billing/armbilling/availablebalances_client_example_test.go @@ -17,8 +17,8 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/AvailableBalanceByBillingProfile.json -func ExampleAvailableBalancesClient_Get() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/availableBalanceGetByBillingAccount.json +func ExampleAvailableBalancesClient_GetByBillingAccount() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -28,7 +28,67 @@ func ExampleAvailableBalancesClient_Get() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewAvailableBalancesClient().Get(ctx, "{billingAccountName}", "{billingProfileName}", nil) + res, err := clientFactory.NewAvailableBalancesClient().GetByBillingAccount(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AvailableBalance = armbilling.AvailableBalance{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/availableBalance"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/availableBalance/default"), + // Properties: &armbilling.AvailableBalanceProperties{ + // Amount: &armbilling.AvailableBalancePropertiesAmount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](500), + // }, + // PaymentsOnAccount: []*armbilling.PaymentOnAccount{ + // { + // Amount: &armbilling.PaymentOnAccountAmount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](50), + // }, + // BillingProfileDisplayName: to.Ptr("Contoso Finance"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-01T00:00:00.000Z"); return t}()), + // InvoiceID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/G123456789"), + // InvoiceName: to.Ptr("G123456789"), + // PaymentMethodType: to.Ptr(armbilling.PaymentMethodFamilyCheckWire), + // }, + // { + // Amount: &armbilling.PaymentOnAccountAmount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](150), + // }, + // BillingProfileDisplayName: to.Ptr("Contoso Engineering"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/yyyy-yyyy-yyy-yyy"), + // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-01T00:00:00.000Z"); return t}()), + // InvoiceID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/G987654321"), + // InvoiceName: to.Ptr("G987654321"), + // PaymentMethodType: to.Ptr(armbilling.PaymentMethodFamilyCheckWire), + // }}, + // TotalPaymentsOnAccount: &armbilling.AvailableBalancePropertiesTotalPaymentsOnAccount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](200), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/availableBalanceGetByBillingProfile.json +func ExampleAvailableBalancesClient_GetByBillingProfile() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAvailableBalancesClient().GetByBillingProfile(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -38,12 +98,29 @@ func ExampleAvailableBalancesClient_Get() { // res.AvailableBalance = armbilling.AvailableBalance{ // Name: to.Ptr("default"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/availableBalance"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/availableBalance/default"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/availableBalance/default"), // Properties: &armbilling.AvailableBalanceProperties{ - // Amount: &armbilling.Amount{ + // Amount: &armbilling.AvailableBalancePropertiesAmount{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](500), // }, + // PaymentsOnAccount: []*armbilling.PaymentOnAccount{ + // { + // Amount: &armbilling.PaymentOnAccountAmount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](50), + // }, + // BillingProfileDisplayName: to.Ptr("Contoso Finance"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-01T00:00:00.000Z"); return t}()), + // InvoiceID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/G123456789"), + // InvoiceName: to.Ptr("G123456789"), + // PaymentMethodType: to.Ptr(armbilling.PaymentMethodFamilyCheckWire), + // }}, + // TotalPaymentsOnAccount: &armbilling.AvailableBalancePropertiesTotalPaymentsOnAccount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](200), + // }, // }, // } } diff --git a/sdk/resourcemanager/billing/armbilling/client_factory.go b/sdk/resourcemanager/billing/armbilling/client_factory.go index a5f2a01cf1ed..edf5fc6207e1 100644 --- a/sdk/resourcemanager/billing/armbilling/client_factory.go +++ b/sdk/resourcemanager/billing/armbilling/client_factory.go @@ -17,148 +17,234 @@ import ( // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { subscriptionID string - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. // The parameter values will be propagated to any client created from this factory. -// - subscriptionID - The ID that uniquely identifies an Azure subscription. +// - subscriptionID - The ID that uniquely identifies a billing subscription. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { - _, err := arm.NewClient(moduleName, moduleVersion, credential, options) + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - subscriptionID: subscriptionID, credential: credential, - options: options.Clone(), + subscriptionID: subscriptionID, + internal: internal, }, nil } // NewAccountsClient creates a new instance of AccountsClient. func (c *ClientFactory) NewAccountsClient() *AccountsClient { - subClient, _ := NewAccountsClient(c.credential, c.options) - return subClient + return &AccountsClient{ + internal: c.internal, + } } // NewAddressClient creates a new instance of AddressClient. func (c *ClientFactory) NewAddressClient() *AddressClient { - subClient, _ := NewAddressClient(c.credential, c.options) - return subClient + return &AddressClient{ + internal: c.internal, + } } // NewAgreementsClient creates a new instance of AgreementsClient. func (c *ClientFactory) NewAgreementsClient() *AgreementsClient { - subClient, _ := NewAgreementsClient(c.credential, c.options) - return subClient + return &AgreementsClient{ + internal: c.internal, + } +} + +// NewAssociatedTenantsClient creates a new instance of AssociatedTenantsClient. +func (c *ClientFactory) NewAssociatedTenantsClient() *AssociatedTenantsClient { + return &AssociatedTenantsClient{ + internal: c.internal, + } } // NewAvailableBalancesClient creates a new instance of AvailableBalancesClient. func (c *ClientFactory) NewAvailableBalancesClient() *AvailableBalancesClient { - subClient, _ := NewAvailableBalancesClient(c.credential, c.options) - return subClient + return &AvailableBalancesClient{ + internal: c.internal, + } } // NewCustomersClient creates a new instance of CustomersClient. func (c *ClientFactory) NewCustomersClient() *CustomersClient { - subClient, _ := NewCustomersClient(c.credential, c.options) - return subClient + return &CustomersClient{ + internal: c.internal, + } } -// NewEnrollmentAccountsClient creates a new instance of EnrollmentAccountsClient. -func (c *ClientFactory) NewEnrollmentAccountsClient() *EnrollmentAccountsClient { - subClient, _ := NewEnrollmentAccountsClient(c.credential, c.options) - return subClient +// NewDepartmentsClient creates a new instance of DepartmentsClient. +func (c *ClientFactory) NewDepartmentsClient() *DepartmentsClient { + return &DepartmentsClient{ + internal: c.internal, + } } -// NewInstructionsClient creates a new instance of InstructionsClient. -func (c *ClientFactory) NewInstructionsClient() *InstructionsClient { - subClient, _ := NewInstructionsClient(c.credential, c.options) - return subClient +// NewEnrollmentAccountsClient creates a new instance of EnrollmentAccountsClient. +func (c *ClientFactory) NewEnrollmentAccountsClient() *EnrollmentAccountsClient { + return &EnrollmentAccountsClient{ + internal: c.internal, + } } // NewInvoiceSectionsClient creates a new instance of InvoiceSectionsClient. func (c *ClientFactory) NewInvoiceSectionsClient() *InvoiceSectionsClient { - subClient, _ := NewInvoiceSectionsClient(c.credential, c.options) - return subClient + return &InvoiceSectionsClient{ + internal: c.internal, + } } // NewInvoicesClient creates a new instance of InvoicesClient. func (c *ClientFactory) NewInvoicesClient() *InvoicesClient { - subClient, _ := NewInvoicesClient(c.subscriptionID, c.credential, c.options) - return subClient + return &InvoicesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewOperationsClient creates a new instance of OperationsClient. func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) - return subClient + return &OperationsClient{ + internal: c.internal, + } } -// NewPeriodsClient creates a new instance of PeriodsClient. -func (c *ClientFactory) NewPeriodsClient() *PeriodsClient { - subClient, _ := NewPeriodsClient(c.subscriptionID, c.credential, c.options) - return subClient +// NewPartnerTransfersClient creates a new instance of PartnerTransfersClient. +func (c *ClientFactory) NewPartnerTransfersClient() *PartnerTransfersClient { + return &PartnerTransfersClient{ + internal: c.internal, + } +} + +// NewPaymentMethodsClient creates a new instance of PaymentMethodsClient. +func (c *ClientFactory) NewPaymentMethodsClient() *PaymentMethodsClient { + return &PaymentMethodsClient{ + internal: c.internal, + } } // NewPermissionsClient creates a new instance of PermissionsClient. func (c *ClientFactory) NewPermissionsClient() *PermissionsClient { - subClient, _ := NewPermissionsClient(c.credential, c.options) - return subClient + return &PermissionsClient{ + internal: c.internal, + } } // NewPoliciesClient creates a new instance of PoliciesClient. func (c *ClientFactory) NewPoliciesClient() *PoliciesClient { - subClient, _ := NewPoliciesClient(c.credential, c.options) - return subClient + return &PoliciesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewProductsClient creates a new instance of ProductsClient. func (c *ClientFactory) NewProductsClient() *ProductsClient { - subClient, _ := NewProductsClient(c.credential, c.options) - return subClient + return &ProductsClient{ + internal: c.internal, + } } // NewProfilesClient creates a new instance of ProfilesClient. func (c *ClientFactory) NewProfilesClient() *ProfilesClient { - subClient, _ := NewProfilesClient(c.credential, c.options) - return subClient + return &ProfilesClient{ + internal: c.internal, + } } // NewPropertyClient creates a new instance of PropertyClient. func (c *ClientFactory) NewPropertyClient() *PropertyClient { - subClient, _ := NewPropertyClient(c.subscriptionID, c.credential, c.options) - return subClient + return &PropertyClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewRecipientTransfersClient creates a new instance of RecipientTransfersClient. +func (c *ClientFactory) NewRecipientTransfersClient() *RecipientTransfersClient { + return &RecipientTransfersClient{ + internal: c.internal, + } +} + +// NewRequestsClient creates a new instance of RequestsClient. +func (c *ClientFactory) NewRequestsClient() *RequestsClient { + return &RequestsClient{ + internal: c.internal, + } +} + +// NewReservationOrdersClient creates a new instance of ReservationOrdersClient. +func (c *ClientFactory) NewReservationOrdersClient() *ReservationOrdersClient { + return &ReservationOrdersClient{ + internal: c.internal, + } } // NewReservationsClient creates a new instance of ReservationsClient. func (c *ClientFactory) NewReservationsClient() *ReservationsClient { - subClient, _ := NewReservationsClient(c.credential, c.options) - return subClient + return &ReservationsClient{ + internal: c.internal, + } } // NewRoleAssignmentsClient creates a new instance of RoleAssignmentsClient. func (c *ClientFactory) NewRoleAssignmentsClient() *RoleAssignmentsClient { - subClient, _ := NewRoleAssignmentsClient(c.credential, c.options) - return subClient + return &RoleAssignmentsClient{ + internal: c.internal, + } +} + +// NewRoleDefinitionClient creates a new instance of RoleDefinitionClient. +func (c *ClientFactory) NewRoleDefinitionClient() *RoleDefinitionClient { + return &RoleDefinitionClient{ + internal: c.internal, + } } -// NewRoleDefinitionsClient creates a new instance of RoleDefinitionsClient. -func (c *ClientFactory) NewRoleDefinitionsClient() *RoleDefinitionsClient { - subClient, _ := NewRoleDefinitionsClient(c.credential, c.options) - return subClient +// NewSavingsPlanOrdersClient creates a new instance of SavingsPlanOrdersClient. +func (c *ClientFactory) NewSavingsPlanOrdersClient() *SavingsPlanOrdersClient { + return &SavingsPlanOrdersClient{ + internal: c.internal, + } +} + +// NewSavingsPlansClient creates a new instance of SavingsPlansClient. +func (c *ClientFactory) NewSavingsPlansClient() *SavingsPlansClient { + return &SavingsPlansClient{ + internal: c.internal, + } +} + +// NewSubscriptionsAliasesClient creates a new instance of SubscriptionsAliasesClient. +func (c *ClientFactory) NewSubscriptionsAliasesClient() *SubscriptionsAliasesClient { + return &SubscriptionsAliasesClient{ + internal: c.internal, + } } // NewSubscriptionsClient creates a new instance of SubscriptionsClient. func (c *ClientFactory) NewSubscriptionsClient() *SubscriptionsClient { - subClient, _ := NewSubscriptionsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &SubscriptionsClient{ + internal: c.internal, + } } // NewTransactionsClient creates a new instance of TransactionsClient. func (c *ClientFactory) NewTransactionsClient() *TransactionsClient { - subClient, _ := NewTransactionsClient(c.credential, c.options) - return subClient + return &TransactionsClient{ + internal: c.internal, + } +} + +// NewTransfersClient creates a new instance of TransfersClient. +func (c *ClientFactory) NewTransfersClient() *TransfersClient { + return &TransfersClient{ + internal: c.internal, + } } diff --git a/sdk/resourcemanager/billing/armbilling/constants.go b/sdk/resourcemanager/billing/armbilling/constants.go index bf4941a4b8e7..cace7d9824f9 100644 --- a/sdk/resourcemanager/billing/armbilling/constants.go +++ b/sdk/resourcemanager/billing/armbilling/constants.go @@ -10,7 +10,7 @@ package armbilling const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" - moduleVersion = "v0.7.0" + moduleVersion = "v1.0.0" ) // AcceptanceMode - The mode of acceptance for an agreement. @@ -20,6 +20,10 @@ const ( AcceptanceModeClickToAccept AcceptanceMode = "ClickToAccept" AcceptanceModeESignEmbedded AcceptanceMode = "ESignEmbedded" AcceptanceModeESignOffline AcceptanceMode = "ESignOffline" + AcceptanceModeImplicit AcceptanceMode = "Implicit" + AcceptanceModeOffline AcceptanceMode = "Offline" + AcceptanceModeOther AcceptanceMode = "Other" + AcceptanceModePhysicalSign AcceptanceMode = "PhysicalSign" ) // PossibleAcceptanceModeValues returns the possible values for the AcceptanceMode const type. @@ -28,6 +32,28 @@ func PossibleAcceptanceModeValues() []AcceptanceMode { AcceptanceModeClickToAccept, AcceptanceModeESignEmbedded, AcceptanceModeESignOffline, + AcceptanceModeImplicit, + AcceptanceModeOffline, + AcceptanceModeOther, + AcceptanceModePhysicalSign, + } +} + +// AccessDecision - Access Decision, specifies access is allowed or not. +type AccessDecision string + +const ( + AccessDecisionAllowed AccessDecision = "Allowed" + AccessDecisionNotAllowed AccessDecision = "NotAllowed" + AccessDecisionOther AccessDecision = "Other" +) + +// PossibleAccessDecisionValues returns the possible values for the AccessDecision const type. +func PossibleAccessDecisionValues() []AccessDecision { + return []AccessDecision{ + AccessDecisionAllowed, + AccessDecisionNotAllowed, + AccessDecisionOther, } } @@ -40,8 +66,12 @@ const ( AccountStatusDisabled AccountStatus = "Disabled" AccountStatusExpired AccountStatus = "Expired" AccountStatusExtended AccountStatus = "Extended" + AccountStatusNew AccountStatus = "New" + AccountStatusOther AccountStatus = "Other" + AccountStatusPending AccountStatus = "Pending" AccountStatusTerminated AccountStatus = "Terminated" AccountStatusTransferred AccountStatus = "Transferred" + AccountStatusUnderReview AccountStatus = "UnderReview" ) // PossibleAccountStatusValues returns the possible values for the AccountStatus const type. @@ -52,8 +82,34 @@ func PossibleAccountStatusValues() []AccountStatus { AccountStatusDisabled, AccountStatusExpired, AccountStatusExtended, + AccountStatusNew, + AccountStatusOther, + AccountStatusPending, AccountStatusTerminated, AccountStatusTransferred, + AccountStatusUnderReview, + } +} + +// AccountSubType - The tier of the account. +type AccountSubType string + +const ( + AccountSubTypeEnterprise AccountSubType = "Enterprise" + AccountSubTypeIndividual AccountSubType = "Individual" + AccountSubTypeNone AccountSubType = "None" + AccountSubTypeOther AccountSubType = "Other" + AccountSubTypeProfessional AccountSubType = "Professional" +) + +// PossibleAccountSubTypeValues returns the possible values for the AccountSubType const type. +func PossibleAccountSubTypeValues() []AccountSubType { + return []AccountSubType{ + AccountSubTypeEnterprise, + AccountSubTypeIndividual, + AccountSubTypeNone, + AccountSubTypeOther, + AccountSubTypeProfessional, } } @@ -61,17 +117,29 @@ func PossibleAccountStatusValues() []AccountStatus { type AccountType string const ( - AccountTypeEnterprise AccountType = "Enterprise" - AccountTypeIndividual AccountType = "Individual" - AccountTypePartner AccountType = "Partner" + AccountTypeBusiness AccountType = "Business" + AccountTypeClassicPartner AccountType = "ClassicPartner" + AccountTypeEnterprise AccountType = "Enterprise" + AccountTypeIndividual AccountType = "Individual" + AccountTypeInternal AccountType = "Internal" + AccountTypeOther AccountType = "Other" + AccountTypePartner AccountType = "Partner" + AccountTypeReseller AccountType = "Reseller" + AccountTypeTenant AccountType = "Tenant" ) // PossibleAccountTypeValues returns the possible values for the AccountType const type. func PossibleAccountTypeValues() []AccountType { return []AccountType{ + AccountTypeBusiness, + AccountTypeClassicPartner, AccountTypeEnterprise, AccountTypeIndividual, + AccountTypeInternal, + AccountTypeOther, AccountTypePartner, + AccountTypeReseller, + AccountTypeTenant, } } @@ -80,6 +148,7 @@ type AddressValidationStatus string const ( AddressValidationStatusInvalid AddressValidationStatus = "Invalid" + AddressValidationStatusOther AddressValidationStatus = "Other" AddressValidationStatusValid AddressValidationStatus = "Valid" ) @@ -87,6 +156,7 @@ const ( func PossibleAddressValidationStatusValues() []AddressValidationStatus { return []AddressValidationStatus{ AddressValidationStatusInvalid, + AddressValidationStatusOther, AddressValidationStatusValid, } } @@ -99,6 +169,7 @@ const ( AgreementTypeMicrosoftCustomerAgreement AgreementType = "MicrosoftCustomerAgreement" AgreementTypeMicrosoftOnlineServicesProgram AgreementType = "MicrosoftOnlineServicesProgram" AgreementTypeMicrosoftPartnerAgreement AgreementType = "MicrosoftPartnerAgreement" + AgreementTypeOther AgreementType = "Other" ) // PossibleAgreementTypeValues returns the possible values for the AgreementType const type. @@ -108,6 +179,25 @@ func PossibleAgreementTypeValues() []AgreementType { AgreementTypeMicrosoftCustomerAgreement, AgreementTypeMicrosoftOnlineServicesProgram, AgreementTypeMicrosoftPartnerAgreement, + AgreementTypeOther, + } +} + +// AppliedScopeType - Type of the Applied Scope. +type AppliedScopeType string + +const ( + AppliedScopeTypeManagementGroup AppliedScopeType = "ManagementGroup" + AppliedScopeTypeShared AppliedScopeType = "Shared" + AppliedScopeTypeSingle AppliedScopeType = "Single" +) + +// PossibleAppliedScopeTypeValues returns the possible values for the AppliedScopeType const type. +func PossibleAppliedScopeTypeValues() []AppliedScopeType { + return []AppliedScopeType{ + AppliedScopeTypeManagementGroup, + AppliedScopeTypeShared, + AppliedScopeTypeSingle, } } @@ -127,37 +217,62 @@ func PossibleAutoRenewValues() []AutoRenew { } } -// BillingFrequency - The frequency at which the product will be billed. -type BillingFrequency string +// BillingAccountStatusReasonCode - Reason for the specified billing account status. +type BillingAccountStatusReasonCode string const ( - BillingFrequencyMonthly BillingFrequency = "Monthly" - BillingFrequencyOneTime BillingFrequency = "OneTime" - BillingFrequencyUsageBased BillingFrequency = "UsageBased" + BillingAccountStatusReasonCodeExpired BillingAccountStatusReasonCode = "Expired" + BillingAccountStatusReasonCodeManuallyTerminated BillingAccountStatusReasonCode = "ManuallyTerminated" + BillingAccountStatusReasonCodeOther BillingAccountStatusReasonCode = "Other" + BillingAccountStatusReasonCodeTerminateProcessing BillingAccountStatusReasonCode = "TerminateProcessing" + BillingAccountStatusReasonCodeTransferred BillingAccountStatusReasonCode = "Transferred" + BillingAccountStatusReasonCodeUnusualActivity BillingAccountStatusReasonCode = "UnusualActivity" ) -// PossibleBillingFrequencyValues returns the possible values for the BillingFrequency const type. -func PossibleBillingFrequencyValues() []BillingFrequency { - return []BillingFrequency{ - BillingFrequencyMonthly, - BillingFrequencyOneTime, - BillingFrequencyUsageBased, +// PossibleBillingAccountStatusReasonCodeValues returns the possible values for the BillingAccountStatusReasonCode const type. +func PossibleBillingAccountStatusReasonCodeValues() []BillingAccountStatusReasonCode { + return []BillingAccountStatusReasonCode{ + BillingAccountStatusReasonCodeExpired, + BillingAccountStatusReasonCodeManuallyTerminated, + BillingAccountStatusReasonCodeOther, + BillingAccountStatusReasonCodeTerminateProcessing, + BillingAccountStatusReasonCodeTransferred, + BillingAccountStatusReasonCodeUnusualActivity, } } -// BillingProfileSpendingLimit - The billing profile spending limit. -type BillingProfileSpendingLimit string +// BillingManagementTenantState - The state determines whether users from the associated tenant can be assigned roles for +// commerce activities like viewing and downloading invoices, managing payments, and making purchases. +type BillingManagementTenantState string const ( - BillingProfileSpendingLimitOff BillingProfileSpendingLimit = "Off" - BillingProfileSpendingLimitOn BillingProfileSpendingLimit = "On" + BillingManagementTenantStateActive BillingManagementTenantState = "Active" + BillingManagementTenantStateNotAllowed BillingManagementTenantState = "NotAllowed" + BillingManagementTenantStateOther BillingManagementTenantState = "Other" + BillingManagementTenantStateRevoked BillingManagementTenantState = "Revoked" ) -// PossibleBillingProfileSpendingLimitValues returns the possible values for the BillingProfileSpendingLimit const type. -func PossibleBillingProfileSpendingLimitValues() []BillingProfileSpendingLimit { - return []BillingProfileSpendingLimit{ - BillingProfileSpendingLimitOff, - BillingProfileSpendingLimitOn, +// PossibleBillingManagementTenantStateValues returns the possible values for the BillingManagementTenantState const type. +func PossibleBillingManagementTenantStateValues() []BillingManagementTenantState { + return []BillingManagementTenantState{ + BillingManagementTenantStateActive, + BillingManagementTenantStateNotAllowed, + BillingManagementTenantStateOther, + BillingManagementTenantStateRevoked, + } +} + +// BillingPlan - Represents the billing plan in ISO 8601 format. Required only for monthly purchases. +type BillingPlan string + +const ( + BillingPlanP1M BillingPlan = "P1M" +) + +// PossibleBillingPlanValues returns the possible values for the BillingPlan const type. +func PossibleBillingPlanValues() []BillingPlan { + return []BillingPlan{ + BillingPlanP1M, } } @@ -165,16 +280,22 @@ func PossibleBillingProfileSpendingLimitValues() []BillingProfileSpendingLimit { type BillingProfileStatus string const ( - BillingProfileStatusActive BillingProfileStatus = "Active" - BillingProfileStatusDisabled BillingProfileStatus = "Disabled" - BillingProfileStatusWarned BillingProfileStatus = "Warned" + BillingProfileStatusActive BillingProfileStatus = "Active" + BillingProfileStatusDeleted BillingProfileStatus = "Deleted" + BillingProfileStatusDisabled BillingProfileStatus = "Disabled" + BillingProfileStatusOther BillingProfileStatus = "Other" + BillingProfileStatusUnderReview BillingProfileStatus = "UnderReview" + BillingProfileStatusWarned BillingProfileStatus = "Warned" ) // PossibleBillingProfileStatusValues returns the possible values for the BillingProfileStatus const type. func PossibleBillingProfileStatusValues() []BillingProfileStatus { return []BillingProfileStatus{ BillingProfileStatusActive, + BillingProfileStatusDeleted, BillingProfileStatusDisabled, + BillingProfileStatusOther, + BillingProfileStatusUnderReview, BillingProfileStatusWarned, } } @@ -183,77 +304,375 @@ func PossibleBillingProfileStatusValues() []BillingProfileStatus { type BillingProfileStatusReasonCode string const ( + BillingProfileStatusReasonCodeOther BillingProfileStatusReasonCode = "Other" BillingProfileStatusReasonCodePastDue BillingProfileStatusReasonCode = "PastDue" BillingProfileStatusReasonCodeSpendingLimitExpired BillingProfileStatusReasonCode = "SpendingLimitExpired" BillingProfileStatusReasonCodeSpendingLimitReached BillingProfileStatusReasonCode = "SpendingLimitReached" + BillingProfileStatusReasonCodeUnusualActivity BillingProfileStatusReasonCode = "UnusualActivity" ) // PossibleBillingProfileStatusReasonCodeValues returns the possible values for the BillingProfileStatusReasonCode const type. func PossibleBillingProfileStatusReasonCodeValues() []BillingProfileStatusReasonCode { return []BillingProfileStatusReasonCode{ + BillingProfileStatusReasonCodeOther, BillingProfileStatusReasonCodePastDue, BillingProfileStatusReasonCodeSpendingLimitExpired, BillingProfileStatusReasonCodeSpendingLimitReached, + BillingProfileStatusReasonCodeUnusualActivity, } } -// BillingRelationshipType - Identifies which services and purchases are paid by a billing profile. +// BillingRelationshipType - Identifies the billing relationships represented by a billing account or billing profile. The +// billing relationship may be between Microsoft, the customer, and/or a third-party. type BillingRelationshipType string const ( + BillingRelationshipTypeCSPCustomer BillingRelationshipType = "CSPCustomer" BillingRelationshipTypeCSPPartner BillingRelationshipType = "CSPPartner" BillingRelationshipTypeDirect BillingRelationshipType = "Direct" BillingRelationshipTypeIndirectCustomer BillingRelationshipType = "IndirectCustomer" BillingRelationshipTypeIndirectPartner BillingRelationshipType = "IndirectPartner" + BillingRelationshipTypeOther BillingRelationshipType = "Other" ) // PossibleBillingRelationshipTypeValues returns the possible values for the BillingRelationshipType const type. func PossibleBillingRelationshipTypeValues() []BillingRelationshipType { return []BillingRelationshipType{ + BillingRelationshipTypeCSPCustomer, BillingRelationshipTypeCSPPartner, BillingRelationshipTypeDirect, BillingRelationshipTypeIndirectCustomer, BillingRelationshipTypeIndirectPartner, + BillingRelationshipTypeOther, + } +} + +// BillingRequestStatus - Status of billing request. +type BillingRequestStatus string + +const ( + BillingRequestStatusApproved BillingRequestStatus = "Approved" + BillingRequestStatusCancelled BillingRequestStatus = "Cancelled" + BillingRequestStatusCompleted BillingRequestStatus = "Completed" + BillingRequestStatusDeclined BillingRequestStatus = "Declined" + BillingRequestStatusExpired BillingRequestStatus = "Expired" + BillingRequestStatusOther BillingRequestStatus = "Other" + BillingRequestStatusPending BillingRequestStatus = "Pending" +) + +// PossibleBillingRequestStatusValues returns the possible values for the BillingRequestStatus const type. +func PossibleBillingRequestStatusValues() []BillingRequestStatus { + return []BillingRequestStatus{ + BillingRequestStatusApproved, + BillingRequestStatusCancelled, + BillingRequestStatusCompleted, + BillingRequestStatusDeclined, + BillingRequestStatusExpired, + BillingRequestStatusOther, + BillingRequestStatusPending, + } +} + +// BillingRequestType - Type of billing request. +type BillingRequestType string + +const ( + BillingRequestTypeInvoiceAccess BillingRequestType = "InvoiceAccess" + BillingRequestTypeOther BillingRequestType = "Other" + BillingRequestTypeProvisioningAccess BillingRequestType = "ProvisioningAccess" + BillingRequestTypeRoleAssignment BillingRequestType = "RoleAssignment" + BillingRequestTypeUpdateBillingPolicy BillingRequestType = "UpdateBillingPolicy" +) + +// PossibleBillingRequestTypeValues returns the possible values for the BillingRequestType const type. +func PossibleBillingRequestTypeValues() []BillingRequestType { + return []BillingRequestType{ + BillingRequestTypeInvoiceAccess, + BillingRequestTypeOther, + BillingRequestTypeProvisioningAccess, + BillingRequestTypeRoleAssignment, + BillingRequestTypeUpdateBillingPolicy, + } +} + +// BillingSubscriptionOperationStatus - The status of an operation on the subscription. When None, there is no ongoing operation. +// When LockedForUpdate, write operations will be blocked on the Billing Subscription. Other is the default value +// and you may need to refer to the latest API version for more details. +type BillingSubscriptionOperationStatus string + +const ( + BillingSubscriptionOperationStatusLockedForUpdate BillingSubscriptionOperationStatus = "LockedForUpdate" + BillingSubscriptionOperationStatusNone BillingSubscriptionOperationStatus = "None" + BillingSubscriptionOperationStatusOther BillingSubscriptionOperationStatus = "Other" +) + +// PossibleBillingSubscriptionOperationStatusValues returns the possible values for the BillingSubscriptionOperationStatus const type. +func PossibleBillingSubscriptionOperationStatusValues() []BillingSubscriptionOperationStatus { + return []BillingSubscriptionOperationStatus{ + BillingSubscriptionOperationStatusLockedForUpdate, + BillingSubscriptionOperationStatusNone, + BillingSubscriptionOperationStatusOther, + } +} + +// BillingSubscriptionStatus - The subscription status. +type BillingSubscriptionStatus string + +const ( + BillingSubscriptionStatusActive BillingSubscriptionStatus = "Active" + BillingSubscriptionStatusAutoRenew BillingSubscriptionStatus = "AutoRenew" + BillingSubscriptionStatusCancelled BillingSubscriptionStatus = "Cancelled" + BillingSubscriptionStatusDeleted BillingSubscriptionStatus = "Deleted" + BillingSubscriptionStatusDisabled BillingSubscriptionStatus = "Disabled" + BillingSubscriptionStatusExpired BillingSubscriptionStatus = "Expired" + BillingSubscriptionStatusExpiring BillingSubscriptionStatus = "Expiring" + BillingSubscriptionStatusFailed BillingSubscriptionStatus = "Failed" + BillingSubscriptionStatusOther BillingSubscriptionStatus = "Other" + BillingSubscriptionStatusSuspended BillingSubscriptionStatus = "Suspended" + BillingSubscriptionStatusUnknown BillingSubscriptionStatus = "Unknown" + BillingSubscriptionStatusWarned BillingSubscriptionStatus = "Warned" +) + +// PossibleBillingSubscriptionStatusValues returns the possible values for the BillingSubscriptionStatus const type. +func PossibleBillingSubscriptionStatusValues() []BillingSubscriptionStatus { + return []BillingSubscriptionStatus{ + BillingSubscriptionStatusActive, + BillingSubscriptionStatusAutoRenew, + BillingSubscriptionStatusCancelled, + BillingSubscriptionStatusDeleted, + BillingSubscriptionStatusDisabled, + BillingSubscriptionStatusExpired, + BillingSubscriptionStatusExpiring, + BillingSubscriptionStatusFailed, + BillingSubscriptionStatusOther, + BillingSubscriptionStatusSuspended, + BillingSubscriptionStatusUnknown, + BillingSubscriptionStatusWarned, } } -// BillingSubscriptionStatusType - The current billing status of the subscription. -type BillingSubscriptionStatusType string +// Cancellation - The policy override for the subscription indicates whether the self-serve cancellation or seat reduction +// is allowed. +type Cancellation string const ( - BillingSubscriptionStatusTypeAbandoned BillingSubscriptionStatusType = "Abandoned" - BillingSubscriptionStatusTypeActive BillingSubscriptionStatusType = "Active" - BillingSubscriptionStatusTypeDeleted BillingSubscriptionStatusType = "Deleted" - BillingSubscriptionStatusTypeInactive BillingSubscriptionStatusType = "Inactive" - BillingSubscriptionStatusTypeWarning BillingSubscriptionStatusType = "Warning" + CancellationAllowed Cancellation = "Allowed" + CancellationNotAllowed Cancellation = "NotAllowed" ) -// PossibleBillingSubscriptionStatusTypeValues returns the possible values for the BillingSubscriptionStatusType const type. -func PossibleBillingSubscriptionStatusTypeValues() []BillingSubscriptionStatusType { - return []BillingSubscriptionStatusType{ - BillingSubscriptionStatusTypeAbandoned, - BillingSubscriptionStatusTypeActive, - BillingSubscriptionStatusTypeDeleted, - BillingSubscriptionStatusTypeInactive, - BillingSubscriptionStatusTypeWarning, +// PossibleCancellationValues returns the possible values for the Cancellation const type. +func PossibleCancellationValues() []Cancellation { + return []Cancellation{ + CancellationAllowed, + CancellationNotAllowed, } } -// Category - The category of the agreement signed by a customer. +// CancellationReason - Cancellation reason. +type CancellationReason string + +const ( + CancellationReasonCompromise CancellationReason = "Compromise" + CancellationReasonDispute CancellationReason = "Dispute" + CancellationReasonOther CancellationReason = "Other" +) + +// PossibleCancellationReasonValues returns the possible values for the CancellationReason const type. +func PossibleCancellationReasonValues() []CancellationReason { + return []CancellationReason{ + CancellationReasonCompromise, + CancellationReasonDispute, + CancellationReasonOther, + } +} + +// Category - The category of the agreement. type Category string const ( - CategoryAffiliatePurchaseTerms Category = "AffiliatePurchaseTerms" - CategoryMicrosoftCustomerAgreement Category = "MicrosoftCustomerAgreement" - CategoryOther Category = "Other" + CategoryAffiliatePurchaseTerms Category = "AffiliatePurchaseTerms" + CategoryIndirectForGovernmentAgreement Category = "IndirectForGovernmentAgreement" + CategoryMicrosoftCustomerAgreement Category = "MicrosoftCustomerAgreement" + CategoryMicrosoftPartnerAgreement Category = "MicrosoftPartnerAgreement" + CategoryOther Category = "Other" + CategoryUKCloudComputeFramework Category = "UKCloudComputeFramework" ) // PossibleCategoryValues returns the possible values for the Category const type. func PossibleCategoryValues() []Category { return []Category{ CategoryAffiliatePurchaseTerms, + CategoryIndirectForGovernmentAgreement, CategoryMicrosoftCustomerAgreement, + CategoryMicrosoftPartnerAgreement, CategoryOther, + CategoryUKCloudComputeFramework, + } +} + +// CommitmentGrain - Commitment grain. +type CommitmentGrain string + +const ( + CommitmentGrainHourly CommitmentGrain = "Hourly" +) + +// PossibleCommitmentGrainValues returns the possible values for the CommitmentGrain const type. +func PossibleCommitmentGrainValues() []CommitmentGrain { + return []CommitmentGrain{ + CommitmentGrainHourly, + } +} + +// CreatedByType - The type of identity that created the resource. +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// CreditType - The credit type of the transaction. Applies only to credited transactions. +type CreditType string + +const ( + CreditTypeAzureCreditOffer CreditType = "AzureCreditOffer" + CreditTypeAzureFreeCredit CreditType = "AzureFreeCredit" + CreditTypeOther CreditType = "Other" + CreditTypeRefund CreditType = "Refund" + CreditTypeServiceInterruption CreditType = "ServiceInterruption" +) + +// PossibleCreditTypeValues returns the possible values for the CreditType const type. +func PossibleCreditTypeValues() []CreditType { + return []CreditType{ + CreditTypeAzureCreditOffer, + CreditTypeAzureFreeCredit, + CreditTypeOther, + CreditTypeRefund, + CreditTypeServiceInterruption, + } +} + +// CustomerStatus - Identifies the status of an customer. This is an upcoming property that will be populated in the future. +type CustomerStatus string + +const ( + CustomerStatusActive CustomerStatus = "Active" + CustomerStatusDeleted CustomerStatus = "Deleted" + CustomerStatusDisabled CustomerStatus = "Disabled" + CustomerStatusOther CustomerStatus = "Other" + CustomerStatusPending CustomerStatus = "Pending" + CustomerStatusUnderReview CustomerStatus = "UnderReview" + CustomerStatusWarned CustomerStatus = "Warned" +) + +// PossibleCustomerStatusValues returns the possible values for the CustomerStatus const type. +func PossibleCustomerStatusValues() []CustomerStatus { + return []CustomerStatus{ + CustomerStatusActive, + CustomerStatusDeleted, + CustomerStatusDisabled, + CustomerStatusOther, + CustomerStatusPending, + CustomerStatusUnderReview, + CustomerStatusWarned, + } +} + +// DeleteBillingProfileEligibilityCode - Code of the delete invoice section eligibility response. +type DeleteBillingProfileEligibilityCode string + +const ( + DeleteBillingProfileEligibilityCodeActiveBillingSubscriptions DeleteBillingProfileEligibilityCode = "ActiveBillingSubscriptions" + DeleteBillingProfileEligibilityCodeActiveCreditCard DeleteBillingProfileEligibilityCode = "ActiveCreditCard" + DeleteBillingProfileEligibilityCodeActiveCredits DeleteBillingProfileEligibilityCode = "ActiveCredits" + DeleteBillingProfileEligibilityCodeLastBillingProfile DeleteBillingProfileEligibilityCode = "LastBillingProfile" + DeleteBillingProfileEligibilityCodeNone DeleteBillingProfileEligibilityCode = "None" + DeleteBillingProfileEligibilityCodeNotSupported DeleteBillingProfileEligibilityCode = "NotSupported" + DeleteBillingProfileEligibilityCodeOutstandingCharges DeleteBillingProfileEligibilityCode = "OutstandingCharges" + DeleteBillingProfileEligibilityCodePendingCharges DeleteBillingProfileEligibilityCode = "PendingCharges" + DeleteBillingProfileEligibilityCodeReservedInstances DeleteBillingProfileEligibilityCode = "ReservedInstances" +) + +// PossibleDeleteBillingProfileEligibilityCodeValues returns the possible values for the DeleteBillingProfileEligibilityCode const type. +func PossibleDeleteBillingProfileEligibilityCodeValues() []DeleteBillingProfileEligibilityCode { + return []DeleteBillingProfileEligibilityCode{ + DeleteBillingProfileEligibilityCodeActiveBillingSubscriptions, + DeleteBillingProfileEligibilityCodeActiveCreditCard, + DeleteBillingProfileEligibilityCodeActiveCredits, + DeleteBillingProfileEligibilityCodeLastBillingProfile, + DeleteBillingProfileEligibilityCodeNone, + DeleteBillingProfileEligibilityCodeNotSupported, + DeleteBillingProfileEligibilityCodeOutstandingCharges, + DeleteBillingProfileEligibilityCodePendingCharges, + DeleteBillingProfileEligibilityCodeReservedInstances, + } +} + +// DeleteBillingProfileEligibilityStatus - Status describing if billing profile is eligible to be deleted. +type DeleteBillingProfileEligibilityStatus string + +const ( + DeleteBillingProfileEligibilityStatusAllowed DeleteBillingProfileEligibilityStatus = "Allowed" + DeleteBillingProfileEligibilityStatusNotAllowed DeleteBillingProfileEligibilityStatus = "NotAllowed" +) + +// PossibleDeleteBillingProfileEligibilityStatusValues returns the possible values for the DeleteBillingProfileEligibilityStatus const type. +func PossibleDeleteBillingProfileEligibilityStatusValues() []DeleteBillingProfileEligibilityStatus { + return []DeleteBillingProfileEligibilityStatus{ + DeleteBillingProfileEligibilityStatusAllowed, + DeleteBillingProfileEligibilityStatusNotAllowed, + } +} + +// DeleteInvoiceSectionEligibilityCode - Code for the delete invoice section validation. +type DeleteInvoiceSectionEligibilityCode string + +const ( + DeleteInvoiceSectionEligibilityCodeActiveAzurePlans DeleteInvoiceSectionEligibilityCode = "ActiveAzurePlans" + DeleteInvoiceSectionEligibilityCodeActiveBillingSubscriptions DeleteInvoiceSectionEligibilityCode = "ActiveBillingSubscriptions" + DeleteInvoiceSectionEligibilityCodeLastInvoiceSection DeleteInvoiceSectionEligibilityCode = "LastInvoiceSection" + DeleteInvoiceSectionEligibilityCodeOther DeleteInvoiceSectionEligibilityCode = "Other" + DeleteInvoiceSectionEligibilityCodeReservedInstances DeleteInvoiceSectionEligibilityCode = "ReservedInstances" +) + +// PossibleDeleteInvoiceSectionEligibilityCodeValues returns the possible values for the DeleteInvoiceSectionEligibilityCode const type. +func PossibleDeleteInvoiceSectionEligibilityCodeValues() []DeleteInvoiceSectionEligibilityCode { + return []DeleteInvoiceSectionEligibilityCode{ + DeleteInvoiceSectionEligibilityCodeActiveAzurePlans, + DeleteInvoiceSectionEligibilityCodeActiveBillingSubscriptions, + DeleteInvoiceSectionEligibilityCodeLastInvoiceSection, + DeleteInvoiceSectionEligibilityCodeOther, + DeleteInvoiceSectionEligibilityCodeReservedInstances, + } +} + +// DeleteInvoiceSectionEligibilityStatus - Status describing if invoice section is eligible to be deleted. +type DeleteInvoiceSectionEligibilityStatus string + +const ( + DeleteInvoiceSectionEligibilityStatusAllowed DeleteInvoiceSectionEligibilityStatus = "Allowed" + DeleteInvoiceSectionEligibilityStatusNotAllowed DeleteInvoiceSectionEligibilityStatus = "NotAllowed" +) + +// PossibleDeleteInvoiceSectionEligibilityStatusValues returns the possible values for the DeleteInvoiceSectionEligibilityStatus const type. +func PossibleDeleteInvoiceSectionEligibilityStatusValues() []DeleteInvoiceSectionEligibilityStatus { + return []DeleteInvoiceSectionEligibilityStatus{ + DeleteInvoiceSectionEligibilityStatusAllowed, + DeleteInvoiceSectionEligibilityStatusNotAllowed, } } @@ -261,8 +680,9 @@ func PossibleCategoryValues() []Category { type DocumentSource string const ( - DocumentSourceDRS DocumentSource = "DRS" - DocumentSourceENF DocumentSource = "ENF" + DocumentSourceDRS DocumentSource = "DRS" + DocumentSourceENF DocumentSource = "ENF" + DocumentSourceOther DocumentSource = "Other" ) // PossibleDocumentSourceValues returns the possible values for the DocumentSource const type. @@ -270,26 +690,158 @@ func PossibleDocumentSourceValues() []DocumentSource { return []DocumentSource{ DocumentSourceDRS, DocumentSourceENF, + DocumentSourceOther, + } +} + +// EligibleProductType - Type of the products that can be transferred. +type EligibleProductType string + +const ( + EligibleProductTypeAzureReservation EligibleProductType = "AzureReservation" + EligibleProductTypeDevTestAzureSubscription EligibleProductType = "DevTestAzureSubscription" + EligibleProductTypeStandardAzureSubscription EligibleProductType = "StandardAzureSubscription" +) + +// PossibleEligibleProductTypeValues returns the possible values for the EligibleProductType const type. +func PossibleEligibleProductTypeValues() []EligibleProductType { + return []EligibleProductType{ + EligibleProductTypeAzureReservation, + EligibleProductTypeDevTestAzureSubscription, + EligibleProductTypeStandardAzureSubscription, } } -// DocumentType - The type of the document. -type DocumentType string +// EnrollmentAccountOwnerViewCharges - The policy that controls whether account owner can view charges. +type EnrollmentAccountOwnerViewCharges string const ( - DocumentTypeCreditNote DocumentType = "CreditNote" - DocumentTypeInvoice DocumentType = "Invoice" - DocumentTypeTaxReceipt DocumentType = "TaxReceipt" - DocumentTypeVoidNote DocumentType = "VoidNote" + EnrollmentAccountOwnerViewChargesAllowed EnrollmentAccountOwnerViewCharges = "Allowed" + EnrollmentAccountOwnerViewChargesDisabled EnrollmentAccountOwnerViewCharges = "Disabled" + EnrollmentAccountOwnerViewChargesNotAllowed EnrollmentAccountOwnerViewCharges = "NotAllowed" + EnrollmentAccountOwnerViewChargesOther EnrollmentAccountOwnerViewCharges = "Other" ) -// PossibleDocumentTypeValues returns the possible values for the DocumentType const type. -func PossibleDocumentTypeValues() []DocumentType { - return []DocumentType{ - DocumentTypeCreditNote, - DocumentTypeInvoice, - DocumentTypeTaxReceipt, - DocumentTypeVoidNote, +// PossibleEnrollmentAccountOwnerViewChargesValues returns the possible values for the EnrollmentAccountOwnerViewCharges const type. +func PossibleEnrollmentAccountOwnerViewChargesValues() []EnrollmentAccountOwnerViewCharges { + return []EnrollmentAccountOwnerViewCharges{ + EnrollmentAccountOwnerViewChargesAllowed, + EnrollmentAccountOwnerViewChargesDisabled, + EnrollmentAccountOwnerViewChargesNotAllowed, + EnrollmentAccountOwnerViewChargesOther, + } +} + +// EnrollmentAuthLevelState - The state showing the enrollment auth level. +type EnrollmentAuthLevelState string + +const ( + EnrollmentAuthLevelStateMicrosoftAccountOnly EnrollmentAuthLevelState = "MicrosoftAccountOnly" + EnrollmentAuthLevelStateMixedAccount EnrollmentAuthLevelState = "MixedAccount" + EnrollmentAuthLevelStateOrganizationalAccountCrossTenant EnrollmentAuthLevelState = "OrganizationalAccountCrossTenant" + EnrollmentAuthLevelStateOrganizationalAccountOnly EnrollmentAuthLevelState = "OrganizationalAccountOnly" + EnrollmentAuthLevelStateOther EnrollmentAuthLevelState = "Other" +) + +// PossibleEnrollmentAuthLevelStateValues returns the possible values for the EnrollmentAuthLevelState const type. +func PossibleEnrollmentAuthLevelStateValues() []EnrollmentAuthLevelState { + return []EnrollmentAuthLevelState{ + EnrollmentAuthLevelStateMicrosoftAccountOnly, + EnrollmentAuthLevelStateMixedAccount, + EnrollmentAuthLevelStateOrganizationalAccountCrossTenant, + EnrollmentAuthLevelStateOrganizationalAccountOnly, + EnrollmentAuthLevelStateOther, + } +} + +// EnrollmentDepartmentAdminViewCharges - The policy that controls whether department admin can view charges. +type EnrollmentDepartmentAdminViewCharges string + +const ( + EnrollmentDepartmentAdminViewChargesAllowed EnrollmentDepartmentAdminViewCharges = "Allowed" + EnrollmentDepartmentAdminViewChargesDisabled EnrollmentDepartmentAdminViewCharges = "Disabled" + EnrollmentDepartmentAdminViewChargesNotAllowed EnrollmentDepartmentAdminViewCharges = "NotAllowed" + EnrollmentDepartmentAdminViewChargesOther EnrollmentDepartmentAdminViewCharges = "Other" +) + +// PossibleEnrollmentDepartmentAdminViewChargesValues returns the possible values for the EnrollmentDepartmentAdminViewCharges const type. +func PossibleEnrollmentDepartmentAdminViewChargesValues() []EnrollmentDepartmentAdminViewCharges { + return []EnrollmentDepartmentAdminViewCharges{ + EnrollmentDepartmentAdminViewChargesAllowed, + EnrollmentDepartmentAdminViewChargesDisabled, + EnrollmentDepartmentAdminViewChargesNotAllowed, + EnrollmentDepartmentAdminViewChargesOther, + } +} + +// ExtendedTermOption - The billing account extension opted by the company. +type ExtendedTermOption string + +const ( + ExtendedTermOptionOptedIn ExtendedTermOption = "Opted-In" + ExtendedTermOptionOptedOut ExtendedTermOption = "Opted-Out" + ExtendedTermOptionOther ExtendedTermOption = "Other" +) + +// PossibleExtendedTermOptionValues returns the possible values for the ExtendedTermOption const type. +func PossibleExtendedTermOptionValues() []ExtendedTermOption { + return []ExtendedTermOption{ + ExtendedTermOptionOptedIn, + ExtendedTermOptionOptedOut, + ExtendedTermOptionOther, + } +} + +// FailedPaymentReason - The reason that the payment failed. +type FailedPaymentReason string + +const ( + FailedPaymentReasonBankDeclined FailedPaymentReason = "BankDeclined" + FailedPaymentReasonCardExpired FailedPaymentReason = "CardExpired" + FailedPaymentReasonIncorrectCardDetails FailedPaymentReason = "IncorrectCardDetails" + FailedPaymentReasonOther FailedPaymentReason = "Other" +) + +// PossibleFailedPaymentReasonValues returns the possible values for the FailedPaymentReason const type. +func PossibleFailedPaymentReasonValues() []FailedPaymentReason { + return []FailedPaymentReason{ + FailedPaymentReasonBankDeclined, + FailedPaymentReasonCardExpired, + FailedPaymentReasonIncorrectCardDetails, + FailedPaymentReasonOther, + } +} + +// InitiatorCustomerType - The type of customer of the transfer initiator. +type InitiatorCustomerType string + +const ( + InitiatorCustomerTypeEA InitiatorCustomerType = "EA" + InitiatorCustomerTypePartner InitiatorCustomerType = "Partner" +) + +// PossibleInitiatorCustomerTypeValues returns the possible values for the InitiatorCustomerType const type. +func PossibleInitiatorCustomerTypeValues() []InitiatorCustomerType { + return []InitiatorCustomerType{ + InitiatorCustomerTypeEA, + InitiatorCustomerTypePartner, + } +} + +// InstanceFlexibility - Turning this on will apply the reservation discount to other VMs in the same VM size group. Only +// specify for VirtualMachines reserved resource type. +type InstanceFlexibility string + +const ( + InstanceFlexibilityOff InstanceFlexibility = "Off" + InstanceFlexibilityOn InstanceFlexibility = "On" +) + +// PossibleInstanceFlexibilityValues returns the possible values for the InstanceFlexibility const type. +func PossibleInstanceFlexibilityValues() []InstanceFlexibility { + return []InstanceFlexibility{ + InstanceFlexibilityOff, + InstanceFlexibilityOn, } } @@ -297,8 +849,13 @@ func PossibleDocumentTypeValues() []DocumentType { type InvoiceDocumentType string const ( - InvoiceDocumentTypeCreditNote InvoiceDocumentType = "CreditNote" - InvoiceDocumentTypeInvoice InvoiceDocumentType = "Invoice" + InvoiceDocumentTypeCreditNote InvoiceDocumentType = "CreditNote" + InvoiceDocumentTypeInvoice InvoiceDocumentType = "Invoice" + InvoiceDocumentTypeOther InvoiceDocumentType = "Other" + InvoiceDocumentTypeSummary InvoiceDocumentType = "Summary" + InvoiceDocumentTypeTaxReceipt InvoiceDocumentType = "TaxReceipt" + InvoiceDocumentTypeTransactions InvoiceDocumentType = "Transactions" + InvoiceDocumentTypeVoidNote InvoiceDocumentType = "VoidNote" ) // PossibleInvoiceDocumentTypeValues returns the possible values for the InvoiceDocumentType const type. @@ -306,22 +863,78 @@ func PossibleInvoiceDocumentTypeValues() []InvoiceDocumentType { return []InvoiceDocumentType{ InvoiceDocumentTypeCreditNote, InvoiceDocumentTypeInvoice, + InvoiceDocumentTypeOther, + InvoiceDocumentTypeSummary, + InvoiceDocumentTypeTaxReceipt, + InvoiceDocumentTypeTransactions, + InvoiceDocumentTypeVoidNote, } } -// InvoiceSectionState - Identifies the state of an invoice section. +// InvoiceSectionLabelManagementPolicy - The policy that controls invoice section label management at invoice section scope. +// This is allowed by default. +type InvoiceSectionLabelManagementPolicy string + +const ( + InvoiceSectionLabelManagementPolicyAllowed InvoiceSectionLabelManagementPolicy = "Allowed" + InvoiceSectionLabelManagementPolicyNotAllowed InvoiceSectionLabelManagementPolicy = "NotAllowed" + InvoiceSectionLabelManagementPolicyOther InvoiceSectionLabelManagementPolicy = "Other" +) + +// PossibleInvoiceSectionLabelManagementPolicyValues returns the possible values for the InvoiceSectionLabelManagementPolicy const type. +func PossibleInvoiceSectionLabelManagementPolicyValues() []InvoiceSectionLabelManagementPolicy { + return []InvoiceSectionLabelManagementPolicy{ + InvoiceSectionLabelManagementPolicyAllowed, + InvoiceSectionLabelManagementPolicyNotAllowed, + InvoiceSectionLabelManagementPolicyOther, + } +} + +// InvoiceSectionState - Identifies the status of an invoice section. type InvoiceSectionState string const ( - InvoiceSectionStateActive InvoiceSectionState = "Active" - InvoiceSectionStateRestricted InvoiceSectionState = "Restricted" + InvoiceSectionStateActive InvoiceSectionState = "Active" + InvoiceSectionStateDeleted InvoiceSectionState = "Deleted" + InvoiceSectionStateDisabled InvoiceSectionState = "Disabled" + InvoiceSectionStateOther InvoiceSectionState = "Other" + InvoiceSectionStateRestricted InvoiceSectionState = "Restricted" + InvoiceSectionStateUnderReview InvoiceSectionState = "UnderReview" + InvoiceSectionStateWarned InvoiceSectionState = "Warned" ) // PossibleInvoiceSectionStateValues returns the possible values for the InvoiceSectionState const type. func PossibleInvoiceSectionStateValues() []InvoiceSectionState { return []InvoiceSectionState{ InvoiceSectionStateActive, + InvoiceSectionStateDeleted, + InvoiceSectionStateDisabled, + InvoiceSectionStateOther, InvoiceSectionStateRestricted, + InvoiceSectionStateUnderReview, + InvoiceSectionStateWarned, + } +} + +// InvoiceSectionStateReasonCode - Reason for the specified invoice section status. +type InvoiceSectionStateReasonCode string + +const ( + InvoiceSectionStateReasonCodeOther InvoiceSectionStateReasonCode = "Other" + InvoiceSectionStateReasonCodePastDue InvoiceSectionStateReasonCode = "PastDue" + InvoiceSectionStateReasonCodeSpendingLimitExpired InvoiceSectionStateReasonCode = "SpendingLimitExpired" + InvoiceSectionStateReasonCodeSpendingLimitReached InvoiceSectionStateReasonCode = "SpendingLimitReached" + InvoiceSectionStateReasonCodeUnusualActivity InvoiceSectionStateReasonCode = "UnusualActivity" +) + +// PossibleInvoiceSectionStateReasonCodeValues returns the possible values for the InvoiceSectionStateReasonCode const type. +func PossibleInvoiceSectionStateReasonCodeValues() []InvoiceSectionStateReasonCode { + return []InvoiceSectionStateReasonCode{ + InvoiceSectionStateReasonCodeOther, + InvoiceSectionStateReasonCodePastDue, + InvoiceSectionStateReasonCodeSpendingLimitExpired, + InvoiceSectionStateReasonCodeSpendingLimitReached, + InvoiceSectionStateReasonCodeUnusualActivity, } } @@ -330,6 +943,8 @@ type InvoiceStatus string const ( InvoiceStatusDue InvoiceStatus = "Due" + InvoiceStatusLocked InvoiceStatus = "Locked" + InvoiceStatusOther InvoiceStatus = "Other" InvoiceStatusOverDue InvoiceStatus = "OverDue" InvoiceStatusPaid InvoiceStatus = "Paid" InvoiceStatusVoid InvoiceStatus = "Void" @@ -339,6 +954,8 @@ const ( func PossibleInvoiceStatusValues() []InvoiceStatus { return []InvoiceStatus{ InvoiceStatusDue, + InvoiceStatusLocked, + InvoiceStatusOther, InvoiceStatusOverDue, InvoiceStatusPaid, InvoiceStatusVoid, @@ -350,45 +967,123 @@ type InvoiceType string const ( InvoiceTypeAzureMarketplace InvoiceType = "AzureMarketplace" - InvoiceTypeAzureService InvoiceType = "AzureService" + InvoiceTypeAzureServices InvoiceType = "AzureServices" InvoiceTypeAzureSupport InvoiceType = "AzureSupport" + InvoiceTypeOther InvoiceType = "Other" ) // PossibleInvoiceTypeValues returns the possible values for the InvoiceType const type. func PossibleInvoiceTypeValues() []InvoiceType { return []InvoiceType{ InvoiceTypeAzureMarketplace, - InvoiceTypeAzureService, + InvoiceTypeAzureServices, InvoiceTypeAzureSupport, + InvoiceTypeOther, } } -// MarketplacePurchasesPolicy - The policy that controls whether Azure marketplace purchases are allowed for a billing profile. +// MarketplacePurchasesPolicy - The policy that controls whether Azure marketplace purchases are allowed. type MarketplacePurchasesPolicy string const ( MarketplacePurchasesPolicyAllAllowed MarketplacePurchasesPolicy = "AllAllowed" + MarketplacePurchasesPolicyDisabled MarketplacePurchasesPolicy = "Disabled" MarketplacePurchasesPolicyNotAllowed MarketplacePurchasesPolicy = "NotAllowed" MarketplacePurchasesPolicyOnlyFreeAllowed MarketplacePurchasesPolicy = "OnlyFreeAllowed" + MarketplacePurchasesPolicyOther MarketplacePurchasesPolicy = "Other" ) // PossibleMarketplacePurchasesPolicyValues returns the possible values for the MarketplacePurchasesPolicy const type. func PossibleMarketplacePurchasesPolicyValues() []MarketplacePurchasesPolicy { return []MarketplacePurchasesPolicy{ MarketplacePurchasesPolicyAllAllowed, + MarketplacePurchasesPolicyDisabled, MarketplacePurchasesPolicyNotAllowed, MarketplacePurchasesPolicyOnlyFreeAllowed, + MarketplacePurchasesPolicyOther, + } +} + +// MarkupStatus - Markup status of enrollment, applicable only for indirect enrollments. +type MarkupStatus string + +const ( + MarkupStatusDisabled MarkupStatus = "Disabled" + MarkupStatusLocked MarkupStatus = "Locked" + MarkupStatusOther MarkupStatus = "Other" + MarkupStatusPreview MarkupStatus = "Preview" + MarkupStatusPublished MarkupStatus = "Published" +) + +// PossibleMarkupStatusValues returns the possible values for the MarkupStatus const type. +func PossibleMarkupStatusValues() []MarkupStatus { + return []MarkupStatus{ + MarkupStatusDisabled, + MarkupStatusLocked, + MarkupStatusOther, + MarkupStatusPreview, + MarkupStatusPublished, } } -// PaymentMethodFamily - The family of payment method. +// MoveValidationErrorCode - Error code for the product transfer validation. +type MoveValidationErrorCode string + +const ( + MoveValidationErrorCodeBillingAccountInactive MoveValidationErrorCode = "BillingAccountInactive" + MoveValidationErrorCodeDestinationBillingProfileInactive MoveValidationErrorCode = "DestinationBillingProfileInactive" + MoveValidationErrorCodeDestinationBillingProfileNotFound MoveValidationErrorCode = "DestinationBillingProfileNotFound" + MoveValidationErrorCodeDestinationBillingProfilePastDue MoveValidationErrorCode = "DestinationBillingProfilePastDue" + MoveValidationErrorCodeDestinationInvoiceSectionInactive MoveValidationErrorCode = "DestinationInvoiceSectionInactive" + MoveValidationErrorCodeDestinationInvoiceSectionNotFound MoveValidationErrorCode = "DestinationInvoiceSectionNotFound" + MoveValidationErrorCodeInsufficientPermissionOnDestination MoveValidationErrorCode = "InsufficientPermissionOnDestination" + MoveValidationErrorCodeInsufficientPermissionOnSource MoveValidationErrorCode = "InsufficientPermissionOnSource" + MoveValidationErrorCodeInvalidDestination MoveValidationErrorCode = "InvalidDestination" + MoveValidationErrorCodeInvalidSource MoveValidationErrorCode = "InvalidSource" + MoveValidationErrorCodeMarketplaceNotEnabledOnDestination MoveValidationErrorCode = "MarketplaceNotEnabledOnDestination" + MoveValidationErrorCodeOther MoveValidationErrorCode = "Other" + MoveValidationErrorCodeProductInactive MoveValidationErrorCode = "ProductInactive" + MoveValidationErrorCodeProductNotFound MoveValidationErrorCode = "ProductNotFound" + MoveValidationErrorCodeProductTypeNotSupported MoveValidationErrorCode = "ProductTypeNotSupported" + MoveValidationErrorCodeSourceBillingProfilePastDue MoveValidationErrorCode = "SourceBillingProfilePastDue" + MoveValidationErrorCodeSourceInvoiceSectionInactive MoveValidationErrorCode = "SourceInvoiceSectionInactive" +) + +// PossibleMoveValidationErrorCodeValues returns the possible values for the MoveValidationErrorCode const type. +func PossibleMoveValidationErrorCodeValues() []MoveValidationErrorCode { + return []MoveValidationErrorCode{ + MoveValidationErrorCodeBillingAccountInactive, + MoveValidationErrorCodeDestinationBillingProfileInactive, + MoveValidationErrorCodeDestinationBillingProfileNotFound, + MoveValidationErrorCodeDestinationBillingProfilePastDue, + MoveValidationErrorCodeDestinationInvoiceSectionInactive, + MoveValidationErrorCodeDestinationInvoiceSectionNotFound, + MoveValidationErrorCodeInsufficientPermissionOnDestination, + MoveValidationErrorCodeInsufficientPermissionOnSource, + MoveValidationErrorCodeInvalidDestination, + MoveValidationErrorCodeInvalidSource, + MoveValidationErrorCodeMarketplaceNotEnabledOnDestination, + MoveValidationErrorCodeOther, + MoveValidationErrorCodeProductInactive, + MoveValidationErrorCodeProductNotFound, + MoveValidationErrorCodeProductTypeNotSupported, + MoveValidationErrorCodeSourceBillingProfilePastDue, + MoveValidationErrorCodeSourceInvoiceSectionInactive, + } +} + +// PaymentMethodFamily - Payment on Account type. type PaymentMethodFamily string const ( - PaymentMethodFamilyCheckWire PaymentMethodFamily = "CheckWire" - PaymentMethodFamilyCreditCard PaymentMethodFamily = "CreditCard" - PaymentMethodFamilyCredits PaymentMethodFamily = "Credits" - PaymentMethodFamilyNone PaymentMethodFamily = "None" + PaymentMethodFamilyCheckWire PaymentMethodFamily = "CheckWire" + PaymentMethodFamilyCreditCard PaymentMethodFamily = "CreditCard" + PaymentMethodFamilyCredits PaymentMethodFamily = "Credits" + PaymentMethodFamilyDirectDebit PaymentMethodFamily = "DirectDebit" + PaymentMethodFamilyEWallet PaymentMethodFamily = "EWallet" + PaymentMethodFamilyNone PaymentMethodFamily = "None" + PaymentMethodFamilyOther PaymentMethodFamily = "Other" + PaymentMethodFamilyTaskOrder PaymentMethodFamily = "TaskOrder" ) // PossiblePaymentMethodFamilyValues returns the possible values for the PaymentMethodFamily const type. @@ -397,97 +1092,486 @@ func PossiblePaymentMethodFamilyValues() []PaymentMethodFamily { PaymentMethodFamilyCheckWire, PaymentMethodFamilyCreditCard, PaymentMethodFamilyCredits, + PaymentMethodFamilyDirectDebit, + PaymentMethodFamilyEWallet, PaymentMethodFamilyNone, + PaymentMethodFamilyOther, + PaymentMethodFamilyTaskOrder, + } +} + +// PaymentMethodStatus - Status of the payment method. +type PaymentMethodStatus string + +const ( + PaymentMethodStatusActive PaymentMethodStatus = "active" + PaymentMethodStatusInactive PaymentMethodStatus = "inactive" +) + +// PossiblePaymentMethodStatusValues returns the possible values for the PaymentMethodStatus const type. +func PossiblePaymentMethodStatusValues() []PaymentMethodStatus { + return []PaymentMethodStatus{ + PaymentMethodStatusActive, + PaymentMethodStatusInactive, + } +} + +// PaymentStatus - Describes whether the payment is completed, failed, pending, cancelled or scheduled in the future. +type PaymentStatus string + +const ( + PaymentStatusCancelled PaymentStatus = "Cancelled" + PaymentStatusCompleted PaymentStatus = "Completed" + PaymentStatusFailed PaymentStatus = "Failed" + PaymentStatusPending PaymentStatus = "Pending" + PaymentStatusScheduled PaymentStatus = "Scheduled" + PaymentStatusSucceeded PaymentStatus = "Succeeded" +) + +// PossiblePaymentStatusValues returns the possible values for the PaymentStatus const type. +func PossiblePaymentStatusValues() []PaymentStatus { + return []PaymentStatus{ + PaymentStatusCancelled, + PaymentStatusCompleted, + PaymentStatusFailed, + PaymentStatusPending, + PaymentStatusScheduled, + PaymentStatusSucceeded, + } +} + +// PaymentTermsEligibilityCode - Indicates the reason for the ineligibility of the payment terms. +type PaymentTermsEligibilityCode string + +const ( + PaymentTermsEligibilityCodeBillingAccountNotFound PaymentTermsEligibilityCode = "BillingAccountNotFound" + PaymentTermsEligibilityCodeInactiveBillingAccount PaymentTermsEligibilityCode = "InactiveBillingAccount" + PaymentTermsEligibilityCodeIneligibleBillingAccountStatus PaymentTermsEligibilityCode = "IneligibleBillingAccountStatus" + PaymentTermsEligibilityCodeInvalidBillingAccountType PaymentTermsEligibilityCode = "InvalidBillingAccountType" + PaymentTermsEligibilityCodeInvalidDateFormat PaymentTermsEligibilityCode = "InvalidDateFormat" + PaymentTermsEligibilityCodeInvalidDateRange PaymentTermsEligibilityCode = "InvalidDateRange" + PaymentTermsEligibilityCodeInvalidTerms PaymentTermsEligibilityCode = "InvalidTerms" + PaymentTermsEligibilityCodeNullOrEmptyPaymentTerms PaymentTermsEligibilityCode = "NullOrEmptyPaymentTerms" + PaymentTermsEligibilityCodeOther PaymentTermsEligibilityCode = "Other" + PaymentTermsEligibilityCodeOverlappingPaymentTerms PaymentTermsEligibilityCode = "OverlappingPaymentTerms" +) + +// PossiblePaymentTermsEligibilityCodeValues returns the possible values for the PaymentTermsEligibilityCode const type. +func PossiblePaymentTermsEligibilityCodeValues() []PaymentTermsEligibilityCode { + return []PaymentTermsEligibilityCode{ + PaymentTermsEligibilityCodeBillingAccountNotFound, + PaymentTermsEligibilityCodeInactiveBillingAccount, + PaymentTermsEligibilityCodeIneligibleBillingAccountStatus, + PaymentTermsEligibilityCodeInvalidBillingAccountType, + PaymentTermsEligibilityCodeInvalidDateFormat, + PaymentTermsEligibilityCodeInvalidDateRange, + PaymentTermsEligibilityCodeInvalidTerms, + PaymentTermsEligibilityCodeNullOrEmptyPaymentTerms, + PaymentTermsEligibilityCodeOther, + PaymentTermsEligibilityCodeOverlappingPaymentTerms, + } +} + +// PaymentTermsEligibilityStatus - Indicates the eligibility status of the payment terms. +type PaymentTermsEligibilityStatus string + +const ( + PaymentTermsEligibilityStatusInvalid PaymentTermsEligibilityStatus = "Invalid" + PaymentTermsEligibilityStatusOther PaymentTermsEligibilityStatus = "Other" + PaymentTermsEligibilityStatusValid PaymentTermsEligibilityStatus = "Valid" +) + +// PossiblePaymentTermsEligibilityStatusValues returns the possible values for the PaymentTermsEligibilityStatus const type. +func PossiblePaymentTermsEligibilityStatusValues() []PaymentTermsEligibilityStatus { + return []PaymentTermsEligibilityStatus{ + PaymentTermsEligibilityStatusInvalid, + PaymentTermsEligibilityStatusOther, + PaymentTermsEligibilityStatusValid, + } +} + +// PolicyType - The type of the policy. +type PolicyType string + +const ( + PolicyTypeOther PolicyType = "Other" + PolicyTypeSystemControlled PolicyType = "SystemControlled" + PolicyTypeUserControlled PolicyType = "UserControlled" +) + +// PossiblePolicyTypeValues returns the possible values for the PolicyType const type. +func PossiblePolicyTypeValues() []PolicyType { + return []PolicyType{ + PolicyTypeOther, + PolicyTypeSystemControlled, + PolicyTypeUserControlled, + } +} + +// PrincipalType - The type of a role Assignment. +type PrincipalType string + +const ( + PrincipalTypeDirectoryRole PrincipalType = "DirectoryRole" + PrincipalTypeEveryone PrincipalType = "Everyone" + PrincipalTypeGroup PrincipalType = "Group" + PrincipalTypeNone PrincipalType = "None" + PrincipalTypeServicePrincipal PrincipalType = "ServicePrincipal" + PrincipalTypeUnknown PrincipalType = "Unknown" + PrincipalTypeUser PrincipalType = "User" +) + +// PossiblePrincipalTypeValues returns the possible values for the PrincipalType const type. +func PossiblePrincipalTypeValues() []PrincipalType { + return []PrincipalType{ + PrincipalTypeDirectoryRole, + PrincipalTypeEveryone, + PrincipalTypeGroup, + PrincipalTypeNone, + PrincipalTypeServicePrincipal, + PrincipalTypeUnknown, + PrincipalTypeUser, + } +} + +// ProductStatus - The status of the product. +type ProductStatus string + +const ( + ProductStatusActive ProductStatus = "Active" + ProductStatusAutoRenew ProductStatus = "AutoRenew" + ProductStatusCanceled ProductStatus = "Canceled" + ProductStatusDeleted ProductStatus = "Deleted" + ProductStatusDisabled ProductStatus = "Disabled" + ProductStatusExpired ProductStatus = "Expired" + ProductStatusExpiring ProductStatus = "Expiring" + ProductStatusOther ProductStatus = "Other" + ProductStatusPastDue ProductStatus = "PastDue" + ProductStatusSuspended ProductStatus = "Suspended" +) + +// PossibleProductStatusValues returns the possible values for the ProductStatus const type. +func PossibleProductStatusValues() []ProductStatus { + return []ProductStatus{ + ProductStatusActive, + ProductStatusAutoRenew, + ProductStatusCanceled, + ProductStatusDeleted, + ProductStatusDisabled, + ProductStatusExpired, + ProductStatusExpiring, + ProductStatusOther, + ProductStatusPastDue, + ProductStatusSuspended, + } +} + +// ProductTransferStatus - The status of a transfer. +type ProductTransferStatus string + +const ( + ProductTransferStatusCompleted ProductTransferStatus = "Completed" + ProductTransferStatusFailed ProductTransferStatus = "Failed" + ProductTransferStatusInProgress ProductTransferStatus = "InProgress" + ProductTransferStatusNotStarted ProductTransferStatus = "NotStarted" +) + +// PossibleProductTransferStatusValues returns the possible values for the ProductTransferStatus const type. +func PossibleProductTransferStatusValues() []ProductTransferStatus { + return []ProductTransferStatus{ + ProductTransferStatusCompleted, + ProductTransferStatusFailed, + ProductTransferStatusInProgress, + ProductTransferStatusNotStarted, + } +} + +// ProductType - The type of product that is transferred. +type ProductType string + +const ( + ProductTypeAzureReservation ProductType = "AzureReservation" + ProductTypeAzureSubscription ProductType = "AzureSubscription" + ProductTypeDepartment ProductType = "Department" + ProductTypeSAAS ProductType = "SAAS" + ProductTypeSavingsPlan ProductType = "SavingsPlan" +) + +// PossibleProductTypeValues returns the possible values for the ProductType const type. +func PossibleProductTypeValues() []ProductType { + return []ProductType{ + ProductTypeAzureReservation, + ProductTypeAzureSubscription, + ProductTypeDepartment, + ProductTypeSAAS, + ProductTypeSavingsPlan, + } +} + +// ProvisioningState - The provisioning state of the resource during a long-running operation. +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateConfirmedBilling ProvisioningState = "ConfirmedBilling" + ProvisioningStateCreated ProvisioningState = "Created" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateExpired ProvisioningState = "Expired" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateNew ProvisioningState = "New" + ProvisioningStatePending ProvisioningState = "Pending" + ProvisioningStatePendingBilling ProvisioningState = "PendingBilling" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateCanceled, + ProvisioningStateConfirmedBilling, + ProvisioningStateCreated, + ProvisioningStateCreating, + ProvisioningStateExpired, + ProvisioningStateFailed, + ProvisioningStateNew, + ProvisioningStatePending, + ProvisioningStatePendingBilling, + ProvisioningStateProvisioning, + ProvisioningStateSucceeded, + } +} + +// ProvisioningTenantState - The state determines whether subscriptions and licenses can be provisioned in the associated +// tenant. It can be set to 'Pending' to initiate a billing request. +type ProvisioningTenantState string + +const ( + ProvisioningTenantStateActive ProvisioningTenantState = "Active" + ProvisioningTenantStateBillingRequestDeclined ProvisioningTenantState = "BillingRequestDeclined" + ProvisioningTenantStateBillingRequestExpired ProvisioningTenantState = "BillingRequestExpired" + ProvisioningTenantStateNotRequested ProvisioningTenantState = "NotRequested" + ProvisioningTenantStateOther ProvisioningTenantState = "Other" + ProvisioningTenantStatePending ProvisioningTenantState = "Pending" + ProvisioningTenantStateRevoked ProvisioningTenantState = "Revoked" +) + +// PossibleProvisioningTenantStateValues returns the possible values for the ProvisioningTenantState const type. +func PossibleProvisioningTenantStateValues() []ProvisioningTenantState { + return []ProvisioningTenantState{ + ProvisioningTenantStateActive, + ProvisioningTenantStateBillingRequestDeclined, + ProvisioningTenantStateBillingRequestExpired, + ProvisioningTenantStateNotRequested, + ProvisioningTenantStateOther, + ProvisioningTenantStatePending, + ProvisioningTenantStateRevoked, + } +} + +// RefundReasonCode - The reason for refund. +type RefundReasonCode string + +const ( + RefundReasonCodeAccidentalConversion RefundReasonCode = "AccidentalConversion" + RefundReasonCodeAccidentalPurchase RefundReasonCode = "AccidentalPurchase" + RefundReasonCodeForgotToCancel RefundReasonCode = "ForgotToCancel" + RefundReasonCodeOther RefundReasonCode = "Other" + RefundReasonCodeUnclearDocumentation RefundReasonCode = "UnclearDocumentation" + RefundReasonCodeUnclearPricing RefundReasonCode = "UnclearPricing" +) + +// PossibleRefundReasonCodeValues returns the possible values for the RefundReasonCode const type. +func PossibleRefundReasonCodeValues() []RefundReasonCode { + return []RefundReasonCode{ + RefundReasonCodeAccidentalConversion, + RefundReasonCodeAccidentalPurchase, + RefundReasonCodeForgotToCancel, + RefundReasonCodeOther, + RefundReasonCodeUnclearDocumentation, + RefundReasonCodeUnclearPricing, } } -// ProductStatusType - The current status of the product. -type ProductStatusType string +// RefundStatus - The status of refund request. +type RefundStatus string const ( - ProductStatusTypeActive ProductStatusType = "Active" - ProductStatusTypeAutoRenew ProductStatusType = "AutoRenew" - ProductStatusTypeCancelled ProductStatusType = "Cancelled" - ProductStatusTypeDisabled ProductStatusType = "Disabled" - ProductStatusTypeExpired ProductStatusType = "Expired" - ProductStatusTypeExpiring ProductStatusType = "Expiring" - ProductStatusTypeInactive ProductStatusType = "Inactive" - ProductStatusTypePastDue ProductStatusType = "PastDue" + RefundStatusApproved RefundStatus = "Approved" + RefundStatusCancelled RefundStatus = "Cancelled" + RefundStatusCompleted RefundStatus = "Completed" + RefundStatusDeclined RefundStatus = "Declined" + RefundStatusExpired RefundStatus = "Expired" + RefundStatusOther RefundStatus = "Other" + RefundStatusPending RefundStatus = "Pending" ) -// PossibleProductStatusTypeValues returns the possible values for the ProductStatusType const type. -func PossibleProductStatusTypeValues() []ProductStatusType { - return []ProductStatusType{ - ProductStatusTypeActive, - ProductStatusTypeAutoRenew, - ProductStatusTypeCancelled, - ProductStatusTypeDisabled, - ProductStatusTypeExpired, - ProductStatusTypeExpiring, - ProductStatusTypeInactive, - ProductStatusTypePastDue, +// PossibleRefundStatusValues returns the possible values for the RefundStatus const type. +func PossibleRefundStatusValues() []RefundStatus { + return []RefundStatus{ + RefundStatusApproved, + RefundStatusCancelled, + RefundStatusCompleted, + RefundStatusDeclined, + RefundStatusExpired, + RefundStatusOther, + RefundStatusPending, } } -// ProductTransferValidationErrorCode - Error code of the transfer validation response. -type ProductTransferValidationErrorCode string +// ReservationBillingPlan - Represent the billing plans. +type ReservationBillingPlan string const ( - ProductTransferValidationErrorCodeCrossBillingAccountNotAllowed ProductTransferValidationErrorCode = "CrossBillingAccountNotAllowed" - ProductTransferValidationErrorCodeDestinationBillingProfilePastDue ProductTransferValidationErrorCode = "DestinationBillingProfilePastDue" - ProductTransferValidationErrorCodeInsufficientPermissionOnDestination ProductTransferValidationErrorCode = "InsufficientPermissionOnDestination" - ProductTransferValidationErrorCodeInsufficientPermissionOnSource ProductTransferValidationErrorCode = "InsufficientPermissionOnSource" - ProductTransferValidationErrorCodeInvalidSource ProductTransferValidationErrorCode = "InvalidSource" - ProductTransferValidationErrorCodeNotAvailableForDestinationMarket ProductTransferValidationErrorCode = "NotAvailableForDestinationMarket" - ProductTransferValidationErrorCodeOneTimePurchaseProductTransferNotAllowed ProductTransferValidationErrorCode = "OneTimePurchaseProductTransferNotAllowed" - ProductTransferValidationErrorCodeProductNotActive ProductTransferValidationErrorCode = "ProductNotActive" - ProductTransferValidationErrorCodeProductTypeNotSupported ProductTransferValidationErrorCode = "ProductTypeNotSupported" + ReservationBillingPlanMonthly ReservationBillingPlan = "Monthly" + ReservationBillingPlanUpfront ReservationBillingPlan = "Upfront" ) -// PossibleProductTransferValidationErrorCodeValues returns the possible values for the ProductTransferValidationErrorCode const type. -func PossibleProductTransferValidationErrorCodeValues() []ProductTransferValidationErrorCode { - return []ProductTransferValidationErrorCode{ - ProductTransferValidationErrorCodeCrossBillingAccountNotAllowed, - ProductTransferValidationErrorCodeDestinationBillingProfilePastDue, - ProductTransferValidationErrorCodeInsufficientPermissionOnDestination, - ProductTransferValidationErrorCodeInsufficientPermissionOnSource, - ProductTransferValidationErrorCodeInvalidSource, - ProductTransferValidationErrorCodeNotAvailableForDestinationMarket, - ProductTransferValidationErrorCodeOneTimePurchaseProductTransferNotAllowed, - ProductTransferValidationErrorCodeProductNotActive, - ProductTransferValidationErrorCodeProductTypeNotSupported, +// PossibleReservationBillingPlanValues returns the possible values for the ReservationBillingPlan const type. +func PossibleReservationBillingPlanValues() []ReservationBillingPlan { + return []ReservationBillingPlan{ + ReservationBillingPlanMonthly, + ReservationBillingPlanUpfront, } } -// ReservationPurchasesPolicy - The policy that controls whether Azure reservation purchases are allowed for a billing profile. +// ReservationPurchasesPolicy - The policy that controls whether Azure reservation purchases are allowed. type ReservationPurchasesPolicy string const ( ReservationPurchasesPolicyAllowed ReservationPurchasesPolicy = "Allowed" + ReservationPurchasesPolicyDisabled ReservationPurchasesPolicy = "Disabled" ReservationPurchasesPolicyNotAllowed ReservationPurchasesPolicy = "NotAllowed" + ReservationPurchasesPolicyOther ReservationPurchasesPolicy = "Other" ) // PossibleReservationPurchasesPolicyValues returns the possible values for the ReservationPurchasesPolicy const type. func PossibleReservationPurchasesPolicyValues() []ReservationPurchasesPolicy { return []ReservationPurchasesPolicy{ ReservationPurchasesPolicyAllowed, + ReservationPurchasesPolicyDisabled, ReservationPurchasesPolicyNotAllowed, + ReservationPurchasesPolicyOther, } } -// ReservationType - The type of transaction. -type ReservationType string +// ReservationStatusCode - The status of the reservation. +type ReservationStatusCode string const ( - ReservationTypePurchase ReservationType = "Purchase" - ReservationTypeUsageCharge ReservationType = "Usage Charge" + ReservationStatusCodeActive ReservationStatusCode = "Active" + ReservationStatusCodeCapacityError ReservationStatusCode = "CapacityError" + ReservationStatusCodeCapacityRestricted ReservationStatusCode = "CapacityRestricted" + ReservationStatusCodeCreditLineCheckFailed ReservationStatusCode = "CreditLineCheckFailed" + ReservationStatusCodeExchanged ReservationStatusCode = "Exchanged" + ReservationStatusCodeExpired ReservationStatusCode = "Expired" + ReservationStatusCodeMerged ReservationStatusCode = "Merged" + ReservationStatusCodeNoBenefit ReservationStatusCode = "NoBenefit" + ReservationStatusCodeNoBenefitDueToSubscriptionDeletion ReservationStatusCode = "NoBenefitDueToSubscriptionDeletion" + ReservationStatusCodeNoBenefitDueToSubscriptionTransfer ReservationStatusCode = "NoBenefitDueToSubscriptionTransfer" + ReservationStatusCodeNone ReservationStatusCode = "None" + ReservationStatusCodePaymentInstrumentError ReservationStatusCode = "PaymentInstrumentError" + ReservationStatusCodePending ReservationStatusCode = "Pending" + ReservationStatusCodeProcessing ReservationStatusCode = "Processing" + ReservationStatusCodePurchaseError ReservationStatusCode = "PurchaseError" + ReservationStatusCodeRiskCheckFailed ReservationStatusCode = "RiskCheckFailed" + ReservationStatusCodeSplit ReservationStatusCode = "Split" + ReservationStatusCodeSucceeded ReservationStatusCode = "Succeeded" + ReservationStatusCodeUnknownError ReservationStatusCode = "UnknownError" + ReservationStatusCodeWarning ReservationStatusCode = "Warning" ) -// PossibleReservationTypeValues returns the possible values for the ReservationType const type. -func PossibleReservationTypeValues() []ReservationType { - return []ReservationType{ - ReservationTypePurchase, - ReservationTypeUsageCharge, +// PossibleReservationStatusCodeValues returns the possible values for the ReservationStatusCode const type. +func PossibleReservationStatusCodeValues() []ReservationStatusCode { + return []ReservationStatusCode{ + ReservationStatusCodeActive, + ReservationStatusCodeCapacityError, + ReservationStatusCodeCapacityRestricted, + ReservationStatusCodeCreditLineCheckFailed, + ReservationStatusCodeExchanged, + ReservationStatusCodeExpired, + ReservationStatusCodeMerged, + ReservationStatusCodeNoBenefit, + ReservationStatusCodeNoBenefitDueToSubscriptionDeletion, + ReservationStatusCodeNoBenefitDueToSubscriptionTransfer, + ReservationStatusCodeNone, + ReservationStatusCodePaymentInstrumentError, + ReservationStatusCodePending, + ReservationStatusCodeProcessing, + ReservationStatusCodePurchaseError, + ReservationStatusCodeRiskCheckFailed, + ReservationStatusCodeSplit, + ReservationStatusCodeSucceeded, + ReservationStatusCodeUnknownError, + ReservationStatusCodeWarning, + } +} + +// SavingsPlanPurchasesPolicy - The policy that controls whether users with Azure savings plan purchase are allowed. +type SavingsPlanPurchasesPolicy string + +const ( + SavingsPlanPurchasesPolicyAllowed SavingsPlanPurchasesPolicy = "Allowed" + SavingsPlanPurchasesPolicyDisabled SavingsPlanPurchasesPolicy = "Disabled" + SavingsPlanPurchasesPolicyNotAllowed SavingsPlanPurchasesPolicy = "NotAllowed" + SavingsPlanPurchasesPolicyOther SavingsPlanPurchasesPolicy = "Other" +) + +// PossibleSavingsPlanPurchasesPolicyValues returns the possible values for the SavingsPlanPurchasesPolicy const type. +func PossibleSavingsPlanPurchasesPolicyValues() []SavingsPlanPurchasesPolicy { + return []SavingsPlanPurchasesPolicy{ + SavingsPlanPurchasesPolicyAllowed, + SavingsPlanPurchasesPolicyDisabled, + SavingsPlanPurchasesPolicyNotAllowed, + SavingsPlanPurchasesPolicyOther, + } +} + +// SavingsPlanTerm - Represents the Savings plan term in ISO 8601 format. +type SavingsPlanTerm string + +const ( + SavingsPlanTermP1Y SavingsPlanTerm = "P1Y" + SavingsPlanTermP3Y SavingsPlanTerm = "P3Y" + SavingsPlanTermP5Y SavingsPlanTerm = "P5Y" +) + +// PossibleSavingsPlanTermValues returns the possible values for the SavingsPlanTerm const type. +func PossibleSavingsPlanTermValues() []SavingsPlanTerm { + return []SavingsPlanTerm{ + SavingsPlanTermP1Y, + SavingsPlanTermP3Y, + SavingsPlanTermP5Y, + } +} + +type ServiceDefinedResourceName string + +const ( + ServiceDefinedResourceNameDefault ServiceDefinedResourceName = "default" +) + +// PossibleServiceDefinedResourceNameValues returns the possible values for the ServiceDefinedResourceName const type. +func PossibleServiceDefinedResourceNameValues() []ServiceDefinedResourceName { + return []ServiceDefinedResourceName{ + ServiceDefinedResourceNameDefault, + } +} + +// SpecialTaxationType - Identifies the type of tax calculation used for the invoice. The field is applicable only to invoices +// with special tax calculation logic. +type SpecialTaxationType string + +const ( + SpecialTaxationTypeInvoiceLevel SpecialTaxationType = "InvoiceLevel" + SpecialTaxationTypeSubtotalLevel SpecialTaxationType = "SubtotalLevel" +) + +// PossibleSpecialTaxationTypeValues returns the possible values for the SpecialTaxationType const type. +func PossibleSpecialTaxationTypeValues() []SpecialTaxationType { + return []SpecialTaxationType{ + SpecialTaxationTypeInvoiceLevel, + SpecialTaxationTypeSubtotalLevel, } } @@ -507,55 +1591,149 @@ func PossibleSpendingLimitValues() []SpendingLimit { } } -// SpendingLimitForBillingProfile - The billing profile spending limit. -type SpendingLimitForBillingProfile string +// SpendingLimitStatus - The status of current spending limit. +type SpendingLimitStatus string const ( - SpendingLimitForBillingProfileOff SpendingLimitForBillingProfile = "Off" - SpendingLimitForBillingProfileOn SpendingLimitForBillingProfile = "On" + SpendingLimitStatusActive SpendingLimitStatus = "Active" + SpendingLimitStatusExpired SpendingLimitStatus = "Expired" + SpendingLimitStatusLimitReached SpendingLimitStatus = "LimitReached" + SpendingLimitStatusLimitRemoved SpendingLimitStatus = "LimitRemoved" + SpendingLimitStatusNone SpendingLimitStatus = "None" + SpendingLimitStatusOther SpendingLimitStatus = "Other" ) -// PossibleSpendingLimitForBillingProfileValues returns the possible values for the SpendingLimitForBillingProfile const type. -func PossibleSpendingLimitForBillingProfileValues() []SpendingLimitForBillingProfile { - return []SpendingLimitForBillingProfile{ - SpendingLimitForBillingProfileOff, - SpendingLimitForBillingProfileOn, +// PossibleSpendingLimitStatusValues returns the possible values for the SpendingLimitStatus const type. +func PossibleSpendingLimitStatusValues() []SpendingLimitStatus { + return []SpendingLimitStatus{ + SpendingLimitStatusActive, + SpendingLimitStatusExpired, + SpendingLimitStatusLimitReached, + SpendingLimitStatusLimitRemoved, + SpendingLimitStatusNone, + SpendingLimitStatusOther, } } -// StatusReasonCode - Reason for the specified billing profile status. -type StatusReasonCode string +// SpendingLimitType - The type of spending limit. +type SpendingLimitType string const ( - StatusReasonCodePastDue StatusReasonCode = "PastDue" - StatusReasonCodeSpendingLimitExpired StatusReasonCode = "SpendingLimitExpired" - StatusReasonCodeSpendingLimitReached StatusReasonCode = "SpendingLimitReached" + SpendingLimitTypeAcademicSponsorship SpendingLimitType = "AcademicSponsorship" + SpendingLimitTypeAzureConsumptionCredit SpendingLimitType = "AzureConsumptionCredit" + SpendingLimitTypeAzureForStudents SpendingLimitType = "AzureForStudents" + SpendingLimitTypeAzureForStudentsStarter SpendingLimitType = "AzureForStudentsStarter" + SpendingLimitTypeAzurePassSponsorship SpendingLimitType = "AzurePassSponsorship" + SpendingLimitTypeFreeAccount SpendingLimitType = "FreeAccount" + SpendingLimitTypeMSDN SpendingLimitType = "MSDN" + SpendingLimitTypeMpnSponsorship SpendingLimitType = "MpnSponsorship" + SpendingLimitTypeNonProfitSponsorship SpendingLimitType = "NonProfitSponsorship" + SpendingLimitTypeNone SpendingLimitType = "None" + SpendingLimitTypeOther SpendingLimitType = "Other" + SpendingLimitTypeSandbox SpendingLimitType = "Sandbox" + SpendingLimitTypeSponsorship SpendingLimitType = "Sponsorship" + SpendingLimitTypeStartupSponsorship SpendingLimitType = "StartupSponsorship" + SpendingLimitTypeVisualStudio SpendingLimitType = "VisualStudio" ) -// PossibleStatusReasonCodeValues returns the possible values for the StatusReasonCode const type. -func PossibleStatusReasonCodeValues() []StatusReasonCode { - return []StatusReasonCode{ - StatusReasonCodePastDue, - StatusReasonCodeSpendingLimitExpired, - StatusReasonCodeSpendingLimitReached, +// PossibleSpendingLimitTypeValues returns the possible values for the SpendingLimitType const type. +func PossibleSpendingLimitTypeValues() []SpendingLimitType { + return []SpendingLimitType{ + SpendingLimitTypeAcademicSponsorship, + SpendingLimitTypeAzureConsumptionCredit, + SpendingLimitTypeAzureForStudents, + SpendingLimitTypeAzureForStudentsStarter, + SpendingLimitTypeAzurePassSponsorship, + SpendingLimitTypeFreeAccount, + SpendingLimitTypeMSDN, + SpendingLimitTypeMpnSponsorship, + SpendingLimitTypeNonProfitSponsorship, + SpendingLimitTypeNone, + SpendingLimitTypeOther, + SpendingLimitTypeSandbox, + SpendingLimitTypeSponsorship, + SpendingLimitTypeStartupSponsorship, + SpendingLimitTypeVisualStudio, } } -// StatusReasonCodeForBillingProfile - Reason for the specified billing profile status. -type StatusReasonCodeForBillingProfile string +// SubscriptionBillingType - The type of billing subscription. +type SubscriptionBillingType string const ( - StatusReasonCodeForBillingProfilePastDue StatusReasonCodeForBillingProfile = "PastDue" - StatusReasonCodeForBillingProfileSpendingLimitExpired StatusReasonCodeForBillingProfile = "SpendingLimitExpired" - StatusReasonCodeForBillingProfileSpendingLimitReached StatusReasonCodeForBillingProfile = "SpendingLimitReached" + SubscriptionBillingTypeBenefit SubscriptionBillingType = "Benefit" + SubscriptionBillingTypeFree SubscriptionBillingType = "Free" + SubscriptionBillingTypeNone SubscriptionBillingType = "None" + SubscriptionBillingTypePaid SubscriptionBillingType = "Paid" + SubscriptionBillingTypePrePaid SubscriptionBillingType = "PrePaid" ) -// PossibleStatusReasonCodeForBillingProfileValues returns the possible values for the StatusReasonCodeForBillingProfile const type. -func PossibleStatusReasonCodeForBillingProfileValues() []StatusReasonCodeForBillingProfile { - return []StatusReasonCodeForBillingProfile{ - StatusReasonCodeForBillingProfilePastDue, - StatusReasonCodeForBillingProfileSpendingLimitExpired, - StatusReasonCodeForBillingProfileSpendingLimitReached, +// PossibleSubscriptionBillingTypeValues returns the possible values for the SubscriptionBillingType const type. +func PossibleSubscriptionBillingTypeValues() []SubscriptionBillingType { + return []SubscriptionBillingType{ + SubscriptionBillingTypeBenefit, + SubscriptionBillingTypeFree, + SubscriptionBillingTypeNone, + SubscriptionBillingTypePaid, + SubscriptionBillingTypePrePaid, + } +} + +// SubscriptionEnrollmentAccountStatus - The current enrollment account status of the subscription. This field is available +// only for the Enterprise Agreement Type. +type SubscriptionEnrollmentAccountStatus string + +const ( + SubscriptionEnrollmentAccountStatusActive SubscriptionEnrollmentAccountStatus = "Active" + SubscriptionEnrollmentAccountStatusCancelled SubscriptionEnrollmentAccountStatus = "Cancelled" + SubscriptionEnrollmentAccountStatusDeleted SubscriptionEnrollmentAccountStatus = "Deleted" + SubscriptionEnrollmentAccountStatusExpired SubscriptionEnrollmentAccountStatus = "Expired" + SubscriptionEnrollmentAccountStatusInactive SubscriptionEnrollmentAccountStatus = "Inactive" + SubscriptionEnrollmentAccountStatusTransferredOut SubscriptionEnrollmentAccountStatus = "TransferredOut" + SubscriptionEnrollmentAccountStatusTransferring SubscriptionEnrollmentAccountStatus = "Transferring" +) + +// PossibleSubscriptionEnrollmentAccountStatusValues returns the possible values for the SubscriptionEnrollmentAccountStatus const type. +func PossibleSubscriptionEnrollmentAccountStatusValues() []SubscriptionEnrollmentAccountStatus { + return []SubscriptionEnrollmentAccountStatus{ + SubscriptionEnrollmentAccountStatusActive, + SubscriptionEnrollmentAccountStatusCancelled, + SubscriptionEnrollmentAccountStatusDeleted, + SubscriptionEnrollmentAccountStatusExpired, + SubscriptionEnrollmentAccountStatusInactive, + SubscriptionEnrollmentAccountStatusTransferredOut, + SubscriptionEnrollmentAccountStatusTransferring, + } +} + +// SubscriptionStatusReason - The suspension reason for a subscription. This field is not available for Enterprise Agreement +// billing accounts. +type SubscriptionStatusReason string + +const ( + SubscriptionStatusReasonCancelled SubscriptionStatusReason = "Cancelled" + SubscriptionStatusReasonExpired SubscriptionStatusReason = "Expired" + SubscriptionStatusReasonNone SubscriptionStatusReason = "None" + SubscriptionStatusReasonOther SubscriptionStatusReason = "Other" + SubscriptionStatusReasonPastDue SubscriptionStatusReason = "PastDue" + SubscriptionStatusReasonPolicyViolation SubscriptionStatusReason = "PolicyViolation" + SubscriptionStatusReasonSpendingLimitReached SubscriptionStatusReason = "SpendingLimitReached" + SubscriptionStatusReasonSuspiciousActivity SubscriptionStatusReason = "SuspiciousActivity" + SubscriptionStatusReasonTransferred SubscriptionStatusReason = "Transferred" +) + +// PossibleSubscriptionStatusReasonValues returns the possible values for the SubscriptionStatusReason const type. +func PossibleSubscriptionStatusReasonValues() []SubscriptionStatusReason { + return []SubscriptionStatusReason{ + SubscriptionStatusReasonCancelled, + SubscriptionStatusReasonExpired, + SubscriptionStatusReasonNone, + SubscriptionStatusReasonOther, + SubscriptionStatusReasonPastDue, + SubscriptionStatusReasonPolicyViolation, + SubscriptionStatusReasonSpendingLimitReached, + SubscriptionStatusReasonSuspiciousActivity, + SubscriptionStatusReasonTransferred, } } @@ -563,7 +1741,11 @@ func PossibleStatusReasonCodeForBillingProfileValues() []StatusReasonCodeForBill type SubscriptionTransferValidationErrorCode string const ( + SubscriptionTransferValidationErrorCodeAccountIsLocked SubscriptionTransferValidationErrorCode = "AccountIsLocked" + SubscriptionTransferValidationErrorCodeAssetHasCap SubscriptionTransferValidationErrorCode = "AssetHasCap" + SubscriptionTransferValidationErrorCodeAssetNotActive SubscriptionTransferValidationErrorCode = "AssetNotActive" SubscriptionTransferValidationErrorCodeBillingAccountInactive SubscriptionTransferValidationErrorCode = "BillingAccountInactive" + SubscriptionTransferValidationErrorCodeBillingProfilePastDue SubscriptionTransferValidationErrorCode = "BillingProfilePastDue" SubscriptionTransferValidationErrorCodeCrossBillingAccountNotAllowed SubscriptionTransferValidationErrorCode = "CrossBillingAccountNotAllowed" SubscriptionTransferValidationErrorCodeDestinationBillingProfileInactive SubscriptionTransferValidationErrorCode = "DestinationBillingProfileInactive" SubscriptionTransferValidationErrorCodeDestinationBillingProfileNotFound SubscriptionTransferValidationErrorCode = "DestinationBillingProfileNotFound" @@ -574,13 +1756,17 @@ const ( SubscriptionTransferValidationErrorCodeInsufficientPermissionOnSource SubscriptionTransferValidationErrorCode = "InsufficientPermissionOnSource" SubscriptionTransferValidationErrorCodeInvalidDestination SubscriptionTransferValidationErrorCode = "InvalidDestination" SubscriptionTransferValidationErrorCodeInvalidSource SubscriptionTransferValidationErrorCode = "InvalidSource" + SubscriptionTransferValidationErrorCodeInvoiceSectionIsRestricted SubscriptionTransferValidationErrorCode = "InvoiceSectionIsRestricted" SubscriptionTransferValidationErrorCodeMarketplaceNotEnabledOnDestination SubscriptionTransferValidationErrorCode = "MarketplaceNotEnabledOnDestination" - SubscriptionTransferValidationErrorCodeNotAvailableForDestinationMarket SubscriptionTransferValidationErrorCode = "NotAvailableForDestinationMarket" + SubscriptionTransferValidationErrorCodeNoActiveAzurePlan SubscriptionTransferValidationErrorCode = "NoActiveAzurePlan" + SubscriptionTransferValidationErrorCodeNone SubscriptionTransferValidationErrorCode = "None" + SubscriptionTransferValidationErrorCodeOther SubscriptionTransferValidationErrorCode = "Other" SubscriptionTransferValidationErrorCodeProductInactive SubscriptionTransferValidationErrorCode = "ProductInactive" SubscriptionTransferValidationErrorCodeProductNotFound SubscriptionTransferValidationErrorCode = "ProductNotFound" SubscriptionTransferValidationErrorCodeProductTypeNotSupported SubscriptionTransferValidationErrorCode = "ProductTypeNotSupported" SubscriptionTransferValidationErrorCodeSourceBillingProfilePastDue SubscriptionTransferValidationErrorCode = "SourceBillingProfilePastDue" SubscriptionTransferValidationErrorCodeSourceInvoiceSectionInactive SubscriptionTransferValidationErrorCode = "SourceInvoiceSectionInactive" + SubscriptionTransferValidationErrorCodeSubscriptionHasReservations SubscriptionTransferValidationErrorCode = "SubscriptionHasReservations" SubscriptionTransferValidationErrorCodeSubscriptionNotActive SubscriptionTransferValidationErrorCode = "SubscriptionNotActive" SubscriptionTransferValidationErrorCodeSubscriptionTypeNotSupported SubscriptionTransferValidationErrorCode = "SubscriptionTypeNotSupported" ) @@ -588,7 +1774,11 @@ const ( // PossibleSubscriptionTransferValidationErrorCodeValues returns the possible values for the SubscriptionTransferValidationErrorCode const type. func PossibleSubscriptionTransferValidationErrorCodeValues() []SubscriptionTransferValidationErrorCode { return []SubscriptionTransferValidationErrorCode{ + SubscriptionTransferValidationErrorCodeAccountIsLocked, + SubscriptionTransferValidationErrorCodeAssetHasCap, + SubscriptionTransferValidationErrorCodeAssetNotActive, SubscriptionTransferValidationErrorCodeBillingAccountInactive, + SubscriptionTransferValidationErrorCodeBillingProfilePastDue, SubscriptionTransferValidationErrorCodeCrossBillingAccountNotAllowed, SubscriptionTransferValidationErrorCodeDestinationBillingProfileInactive, SubscriptionTransferValidationErrorCodeDestinationBillingProfileNotFound, @@ -599,74 +1789,223 @@ func PossibleSubscriptionTransferValidationErrorCodeValues() []SubscriptionTrans SubscriptionTransferValidationErrorCodeInsufficientPermissionOnSource, SubscriptionTransferValidationErrorCodeInvalidDestination, SubscriptionTransferValidationErrorCodeInvalidSource, + SubscriptionTransferValidationErrorCodeInvoiceSectionIsRestricted, SubscriptionTransferValidationErrorCodeMarketplaceNotEnabledOnDestination, - SubscriptionTransferValidationErrorCodeNotAvailableForDestinationMarket, + SubscriptionTransferValidationErrorCodeNoActiveAzurePlan, + SubscriptionTransferValidationErrorCodeNone, + SubscriptionTransferValidationErrorCodeOther, SubscriptionTransferValidationErrorCodeProductInactive, SubscriptionTransferValidationErrorCodeProductNotFound, SubscriptionTransferValidationErrorCodeProductTypeNotSupported, SubscriptionTransferValidationErrorCodeSourceBillingProfilePastDue, SubscriptionTransferValidationErrorCodeSourceInvoiceSectionInactive, + SubscriptionTransferValidationErrorCodeSubscriptionHasReservations, SubscriptionTransferValidationErrorCodeSubscriptionNotActive, SubscriptionTransferValidationErrorCodeSubscriptionTypeNotSupported, } } -// TargetCloud - Possible cloud environments. -type TargetCloud string +// SubscriptionWorkloadType - The Azure workload type of the subscription. +type SubscriptionWorkloadType string + +const ( + SubscriptionWorkloadTypeDevTest SubscriptionWorkloadType = "DevTest" + SubscriptionWorkloadTypeInternal SubscriptionWorkloadType = "Internal" + SubscriptionWorkloadTypeNone SubscriptionWorkloadType = "None" + SubscriptionWorkloadTypeProduction SubscriptionWorkloadType = "Production" +) + +// PossibleSubscriptionWorkloadTypeValues returns the possible values for the SubscriptionWorkloadType const type. +func PossibleSubscriptionWorkloadTypeValues() []SubscriptionWorkloadType { + return []SubscriptionWorkloadType{ + SubscriptionWorkloadTypeDevTest, + SubscriptionWorkloadTypeInternal, + SubscriptionWorkloadTypeNone, + SubscriptionWorkloadTypeProduction, + } +} + +// SupportLevel - The support level offer associated with an enrollment. +type SupportLevel string + +const ( + SupportLevelDeveloper SupportLevel = "Developer" + SupportLevelOther SupportLevel = "Other" + SupportLevelProDirect SupportLevel = "Pro-Direct" + SupportLevelStandard SupportLevel = "Standard" +) + +// PossibleSupportLevelValues returns the possible values for the SupportLevel const type. +func PossibleSupportLevelValues() []SupportLevel { + return []SupportLevel{ + SupportLevelDeveloper, + SupportLevelOther, + SupportLevelProDirect, + SupportLevelStandard, + } +} + +// SupportedAccountType - The supported account types. +type SupportedAccountType string + +const ( + SupportedAccountTypeEnterprise SupportedAccountType = "Enterprise" + SupportedAccountTypeIndividual SupportedAccountType = "Individual" + SupportedAccountTypeNone SupportedAccountType = "None" + SupportedAccountTypePartner SupportedAccountType = "Partner" +) + +// PossibleSupportedAccountTypeValues returns the possible values for the SupportedAccountType const type. +func PossibleSupportedAccountTypeValues() []SupportedAccountType { + return []SupportedAccountType{ + SupportedAccountTypeEnterprise, + SupportedAccountTypeIndividual, + SupportedAccountTypeNone, + SupportedAccountTypePartner, + } +} + +// TaxIdentifierStatus - The status of the tax identifier. +type TaxIdentifierStatus string + +const ( + TaxIdentifierStatusInvalid TaxIdentifierStatus = "Invalid" + TaxIdentifierStatusOther TaxIdentifierStatus = "Other" + TaxIdentifierStatusValid TaxIdentifierStatus = "Valid" +) + +// PossibleTaxIdentifierStatusValues returns the possible values for the TaxIdentifierStatus const type. +func PossibleTaxIdentifierStatusValues() []TaxIdentifierStatus { + return []TaxIdentifierStatus{ + TaxIdentifierStatusInvalid, + TaxIdentifierStatusOther, + TaxIdentifierStatusValid, + } +} + +// TaxIdentifierType - The type of the tax identifier. +type TaxIdentifierType string + +const ( + TaxIdentifierTypeBrazilCcmID TaxIdentifierType = "BrazilCcmId" + TaxIdentifierTypeBrazilCnpjID TaxIdentifierType = "BrazilCnpjId" + TaxIdentifierTypeBrazilCpfID TaxIdentifierType = "BrazilCpfId" + TaxIdentifierTypeCanadianFederalExempt TaxIdentifierType = "CanadianFederalExempt" + TaxIdentifierTypeCanadianProvinceExempt TaxIdentifierType = "CanadianProvinceExempt" + TaxIdentifierTypeExternalTaxation TaxIdentifierType = "ExternalTaxation" + TaxIdentifierTypeIndiaFederalServiceTaxID TaxIdentifierType = "IndiaFederalServiceTaxId" + TaxIdentifierTypeIndiaFederalTanID TaxIdentifierType = "IndiaFederalTanId" + TaxIdentifierTypeIndiaPanID TaxIdentifierType = "IndiaPanId" + TaxIdentifierTypeIndiaStateCstID TaxIdentifierType = "IndiaStateCstId" + TaxIdentifierTypeIndiaStateGstINID TaxIdentifierType = "IndiaStateGstINId" + TaxIdentifierTypeIndiaStateVatID TaxIdentifierType = "IndiaStateVatId" + TaxIdentifierTypeIntlExempt TaxIdentifierType = "IntlExempt" + TaxIdentifierTypeLoveCode TaxIdentifierType = "LoveCode" + TaxIdentifierTypeMobileBarCode TaxIdentifierType = "MobileBarCode" + TaxIdentifierTypeNationalIdentificationNumber TaxIdentifierType = "NationalIdentificationNumber" + TaxIdentifierTypeOther TaxIdentifierType = "Other" + TaxIdentifierTypePublicSectorID TaxIdentifierType = "PublicSectorId" + TaxIdentifierTypeUSExempt TaxIdentifierType = "USExempt" + TaxIdentifierTypeVatID TaxIdentifierType = "VatId" +) + +// PossibleTaxIdentifierTypeValues returns the possible values for the TaxIdentifierType const type. +func PossibleTaxIdentifierTypeValues() []TaxIdentifierType { + return []TaxIdentifierType{ + TaxIdentifierTypeBrazilCcmID, + TaxIdentifierTypeBrazilCnpjID, + TaxIdentifierTypeBrazilCpfID, + TaxIdentifierTypeCanadianFederalExempt, + TaxIdentifierTypeCanadianProvinceExempt, + TaxIdentifierTypeExternalTaxation, + TaxIdentifierTypeIndiaFederalServiceTaxID, + TaxIdentifierTypeIndiaFederalTanID, + TaxIdentifierTypeIndiaPanID, + TaxIdentifierTypeIndiaStateCstID, + TaxIdentifierTypeIndiaStateGstINID, + TaxIdentifierTypeIndiaStateVatID, + TaxIdentifierTypeIntlExempt, + TaxIdentifierTypeLoveCode, + TaxIdentifierTypeMobileBarCode, + TaxIdentifierTypeNationalIdentificationNumber, + TaxIdentifierTypeOther, + TaxIdentifierTypePublicSectorID, + TaxIdentifierTypeUSExempt, + TaxIdentifierTypeVatID, + } +} + +// TransactionKind - Type of the transaction, billed or unbilled. +type TransactionKind string const ( - TargetCloudUSGov TargetCloud = "USGov" - TargetCloudUSNat TargetCloud = "USNat" - TargetCloudUSSec TargetCloud = "USSec" + TransactionKindAll TransactionKind = "All" + TransactionKindOther TransactionKind = "Other" + TransactionKindReservation TransactionKind = "Reservation" ) -// PossibleTargetCloudValues returns the possible values for the TargetCloud const type. -func PossibleTargetCloudValues() []TargetCloud { - return []TargetCloud{ - TargetCloudUSGov, - TargetCloudUSNat, - TargetCloudUSSec, +// PossibleTransactionKindValues returns the possible values for the TransactionKind const type. +func PossibleTransactionKindValues() []TransactionKind { + return []TransactionKind{ + TransactionKindAll, + TransactionKindOther, + TransactionKindReservation, } } -// TransactionTypeKind - The kind of transaction. Options are all or reservation. -type TransactionTypeKind string +type TransactionType string const ( - TransactionTypeKindAll TransactionTypeKind = "all" - TransactionTypeKindReservation TransactionTypeKind = "reservation" + TransactionTypeBilled TransactionType = "Billed" + TransactionTypeOther TransactionType = "Other" + TransactionTypeUnbilled TransactionType = "Unbilled" ) -// PossibleTransactionTypeKindValues returns the possible values for the TransactionTypeKind const type. -func PossibleTransactionTypeKindValues() []TransactionTypeKind { - return []TransactionTypeKind{ - TransactionTypeKindAll, - TransactionTypeKindReservation, +// PossibleTransactionTypeValues returns the possible values for the TransactionType const type. +func PossibleTransactionTypeValues() []TransactionType { + return []TransactionType{ + TransactionTypeBilled, + TransactionTypeOther, + TransactionTypeUnbilled, } } -// ViewCharges - The policy that controls whether the users in customer's organization can view charges at pay-as-you-go prices. -type ViewCharges string +// TransferStatus - The status of a transfer. +type TransferStatus string const ( - ViewChargesAllowed ViewCharges = "Allowed" - ViewChargesNotAllowed ViewCharges = "NotAllowed" + TransferStatusCanceled TransferStatus = "Canceled" + TransferStatusCompleted TransferStatus = "Completed" + TransferStatusCompletedWithErrors TransferStatus = "CompletedWithErrors" + TransferStatusDeclined TransferStatus = "Declined" + TransferStatusExpired TransferStatus = "Expired" + TransferStatusFailed TransferStatus = "Failed" + TransferStatusInProgress TransferStatus = "InProgress" + TransferStatusPending TransferStatus = "Pending" ) -// PossibleViewChargesValues returns the possible values for the ViewCharges const type. -func PossibleViewChargesValues() []ViewCharges { - return []ViewCharges{ - ViewChargesAllowed, - ViewChargesNotAllowed, +// PossibleTransferStatusValues returns the possible values for the TransferStatus const type. +func PossibleTransferStatusValues() []TransferStatus { + return []TransferStatus{ + TransferStatusCanceled, + TransferStatusCompleted, + TransferStatusCompletedWithErrors, + TransferStatusDeclined, + TransferStatusExpired, + TransferStatusFailed, + TransferStatusInProgress, + TransferStatusPending, } } -// ViewChargesPolicy - The policy that controls whether users with Azure RBAC access to a subscription can view its charges. +// ViewChargesPolicy - The policy that controls whether the users in customer's organization can view charges at pay-as-you-go +// prices. type ViewChargesPolicy string const ( ViewChargesPolicyAllowed ViewChargesPolicy = "Allowed" ViewChargesPolicyNotAllowed ViewChargesPolicy = "NotAllowed" + ViewChargesPolicyOther ViewChargesPolicy = "Other" ) // PossibleViewChargesPolicyValues returns the possible values for the ViewChargesPolicy const type. @@ -674,5 +2013,6 @@ func PossibleViewChargesPolicyValues() []ViewChargesPolicy { return []ViewChargesPolicy{ ViewChargesPolicyAllowed, ViewChargesPolicyNotAllowed, + ViewChargesPolicyOther, } } diff --git a/sdk/resourcemanager/billing/armbilling/customers_client.go b/sdk/resourcemanager/billing/armbilling/customers_client.go index 2db25d5e96e5..09800d9bfc45 100644 --- a/sdk/resourcemanager/billing/armbilling/customers_client.go +++ b/sdk/resourcemanager/billing/armbilling/customers_client.go @@ -11,13 +11,15 @@ package armbilling import ( "context" "errors" + "net/http" + "net/url" + "strconv" + "strings" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" ) // CustomersClient contains the methods for the Customers group. @@ -44,17 +46,18 @@ func NewCustomersClient(credential azcore.TokenCredential, options *arm.ClientOp // Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. // - customerName - The ID that uniquely identifies a customer. // - options - CustomersClientGetOptions contains the optional parameters for the CustomersClient.Get method. -func (client *CustomersClient) Get(ctx context.Context, billingAccountName string, customerName string, options *CustomersClientGetOptions) (CustomersClientGetResponse, error) { +func (client *CustomersClient) Get(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, options *CustomersClientGetOptions) (CustomersClientGetResponse, error) { var err error const operationName = "CustomersClient.Get" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, billingAccountName, customerName, options) + req, err := client.getCreateRequest(ctx, billingAccountName, billingProfileName, customerName, options) if err != nil { return CustomersClientGetResponse{}, err } @@ -71,12 +74,16 @@ func (client *CustomersClient) Get(ctx context.Context, billingAccountName strin } // getCreateRequest creates the Get request. -func (client *CustomersClient) getCreateRequest(ctx context.Context, billingAccountName string, customerName string, options *CustomersClientGetOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}" +func (client *CustomersClient) getCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, options *CustomersClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) if customerName == "" { return nil, errors.New("parameter customerName cannot be empty") } @@ -86,10 +93,7 @@ func (client *CustomersClient) getCreateRequest(ctx context.Context, billingAcco return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") - if options != nil && options.Expand != nil { - reqQP.Set("$expand", *options.Expand) - } + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -104,10 +108,72 @@ func (client *CustomersClient) getHandleResponse(resp *http.Response) (Customers return result, nil } +// GetByBillingAccount - Gets a customer by its ID at billing account level. The operation is supported only for billing accounts +// with agreement type Microsoft Partner Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - customerName - The ID that uniquely identifies a customer. +// - options - CustomersClientGetByBillingAccountOptions contains the optional parameters for the CustomersClient.GetByBillingAccount +// method. +func (client *CustomersClient) GetByBillingAccount(ctx context.Context, billingAccountName string, customerName string, options *CustomersClientGetByBillingAccountOptions) (CustomersClientGetByBillingAccountResponse, error) { + var err error + const operationName = "CustomersClient.GetByBillingAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByBillingAccountCreateRequest(ctx, billingAccountName, customerName, options) + if err != nil { + return CustomersClientGetByBillingAccountResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CustomersClientGetByBillingAccountResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return CustomersClientGetByBillingAccountResponse{}, err + } + resp, err := client.getByBillingAccountHandleResponse(httpResp) + return resp, err +} + +// getByBillingAccountCreateRequest creates the GetByBillingAccount request. +func (client *CustomersClient) getByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, customerName string, options *CustomersClientGetByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if customerName == "" { + return nil, errors.New("parameter customerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{customerName}", url.PathEscape(customerName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByBillingAccountHandleResponse handles the GetByBillingAccount response. +func (client *CustomersClient) getByBillingAccountHandleResponse(resp *http.Response) (CustomersClientGetByBillingAccountResponse, error) { + result := CustomersClientGetByBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Customer); err != nil { + return CustomersClientGetByBillingAccountResponse{}, err + } + return result, nil +} + // NewListByBillingAccountPager - Lists the customers that are billed to a billing account. The operation is supported only // for billing accounts with agreement type Microsoft Partner Agreement. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - options - CustomersClientListByBillingAccountOptions contains the optional parameters for the CustomersClient.NewListByBillingAccountPager // method. @@ -146,12 +212,27 @@ func (client *CustomersClient) listByBillingAccountCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") - if options != nil && options.Search != nil { - reqQP.Set("$search", *options.Search) + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Expand != nil { + reqQP.Set("expand", *options.Expand) } if options != nil && options.Filter != nil { - reqQP.Set("$filter", *options.Filter) + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} @@ -170,7 +251,7 @@ func (client *CustomersClient) listByBillingAccountHandleResponse(resp *http.Res // NewListByBillingProfilePager - Lists the customers that are billed to a billing profile. The operation is supported only // for billing accounts with agreement type Microsoft Partner Agreement. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingProfileName - The ID that uniquely identifies a billing profile. // - options - CustomersClientListByBillingProfileOptions contains the optional parameters for the CustomersClient.NewListByBillingProfilePager @@ -214,12 +295,27 @@ func (client *CustomersClient) listByBillingProfileCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") - if options != nil && options.Search != nil { - reqQP.Set("$search", *options.Search) + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Expand != nil { + reqQP.Set("expand", *options.Expand) } if options != nil && options.Filter != nil { - reqQP.Set("$filter", *options.Filter) + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} diff --git a/sdk/resourcemanager/billing/armbilling/customers_client_example_test.go b/sdk/resourcemanager/billing/armbilling/customers_client_example_test.go index 48e59ccc8f25..713b5f35d206 100644 --- a/sdk/resourcemanager/billing/armbilling/customers_client_example_test.go +++ b/sdk/resourcemanager/billing/armbilling/customers_client_example_test.go @@ -18,7 +18,57 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/CustomersListByBillingProfile.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/customersGet.json +func ExampleCustomersClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewCustomersClient().Get(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "11111111-1111-1111-1111-111111111111", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Customer = armbilling.Customer{ + // Name: to.Ptr("11111111-1111-1111-1111-111111111111"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/customers"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/customers/11111111-1111-1111-1111-111111111111"), + // Properties: &armbilling.CustomerProperties{ + // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // DisplayName: to.Ptr("customer1"), + // EnabledAzurePlans: []*armbilling.AzurePlan{ + // { + // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), + // SKUID: to.Ptr("0002"), + // }}, + // Resellers: []*armbilling.Reseller{ + // { + // Description: to.Ptr("Reseller1"), + // ResellerID: to.Ptr("89e87bdf-a2a2-4687-925f-4c18b27bccfd"), + // }, + // { + // Description: to.Ptr("Reseller2"), + // ResellerID: to.Ptr("3b65b5a8-bd4f-4084-90e9-e1bd667a2b19"), + // }}, + // Status: to.Ptr(armbilling.CustomerStatusActive), + // SystemID: to.Ptr("yyyy-yyyy-yyy-yyy"), + // Tags: map[string]*string{ + // "costCategory": to.Ptr("Support"), + // "pcCode": to.Ptr("A123456"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/customersListByBillingProfile.json func ExampleCustomersClient_NewListByBillingProfilePager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -29,8 +79,13 @@ func ExampleCustomersClient_NewListByBillingProfilePager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewCustomersClient().NewListByBillingProfilePager("{billingAccountName}", "{billingProfileName}", &armbilling.CustomersClientListByBillingProfileOptions{Search: nil, - Filter: nil, + pager := clientFactory.NewCustomersClient().NewListByBillingProfilePager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", &armbilling.CustomersClientListByBillingProfileOptions{Expand: nil, + Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, }) for pager.More() { page, err := pager.NextPage(ctx) @@ -45,31 +100,39 @@ func ExampleCustomersClient_NewListByBillingProfilePager() { // page.CustomerListResult = armbilling.CustomerListResult{ // Value: []*armbilling.Customer{ // { - // Name: to.Ptr("22000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/customers"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/22000000-0000-0000-0000-000000000000"), + // Name: to.Ptr("11111111-1111-1111-1111-111111111111"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/customers"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/customers/11111111-1111-1111-1111-111111111111"), // Properties: &armbilling.CustomerProperties{ // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), // DisplayName: to.Ptr("customer1"), + // Status: to.Ptr(armbilling.CustomerStatusActive), + // SystemID: to.Ptr("yyyy-yyyy-yyy-yyy"), + // Tags: map[string]*string{ + // "costCategory": to.Ptr("Support"), + // "pcCode": to.Ptr("A123456"), + // }, // }, // }, // { - // Name: to.Ptr("22000000-0000-0000-0000-000000000011"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/customers"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/22000000-0000-0000-0000-000000000011"), + // Name: to.Ptr("22222222-2222-2222-2222-222222222222"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/customers"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/customers/22222222-2222-2222-2222-222222222222"), // Properties: &armbilling.CustomerProperties{ // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), // DisplayName: to.Ptr("customer2"), + // Status: to.Ptr(armbilling.CustomerStatusActive), + // SystemID: to.Ptr("zzzz-zzzz-zzz-zzz"), // }, // }}, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/CustomersListByBillingAccount.json -func ExampleCustomersClient_NewListByBillingAccountPager() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/customersGetByBillingAccount.json +func ExampleCustomersClient_GetByBillingAccount() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -79,8 +142,63 @@ func ExampleCustomersClient_NewListByBillingAccountPager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewCustomersClient().NewListByBillingAccountPager("{billingAccountName}", &armbilling.CustomersClientListByBillingAccountOptions{Search: nil, - Filter: nil, + res, err := clientFactory.NewCustomersClient().GetByBillingAccount(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "11111111-1111-1111-1111-111111111111", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Customer = armbilling.Customer{ + // Name: to.Ptr("11111111-1111-1111-1111-111111111111"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/customers"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/customers/11111111-1111-1111-1111-111111111111"), + // Properties: &armbilling.CustomerProperties{ + // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // DisplayName: to.Ptr("customer1"), + // EnabledAzurePlans: []*armbilling.AzurePlan{ + // { + // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), + // SKUID: to.Ptr("0002"), + // }}, + // Resellers: []*armbilling.Reseller{ + // { + // Description: to.Ptr("Reseller1"), + // ResellerID: to.Ptr("89e87bdf-a2a2-4687-925f-4c18b27bccfd"), + // }, + // { + // Description: to.Ptr("Reseller2"), + // ResellerID: to.Ptr("3b65b5a8-bd4f-4084-90e9-e1bd667a2b19"), + // }}, + // Status: to.Ptr(armbilling.CustomerStatusActive), + // SystemID: to.Ptr("yyyy-yyyy-yyy-yyy"), + // Tags: map[string]*string{ + // "costCategory": to.Ptr("Support"), + // "pcCode": to.Ptr("A123456"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/customersListByBillingAccount.json +func ExampleCustomersClient_NewListByBillingAccountPager_customersListByBillingAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewCustomersClient().NewListByBillingAccountPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", &armbilling.CustomersClientListByBillingAccountOptions{Expand: nil, + Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, }) for pager.More() { page, err := pager.NextPage(ctx) @@ -95,31 +213,39 @@ func ExampleCustomersClient_NewListByBillingAccountPager() { // page.CustomerListResult = armbilling.CustomerListResult{ // Value: []*armbilling.Customer{ // { - // Name: to.Ptr("22000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/customers"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/22000000-0000-0000-0000-000000000000"), + // Name: to.Ptr("11111111-1111-1111-1111-111111111111"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/customers"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/customers/11111111-1111-1111-1111-111111111111"), // Properties: &armbilling.CustomerProperties{ // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), // DisplayName: to.Ptr("customer1"), + // Status: to.Ptr(armbilling.CustomerStatusActive), + // SystemID: to.Ptr("yyyy-yyyy-yyy-yyy"), + // Tags: map[string]*string{ + // "costCategory": to.Ptr("Support"), + // "pcCode": to.Ptr("A123456"), + // }, // }, // }, // { - // Name: to.Ptr("22000000-0000-0000-0000-000000000011"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/customers"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/22000000-0000-0000-0000-000000000011"), + // Name: to.Ptr("22222222-2222-2222-2222-222222222222"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/customers"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/customers/22222222-2222-2222-2222-222222222222"), // Properties: &armbilling.CustomerProperties{ // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), // DisplayName: to.Ptr("customer2"), + // Status: to.Ptr(armbilling.CustomerStatusActive), + // SystemID: to.Ptr("zzzz-zzzz-zzz-zzz"), // }, // }}, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/Customer.json -func ExampleCustomersClient_Get_customer() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/customersListByBillingAccountWithExpand.json +func ExampleCustomersClient_NewListByBillingAccountPager_customersListByBillingAccountWithExpand() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -129,65 +255,56 @@ func ExampleCustomersClient_Get_customer() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewCustomersClient().Get(ctx, "{billingAccountName}", "{customerName}", &armbilling.CustomersClientGetOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Customer = armbilling.Customer{ - // Name: to.Ptr("{customerName}"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/customers"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}"), - // Properties: &armbilling.CustomerProperties{ - // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // DisplayName: to.Ptr("customer1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/CustomerWithExpand.json -func ExampleCustomersClient_Get_customerWithExpand() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbilling.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewCustomersClient().Get(ctx, "{billingAccountName}", "{customerName}", &armbilling.CustomersClientGetOptions{Expand: to.Ptr("enabledAzurePlans,resellers")}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) + pager := clientFactory.NewCustomersClient().NewListByBillingAccountPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", &armbilling.CustomersClientListByBillingAccountOptions{Expand: to.Ptr("enabledAzurePlans,resellers"), + Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.CustomerListResult = armbilling.CustomerListResult{ + // Value: []*armbilling.Customer{ + // { + // Name: to.Ptr("11111111-1111-1111-1111-111111111111"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/customers"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/customers/11111111-1111-1111-1111-111111111111"), + // Properties: &armbilling.CustomerProperties{ + // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // DisplayName: to.Ptr("customer1"), + // EnabledAzurePlans: []*armbilling.AzurePlan{ + // { + // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), + // SKUID: to.Ptr("0002"), + // }}, + // Resellers: []*armbilling.Reseller{ + // { + // Description: to.Ptr("Reseller1"), + // ResellerID: to.Ptr("89e87bdf-a2a2-4687-925f-4c18b27bccfd"), + // }, + // { + // Description: to.Ptr("Reseller2"), + // ResellerID: to.Ptr("3b65b5a8-bd4f-4084-90e9-e1bd667a2b19"), + // }}, + // Status: to.Ptr(armbilling.CustomerStatusActive), + // SystemID: to.Ptr("yyyy-yyyy-yyy-yyy"), + // Tags: map[string]*string{ + // "costCategory": to.Ptr("Support"), + // "pcCode": to.Ptr("A123456"), + // }, + // }, + // }}, + // } } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Customer = armbilling.Customer{ - // Name: to.Ptr("{customerName}"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/customers"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}"), - // Properties: &armbilling.CustomerProperties{ - // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // DisplayName: to.Ptr("customerName1"), - // EnabledAzurePlans: []*armbilling.AzurePlan{ - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), - // SKUID: to.Ptr("0002"), - // }}, - // Resellers: []*armbilling.Reseller{ - // { - // Description: to.Ptr("Reseller1"), - // ResellerID: to.Ptr("89e87bdf-a2a2-4687-925f-4c18b27bccfd"), - // }, - // { - // Description: to.Ptr("Reseller2"), - // ResellerID: to.Ptr("3b65b5a8-bd4f-4084-90e9-e1bd667a2b19"), - // }}, - // }, - // } } diff --git a/sdk/resourcemanager/billing/armbilling/date_type.go b/sdk/resourcemanager/billing/armbilling/date_type.go index 1cb512363a8c..50bb7e53c398 100644 --- a/sdk/resourcemanager/billing/armbilling/date_type.go +++ b/sdk/resourcemanager/billing/armbilling/date_type.go @@ -11,10 +11,10 @@ package armbilling import ( "encoding/json" "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" "reflect" - "strings" "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" ) const ( @@ -47,7 +47,7 @@ func populateDateType(m map[string]any, k string, t *time.Time) { } func unpopulateDateType(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateType diff --git a/sdk/resourcemanager/billing/armbilling/departments_client.go b/sdk/resourcemanager/billing/armbilling/departments_client.go new file mode 100644 index 000000000000..8ae370572fbf --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/departments_client.go @@ -0,0 +1,175 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armbilling + +import ( + "context" + "errors" + "net/http" + "net/url" + "strconv" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// DepartmentsClient contains the methods for the Departments group. +// Don't use this type directly, use NewDepartmentsClient() instead. +type DepartmentsClient struct { + internal *arm.Client +} + +// NewDepartmentsClient creates a new instance of DepartmentsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewDepartmentsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*DepartmentsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &DepartmentsClient{ + internal: cl, + } + return client, nil +} + +// Get - Gets a department by ID. The operation is supported only for billing accounts with agreement type Enterprise Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - departmentName - The name of the department. +// - options - DepartmentsClientGetOptions contains the optional parameters for the DepartmentsClient.Get method. +func (client *DepartmentsClient) Get(ctx context.Context, billingAccountName string, departmentName string, options *DepartmentsClientGetOptions) (DepartmentsClientGetResponse, error) { + var err error + const operationName = "DepartmentsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, billingAccountName, departmentName, options) + if err != nil { + return DepartmentsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DepartmentsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DepartmentsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *DepartmentsClient) getCreateRequest(ctx context.Context, billingAccountName string, departmentName string, options *DepartmentsClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if departmentName == "" { + return nil, errors.New("parameter departmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{departmentName}", url.PathEscape(departmentName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DepartmentsClient) getHandleResponse(resp *http.Response) (DepartmentsClientGetResponse, error) { + result := DepartmentsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Department); err != nil { + return DepartmentsClientGetResponse{}, err + } + return result, nil +} + +// NewListByBillingAccountPager - Lists the departments that a user has access to. The operation is supported only for billing +// accounts with agreement type Enterprise Agreement. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - options - DepartmentsClientListByBillingAccountOptions contains the optional parameters for the DepartmentsClient.NewListByBillingAccountPager +// method. +func (client *DepartmentsClient) NewListByBillingAccountPager(billingAccountName string, options *DepartmentsClientListByBillingAccountOptions) *runtime.Pager[DepartmentsClientListByBillingAccountResponse] { + return runtime.NewPager(runtime.PagingHandler[DepartmentsClientListByBillingAccountResponse]{ + More: func(page DepartmentsClientListByBillingAccountResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DepartmentsClientListByBillingAccountResponse) (DepartmentsClientListByBillingAccountResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DepartmentsClient.NewListByBillingAccountPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByBillingAccountCreateRequest(ctx, billingAccountName, options) + }, nil) + if err != nil { + return DepartmentsClientListByBillingAccountResponse{}, err + } + return client.listByBillingAccountHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByBillingAccountCreateRequest creates the ListByBillingAccount request. +func (client *DepartmentsClient) listByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, options *DepartmentsClientListByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByBillingAccountHandleResponse handles the ListByBillingAccount response. +func (client *DepartmentsClient) listByBillingAccountHandleResponse(resp *http.Response) (DepartmentsClientListByBillingAccountResponse, error) { + result := DepartmentsClientListByBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DepartmentListResult); err != nil { + return DepartmentsClientListByBillingAccountResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/departments_client_example_test.go b/sdk/resourcemanager/billing/armbilling/departments_client_example_test.go new file mode 100644 index 000000000000..b270f52e325a --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/departments_client_example_test.go @@ -0,0 +1,101 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armbilling_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/departmentGet.json +func ExampleDepartmentsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDepartmentsClient().Get(ctx, "456598", "164821", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Department = armbilling.Department{ + // Name: to.Ptr("164821"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/departments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/456598/departments/164821"), + // Properties: &armbilling.DepartmentProperties{ + // CostCenter: to.Ptr("C1"), + // DisplayName: to.Ptr("Test department"), + // Status: to.Ptr("Active"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/departmentsListByBillingAccount.json +func ExampleDepartmentsClient_NewListByBillingAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDepartmentsClient().NewListByBillingAccountPager("456598", &armbilling.DepartmentsClientListByBillingAccountOptions{Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Search: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.DepartmentListResult = armbilling.DepartmentListResult{ + // Value: []*armbilling.Department{ + // { + // Name: to.Ptr("164821"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/departments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/456598/departments/164821"), + // Properties: &armbilling.DepartmentProperties{ + // CostCenter: to.Ptr("C1"), + // DisplayName: to.Ptr("departmentName1"), + // Status: to.Ptr("Active"), + // }, + // }, + // { + // Name: to.Ptr("164822"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/departments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/456598/departments/164822"), + // Properties: &armbilling.DepartmentProperties{ + // CostCenter: to.Ptr("C4"), + // DisplayName: to.Ptr("departmentName2"), + // Status: to.Ptr("Active"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/billing/armbilling/enrollmentaccounts_client.go b/sdk/resourcemanager/billing/armbilling/enrollmentaccounts_client.go index d406cad4c59e..694e9b71822b 100644 --- a/sdk/resourcemanager/billing/armbilling/enrollmentaccounts_client.go +++ b/sdk/resourcemanager/billing/armbilling/enrollmentaccounts_client.go @@ -11,13 +11,15 @@ package armbilling import ( "context" "errors" + "net/http" + "net/url" + "strconv" + "strings" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" ) // EnrollmentAccountsClient contains the methods for the EnrollmentAccounts group. @@ -40,19 +42,21 @@ func NewEnrollmentAccountsClient(credential azcore.TokenCredential, options *arm return client, nil } -// Get - Gets a enrollment account by name. +// Get - Gets an enrollment account by ID. The operation is supported only for billing accounts with agreement type Enterprise +// Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2018-03-01-preview -// - name - Enrollment Account name. +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - enrollmentAccountName - The name of the enrollment account. // - options - EnrollmentAccountsClientGetOptions contains the optional parameters for the EnrollmentAccountsClient.Get method. -func (client *EnrollmentAccountsClient) Get(ctx context.Context, name string, options *EnrollmentAccountsClientGetOptions) (EnrollmentAccountsClientGetResponse, error) { +func (client *EnrollmentAccountsClient) Get(ctx context.Context, billingAccountName string, enrollmentAccountName string, options *EnrollmentAccountsClientGetOptions) (EnrollmentAccountsClientGetResponse, error) { var err error const operationName = "EnrollmentAccountsClient.Get" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, name, options) + req, err := client.getCreateRequest(ctx, billingAccountName, enrollmentAccountName, options) if err != nil { return EnrollmentAccountsClientGetResponse{}, err } @@ -69,18 +73,22 @@ func (client *EnrollmentAccountsClient) Get(ctx context.Context, name string, op } // getCreateRequest creates the Get request. -func (client *EnrollmentAccountsClient) getCreateRequest(ctx context.Context, name string, options *EnrollmentAccountsClientGetOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/enrollmentAccounts/{name}" - if name == "" { - return nil, errors.New("parameter name cannot be empty") +func (client *EnrollmentAccountsClient) getCreateRequest(ctx context.Context, billingAccountName string, enrollmentAccountName string, options *EnrollmentAccountsClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if enrollmentAccountName == "" { + return nil, errors.New("parameter enrollmentAccountName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + urlPath = strings.ReplaceAll(urlPath, "{enrollmentAccountName}", url.PathEscape(enrollmentAccountName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2018-03-01-preview") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -89,59 +97,230 @@ func (client *EnrollmentAccountsClient) getCreateRequest(ctx context.Context, na // getHandleResponse handles the Get response. func (client *EnrollmentAccountsClient) getHandleResponse(resp *http.Response) (EnrollmentAccountsClientGetResponse, error) { result := EnrollmentAccountsClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.EnrollmentAccountSummary); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.EnrollmentAccount); err != nil { return EnrollmentAccountsClientGetResponse{}, err } return result, nil } -// NewListPager - Lists the enrollment accounts the caller has access to. +// GetByDepartment - Gets an enrollment account by department. The operation is supported only for billing accounts with agreement +// type Enterprise Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - departmentName - The name of the department. +// - enrollmentAccountName - The name of the enrollment account. +// - options - EnrollmentAccountsClientGetByDepartmentOptions contains the optional parameters for the EnrollmentAccountsClient.GetByDepartment +// method. +func (client *EnrollmentAccountsClient) GetByDepartment(ctx context.Context, billingAccountName string, departmentName string, enrollmentAccountName string, options *EnrollmentAccountsClientGetByDepartmentOptions) (EnrollmentAccountsClientGetByDepartmentResponse, error) { + var err error + const operationName = "EnrollmentAccountsClient.GetByDepartment" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByDepartmentCreateRequest(ctx, billingAccountName, departmentName, enrollmentAccountName, options) + if err != nil { + return EnrollmentAccountsClientGetByDepartmentResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EnrollmentAccountsClientGetByDepartmentResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return EnrollmentAccountsClientGetByDepartmentResponse{}, err + } + resp, err := client.getByDepartmentHandleResponse(httpResp) + return resp, err +} + +// getByDepartmentCreateRequest creates the GetByDepartment request. +func (client *EnrollmentAccountsClient) getByDepartmentCreateRequest(ctx context.Context, billingAccountName string, departmentName string, enrollmentAccountName string, options *EnrollmentAccountsClientGetByDepartmentOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}/enrollmentAccounts/{enrollmentAccountName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if departmentName == "" { + return nil, errors.New("parameter departmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{departmentName}", url.PathEscape(departmentName)) + if enrollmentAccountName == "" { + return nil, errors.New("parameter enrollmentAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{enrollmentAccountName}", url.PathEscape(enrollmentAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByDepartmentHandleResponse handles the GetByDepartment response. +func (client *EnrollmentAccountsClient) getByDepartmentHandleResponse(resp *http.Response) (EnrollmentAccountsClientGetByDepartmentResponse, error) { + result := EnrollmentAccountsClientGetByDepartmentResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EnrollmentAccount); err != nil { + return EnrollmentAccountsClientGetByDepartmentResponse{}, err + } + return result, nil +} + +// NewListByBillingAccountPager - Lists the enrollment accounts for a billing account. The operation is supported only for +// billing accounts with agreement type Enterprise Agreement. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - options - EnrollmentAccountsClientListByBillingAccountOptions contains the optional parameters for the EnrollmentAccountsClient.NewListByBillingAccountPager +// method. +func (client *EnrollmentAccountsClient) NewListByBillingAccountPager(billingAccountName string, options *EnrollmentAccountsClientListByBillingAccountOptions) *runtime.Pager[EnrollmentAccountsClientListByBillingAccountResponse] { + return runtime.NewPager(runtime.PagingHandler[EnrollmentAccountsClientListByBillingAccountResponse]{ + More: func(page EnrollmentAccountsClientListByBillingAccountResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *EnrollmentAccountsClientListByBillingAccountResponse) (EnrollmentAccountsClientListByBillingAccountResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "EnrollmentAccountsClient.NewListByBillingAccountPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByBillingAccountCreateRequest(ctx, billingAccountName, options) + }, nil) + if err != nil { + return EnrollmentAccountsClientListByBillingAccountResponse{}, err + } + return client.listByBillingAccountHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByBillingAccountCreateRequest creates the ListByBillingAccount request. +func (client *EnrollmentAccountsClient) listByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, options *EnrollmentAccountsClientListByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByBillingAccountHandleResponse handles the ListByBillingAccount response. +func (client *EnrollmentAccountsClient) listByBillingAccountHandleResponse(resp *http.Response) (EnrollmentAccountsClientListByBillingAccountResponse, error) { + result := EnrollmentAccountsClientListByBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EnrollmentAccountListResult); err != nil { + return EnrollmentAccountsClientListByBillingAccountResponse{}, err + } + return result, nil +} + +// NewListByDepartmentPager - Lists the enrollment accounts for a department. The operation is supported only for billing +// accounts with agreement type Enterprise Agreement. // -// Generated from API version 2018-03-01-preview -// - options - EnrollmentAccountsClientListOptions contains the optional parameters for the EnrollmentAccountsClient.NewListPager +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - departmentName - The name of the department. +// - options - EnrollmentAccountsClientListByDepartmentOptions contains the optional parameters for the EnrollmentAccountsClient.NewListByDepartmentPager // method. -func (client *EnrollmentAccountsClient) NewListPager(options *EnrollmentAccountsClientListOptions) *runtime.Pager[EnrollmentAccountsClientListResponse] { - return runtime.NewPager(runtime.PagingHandler[EnrollmentAccountsClientListResponse]{ - More: func(page EnrollmentAccountsClientListResponse) bool { +func (client *EnrollmentAccountsClient) NewListByDepartmentPager(billingAccountName string, departmentName string, options *EnrollmentAccountsClientListByDepartmentOptions) *runtime.Pager[EnrollmentAccountsClientListByDepartmentResponse] { + return runtime.NewPager(runtime.PagingHandler[EnrollmentAccountsClientListByDepartmentResponse]{ + More: func(page EnrollmentAccountsClientListByDepartmentResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *EnrollmentAccountsClientListResponse) (EnrollmentAccountsClientListResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "EnrollmentAccountsClient.NewListPager") + Fetcher: func(ctx context.Context, page *EnrollmentAccountsClientListByDepartmentResponse) (EnrollmentAccountsClientListByDepartmentResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "EnrollmentAccountsClient.NewListByDepartmentPager") nextLink := "" if page != nil { nextLink = *page.NextLink } resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, options) + return client.listByDepartmentCreateRequest(ctx, billingAccountName, departmentName, options) }, nil) if err != nil { - return EnrollmentAccountsClientListResponse{}, err + return EnrollmentAccountsClientListByDepartmentResponse{}, err } - return client.listHandleResponse(resp) + return client.listByDepartmentHandleResponse(resp) }, Tracer: client.internal.Tracer(), }) } -// listCreateRequest creates the List request. -func (client *EnrollmentAccountsClient) listCreateRequest(ctx context.Context, options *EnrollmentAccountsClientListOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/enrollmentAccounts" +// listByDepartmentCreateRequest creates the ListByDepartment request. +func (client *EnrollmentAccountsClient) listByDepartmentCreateRequest(ctx context.Context, billingAccountName string, departmentName string, options *EnrollmentAccountsClientListByDepartmentOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}/enrollmentAccounts" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if departmentName == "" { + return nil, errors.New("parameter departmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{departmentName}", url.PathEscape(departmentName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2018-03-01-preview") + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } -// listHandleResponse handles the List response. -func (client *EnrollmentAccountsClient) listHandleResponse(resp *http.Response) (EnrollmentAccountsClientListResponse, error) { - result := EnrollmentAccountsClientListResponse{} +// listByDepartmentHandleResponse handles the ListByDepartment response. +func (client *EnrollmentAccountsClient) listByDepartmentHandleResponse(resp *http.Response) (EnrollmentAccountsClientListByDepartmentResponse, error) { + result := EnrollmentAccountsClientListByDepartmentResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.EnrollmentAccountListResult); err != nil { - return EnrollmentAccountsClientListResponse{}, err + return EnrollmentAccountsClientListByDepartmentResponse{}, err } return result, nil } diff --git a/sdk/resourcemanager/billing/armbilling/enrollmentaccounts_client_example_test.go b/sdk/resourcemanager/billing/armbilling/enrollmentaccounts_client_example_test.go index beae6ecf5154..ed55d585f339 100644 --- a/sdk/resourcemanager/billing/armbilling/enrollmentaccounts_client_example_test.go +++ b/sdk/resourcemanager/billing/armbilling/enrollmentaccounts_client_example_test.go @@ -17,8 +17,8 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/preview/2018-03-01-preview/examples/EnrollmentAccountsList.json -func ExampleEnrollmentAccountsClient_NewListPager() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/enrollmentAccountByDepartment.json +func ExampleEnrollmentAccountsClient_GetByDepartment() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -28,7 +28,50 @@ func ExampleEnrollmentAccountsClient_NewListPager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewEnrollmentAccountsClient().NewListPager(nil) + res, err := clientFactory.NewEnrollmentAccountsClient().GetByDepartment(ctx, "6564892", "164821", "257698", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.EnrollmentAccount = armbilling.EnrollmentAccount{ + // Name: to.Ptr("257698"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/departments/enrollmentAccounts"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/6564892/departments/164821/enrollmentAccounts/257698"), + // Properties: &armbilling.EnrollmentAccountProperties{ + // AccountOwner: to.Ptr("account0@contoso.com"), + // AuthType: to.Ptr("MicrosoftAccount"), + // CostCenter: to.Ptr("C0"), + // DepartmentDisplayName: to.Ptr("TestDept"), + // DepartmentID: to.Ptr("164821"), + // DisplayName: to.Ptr("AccountName0"), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-31T17:32:28.000Z"); return t}()), + // IsDevTestEnabled: to.Ptr(true), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T17:32:28.000Z"); return t}()), + // Status: to.Ptr("Active"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/enrollmentAccountsListByDepartment.json +func ExampleEnrollmentAccountsClient_NewListByDepartmentPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewEnrollmentAccountsClient().NewListByDepartmentPager("6564892", "164821", &armbilling.EnrollmentAccountsClientListByDepartmentOptions{Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -40,28 +83,46 @@ func ExampleEnrollmentAccountsClient_NewListPager() { } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.EnrollmentAccountListResult = armbilling.EnrollmentAccountListResult{ - // Value: []*armbilling.EnrollmentAccountSummary{ + // Value: []*armbilling.EnrollmentAccount{ // { - // Name: to.Ptr("e1bf1c8c-5ac6-44a0-bdcd-aa7c1cf60556"), - // Type: to.Ptr("Microsoft.Billing/enrollmentAccounts"), - // ID: to.Ptr("/providers/Microsoft.Billing/enrollmentAccounts/e1bf1c8c-5ac6-44a0-bdcd-aa7c1cf60556"), - // Properties: &armbilling.EnrollmentAccountSummaryProperties{ - // PrincipalName: to.Ptr("kathy@contoso.com"), + // Name: to.Ptr("257698"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/departments/enrollmentAccounts"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/6564892/departments/164821/enrollmentAccounts/257698"), + // Properties: &armbilling.EnrollmentAccountProperties{ + // AccountOwner: to.Ptr("account0@contoso.com"), + // AuthType: to.Ptr("MicrosoftAccount"), + // CostCenter: to.Ptr("C0"), + // DepartmentDisplayName: to.Ptr("TestDept"), + // DepartmentID: to.Ptr("164821"), + // DisplayName: to.Ptr("AccountName0"), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-31T17:32:28.000Z"); return t}()), + // IsDevTestEnabled: to.Ptr(true), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T17:32:28.000Z"); return t}()), + // Status: to.Ptr("Active"), // }, // }, // { - // Name: to.Ptr("edd24053-07cd-4ed4-aa5b-326160a6680d"), - // Type: to.Ptr("Microsoft.Billing/enrollmentAccounts"), - // ID: to.Ptr("/providers/Microsoft.Billing/enrollmentAccounts/edd24053-07cd-4ed4-aa5b-326160a6680d"), - // Properties: &armbilling.EnrollmentAccountSummaryProperties{ - // PrincipalName: to.Ptr("dan@contoso.com"), + // Name: to.Ptr("264698"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/departments/enrollmentAccounts"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/6564892/departments/164821/enrollmentAccounts/264698"), + // Properties: &armbilling.EnrollmentAccountProperties{ + // AccountOwner: to.Ptr("account1@contoso.com"), + // AuthType: to.Ptr("Organization"), + // CostCenter: to.Ptr("C1"), + // DepartmentDisplayName: to.Ptr("TestDept"), + // DepartmentID: to.Ptr("164821"), + // DisplayName: to.Ptr("AccountName1"), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-31T17:32:28.000Z"); return t}()), + // IsDevTestEnabled: to.Ptr(false), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T17:32:28.000Z"); return t}()), + // Status: to.Ptr("Active"), // }, // }}, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/preview/2018-03-01-preview/examples/EnrollmentAccountsGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/enrollmentAccountGet.json func ExampleEnrollmentAccountsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -72,19 +133,113 @@ func ExampleEnrollmentAccountsClient_Get() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewEnrollmentAccountsClient().Get(ctx, "e1bf1c8c-5ac6-44a0-bdcd-aa7c1cf60556", nil) + res, err := clientFactory.NewEnrollmentAccountsClient().Get(ctx, "6564892", "257698", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.EnrollmentAccountSummary = armbilling.EnrollmentAccountSummary{ - // Name: to.Ptr("e1bf1c8c-5ac6-44a0-bdcd-aa7c1cf60556"), - // Type: to.Ptr("Microsoft.Billing/enrollmentAccounts"), - // ID: to.Ptr("/providers/Microsoft.Billing/enrollmentAccounts/e1bf1c8c-5ac6-44a0-bdcd-aa7c1cf60556"), - // Properties: &armbilling.EnrollmentAccountSummaryProperties{ - // PrincipalName: to.Ptr("kathy@contoso.com"), + // res.EnrollmentAccount = armbilling.EnrollmentAccount{ + // Name: to.Ptr("257698"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/6564892/enrollmentAccounts/257698"), + // Properties: &armbilling.EnrollmentAccountProperties{ + // AccountOwner: to.Ptr("account0@contoso.com"), + // AuthType: to.Ptr("Organization"), + // CostCenter: to.Ptr("C0"), + // DepartmentDisplayName: to.Ptr("TestDept123"), + // DepartmentID: to.Ptr("234516"), + // DisplayName: to.Ptr("AccountName0"), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-31T17:32:28.000Z"); return t}()), + // IsDevTestEnabled: to.Ptr(true), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T17:32:28.000Z"); return t}()), + // Status: to.Ptr("Active"), // }, // } } + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/enrollmentAccountsListByBillingAccount.json +func ExampleEnrollmentAccountsClient_NewListByBillingAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewEnrollmentAccountsClient().NewListByBillingAccountPager("6564892", &armbilling.EnrollmentAccountsClientListByBillingAccountOptions{Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.EnrollmentAccountListResult = armbilling.EnrollmentAccountListResult{ + // Value: []*armbilling.EnrollmentAccount{ + // { + // Name: to.Ptr("257698"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/6564892/enrollmentAccounts/257698"), + // Properties: &armbilling.EnrollmentAccountProperties{ + // AccountOwner: to.Ptr("account0@contoso.com"), + // AuthType: to.Ptr("Organization"), + // CostCenter: to.Ptr("C0"), + // DepartmentDisplayName: to.Ptr("TestDept123"), + // DepartmentID: to.Ptr("234516"), + // DisplayName: to.Ptr("AccountName0"), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-31T17:32:28.000Z"); return t}()), + // IsDevTestEnabled: to.Ptr(true), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T17:32:28.000Z"); return t}()), + // Status: to.Ptr("Active"), + // }, + // }, + // { + // Name: to.Ptr("264698"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/6564892/enrollmentAccounts/264698"), + // Properties: &armbilling.EnrollmentAccountProperties{ + // AccountOwner: to.Ptr("account1@contoso.com"), + // AuthType: to.Ptr("MicrosoftAccount"), + // CostCenter: to.Ptr("C1"), + // DepartmentDisplayName: to.Ptr("TestDept1"), + // DepartmentID: to.Ptr("234531"), + // DisplayName: to.Ptr("AccountName1"), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-31T17:32:28.000Z"); return t}()), + // IsDevTestEnabled: to.Ptr(true), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T17:32:28.000Z"); return t}()), + // Status: to.Ptr("Active"), + // }, + // }, + // { + // Name: to.Ptr("276290"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/6564892/enrollmentAccounts/276290"), + // Properties: &armbilling.EnrollmentAccountProperties{ + // AccountOwner: to.Ptr("account2@contoso.com"), + // AuthType: to.Ptr("Organization"), + // CostCenter: to.Ptr("C2"), + // DepartmentDisplayName: to.Ptr("TestDept2"), + // DepartmentID: to.Ptr("234512"), + // DisplayName: to.Ptr("AccountName2"), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-31T17:32:28.000Z"); return t}()), + // IsDevTestEnabled: to.Ptr(true), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T17:32:28.000Z"); return t}()), + // Status: to.Ptr("Active"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/billing/armbilling/fake/accounts_server.go b/sdk/resourcemanager/billing/armbilling/fake/accounts_server.go index c08be7454913..5d44940214a7 100644 --- a/sdk/resourcemanager/billing/armbilling/fake/accounts_server.go +++ b/sdk/resourcemanager/billing/armbilling/fake/accounts_server.go @@ -12,18 +12,33 @@ import ( "context" "errors" "fmt" + "net/http" + "net/url" + "regexp" + "strconv" + "time" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" - "net/http" - "net/url" - "regexp" ) // AccountsServer is a fake server for instances of the armbilling.AccountsClient type. type AccountsServer struct { + // BeginAddPaymentTerms is the fake for method AccountsClient.BeginAddPaymentTerms + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginAddPaymentTerms func(ctx context.Context, billingAccountName string, parameters []*armbilling.PaymentTerm, options *armbilling.AccountsClientBeginAddPaymentTermsOptions) (resp azfake.PollerResponder[armbilling.AccountsClientAddPaymentTermsResponse], errResp azfake.ErrorResponder) + + // BeginCancelPaymentTerms is the fake for method AccountsClient.BeginCancelPaymentTerms + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginCancelPaymentTerms func(ctx context.Context, billingAccountName string, parameters time.Time, options *armbilling.AccountsClientBeginCancelPaymentTermsOptions) (resp azfake.PollerResponder[armbilling.AccountsClientCancelPaymentTermsResponse], errResp azfake.ErrorResponder) + + // ConfirmTransition is the fake for method AccountsClient.ConfirmTransition + // HTTP status codes to indicate success: http.StatusOK + ConfirmTransition func(ctx context.Context, billingAccountName string, options *armbilling.AccountsClientConfirmTransitionOptions) (resp azfake.Responder[armbilling.AccountsClientConfirmTransitionResponse], errResp azfake.ErrorResponder) + // Get is the fake for method AccountsClient.Get // HTTP status codes to indicate success: http.StatusOK Get func(ctx context.Context, billingAccountName string, options *armbilling.AccountsClientGetOptions) (resp azfake.Responder[armbilling.AccountsClientGetResponse], errResp azfake.ErrorResponder) @@ -38,7 +53,11 @@ type AccountsServer struct { // BeginUpdate is the fake for method AccountsClient.BeginUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginUpdate func(ctx context.Context, billingAccountName string, parameters armbilling.AccountUpdateRequest, options *armbilling.AccountsClientBeginUpdateOptions) (resp azfake.PollerResponder[armbilling.AccountsClientUpdateResponse], errResp azfake.ErrorResponder) + BeginUpdate func(ctx context.Context, billingAccountName string, parameters armbilling.AccountPatch, options *armbilling.AccountsClientBeginUpdateOptions) (resp azfake.PollerResponder[armbilling.AccountsClientUpdateResponse], errResp azfake.ErrorResponder) + + // ValidatePaymentTerms is the fake for method AccountsClient.ValidatePaymentTerms + // HTTP status codes to indicate success: http.StatusOK + ValidatePaymentTerms func(ctx context.Context, billingAccountName string, parameters []*armbilling.PaymentTerm, options *armbilling.AccountsClientValidatePaymentTermsOptions) (resp azfake.Responder[armbilling.AccountsClientValidatePaymentTermsResponse], errResp azfake.ErrorResponder) } // NewAccountsServerTransport creates a new instance of AccountsServerTransport with the provided implementation. @@ -46,8 +65,10 @@ type AccountsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewAccountsServerTransport(srv *AccountsServer) *AccountsServerTransport { return &AccountsServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armbilling.AccountsClientListResponse]](), + srv: srv, + beginAddPaymentTerms: newTracker[azfake.PollerResponder[armbilling.AccountsClientAddPaymentTermsResponse]](), + beginCancelPaymentTerms: newTracker[azfake.PollerResponder[armbilling.AccountsClientCancelPaymentTermsResponse]](), + newListPager: newTracker[azfake.PagerResponder[armbilling.AccountsClientListResponse]](), newListInvoiceSectionsByCreateSubscriptionPermissionPager: newTracker[azfake.PagerResponder[armbilling.AccountsClientListInvoiceSectionsByCreateSubscriptionPermissionResponse]](), beginUpdate: newTracker[azfake.PollerResponder[armbilling.AccountsClientUpdateResponse]](), } @@ -57,6 +78,8 @@ func NewAccountsServerTransport(srv *AccountsServer) *AccountsServerTransport { // Don't use this type directly, use NewAccountsServerTransport instead. type AccountsServerTransport struct { srv *AccountsServer + beginAddPaymentTerms *tracker[azfake.PollerResponder[armbilling.AccountsClientAddPaymentTermsResponse]] + beginCancelPaymentTerms *tracker[azfake.PollerResponder[armbilling.AccountsClientCancelPaymentTermsResponse]] newListPager *tracker[azfake.PagerResponder[armbilling.AccountsClientListResponse]] newListInvoiceSectionsByCreateSubscriptionPermissionPager *tracker[azfake.PagerResponder[armbilling.AccountsClientListInvoiceSectionsByCreateSubscriptionPermissionResponse]] beginUpdate *tracker[azfake.PollerResponder[armbilling.AccountsClientUpdateResponse]] @@ -74,6 +97,12 @@ func (a *AccountsServerTransport) Do(req *http.Request) (*http.Response, error) var err error switch method { + case "AccountsClient.BeginAddPaymentTerms": + resp, err = a.dispatchBeginAddPaymentTerms(req) + case "AccountsClient.BeginCancelPaymentTerms": + resp, err = a.dispatchBeginCancelPaymentTerms(req) + case "AccountsClient.ConfirmTransition": + resp, err = a.dispatchConfirmTransition(req) case "AccountsClient.Get": resp, err = a.dispatchGet(req) case "AccountsClient.NewListPager": @@ -82,6 +111,8 @@ func (a *AccountsServerTransport) Do(req *http.Request) (*http.Response, error) resp, err = a.dispatchNewListInvoiceSectionsByCreateSubscriptionPermissionPager(req) case "AccountsClient.BeginUpdate": resp, err = a.dispatchBeginUpdate(req) + case "AccountsClient.ValidatePaymentTerms": + resp, err = a.dispatchValidatePaymentTerms(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -93,33 +124,138 @@ func (a *AccountsServerTransport) Do(req *http.Request) (*http.Response, error) return resp, nil } -func (a *AccountsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if a.srv.Get == nil { - return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} +func (a *AccountsServerTransport) dispatchBeginAddPaymentTerms(req *http.Request) (*http.Response, error) { + if a.srv.BeginAddPaymentTerms == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginAddPaymentTerms not implemented")} } - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + beginAddPaymentTerms := a.beginAddPaymentTerms.get(req) + if beginAddPaymentTerms == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/addPaymentTerms` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[[]*armbilling.PaymentTerm](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginAddPaymentTerms(req.Context(), billingAccountNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginAddPaymentTerms = &respr + a.beginAddPaymentTerms.add(req, beginAddPaymentTerms) + } + + resp, err := server.PollerResponderNext(beginAddPaymentTerms, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + a.beginAddPaymentTerms.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginAddPaymentTerms) { + a.beginAddPaymentTerms.remove(req) + } + + return resp, nil +} + +func (a *AccountsServerTransport) dispatchBeginCancelPaymentTerms(req *http.Request) (*http.Response, error) { + if a.srv.BeginCancelPaymentTerms == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCancelPaymentTerms not implemented")} + } + beginCancelPaymentTerms := a.beginCancelPaymentTerms.get(req) + if beginCancelPaymentTerms == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/cancelPaymentTerms` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[dateTimeRFC3339](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginCancelPaymentTerms(req.Context(), billingAccountNameParam, time.Time(body), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCancelPaymentTerms = &respr + a.beginCancelPaymentTerms.add(req, beginCancelPaymentTerms) + } + + resp, err := server.PollerResponderNext(beginCancelPaymentTerms, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + a.beginCancelPaymentTerms.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCancelPaymentTerms) { + a.beginCancelPaymentTerms.remove(req) + } + + return resp, nil +} + +func (a *AccountsServerTransport) dispatchConfirmTransition(req *http.Request) (*http.Response, error) { + if a.srv.ConfirmTransition == nil { + return nil, &nonRetriableError{errors.New("fake for method ConfirmTransition not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/confirmTransition` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - qp := req.URL.Query() billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) if err != nil { return nil, err } - expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + respr, errRespr := a.srv.ConfirmTransition(req.Context(), billingAccountNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TransitionDetails, req) if err != nil { return nil, err } - expandParam := getOptional(expandUnescaped) - var options *armbilling.AccountsClientGetOptions - if expandParam != nil { - options = &armbilling.AccountsClientGetOptions{ - Expand: expandParam, - } + return resp, nil +} + +func (a *AccountsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if a.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - respr, errRespr := a.srv.Get(req.Context(), billingAccountNameParam, options) + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Get(req.Context(), billingAccountNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -141,15 +277,114 @@ func (a *AccountsServerTransport) dispatchNewListPager(req *http.Request) (*http newListPager := a.newListPager.get(req) if newListPager == nil { qp := req.URL.Query() - expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + includeAllUnescaped, err := url.QueryUnescape(qp.Get("includeAll")) + if err != nil { + return nil, err + } + includeAllParam, err := parseOptional(includeAllUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + includeAllWithoutBillingProfilesUnescaped, err := url.QueryUnescape(qp.Get("includeAllWithoutBillingProfiles")) + if err != nil { + return nil, err + } + includeAllWithoutBillingProfilesParam, err := parseOptional(includeAllWithoutBillingProfilesUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + includeDeletedUnescaped, err := url.QueryUnescape(qp.Get("includeDeleted")) + if err != nil { + return nil, err + } + includeDeletedParam, err := parseOptional(includeDeletedUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + includePendingAgreementUnescaped, err := url.QueryUnescape(qp.Get("includePendingAgreement")) + if err != nil { + return nil, err + } + includePendingAgreementParam, err := parseOptional(includePendingAgreementUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + includeReselleeUnescaped, err := url.QueryUnescape(qp.Get("includeResellee")) + if err != nil { + return nil, err + } + includeReselleeParam, err := parseOptional(includeReselleeUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + legalOwnerTIDUnescaped, err := url.QueryUnescape(qp.Get("legalOwnerTID")) + if err != nil { + return nil, err + } + legalOwnerTIDParam := getOptional(legalOwnerTIDUnescaped) + legalOwnerOIDUnescaped, err := url.QueryUnescape(qp.Get("legalOwnerOID")) + if err != nil { + return nil, err + } + legalOwnerOIDParam := getOptional(legalOwnerOIDUnescaped) + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + expandUnescaped, err := url.QueryUnescape(qp.Get("expand")) if err != nil { return nil, err } expandParam := getOptional(expandUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) var options *armbilling.AccountsClientListOptions - if expandParam != nil { + if includeAllParam != nil || includeAllWithoutBillingProfilesParam != nil || includeDeletedParam != nil || includePendingAgreementParam != nil || includeReselleeParam != nil || legalOwnerTIDParam != nil || legalOwnerOIDParam != nil || filterParam != nil || expandParam != nil || topParam != nil || skipParam != nil || searchParam != nil { options = &armbilling.AccountsClientListOptions{ - Expand: expandParam, + IncludeAll: includeAllParam, + IncludeAllWithoutBillingProfiles: includeAllWithoutBillingProfilesParam, + IncludeDeleted: includeDeletedParam, + IncludePendingAgreement: includePendingAgreementParam, + IncludeResellee: includeReselleeParam, + LegalOwnerTID: legalOwnerTIDParam, + LegalOwnerOID: legalOwnerOIDParam, + Filter: filterParam, + Expand: expandParam, + Top: topParam, + Skip: skipParam, + Search: searchParam, } } resp := a.srv.NewListPager(options) @@ -185,11 +420,23 @@ func (a *AccountsServerTransport) dispatchNewListInvoiceSectionsByCreateSubscrip if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } + qp := req.URL.Query() billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) if err != nil { return nil, err } - resp := a.srv.NewListInvoiceSectionsByCreateSubscriptionPermissionPager(billingAccountNameParam, nil) + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armbilling.AccountsClientListInvoiceSectionsByCreateSubscriptionPermissionOptions + if filterParam != nil { + options = &armbilling.AccountsClientListInvoiceSectionsByCreateSubscriptionPermissionOptions{ + Filter: filterParam, + } + } + resp := a.srv.NewListInvoiceSectionsByCreateSubscriptionPermissionPager(billingAccountNameParam, options) newListInvoiceSectionsByCreateSubscriptionPermissionPager = &resp a.newListInvoiceSectionsByCreateSubscriptionPermissionPager.add(req, newListInvoiceSectionsByCreateSubscriptionPermissionPager) server.PagerResponderInjectNextLinks(newListInvoiceSectionsByCreateSubscriptionPermissionPager, req, func(page *armbilling.AccountsClientListInvoiceSectionsByCreateSubscriptionPermissionResponse, createLink func() string) { @@ -222,7 +469,7 @@ func (a *AccountsServerTransport) dispatchBeginUpdate(req *http.Request) (*http. if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armbilling.AccountUpdateRequest](req) + body, err := server.UnmarshalRequestAsJSON[armbilling.AccountPatch](req) if err != nil { return nil, err } @@ -253,3 +500,36 @@ func (a *AccountsServerTransport) dispatchBeginUpdate(req *http.Request) (*http. return resp, nil } + +func (a *AccountsServerTransport) dispatchValidatePaymentTerms(req *http.Request) (*http.Response, error) { + if a.srv.ValidatePaymentTerms == nil { + return nil, &nonRetriableError{errors.New("fake for method ValidatePaymentTerms not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validatePaymentTerms` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[[]*armbilling.PaymentTerm](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.ValidatePaymentTerms(req.Context(), billingAccountNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PaymentTermsEligibilityResult, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/fake/address_server.go b/sdk/resourcemanager/billing/armbilling/fake/address_server.go index 268f6abe642e..0bfa78711910 100644 --- a/sdk/resourcemanager/billing/armbilling/fake/address_server.go +++ b/sdk/resourcemanager/billing/armbilling/fake/address_server.go @@ -12,18 +12,19 @@ import ( "context" "errors" "fmt" + "net/http" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" - "net/http" ) // AddressServer is a fake server for instances of the armbilling.AddressClient type. type AddressServer struct { // Validate is the fake for method AddressClient.Validate // HTTP status codes to indicate success: http.StatusOK - Validate func(ctx context.Context, address armbilling.AddressDetails, options *armbilling.AddressClientValidateOptions) (resp azfake.Responder[armbilling.AddressClientValidateResponse], errResp azfake.ErrorResponder) + Validate func(ctx context.Context, parameters armbilling.AddressDetails, options *armbilling.AddressClientValidateOptions) (resp azfake.Responder[armbilling.AddressClientValidateResponse], errResp azfake.ErrorResponder) } // NewAddressServerTransport creates a new instance of AddressServerTransport with the provided implementation. @@ -80,7 +81,7 @@ func (a *AddressServerTransport) dispatchValidate(req *http.Request) (*http.Resp if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ValidateAddressResponse, req) + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AddressValidationResponse, req) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/billing/armbilling/fake/agreements_server.go b/sdk/resourcemanager/billing/armbilling/fake/agreements_server.go index c71f1f5e92a1..8f2614dbeb2a 100644 --- a/sdk/resourcemanager/billing/armbilling/fake/agreements_server.go +++ b/sdk/resourcemanager/billing/armbilling/fake/agreements_server.go @@ -12,14 +12,15 @@ import ( "context" "errors" "fmt" + "net/http" + "net/url" + "regexp" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" - "net/http" - "net/url" - "regexp" ) // AgreementsServer is a fake server for instances of the armbilling.AgreementsClient type. @@ -87,7 +88,6 @@ func (a *AgreementsServerTransport) dispatchGet(req *http.Request) (*http.Respon if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - qp := req.URL.Query() billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) if err != nil { return nil, err @@ -96,18 +96,7 @@ func (a *AgreementsServerTransport) dispatchGet(req *http.Request) (*http.Respon if err != nil { return nil, err } - expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) - if err != nil { - return nil, err - } - expandParam := getOptional(expandUnescaped) - var options *armbilling.AgreementsClientGetOptions - if expandParam != nil { - options = &armbilling.AgreementsClientGetOptions{ - Expand: expandParam, - } - } - respr, errRespr := a.srv.Get(req.Context(), billingAccountNameParam, agreementNameParam, options) + respr, errRespr := a.srv.Get(req.Context(), billingAccountNameParam, agreementNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -139,7 +128,7 @@ func (a *AgreementsServerTransport) dispatchNewListByBillingAccountPager(req *ht if err != nil { return nil, err } - expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + expandUnescaped, err := url.QueryUnescape(qp.Get("expand")) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/billing/armbilling/fake/associatedtenants_server.go b/sdk/resourcemanager/billing/armbilling/fake/associatedtenants_server.go new file mode 100644 index 000000000000..6380ca83ff21 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/fake/associatedtenants_server.go @@ -0,0 +1,330 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "regexp" + "strconv" + + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// AssociatedTenantsServer is a fake server for instances of the armbilling.AssociatedTenantsClient type. +type AssociatedTenantsServer struct { + // BeginCreateOrUpdate is the fake for method AssociatedTenantsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, billingAccountName string, associatedTenantName string, parameters armbilling.AssociatedTenant, options *armbilling.AssociatedTenantsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armbilling.AssociatedTenantsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method AssociatedTenantsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, billingAccountName string, associatedTenantName string, options *armbilling.AssociatedTenantsClientBeginDeleteOptions) (resp azfake.PollerResponder[armbilling.AssociatedTenantsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method AssociatedTenantsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, billingAccountName string, associatedTenantName string, options *armbilling.AssociatedTenantsClientGetOptions) (resp azfake.Responder[armbilling.AssociatedTenantsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByBillingAccountPager is the fake for method AssociatedTenantsClient.NewListByBillingAccountPager + // HTTP status codes to indicate success: http.StatusOK + NewListByBillingAccountPager func(billingAccountName string, options *armbilling.AssociatedTenantsClientListByBillingAccountOptions) (resp azfake.PagerResponder[armbilling.AssociatedTenantsClientListByBillingAccountResponse]) +} + +// NewAssociatedTenantsServerTransport creates a new instance of AssociatedTenantsServerTransport with the provided implementation. +// The returned AssociatedTenantsServerTransport instance is connected to an instance of armbilling.AssociatedTenantsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewAssociatedTenantsServerTransport(srv *AssociatedTenantsServer) *AssociatedTenantsServerTransport { + return &AssociatedTenantsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armbilling.AssociatedTenantsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armbilling.AssociatedTenantsClientDeleteResponse]](), + newListByBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.AssociatedTenantsClientListByBillingAccountResponse]](), + } +} + +// AssociatedTenantsServerTransport connects instances of armbilling.AssociatedTenantsClient to instances of AssociatedTenantsServer. +// Don't use this type directly, use NewAssociatedTenantsServerTransport instead. +type AssociatedTenantsServerTransport struct { + srv *AssociatedTenantsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armbilling.AssociatedTenantsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armbilling.AssociatedTenantsClientDeleteResponse]] + newListByBillingAccountPager *tracker[azfake.PagerResponder[armbilling.AssociatedTenantsClientListByBillingAccountResponse]] +} + +// Do implements the policy.Transporter interface for AssociatedTenantsServerTransport. +func (a *AssociatedTenantsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "AssociatedTenantsClient.BeginCreateOrUpdate": + resp, err = a.dispatchBeginCreateOrUpdate(req) + case "AssociatedTenantsClient.BeginDelete": + resp, err = a.dispatchBeginDelete(req) + case "AssociatedTenantsClient.Get": + resp, err = a.dispatchGet(req) + case "AssociatedTenantsClient.NewListByBillingAccountPager": + resp, err = a.dispatchNewListByBillingAccountPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (a *AssociatedTenantsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if a.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := a.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/associatedTenants/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.AssociatedTenant](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + associatedTenantNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("associatedTenantName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginCreateOrUpdate(req.Context(), billingAccountNameParam, associatedTenantNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + a.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + a.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + a.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (a *AssociatedTenantsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if a.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := a.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/associatedTenants/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + associatedTenantNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("associatedTenantName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginDelete(req.Context(), billingAccountNameParam, associatedTenantNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + a.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + a.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + a.beginDelete.remove(req) + } + + return resp, nil +} + +func (a *AssociatedTenantsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if a.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/associatedTenants/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + associatedTenantNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("associatedTenantName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Get(req.Context(), billingAccountNameParam, associatedTenantNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AssociatedTenant, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AssociatedTenantsServerTransport) dispatchNewListByBillingAccountPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListByBillingAccountPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByBillingAccountPager not implemented")} + } + newListByBillingAccountPager := a.newListByBillingAccountPager.get(req) + if newListByBillingAccountPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/associatedTenants` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + includeRevokedUnescaped, err := url.QueryUnescape(qp.Get("includeRevoked")) + if err != nil { + return nil, err + } + includeRevokedParam, err := parseOptional(includeRevokedUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.AssociatedTenantsClientListByBillingAccountOptions + if includeRevokedParam != nil || filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.AssociatedTenantsClientListByBillingAccountOptions{ + IncludeRevoked: includeRevokedParam, + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := a.srv.NewListByBillingAccountPager(billingAccountNameParam, options) + newListByBillingAccountPager = &resp + a.newListByBillingAccountPager.add(req, newListByBillingAccountPager) + server.PagerResponderInjectNextLinks(newListByBillingAccountPager, req, func(page *armbilling.AssociatedTenantsClientListByBillingAccountResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByBillingAccountPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListByBillingAccountPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByBillingAccountPager) { + a.newListByBillingAccountPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/fake/availablebalances_server.go b/sdk/resourcemanager/billing/armbilling/fake/availablebalances_server.go index a71cd0ba437e..a9d4dbd3578d 100644 --- a/sdk/resourcemanager/billing/armbilling/fake/availablebalances_server.go +++ b/sdk/resourcemanager/billing/armbilling/fake/availablebalances_server.go @@ -12,20 +12,25 @@ import ( "context" "errors" "fmt" + "net/http" + "net/url" + "regexp" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" - "net/http" - "net/url" - "regexp" ) // AvailableBalancesServer is a fake server for instances of the armbilling.AvailableBalancesClient type. type AvailableBalancesServer struct { - // Get is the fake for method AvailableBalancesClient.Get + // GetByBillingAccount is the fake for method AvailableBalancesClient.GetByBillingAccount + // HTTP status codes to indicate success: http.StatusOK + GetByBillingAccount func(ctx context.Context, billingAccountName string, options *armbilling.AvailableBalancesClientGetByBillingAccountOptions) (resp azfake.Responder[armbilling.AvailableBalancesClientGetByBillingAccountResponse], errResp azfake.ErrorResponder) + + // GetByBillingProfile is the fake for method AvailableBalancesClient.GetByBillingProfile // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, billingAccountName string, billingProfileName string, options *armbilling.AvailableBalancesClientGetOptions) (resp azfake.Responder[armbilling.AvailableBalancesClientGetResponse], errResp azfake.ErrorResponder) + GetByBillingProfile func(ctx context.Context, billingAccountName string, billingProfileName string, options *armbilling.AvailableBalancesClientGetByBillingProfileOptions) (resp azfake.Responder[armbilling.AvailableBalancesClientGetByBillingProfileResponse], errResp azfake.ErrorResponder) } // NewAvailableBalancesServerTransport creates a new instance of AvailableBalancesServerTransport with the provided implementation. @@ -53,8 +58,10 @@ func (a *AvailableBalancesServerTransport) Do(req *http.Request) (*http.Response var err error switch method { - case "AvailableBalancesClient.Get": - resp, err = a.dispatchGet(req) + case "AvailableBalancesClient.GetByBillingAccount": + resp, err = a.dispatchGetByBillingAccount(req) + case "AvailableBalancesClient.GetByBillingProfile": + resp, err = a.dispatchGetByBillingProfile(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -66,9 +73,38 @@ func (a *AvailableBalancesServerTransport) Do(req *http.Request) (*http.Response return resp, nil } -func (a *AvailableBalancesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if a.srv.Get == nil { - return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} +func (a *AvailableBalancesServerTransport) dispatchGetByBillingAccount(req *http.Request) (*http.Response, error) { + if a.srv.GetByBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByBillingAccount not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/availableBalance/default` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.GetByBillingAccount(req.Context(), billingAccountNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AvailableBalance, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AvailableBalancesServerTransport) dispatchGetByBillingProfile(req *http.Request) (*http.Response, error) { + if a.srv.GetByBillingProfile == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByBillingProfile not implemented")} } const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/availableBalance/default` regex := regexp.MustCompile(regexStr) @@ -84,7 +120,7 @@ func (a *AvailableBalancesServerTransport) dispatchGet(req *http.Request) (*http if err != nil { return nil, err } - respr, errRespr := a.srv.Get(req.Context(), billingAccountNameParam, billingProfileNameParam, nil) + respr, errRespr := a.srv.GetByBillingProfile(req.Context(), billingAccountNameParam, billingProfileNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/billing/armbilling/fake/customers_server.go b/sdk/resourcemanager/billing/armbilling/fake/customers_server.go index 20d380672e75..bb3a9f77de99 100644 --- a/sdk/resourcemanager/billing/armbilling/fake/customers_server.go +++ b/sdk/resourcemanager/billing/armbilling/fake/customers_server.go @@ -12,21 +12,27 @@ import ( "context" "errors" "fmt" + "net/http" + "net/url" + "regexp" + "strconv" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" - "net/http" - "net/url" - "regexp" ) // CustomersServer is a fake server for instances of the armbilling.CustomersClient type. type CustomersServer struct { // Get is the fake for method CustomersClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, billingAccountName string, customerName string, options *armbilling.CustomersClientGetOptions) (resp azfake.Responder[armbilling.CustomersClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, options *armbilling.CustomersClientGetOptions) (resp azfake.Responder[armbilling.CustomersClientGetResponse], errResp azfake.ErrorResponder) + + // GetByBillingAccount is the fake for method CustomersClient.GetByBillingAccount + // HTTP status codes to indicate success: http.StatusOK + GetByBillingAccount func(ctx context.Context, billingAccountName string, customerName string, options *armbilling.CustomersClientGetByBillingAccountOptions) (resp azfake.Responder[armbilling.CustomersClientGetByBillingAccountResponse], errResp azfake.ErrorResponder) // NewListByBillingAccountPager is the fake for method CustomersClient.NewListByBillingAccountPager // HTTP status codes to indicate success: http.StatusOK @@ -70,6 +76,8 @@ func (c *CustomersServerTransport) Do(req *http.Request) (*http.Response, error) switch method { case "CustomersClient.Get": resp, err = c.dispatchGet(req) + case "CustomersClient.GetByBillingAccount": + resp, err = c.dispatchGetByBillingAccount(req) case "CustomersClient.NewListByBillingAccountPager": resp, err = c.dispatchNewListByBillingAccountPager(req) case "CustomersClient.NewListByBillingProfilePager": @@ -89,33 +97,58 @@ func (c *CustomersServerTransport) dispatchGet(req *http.Request) (*http.Respons if c.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - qp := req.URL.Query() billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) if err != nil { return nil, err } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) if err != nil { return nil, err } - expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + respr, errRespr := c.srv.Get(req.Context(), billingAccountNameParam, billingProfileNameParam, customerNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Customer, req) if err != nil { return nil, err } - expandParam := getOptional(expandUnescaped) - var options *armbilling.CustomersClientGetOptions - if expandParam != nil { - options = &armbilling.CustomersClientGetOptions{ - Expand: expandParam, - } + return resp, nil +} + +func (c *CustomersServerTransport) dispatchGetByBillingAccount(req *http.Request) (*http.Response, error) { + if c.srv.GetByBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByBillingAccount not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := c.srv.Get(req.Context(), billingAccountNameParam, customerNameParam, options) + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.GetByBillingAccount(req.Context(), billingAccountNameParam, customerNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -147,21 +180,72 @@ func (c *CustomersServerTransport) dispatchNewListByBillingAccountPager(req *htt if err != nil { return nil, err } - searchUnescaped, err := url.QueryUnescape(qp.Get("$search")) + expandUnescaped, err := url.QueryUnescape(qp.Get("expand")) if err != nil { return nil, err } - searchParam := getOptional(searchUnescaped) - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + expandParam := getOptional(expandUnescaped) + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) if err != nil { return nil, err } filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) var options *armbilling.CustomersClientListByBillingAccountOptions - if searchParam != nil || filterParam != nil { + if expandParam != nil || filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { options = &armbilling.CustomersClientListByBillingAccountOptions{ - Search: searchParam, - Filter: filterParam, + Expand: expandParam, + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, } } resp := c.srv.NewListByBillingAccountPager(billingAccountNameParam, options) @@ -206,21 +290,72 @@ func (c *CustomersServerTransport) dispatchNewListByBillingProfilePager(req *htt if err != nil { return nil, err } - searchUnescaped, err := url.QueryUnescape(qp.Get("$search")) + expandUnescaped, err := url.QueryUnescape(qp.Get("expand")) if err != nil { return nil, err } - searchParam := getOptional(searchUnescaped) - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + expandParam := getOptional(expandUnescaped) + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) if err != nil { return nil, err } filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) var options *armbilling.CustomersClientListByBillingProfileOptions - if searchParam != nil || filterParam != nil { + if expandParam != nil || filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { options = &armbilling.CustomersClientListByBillingProfileOptions{ - Search: searchParam, - Filter: filterParam, + Expand: expandParam, + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, } } resp := c.srv.NewListByBillingProfilePager(billingAccountNameParam, billingProfileNameParam, options) diff --git a/sdk/resourcemanager/billing/armbilling/fake/date_type.go b/sdk/resourcemanager/billing/armbilling/fake/date_type.go index efb0b705ae45..0fcc8f604e56 100644 --- a/sdk/resourcemanager/billing/armbilling/fake/date_type.go +++ b/sdk/resourcemanager/billing/armbilling/fake/date_type.go @@ -11,10 +11,10 @@ package fake import ( "encoding/json" "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" "reflect" - "strings" "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" ) const ( @@ -47,7 +47,7 @@ func populateDateType(m map[string]any, k string, t *time.Time) { } func unpopulateDateType(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateType diff --git a/sdk/resourcemanager/billing/armbilling/fake/departments_server.go b/sdk/resourcemanager/billing/armbilling/fake/departments_server.go new file mode 100644 index 000000000000..676e4cfed8e0 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/fake/departments_server.go @@ -0,0 +1,204 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "regexp" + "strconv" + + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// DepartmentsServer is a fake server for instances of the armbilling.DepartmentsClient type. +type DepartmentsServer struct { + // Get is the fake for method DepartmentsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, billingAccountName string, departmentName string, options *armbilling.DepartmentsClientGetOptions) (resp azfake.Responder[armbilling.DepartmentsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByBillingAccountPager is the fake for method DepartmentsClient.NewListByBillingAccountPager + // HTTP status codes to indicate success: http.StatusOK + NewListByBillingAccountPager func(billingAccountName string, options *armbilling.DepartmentsClientListByBillingAccountOptions) (resp azfake.PagerResponder[armbilling.DepartmentsClientListByBillingAccountResponse]) +} + +// NewDepartmentsServerTransport creates a new instance of DepartmentsServerTransport with the provided implementation. +// The returned DepartmentsServerTransport instance is connected to an instance of armbilling.DepartmentsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDepartmentsServerTransport(srv *DepartmentsServer) *DepartmentsServerTransport { + return &DepartmentsServerTransport{ + srv: srv, + newListByBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.DepartmentsClientListByBillingAccountResponse]](), + } +} + +// DepartmentsServerTransport connects instances of armbilling.DepartmentsClient to instances of DepartmentsServer. +// Don't use this type directly, use NewDepartmentsServerTransport instead. +type DepartmentsServerTransport struct { + srv *DepartmentsServer + newListByBillingAccountPager *tracker[azfake.PagerResponder[armbilling.DepartmentsClientListByBillingAccountResponse]] +} + +// Do implements the policy.Transporter interface for DepartmentsServerTransport. +func (d *DepartmentsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "DepartmentsClient.Get": + resp, err = d.dispatchGet(req) + case "DepartmentsClient.NewListByBillingAccountPager": + resp, err = d.dispatchNewListByBillingAccountPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (d *DepartmentsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if d.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/departments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + departmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("departmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Get(req.Context(), billingAccountNameParam, departmentNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Department, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DepartmentsServerTransport) dispatchNewListByBillingAccountPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListByBillingAccountPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByBillingAccountPager not implemented")} + } + newListByBillingAccountPager := d.newListByBillingAccountPager.get(req) + if newListByBillingAccountPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/departments` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.DepartmentsClientListByBillingAccountOptions + if filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || searchParam != nil { + options = &armbilling.DepartmentsClientListByBillingAccountOptions{ + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Search: searchParam, + } + } + resp := d.srv.NewListByBillingAccountPager(billingAccountNameParam, options) + newListByBillingAccountPager = &resp + d.newListByBillingAccountPager.add(req, newListByBillingAccountPager) + server.PagerResponderInjectNextLinks(newListByBillingAccountPager, req, func(page *armbilling.DepartmentsClientListByBillingAccountResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByBillingAccountPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newListByBillingAccountPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByBillingAccountPager) { + d.newListByBillingAccountPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/fake/enrollmentaccounts_server.go b/sdk/resourcemanager/billing/armbilling/fake/enrollmentaccounts_server.go index e7fc13474017..baf476f747ac 100644 --- a/sdk/resourcemanager/billing/armbilling/fake/enrollmentaccounts_server.go +++ b/sdk/resourcemanager/billing/armbilling/fake/enrollmentaccounts_server.go @@ -12,25 +12,35 @@ import ( "context" "errors" "fmt" + "net/http" + "net/url" + "regexp" + "strconv" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" - "net/http" - "net/url" - "regexp" ) // EnrollmentAccountsServer is a fake server for instances of the armbilling.EnrollmentAccountsClient type. type EnrollmentAccountsServer struct { // Get is the fake for method EnrollmentAccountsClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, name string, options *armbilling.EnrollmentAccountsClientGetOptions) (resp azfake.Responder[armbilling.EnrollmentAccountsClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, billingAccountName string, enrollmentAccountName string, options *armbilling.EnrollmentAccountsClientGetOptions) (resp azfake.Responder[armbilling.EnrollmentAccountsClientGetResponse], errResp azfake.ErrorResponder) - // NewListPager is the fake for method EnrollmentAccountsClient.NewListPager + // GetByDepartment is the fake for method EnrollmentAccountsClient.GetByDepartment // HTTP status codes to indicate success: http.StatusOK - NewListPager func(options *armbilling.EnrollmentAccountsClientListOptions) (resp azfake.PagerResponder[armbilling.EnrollmentAccountsClientListResponse]) + GetByDepartment func(ctx context.Context, billingAccountName string, departmentName string, enrollmentAccountName string, options *armbilling.EnrollmentAccountsClientGetByDepartmentOptions) (resp azfake.Responder[armbilling.EnrollmentAccountsClientGetByDepartmentResponse], errResp azfake.ErrorResponder) + + // NewListByBillingAccountPager is the fake for method EnrollmentAccountsClient.NewListByBillingAccountPager + // HTTP status codes to indicate success: http.StatusOK + NewListByBillingAccountPager func(billingAccountName string, options *armbilling.EnrollmentAccountsClientListByBillingAccountOptions) (resp azfake.PagerResponder[armbilling.EnrollmentAccountsClientListByBillingAccountResponse]) + + // NewListByDepartmentPager is the fake for method EnrollmentAccountsClient.NewListByDepartmentPager + // HTTP status codes to indicate success: http.StatusOK + NewListByDepartmentPager func(billingAccountName string, departmentName string, options *armbilling.EnrollmentAccountsClientListByDepartmentOptions) (resp azfake.PagerResponder[armbilling.EnrollmentAccountsClientListByDepartmentResponse]) } // NewEnrollmentAccountsServerTransport creates a new instance of EnrollmentAccountsServerTransport with the provided implementation. @@ -38,16 +48,18 @@ type EnrollmentAccountsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewEnrollmentAccountsServerTransport(srv *EnrollmentAccountsServer) *EnrollmentAccountsServerTransport { return &EnrollmentAccountsServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armbilling.EnrollmentAccountsClientListResponse]](), + srv: srv, + newListByBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.EnrollmentAccountsClientListByBillingAccountResponse]](), + newListByDepartmentPager: newTracker[azfake.PagerResponder[armbilling.EnrollmentAccountsClientListByDepartmentResponse]](), } } // EnrollmentAccountsServerTransport connects instances of armbilling.EnrollmentAccountsClient to instances of EnrollmentAccountsServer. // Don't use this type directly, use NewEnrollmentAccountsServerTransport instead. type EnrollmentAccountsServerTransport struct { - srv *EnrollmentAccountsServer - newListPager *tracker[azfake.PagerResponder[armbilling.EnrollmentAccountsClientListResponse]] + srv *EnrollmentAccountsServer + newListByBillingAccountPager *tracker[azfake.PagerResponder[armbilling.EnrollmentAccountsClientListByBillingAccountResponse]] + newListByDepartmentPager *tracker[azfake.PagerResponder[armbilling.EnrollmentAccountsClientListByDepartmentResponse]] } // Do implements the policy.Transporter interface for EnrollmentAccountsServerTransport. @@ -64,8 +76,12 @@ func (e *EnrollmentAccountsServerTransport) Do(req *http.Request) (*http.Respons switch method { case "EnrollmentAccountsClient.Get": resp, err = e.dispatchGet(req) - case "EnrollmentAccountsClient.NewListPager": - resp, err = e.dispatchNewListPager(req) + case "EnrollmentAccountsClient.GetByDepartment": + resp, err = e.dispatchGetByDepartment(req) + case "EnrollmentAccountsClient.NewListByBillingAccountPager": + resp, err = e.dispatchNewListByBillingAccountPager(req) + case "EnrollmentAccountsClient.NewListByDepartmentPager": + resp, err = e.dispatchNewListByDepartmentPager(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -81,17 +97,21 @@ func (e *EnrollmentAccountsServerTransport) dispatchGet(req *http.Request) (*htt if e.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - const regexStr = `/providers/Microsoft\.Billing/enrollmentAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enrollmentAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) if err != nil { return nil, err } - respr, errRespr := e.srv.Get(req.Context(), nameParam, nil) + enrollmentAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enrollmentAccountName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.Get(req.Context(), billingAccountNameParam, enrollmentAccountNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -99,36 +119,250 @@ func (e *EnrollmentAccountsServerTransport) dispatchGet(req *http.Request) (*htt if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).EnrollmentAccountSummary, req) + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).EnrollmentAccount, req) if err != nil { return nil, err } return resp, nil } -func (e *EnrollmentAccountsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { - if e.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} +func (e *EnrollmentAccountsServerTransport) dispatchGetByDepartment(req *http.Request) (*http.Response, error) { + if e.srv.GetByDepartment == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByDepartment not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/departments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enrollmentAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + departmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("departmentName")]) + if err != nil { + return nil, err + } + enrollmentAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enrollmentAccountName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.GetByDepartment(req.Context(), billingAccountNameParam, departmentNameParam, enrollmentAccountNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr } - newListPager := e.newListPager.get(req) - if newListPager == nil { - resp := e.srv.NewListPager(nil) - newListPager = &resp - e.newListPager.add(req, newListPager) - server.PagerResponderInjectNextLinks(newListPager, req, func(page *armbilling.EnrollmentAccountsClientListResponse, createLink func() string) { + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).EnrollmentAccount, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (e *EnrollmentAccountsServerTransport) dispatchNewListByBillingAccountPager(req *http.Request) (*http.Response, error) { + if e.srv.NewListByBillingAccountPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByBillingAccountPager not implemented")} + } + newListByBillingAccountPager := e.newListByBillingAccountPager.get(req) + if newListByBillingAccountPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enrollmentAccounts` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.EnrollmentAccountsClientListByBillingAccountOptions + if filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.EnrollmentAccountsClientListByBillingAccountOptions{ + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := e.srv.NewListByBillingAccountPager(billingAccountNameParam, options) + newListByBillingAccountPager = &resp + e.newListByBillingAccountPager.add(req, newListByBillingAccountPager) + server.PagerResponderInjectNextLinks(newListByBillingAccountPager, req, func(page *armbilling.EnrollmentAccountsClientListByBillingAccountResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByBillingAccountPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + e.newListByBillingAccountPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByBillingAccountPager) { + e.newListByBillingAccountPager.remove(req) + } + return resp, nil +} + +func (e *EnrollmentAccountsServerTransport) dispatchNewListByDepartmentPager(req *http.Request) (*http.Response, error) { + if e.srv.NewListByDepartmentPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByDepartmentPager not implemented")} + } + newListByDepartmentPager := e.newListByDepartmentPager.get(req) + if newListByDepartmentPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/departments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enrollmentAccounts` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + departmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("departmentName")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.EnrollmentAccountsClientListByDepartmentOptions + if filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.EnrollmentAccountsClientListByDepartmentOptions{ + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := e.srv.NewListByDepartmentPager(billingAccountNameParam, departmentNameParam, options) + newListByDepartmentPager = &resp + e.newListByDepartmentPager.add(req, newListByDepartmentPager) + server.PagerResponderInjectNextLinks(newListByDepartmentPager, req, func(page *armbilling.EnrollmentAccountsClientListByDepartmentResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } - resp, err := server.PagerResponderNext(newListPager, req) + resp, err := server.PagerResponderNext(newListByDepartmentPager, req) if err != nil { return nil, err } if !contains([]int{http.StatusOK}, resp.StatusCode) { - e.newListPager.remove(req) + e.newListByDepartmentPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } - if !server.PagerResponderMore(newListPager) { - e.newListPager.remove(req) + if !server.PagerResponderMore(newListByDepartmentPager) { + e.newListByDepartmentPager.remove(req) } return resp, nil } diff --git a/sdk/resourcemanager/billing/armbilling/fake/instructions_server.go b/sdk/resourcemanager/billing/armbilling/fake/instructions_server.go deleted file mode 100644 index 7d6d03a9b6e7..000000000000 --- a/sdk/resourcemanager/billing/armbilling/fake/instructions_server.go +++ /dev/null @@ -1,203 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "context" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" - "net/http" - "net/url" - "regexp" -) - -// InstructionsServer is a fake server for instances of the armbilling.InstructionsClient type. -type InstructionsServer struct { - // Get is the fake for method InstructionsClient.Get - // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, billingAccountName string, billingProfileName string, instructionName string, options *armbilling.InstructionsClientGetOptions) (resp azfake.Responder[armbilling.InstructionsClientGetResponse], errResp azfake.ErrorResponder) - - // NewListByBillingProfilePager is the fake for method InstructionsClient.NewListByBillingProfilePager - // HTTP status codes to indicate success: http.StatusOK - NewListByBillingProfilePager func(billingAccountName string, billingProfileName string, options *armbilling.InstructionsClientListByBillingProfileOptions) (resp azfake.PagerResponder[armbilling.InstructionsClientListByBillingProfileResponse]) - - // Put is the fake for method InstructionsClient.Put - // HTTP status codes to indicate success: http.StatusOK - Put func(ctx context.Context, billingAccountName string, billingProfileName string, instructionName string, parameters armbilling.Instruction, options *armbilling.InstructionsClientPutOptions) (resp azfake.Responder[armbilling.InstructionsClientPutResponse], errResp azfake.ErrorResponder) -} - -// NewInstructionsServerTransport creates a new instance of InstructionsServerTransport with the provided implementation. -// The returned InstructionsServerTransport instance is connected to an instance of armbilling.InstructionsClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewInstructionsServerTransport(srv *InstructionsServer) *InstructionsServerTransport { - return &InstructionsServerTransport{ - srv: srv, - newListByBillingProfilePager: newTracker[azfake.PagerResponder[armbilling.InstructionsClientListByBillingProfileResponse]](), - } -} - -// InstructionsServerTransport connects instances of armbilling.InstructionsClient to instances of InstructionsServer. -// Don't use this type directly, use NewInstructionsServerTransport instead. -type InstructionsServerTransport struct { - srv *InstructionsServer - newListByBillingProfilePager *tracker[azfake.PagerResponder[armbilling.InstructionsClientListByBillingProfileResponse]] -} - -// Do implements the policy.Transporter interface for InstructionsServerTransport. -func (i *InstructionsServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - var resp *http.Response - var err error - - switch method { - case "InstructionsClient.Get": - resp, err = i.dispatchGet(req) - case "InstructionsClient.NewListByBillingProfilePager": - resp, err = i.dispatchNewListByBillingProfilePager(req) - case "InstructionsClient.Put": - resp, err = i.dispatchPut(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } - - if err != nil { - return nil, err - } - - return resp, nil -} - -func (i *InstructionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if i.srv.Get == nil { - return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} - } - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/instructions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) - if err != nil { - return nil, err - } - billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) - if err != nil { - return nil, err - } - instructionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("instructionName")]) - if err != nil { - return nil, err - } - respr, errRespr := i.srv.Get(req.Context(), billingAccountNameParam, billingProfileNameParam, instructionNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Instruction, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (i *InstructionsServerTransport) dispatchNewListByBillingProfilePager(req *http.Request) (*http.Response, error) { - if i.srv.NewListByBillingProfilePager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListByBillingProfilePager not implemented")} - } - newListByBillingProfilePager := i.newListByBillingProfilePager.get(req) - if newListByBillingProfilePager == nil { - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/instructions` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) - if err != nil { - return nil, err - } - billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) - if err != nil { - return nil, err - } - resp := i.srv.NewListByBillingProfilePager(billingAccountNameParam, billingProfileNameParam, nil) - newListByBillingProfilePager = &resp - i.newListByBillingProfilePager.add(req, newListByBillingProfilePager) - server.PagerResponderInjectNextLinks(newListByBillingProfilePager, req, func(page *armbilling.InstructionsClientListByBillingProfileResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListByBillingProfilePager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - i.newListByBillingProfilePager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListByBillingProfilePager) { - i.newListByBillingProfilePager.remove(req) - } - return resp, nil -} - -func (i *InstructionsServerTransport) dispatchPut(req *http.Request) (*http.Response, error) { - if i.srv.Put == nil { - return nil, &nonRetriableError{errors.New("fake for method Put not implemented")} - } - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/instructions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armbilling.Instruction](req) - if err != nil { - return nil, err - } - billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) - if err != nil { - return nil, err - } - billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) - if err != nil { - return nil, err - } - instructionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("instructionName")]) - if err != nil { - return nil, err - } - respr, errRespr := i.srv.Put(req.Context(), billingAccountNameParam, billingProfileNameParam, instructionNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Instruction, req) - if err != nil { - return nil, err - } - return resp, nil -} diff --git a/sdk/resourcemanager/billing/armbilling/fake/internal.go b/sdk/resourcemanager/billing/armbilling/fake/internal.go index 7d2f89ba4bb2..9b74f6994585 100644 --- a/sdk/resourcemanager/billing/armbilling/fake/internal.go +++ b/sdk/resourcemanager/billing/armbilling/fake/internal.go @@ -9,10 +9,11 @@ package fake import ( - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "net/http" "reflect" "sync" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" ) type nonRetriableError struct { @@ -50,6 +51,14 @@ func parseOptional[T any](v string, parse func(v string) (T, error)) (*T, error) return &t, err } +func parseWithCast[T any](v string, parse func(v string) (T, error)) (T, error) { + t, err := parse(v) + if err != nil { + return *new(T), err + } + return t, err +} + func newTracker[T any]() *tracker[T] { return &tracker[T]{ items: map[string]*T{}, diff --git a/sdk/resourcemanager/billing/armbilling/fake/invoices_server.go b/sdk/resourcemanager/billing/armbilling/fake/invoices_server.go index 007adf12950c..cbbb92e100ce 100644 --- a/sdk/resourcemanager/billing/armbilling/fake/invoices_server.go +++ b/sdk/resourcemanager/billing/armbilling/fake/invoices_server.go @@ -12,57 +12,68 @@ import ( "context" "errors" "fmt" + "net/http" + "net/url" + "regexp" + "strconv" + "time" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" - "net/http" - "net/url" - "regexp" ) // InvoicesServer is a fake server for instances of the armbilling.InvoicesClient type. type InvoicesServer struct { - // BeginDownloadBillingSubscriptionInvoice is the fake for method InvoicesClient.BeginDownloadBillingSubscriptionInvoice + // BeginAmend is the fake for method InvoicesClient.BeginAmend + // HTTP status codes to indicate success: http.StatusAccepted + BeginAmend func(ctx context.Context, billingAccountName string, invoiceName string, options *armbilling.InvoicesClientBeginAmendOptions) (resp azfake.PollerResponder[armbilling.InvoicesClientAmendResponse], errResp azfake.ErrorResponder) + + // BeginDownloadByBillingAccount is the fake for method InvoicesClient.BeginDownloadByBillingAccount + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginDownloadByBillingAccount func(ctx context.Context, billingAccountName string, invoiceName string, options *armbilling.InvoicesClientBeginDownloadByBillingAccountOptions) (resp azfake.PollerResponder[armbilling.InvoicesClientDownloadByBillingAccountResponse], errResp azfake.ErrorResponder) + + // BeginDownloadByBillingSubscription is the fake for method InvoicesClient.BeginDownloadByBillingSubscription // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginDownloadBillingSubscriptionInvoice func(ctx context.Context, invoiceName string, downloadToken string, options *armbilling.InvoicesClientBeginDownloadBillingSubscriptionInvoiceOptions) (resp azfake.PollerResponder[armbilling.InvoicesClientDownloadBillingSubscriptionInvoiceResponse], errResp azfake.ErrorResponder) + BeginDownloadByBillingSubscription func(ctx context.Context, invoiceName string, options *armbilling.InvoicesClientBeginDownloadByBillingSubscriptionOptions) (resp azfake.PollerResponder[armbilling.InvoicesClientDownloadByBillingSubscriptionResponse], errResp azfake.ErrorResponder) - // BeginDownloadInvoice is the fake for method InvoicesClient.BeginDownloadInvoice + // BeginDownloadDocumentsByBillingAccount is the fake for method InvoicesClient.BeginDownloadDocumentsByBillingAccount // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginDownloadInvoice func(ctx context.Context, billingAccountName string, invoiceName string, downloadToken string, options *armbilling.InvoicesClientBeginDownloadInvoiceOptions) (resp azfake.PollerResponder[armbilling.InvoicesClientDownloadInvoiceResponse], errResp azfake.ErrorResponder) + BeginDownloadDocumentsByBillingAccount func(ctx context.Context, billingAccountName string, parameters []*armbilling.DocumentDownloadRequest, options *armbilling.InvoicesClientBeginDownloadDocumentsByBillingAccountOptions) (resp azfake.PollerResponder[armbilling.InvoicesClientDownloadDocumentsByBillingAccountResponse], errResp azfake.ErrorResponder) - // BeginDownloadMultipleBillingProfileInvoices is the fake for method InvoicesClient.BeginDownloadMultipleBillingProfileInvoices + // BeginDownloadDocumentsByBillingSubscription is the fake for method InvoicesClient.BeginDownloadDocumentsByBillingSubscription // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginDownloadMultipleBillingProfileInvoices func(ctx context.Context, billingAccountName string, downloadUrls []*string, options *armbilling.InvoicesClientBeginDownloadMultipleBillingProfileInvoicesOptions) (resp azfake.PollerResponder[armbilling.InvoicesClientDownloadMultipleBillingProfileInvoicesResponse], errResp azfake.ErrorResponder) + BeginDownloadDocumentsByBillingSubscription func(ctx context.Context, parameters []*armbilling.DocumentDownloadRequest, options *armbilling.InvoicesClientBeginDownloadDocumentsByBillingSubscriptionOptions) (resp azfake.PollerResponder[armbilling.InvoicesClientDownloadDocumentsByBillingSubscriptionResponse], errResp azfake.ErrorResponder) - // BeginDownloadMultipleBillingSubscriptionInvoices is the fake for method InvoicesClient.BeginDownloadMultipleBillingSubscriptionInvoices + // BeginDownloadSummaryByBillingAccount is the fake for method InvoicesClient.BeginDownloadSummaryByBillingAccount // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginDownloadMultipleBillingSubscriptionInvoices func(ctx context.Context, downloadUrls []*string, options *armbilling.InvoicesClientBeginDownloadMultipleBillingSubscriptionInvoicesOptions) (resp azfake.PollerResponder[armbilling.InvoicesClientDownloadMultipleBillingSubscriptionInvoicesResponse], errResp azfake.ErrorResponder) + BeginDownloadSummaryByBillingAccount func(ctx context.Context, billingAccountName string, invoiceName string, options *armbilling.InvoicesClientBeginDownloadSummaryByBillingAccountOptions) (resp azfake.PollerResponder[armbilling.InvoicesClientDownloadSummaryByBillingAccountResponse], errResp azfake.ErrorResponder) // Get is the fake for method InvoicesClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, billingAccountName string, invoiceName string, options *armbilling.InvoicesClientGetOptions) (resp azfake.Responder[armbilling.InvoicesClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, invoiceName string, options *armbilling.InvoicesClientGetOptions) (resp azfake.Responder[armbilling.InvoicesClientGetResponse], errResp azfake.ErrorResponder) - // GetByID is the fake for method InvoicesClient.GetByID + // GetByBillingAccount is the fake for method InvoicesClient.GetByBillingAccount // HTTP status codes to indicate success: http.StatusOK - GetByID func(ctx context.Context, invoiceName string, options *armbilling.InvoicesClientGetByIDOptions) (resp azfake.Responder[armbilling.InvoicesClientGetByIDResponse], errResp azfake.ErrorResponder) + GetByBillingAccount func(ctx context.Context, billingAccountName string, invoiceName string, options *armbilling.InvoicesClientGetByBillingAccountOptions) (resp azfake.Responder[armbilling.InvoicesClientGetByBillingAccountResponse], errResp azfake.ErrorResponder) - // GetBySubscriptionAndInvoiceID is the fake for method InvoicesClient.GetBySubscriptionAndInvoiceID + // GetByBillingSubscription is the fake for method InvoicesClient.GetByBillingSubscription // HTTP status codes to indicate success: http.StatusOK - GetBySubscriptionAndInvoiceID func(ctx context.Context, invoiceName string, options *armbilling.InvoicesClientGetBySubscriptionAndInvoiceIDOptions) (resp azfake.Responder[armbilling.InvoicesClientGetBySubscriptionAndInvoiceIDResponse], errResp azfake.ErrorResponder) + GetByBillingSubscription func(ctx context.Context, invoiceName string, options *armbilling.InvoicesClientGetByBillingSubscriptionOptions) (resp azfake.Responder[armbilling.InvoicesClientGetByBillingSubscriptionResponse], errResp azfake.ErrorResponder) // NewListByBillingAccountPager is the fake for method InvoicesClient.NewListByBillingAccountPager // HTTP status codes to indicate success: http.StatusOK - NewListByBillingAccountPager func(billingAccountName string, periodStartDate string, periodEndDate string, options *armbilling.InvoicesClientListByBillingAccountOptions) (resp azfake.PagerResponder[armbilling.InvoicesClientListByBillingAccountResponse]) + NewListByBillingAccountPager func(billingAccountName string, options *armbilling.InvoicesClientListByBillingAccountOptions) (resp azfake.PagerResponder[armbilling.InvoicesClientListByBillingAccountResponse]) // NewListByBillingProfilePager is the fake for method InvoicesClient.NewListByBillingProfilePager // HTTP status codes to indicate success: http.StatusOK - NewListByBillingProfilePager func(billingAccountName string, billingProfileName string, periodStartDate string, periodEndDate string, options *armbilling.InvoicesClientListByBillingProfileOptions) (resp azfake.PagerResponder[armbilling.InvoicesClientListByBillingProfileResponse]) + NewListByBillingProfilePager func(billingAccountName string, billingProfileName string, options *armbilling.InvoicesClientListByBillingProfileOptions) (resp azfake.PagerResponder[armbilling.InvoicesClientListByBillingProfileResponse]) // NewListByBillingSubscriptionPager is the fake for method InvoicesClient.NewListByBillingSubscriptionPager // HTTP status codes to indicate success: http.StatusOK - NewListByBillingSubscriptionPager func(periodStartDate string, periodEndDate string, options *armbilling.InvoicesClientListByBillingSubscriptionOptions) (resp azfake.PagerResponder[armbilling.InvoicesClientListByBillingSubscriptionResponse]) + NewListByBillingSubscriptionPager func(options *armbilling.InvoicesClientListByBillingSubscriptionOptions) (resp azfake.PagerResponder[armbilling.InvoicesClientListByBillingSubscriptionResponse]) } // NewInvoicesServerTransport creates a new instance of InvoicesServerTransport with the provided implementation. @@ -70,28 +81,32 @@ type InvoicesServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewInvoicesServerTransport(srv *InvoicesServer) *InvoicesServerTransport { return &InvoicesServerTransport{ - srv: srv, - beginDownloadBillingSubscriptionInvoice: newTracker[azfake.PollerResponder[armbilling.InvoicesClientDownloadBillingSubscriptionInvoiceResponse]](), - beginDownloadInvoice: newTracker[azfake.PollerResponder[armbilling.InvoicesClientDownloadInvoiceResponse]](), - beginDownloadMultipleBillingProfileInvoices: newTracker[azfake.PollerResponder[armbilling.InvoicesClientDownloadMultipleBillingProfileInvoicesResponse]](), - beginDownloadMultipleBillingSubscriptionInvoices: newTracker[azfake.PollerResponder[armbilling.InvoicesClientDownloadMultipleBillingSubscriptionInvoicesResponse]](), - newListByBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.InvoicesClientListByBillingAccountResponse]](), - newListByBillingProfilePager: newTracker[azfake.PagerResponder[armbilling.InvoicesClientListByBillingProfileResponse]](), - newListByBillingSubscriptionPager: newTracker[azfake.PagerResponder[armbilling.InvoicesClientListByBillingSubscriptionResponse]](), + srv: srv, + beginAmend: newTracker[azfake.PollerResponder[armbilling.InvoicesClientAmendResponse]](), + beginDownloadByBillingAccount: newTracker[azfake.PollerResponder[armbilling.InvoicesClientDownloadByBillingAccountResponse]](), + beginDownloadByBillingSubscription: newTracker[azfake.PollerResponder[armbilling.InvoicesClientDownloadByBillingSubscriptionResponse]](), + beginDownloadDocumentsByBillingAccount: newTracker[azfake.PollerResponder[armbilling.InvoicesClientDownloadDocumentsByBillingAccountResponse]](), + beginDownloadDocumentsByBillingSubscription: newTracker[azfake.PollerResponder[armbilling.InvoicesClientDownloadDocumentsByBillingSubscriptionResponse]](), + beginDownloadSummaryByBillingAccount: newTracker[azfake.PollerResponder[armbilling.InvoicesClientDownloadSummaryByBillingAccountResponse]](), + newListByBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.InvoicesClientListByBillingAccountResponse]](), + newListByBillingProfilePager: newTracker[azfake.PagerResponder[armbilling.InvoicesClientListByBillingProfileResponse]](), + newListByBillingSubscriptionPager: newTracker[azfake.PagerResponder[armbilling.InvoicesClientListByBillingSubscriptionResponse]](), } } // InvoicesServerTransport connects instances of armbilling.InvoicesClient to instances of InvoicesServer. // Don't use this type directly, use NewInvoicesServerTransport instead. type InvoicesServerTransport struct { - srv *InvoicesServer - beginDownloadBillingSubscriptionInvoice *tracker[azfake.PollerResponder[armbilling.InvoicesClientDownloadBillingSubscriptionInvoiceResponse]] - beginDownloadInvoice *tracker[azfake.PollerResponder[armbilling.InvoicesClientDownloadInvoiceResponse]] - beginDownloadMultipleBillingProfileInvoices *tracker[azfake.PollerResponder[armbilling.InvoicesClientDownloadMultipleBillingProfileInvoicesResponse]] - beginDownloadMultipleBillingSubscriptionInvoices *tracker[azfake.PollerResponder[armbilling.InvoicesClientDownloadMultipleBillingSubscriptionInvoicesResponse]] - newListByBillingAccountPager *tracker[azfake.PagerResponder[armbilling.InvoicesClientListByBillingAccountResponse]] - newListByBillingProfilePager *tracker[azfake.PagerResponder[armbilling.InvoicesClientListByBillingProfileResponse]] - newListByBillingSubscriptionPager *tracker[azfake.PagerResponder[armbilling.InvoicesClientListByBillingSubscriptionResponse]] + srv *InvoicesServer + beginAmend *tracker[azfake.PollerResponder[armbilling.InvoicesClientAmendResponse]] + beginDownloadByBillingAccount *tracker[azfake.PollerResponder[armbilling.InvoicesClientDownloadByBillingAccountResponse]] + beginDownloadByBillingSubscription *tracker[azfake.PollerResponder[armbilling.InvoicesClientDownloadByBillingSubscriptionResponse]] + beginDownloadDocumentsByBillingAccount *tracker[azfake.PollerResponder[armbilling.InvoicesClientDownloadDocumentsByBillingAccountResponse]] + beginDownloadDocumentsByBillingSubscription *tracker[azfake.PollerResponder[armbilling.InvoicesClientDownloadDocumentsByBillingSubscriptionResponse]] + beginDownloadSummaryByBillingAccount *tracker[azfake.PollerResponder[armbilling.InvoicesClientDownloadSummaryByBillingAccountResponse]] + newListByBillingAccountPager *tracker[azfake.PagerResponder[armbilling.InvoicesClientListByBillingAccountResponse]] + newListByBillingProfilePager *tracker[azfake.PagerResponder[armbilling.InvoicesClientListByBillingProfileResponse]] + newListByBillingSubscriptionPager *tracker[azfake.PagerResponder[armbilling.InvoicesClientListByBillingSubscriptionResponse]] } // Do implements the policy.Transporter interface for InvoicesServerTransport. @@ -106,20 +121,24 @@ func (i *InvoicesServerTransport) Do(req *http.Request) (*http.Response, error) var err error switch method { - case "InvoicesClient.BeginDownloadBillingSubscriptionInvoice": - resp, err = i.dispatchBeginDownloadBillingSubscriptionInvoice(req) - case "InvoicesClient.BeginDownloadInvoice": - resp, err = i.dispatchBeginDownloadInvoice(req) - case "InvoicesClient.BeginDownloadMultipleBillingProfileInvoices": - resp, err = i.dispatchBeginDownloadMultipleBillingProfileInvoices(req) - case "InvoicesClient.BeginDownloadMultipleBillingSubscriptionInvoices": - resp, err = i.dispatchBeginDownloadMultipleBillingSubscriptionInvoices(req) + case "InvoicesClient.BeginAmend": + resp, err = i.dispatchBeginAmend(req) + case "InvoicesClient.BeginDownloadByBillingAccount": + resp, err = i.dispatchBeginDownloadByBillingAccount(req) + case "InvoicesClient.BeginDownloadByBillingSubscription": + resp, err = i.dispatchBeginDownloadByBillingSubscription(req) + case "InvoicesClient.BeginDownloadDocumentsByBillingAccount": + resp, err = i.dispatchBeginDownloadDocumentsByBillingAccount(req) + case "InvoicesClient.BeginDownloadDocumentsByBillingSubscription": + resp, err = i.dispatchBeginDownloadDocumentsByBillingSubscription(req) + case "InvoicesClient.BeginDownloadSummaryByBillingAccount": + resp, err = i.dispatchBeginDownloadSummaryByBillingAccount(req) case "InvoicesClient.Get": resp, err = i.dispatchGet(req) - case "InvoicesClient.GetByID": - resp, err = i.dispatchGetByID(req) - case "InvoicesClient.GetBySubscriptionAndInvoiceID": - resp, err = i.dispatchGetBySubscriptionAndInvoiceID(req) + case "InvoicesClient.GetByBillingAccount": + resp, err = i.dispatchGetByBillingAccount(req) + case "InvoicesClient.GetByBillingSubscription": + resp, err = i.dispatchGetByBillingSubscription(req) case "InvoicesClient.NewListByBillingAccountPager": resp, err = i.dispatchNewListByBillingAccountPager(req) case "InvoicesClient.NewListByBillingProfilePager": @@ -137,57 +156,56 @@ func (i *InvoicesServerTransport) Do(req *http.Request) (*http.Response, error) return resp, nil } -func (i *InvoicesServerTransport) dispatchBeginDownloadBillingSubscriptionInvoice(req *http.Request) (*http.Response, error) { - if i.srv.BeginDownloadBillingSubscriptionInvoice == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginDownloadBillingSubscriptionInvoice not implemented")} +func (i *InvoicesServerTransport) dispatchBeginAmend(req *http.Request) (*http.Response, error) { + if i.srv.BeginAmend == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginAmend not implemented")} } - beginDownloadBillingSubscriptionInvoice := i.beginDownloadBillingSubscriptionInvoice.get(req) - if beginDownloadBillingSubscriptionInvoice == nil { - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/default/billingSubscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/download` + beginAmend := i.beginAmend.get(req) + if beginAmend == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/amend` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - qp := req.URL.Query() - invoiceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceName")]) + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) if err != nil { return nil, err } - downloadTokenParam, err := url.QueryUnescape(qp.Get("downloadToken")) + invoiceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceName")]) if err != nil { return nil, err } - respr, errRespr := i.srv.BeginDownloadBillingSubscriptionInvoice(req.Context(), invoiceNameParam, downloadTokenParam, nil) + respr, errRespr := i.srv.BeginAmend(req.Context(), billingAccountNameParam, invoiceNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } - beginDownloadBillingSubscriptionInvoice = &respr - i.beginDownloadBillingSubscriptionInvoice.add(req, beginDownloadBillingSubscriptionInvoice) + beginAmend = &respr + i.beginAmend.add(req, beginAmend) } - resp, err := server.PollerResponderNext(beginDownloadBillingSubscriptionInvoice, req) + resp, err := server.PollerResponderNext(beginAmend, req) if err != nil { return nil, err } - if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { - i.beginDownloadBillingSubscriptionInvoice.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + if !contains([]int{http.StatusAccepted}, resp.StatusCode) { + i.beginAmend.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted", resp.StatusCode)} } - if !server.PollerResponderMore(beginDownloadBillingSubscriptionInvoice) { - i.beginDownloadBillingSubscriptionInvoice.remove(req) + if !server.PollerResponderMore(beginAmend) { + i.beginAmend.remove(req) } return resp, nil } -func (i *InvoicesServerTransport) dispatchBeginDownloadInvoice(req *http.Request) (*http.Response, error) { - if i.srv.BeginDownloadInvoice == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginDownloadInvoice not implemented")} +func (i *InvoicesServerTransport) dispatchBeginDownloadByBillingAccount(req *http.Request) (*http.Response, error) { + if i.srv.BeginDownloadByBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDownloadByBillingAccount not implemented")} } - beginDownloadInvoice := i.beginDownloadInvoice.get(req) - if beginDownloadInvoice == nil { + beginDownloadByBillingAccount := i.beginDownloadByBillingAccount.get(req) + if beginDownloadByBillingAccount == nil { const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/download` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) @@ -203,47 +221,106 @@ func (i *InvoicesServerTransport) dispatchBeginDownloadInvoice(req *http.Request if err != nil { return nil, err } - downloadTokenParam, err := url.QueryUnescape(qp.Get("downloadToken")) + documentNameUnescaped, err := url.QueryUnescape(qp.Get("documentName")) + if err != nil { + return nil, err + } + documentNameParam := getOptional(documentNameUnescaped) + var options *armbilling.InvoicesClientBeginDownloadByBillingAccountOptions + if documentNameParam != nil { + options = &armbilling.InvoicesClientBeginDownloadByBillingAccountOptions{ + DocumentName: documentNameParam, + } + } + respr, errRespr := i.srv.BeginDownloadByBillingAccount(req.Context(), billingAccountNameParam, invoiceNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDownloadByBillingAccount = &respr + i.beginDownloadByBillingAccount.add(req, beginDownloadByBillingAccount) + } + + resp, err := server.PollerResponderNext(beginDownloadByBillingAccount, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + i.beginDownloadByBillingAccount.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDownloadByBillingAccount) { + i.beginDownloadByBillingAccount.remove(req) + } + + return resp, nil +} + +func (i *InvoicesServerTransport) dispatchBeginDownloadByBillingSubscription(req *http.Request) (*http.Response, error) { + if i.srv.BeginDownloadByBillingSubscription == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDownloadByBillingSubscription not implemented")} + } + beginDownloadByBillingSubscription := i.beginDownloadByBillingSubscription.get(req) + if beginDownloadByBillingSubscription == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/default/billingSubscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/download` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + invoiceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceName")]) + if err != nil { + return nil, err + } + documentNameUnescaped, err := url.QueryUnescape(qp.Get("documentName")) if err != nil { return nil, err } - respr, errRespr := i.srv.BeginDownloadInvoice(req.Context(), billingAccountNameParam, invoiceNameParam, downloadTokenParam, nil) + documentNameParam := getOptional(documentNameUnescaped) + var options *armbilling.InvoicesClientBeginDownloadByBillingSubscriptionOptions + if documentNameParam != nil { + options = &armbilling.InvoicesClientBeginDownloadByBillingSubscriptionOptions{ + DocumentName: documentNameParam, + } + } + respr, errRespr := i.srv.BeginDownloadByBillingSubscription(req.Context(), invoiceNameParam, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } - beginDownloadInvoice = &respr - i.beginDownloadInvoice.add(req, beginDownloadInvoice) + beginDownloadByBillingSubscription = &respr + i.beginDownloadByBillingSubscription.add(req, beginDownloadByBillingSubscription) } - resp, err := server.PollerResponderNext(beginDownloadInvoice, req) + resp, err := server.PollerResponderNext(beginDownloadByBillingSubscription, req) if err != nil { return nil, err } if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { - i.beginDownloadInvoice.remove(req) + i.beginDownloadByBillingSubscription.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } - if !server.PollerResponderMore(beginDownloadInvoice) { - i.beginDownloadInvoice.remove(req) + if !server.PollerResponderMore(beginDownloadByBillingSubscription) { + i.beginDownloadByBillingSubscription.remove(req) } return resp, nil } -func (i *InvoicesServerTransport) dispatchBeginDownloadMultipleBillingProfileInvoices(req *http.Request) (*http.Response, error) { - if i.srv.BeginDownloadMultipleBillingProfileInvoices == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginDownloadMultipleBillingProfileInvoices not implemented")} +func (i *InvoicesServerTransport) dispatchBeginDownloadDocumentsByBillingAccount(req *http.Request) (*http.Response, error) { + if i.srv.BeginDownloadDocumentsByBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDownloadDocumentsByBillingAccount not implemented")} } - beginDownloadMultipleBillingProfileInvoices := i.beginDownloadMultipleBillingProfileInvoices.get(req) - if beginDownloadMultipleBillingProfileInvoices == nil { + beginDownloadDocumentsByBillingAccount := i.beginDownloadDocumentsByBillingAccount.get(req) + if beginDownloadDocumentsByBillingAccount == nil { const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/downloadDocuments` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[[]*string](req) + body, err := server.UnmarshalRequestAsJSON[[]*armbilling.DocumentDownloadRequest](req) if err != nil { return nil, err } @@ -251,65 +328,109 @@ func (i *InvoicesServerTransport) dispatchBeginDownloadMultipleBillingProfileInv if err != nil { return nil, err } - respr, errRespr := i.srv.BeginDownloadMultipleBillingProfileInvoices(req.Context(), billingAccountNameParam, body, nil) + respr, errRespr := i.srv.BeginDownloadDocumentsByBillingAccount(req.Context(), billingAccountNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } - beginDownloadMultipleBillingProfileInvoices = &respr - i.beginDownloadMultipleBillingProfileInvoices.add(req, beginDownloadMultipleBillingProfileInvoices) + beginDownloadDocumentsByBillingAccount = &respr + i.beginDownloadDocumentsByBillingAccount.add(req, beginDownloadDocumentsByBillingAccount) } - resp, err := server.PollerResponderNext(beginDownloadMultipleBillingProfileInvoices, req) + resp, err := server.PollerResponderNext(beginDownloadDocumentsByBillingAccount, req) if err != nil { return nil, err } if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { - i.beginDownloadMultipleBillingProfileInvoices.remove(req) + i.beginDownloadDocumentsByBillingAccount.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } - if !server.PollerResponderMore(beginDownloadMultipleBillingProfileInvoices) { - i.beginDownloadMultipleBillingProfileInvoices.remove(req) + if !server.PollerResponderMore(beginDownloadDocumentsByBillingAccount) { + i.beginDownloadDocumentsByBillingAccount.remove(req) } return resp, nil } -func (i *InvoicesServerTransport) dispatchBeginDownloadMultipleBillingSubscriptionInvoices(req *http.Request) (*http.Response, error) { - if i.srv.BeginDownloadMultipleBillingSubscriptionInvoices == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginDownloadMultipleBillingSubscriptionInvoices not implemented")} +func (i *InvoicesServerTransport) dispatchBeginDownloadDocumentsByBillingSubscription(req *http.Request) (*http.Response, error) { + if i.srv.BeginDownloadDocumentsByBillingSubscription == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDownloadDocumentsByBillingSubscription not implemented")} } - beginDownloadMultipleBillingSubscriptionInvoices := i.beginDownloadMultipleBillingSubscriptionInvoices.get(req) - if beginDownloadMultipleBillingSubscriptionInvoices == nil { + beginDownloadDocumentsByBillingSubscription := i.beginDownloadDocumentsByBillingSubscription.get(req) + if beginDownloadDocumentsByBillingSubscription == nil { const regexStr = `/providers/Microsoft\.Billing/billingAccounts/default/billingSubscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/downloadDocuments` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[[]*string](req) + body, err := server.UnmarshalRequestAsJSON[[]*armbilling.DocumentDownloadRequest](req) if err != nil { return nil, err } - respr, errRespr := i.srv.BeginDownloadMultipleBillingSubscriptionInvoices(req.Context(), body, nil) + respr, errRespr := i.srv.BeginDownloadDocumentsByBillingSubscription(req.Context(), body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } - beginDownloadMultipleBillingSubscriptionInvoices = &respr - i.beginDownloadMultipleBillingSubscriptionInvoices.add(req, beginDownloadMultipleBillingSubscriptionInvoices) + beginDownloadDocumentsByBillingSubscription = &respr + i.beginDownloadDocumentsByBillingSubscription.add(req, beginDownloadDocumentsByBillingSubscription) } - resp, err := server.PollerResponderNext(beginDownloadMultipleBillingSubscriptionInvoices, req) + resp, err := server.PollerResponderNext(beginDownloadDocumentsByBillingSubscription, req) if err != nil { return nil, err } if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { - i.beginDownloadMultipleBillingSubscriptionInvoices.remove(req) + i.beginDownloadDocumentsByBillingSubscription.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } - if !server.PollerResponderMore(beginDownloadMultipleBillingSubscriptionInvoices) { - i.beginDownloadMultipleBillingSubscriptionInvoices.remove(req) + if !server.PollerResponderMore(beginDownloadDocumentsByBillingSubscription) { + i.beginDownloadDocumentsByBillingSubscription.remove(req) + } + + return resp, nil +} + +func (i *InvoicesServerTransport) dispatchBeginDownloadSummaryByBillingAccount(req *http.Request) (*http.Response, error) { + if i.srv.BeginDownloadSummaryByBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDownloadSummaryByBillingAccount not implemented")} + } + beginDownloadSummaryByBillingAccount := i.beginDownloadSummaryByBillingAccount.get(req) + if beginDownloadSummaryByBillingAccount == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/downloadSummary` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + invoiceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.BeginDownloadSummaryByBillingAccount(req.Context(), billingAccountNameParam, invoiceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDownloadSummaryByBillingAccount = &respr + i.beginDownloadSummaryByBillingAccount.add(req, beginDownloadSummaryByBillingAccount) + } + + resp, err := server.PollerResponderNext(beginDownloadSummaryByBillingAccount, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + i.beginDownloadSummaryByBillingAccount.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDownloadSummaryByBillingAccount) { + i.beginDownloadSummaryByBillingAccount.remove(req) } return resp, nil @@ -319,21 +440,17 @@ func (i *InvoicesServerTransport) dispatchGet(req *http.Request) (*http.Response if i.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/default/invoices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) - if err != nil { - return nil, err - } invoiceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceName")]) if err != nil { return nil, err } - respr, errRespr := i.srv.Get(req.Context(), billingAccountNameParam, invoiceNameParam, nil) + respr, errRespr := i.srv.Get(req.Context(), invoiceNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -348,21 +465,25 @@ func (i *InvoicesServerTransport) dispatchGet(req *http.Request) (*http.Response return resp, nil } -func (i *InvoicesServerTransport) dispatchGetByID(req *http.Request) (*http.Response, error) { - if i.srv.GetByID == nil { - return nil, &nonRetriableError{errors.New("fake for method GetByID not implemented")} +func (i *InvoicesServerTransport) dispatchGetByBillingAccount(req *http.Request) (*http.Response, error) { + if i.srv.GetByBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByBillingAccount not implemented")} } - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/default/invoices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } invoiceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceName")]) if err != nil { return nil, err } - respr, errRespr := i.srv.GetByID(req.Context(), invoiceNameParam, nil) + respr, errRespr := i.srv.GetByBillingAccount(req.Context(), billingAccountNameParam, invoiceNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -377,9 +498,9 @@ func (i *InvoicesServerTransport) dispatchGetByID(req *http.Request) (*http.Resp return resp, nil } -func (i *InvoicesServerTransport) dispatchGetBySubscriptionAndInvoiceID(req *http.Request) (*http.Response, error) { - if i.srv.GetBySubscriptionAndInvoiceID == nil { - return nil, &nonRetriableError{errors.New("fake for method GetBySubscriptionAndInvoiceID not implemented")} +func (i *InvoicesServerTransport) dispatchGetByBillingSubscription(req *http.Request) (*http.Response, error) { + if i.srv.GetByBillingSubscription == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByBillingSubscription not implemented")} } const regexStr = `/providers/Microsoft\.Billing/billingAccounts/default/billingSubscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) @@ -391,7 +512,7 @@ func (i *InvoicesServerTransport) dispatchGetBySubscriptionAndInvoiceID(req *htt if err != nil { return nil, err } - respr, errRespr := i.srv.GetBySubscriptionAndInvoiceID(req.Context(), invoiceNameParam, nil) + respr, errRespr := i.srv.GetByBillingSubscription(req.Context(), invoiceNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -423,15 +544,87 @@ func (i *InvoicesServerTransport) dispatchNewListByBillingAccountPager(req *http if err != nil { return nil, err } - periodStartDateParam, err := url.QueryUnescape(qp.Get("periodStartDate")) + periodStartDateUnescaped, err := url.QueryUnescape(qp.Get("periodStartDate")) + if err != nil { + return nil, err + } + periodStartDateParam, err := parseOptional(periodStartDateUnescaped, func(v string) (time.Time, error) { return time.Parse("2006-01-02", v) }) + if err != nil { + return nil, err + } + periodEndDateUnescaped, err := url.QueryUnescape(qp.Get("periodEndDate")) + if err != nil { + return nil, err + } + periodEndDateParam, err := parseOptional(periodEndDateUnescaped, func(v string) (time.Time, error) { return time.Parse("2006-01-02", v) }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) if err != nil { return nil, err } - periodEndDateParam, err := url.QueryUnescape(qp.Get("periodEndDate")) + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) if err != nil { return nil, err } - resp := i.srv.NewListByBillingAccountPager(billingAccountNameParam, periodStartDateParam, periodEndDateParam, nil) + searchParam := getOptional(searchUnescaped) + var options *armbilling.InvoicesClientListByBillingAccountOptions + if periodStartDateParam != nil || periodEndDateParam != nil || filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.InvoicesClientListByBillingAccountOptions{ + PeriodStartDate: periodStartDateParam, + PeriodEndDate: periodEndDateParam, + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := i.srv.NewListByBillingAccountPager(billingAccountNameParam, options) newListByBillingAccountPager = &resp i.newListByBillingAccountPager.add(req, newListByBillingAccountPager) server.PagerResponderInjectNextLinks(newListByBillingAccountPager, req, func(page *armbilling.InvoicesClientListByBillingAccountResponse, createLink func() string) { @@ -473,15 +666,87 @@ func (i *InvoicesServerTransport) dispatchNewListByBillingProfilePager(req *http if err != nil { return nil, err } - periodStartDateParam, err := url.QueryUnescape(qp.Get("periodStartDate")) + periodStartDateUnescaped, err := url.QueryUnescape(qp.Get("periodStartDate")) + if err != nil { + return nil, err + } + periodStartDateParam, err := parseOptional(periodStartDateUnescaped, func(v string) (time.Time, error) { return time.Parse("2006-01-02", v) }) + if err != nil { + return nil, err + } + periodEndDateUnescaped, err := url.QueryUnescape(qp.Get("periodEndDate")) + if err != nil { + return nil, err + } + periodEndDateParam, err := parseOptional(periodEndDateUnescaped, func(v string) (time.Time, error) { return time.Parse("2006-01-02", v) }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) if err != nil { return nil, err } - periodEndDateParam, err := url.QueryUnescape(qp.Get("periodEndDate")) + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) if err != nil { return nil, err } - resp := i.srv.NewListByBillingProfilePager(billingAccountNameParam, billingProfileNameParam, periodStartDateParam, periodEndDateParam, nil) + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.InvoicesClientListByBillingProfileOptions + if periodStartDateParam != nil || periodEndDateParam != nil || filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.InvoicesClientListByBillingProfileOptions{ + PeriodStartDate: periodStartDateParam, + PeriodEndDate: periodEndDateParam, + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := i.srv.NewListByBillingProfilePager(billingAccountNameParam, billingProfileNameParam, options) newListByBillingProfilePager = &resp i.newListByBillingProfilePager.add(req, newListByBillingProfilePager) server.PagerResponderInjectNextLinks(newListByBillingProfilePager, req, func(page *armbilling.InvoicesClientListByBillingProfileResponse, createLink func() string) { @@ -515,15 +780,87 @@ func (i *InvoicesServerTransport) dispatchNewListByBillingSubscriptionPager(req return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() - periodStartDateParam, err := url.QueryUnescape(qp.Get("periodStartDate")) + periodStartDateUnescaped, err := url.QueryUnescape(qp.Get("periodStartDate")) if err != nil { return nil, err } - periodEndDateParam, err := url.QueryUnescape(qp.Get("periodEndDate")) + periodStartDateParam, err := parseOptional(periodStartDateUnescaped, func(v string) (time.Time, error) { return time.Parse("2006-01-02", v) }) if err != nil { return nil, err } - resp := i.srv.NewListByBillingSubscriptionPager(periodStartDateParam, periodEndDateParam, nil) + periodEndDateUnescaped, err := url.QueryUnescape(qp.Get("periodEndDate")) + if err != nil { + return nil, err + } + periodEndDateParam, err := parseOptional(periodEndDateUnescaped, func(v string) (time.Time, error) { return time.Parse("2006-01-02", v) }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.InvoicesClientListByBillingSubscriptionOptions + if periodStartDateParam != nil || periodEndDateParam != nil || filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.InvoicesClientListByBillingSubscriptionOptions{ + PeriodStartDate: periodStartDateParam, + PeriodEndDate: periodEndDateParam, + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := i.srv.NewListByBillingSubscriptionPager(options) newListByBillingSubscriptionPager = &resp i.newListByBillingSubscriptionPager.add(req, newListByBillingSubscriptionPager) server.PagerResponderInjectNextLinks(newListByBillingSubscriptionPager, req, func(page *armbilling.InvoicesClientListByBillingSubscriptionResponse, createLink func() string) { diff --git a/sdk/resourcemanager/billing/armbilling/fake/invoicesections_server.go b/sdk/resourcemanager/billing/armbilling/fake/invoicesections_server.go index 1d3dcad6bb98..fab7b99e45f6 100644 --- a/sdk/resourcemanager/billing/armbilling/fake/invoicesections_server.go +++ b/sdk/resourcemanager/billing/armbilling/fake/invoicesections_server.go @@ -12,22 +12,28 @@ import ( "context" "errors" "fmt" + "net/http" + "net/url" + "regexp" + "strconv" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" - "net/http" - "net/url" - "regexp" ) // InvoiceSectionsServer is a fake server for instances of the armbilling.InvoiceSectionsClient type. type InvoiceSectionsServer struct { // BeginCreateOrUpdate is the fake for method InvoiceSectionsClient.BeginCreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted BeginCreateOrUpdate func(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, parameters armbilling.InvoiceSection, options *armbilling.InvoiceSectionsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armbilling.InvoiceSectionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + // BeginDelete is the fake for method InvoiceSectionsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, options *armbilling.InvoiceSectionsClientBeginDeleteOptions) (resp azfake.PollerResponder[armbilling.InvoiceSectionsClientDeleteResponse], errResp azfake.ErrorResponder) + // Get is the fake for method InvoiceSectionsClient.Get // HTTP status codes to indicate success: http.StatusOK Get func(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, options *armbilling.InvoiceSectionsClientGetOptions) (resp azfake.Responder[armbilling.InvoiceSectionsClientGetResponse], errResp azfake.ErrorResponder) @@ -35,6 +41,10 @@ type InvoiceSectionsServer struct { // NewListByBillingProfilePager is the fake for method InvoiceSectionsClient.NewListByBillingProfilePager // HTTP status codes to indicate success: http.StatusOK NewListByBillingProfilePager func(billingAccountName string, billingProfileName string, options *armbilling.InvoiceSectionsClientListByBillingProfileOptions) (resp azfake.PagerResponder[armbilling.InvoiceSectionsClientListByBillingProfileResponse]) + + // ValidateDeleteEligibility is the fake for method InvoiceSectionsClient.ValidateDeleteEligibility + // HTTP status codes to indicate success: http.StatusOK + ValidateDeleteEligibility func(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, options *armbilling.InvoiceSectionsClientValidateDeleteEligibilityOptions) (resp azfake.Responder[armbilling.InvoiceSectionsClientValidateDeleteEligibilityResponse], errResp azfake.ErrorResponder) } // NewInvoiceSectionsServerTransport creates a new instance of InvoiceSectionsServerTransport with the provided implementation. @@ -44,6 +54,7 @@ func NewInvoiceSectionsServerTransport(srv *InvoiceSectionsServer) *InvoiceSecti return &InvoiceSectionsServerTransport{ srv: srv, beginCreateOrUpdate: newTracker[azfake.PollerResponder[armbilling.InvoiceSectionsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armbilling.InvoiceSectionsClientDeleteResponse]](), newListByBillingProfilePager: newTracker[azfake.PagerResponder[armbilling.InvoiceSectionsClientListByBillingProfileResponse]](), } } @@ -53,6 +64,7 @@ func NewInvoiceSectionsServerTransport(srv *InvoiceSectionsServer) *InvoiceSecti type InvoiceSectionsServerTransport struct { srv *InvoiceSectionsServer beginCreateOrUpdate *tracker[azfake.PollerResponder[armbilling.InvoiceSectionsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armbilling.InvoiceSectionsClientDeleteResponse]] newListByBillingProfilePager *tracker[azfake.PagerResponder[armbilling.InvoiceSectionsClientListByBillingProfileResponse]] } @@ -70,10 +82,14 @@ func (i *InvoiceSectionsServerTransport) Do(req *http.Request) (*http.Response, switch method { case "InvoiceSectionsClient.BeginCreateOrUpdate": resp, err = i.dispatchBeginCreateOrUpdate(req) + case "InvoiceSectionsClient.BeginDelete": + resp, err = i.dispatchBeginDelete(req) case "InvoiceSectionsClient.Get": resp, err = i.dispatchGet(req) case "InvoiceSectionsClient.NewListByBillingProfilePager": resp, err = i.dispatchNewListByBillingProfilePager(req) + case "InvoiceSectionsClient.ValidateDeleteEligibility": + resp, err = i.dispatchValidateDeleteEligibility(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -126,9 +142,9 @@ func (i *InvoiceSectionsServerTransport) dispatchBeginCreateOrUpdate(req *http.R return nil, err } - if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { i.beginCreateOrUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} } if !server.PollerResponderMore(beginCreateOrUpdate) { i.beginCreateOrUpdate.remove(req) @@ -137,6 +153,54 @@ func (i *InvoiceSectionsServerTransport) dispatchBeginCreateOrUpdate(req *http.R return resp, nil } +func (i *InvoiceSectionsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if i.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := i.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoiceSections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + invoiceSectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceSectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.BeginDelete(req.Context(), billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + i.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + i.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + i.beginDelete.remove(req) + } + + return resp, nil +} + func (i *InvoiceSectionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if i.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} @@ -186,6 +250,7 @@ func (i *InvoiceSectionsServerTransport) dispatchNewListByBillingProfilePager(re if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } + qp := req.URL.Query() billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) if err != nil { return nil, err @@ -194,7 +259,78 @@ func (i *InvoiceSectionsServerTransport) dispatchNewListByBillingProfilePager(re if err != nil { return nil, err } - resp := i.srv.NewListByBillingProfilePager(billingAccountNameParam, billingProfileNameParam, nil) + includeDeletedUnescaped, err := url.QueryUnescape(qp.Get("includeDeleted")) + if err != nil { + return nil, err + } + includeDeletedParam, err := parseOptional(includeDeletedUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.InvoiceSectionsClientListByBillingProfileOptions + if includeDeletedParam != nil || filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.InvoiceSectionsClientListByBillingProfileOptions{ + IncludeDeleted: includeDeletedParam, + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := i.srv.NewListByBillingProfilePager(billingAccountNameParam, billingProfileNameParam, options) newListByBillingProfilePager = &resp i.newListByBillingProfilePager.add(req, newListByBillingProfilePager) server.PagerResponderInjectNextLinks(newListByBillingProfilePager, req, func(page *armbilling.InvoiceSectionsClientListByBillingProfileResponse, createLink func() string) { @@ -214,3 +350,40 @@ func (i *InvoiceSectionsServerTransport) dispatchNewListByBillingProfilePager(re } return resp, nil } + +func (i *InvoiceSectionsServerTransport) dispatchValidateDeleteEligibility(req *http.Request) (*http.Response, error) { + if i.srv.ValidateDeleteEligibility == nil { + return nil, &nonRetriableError{errors.New("fake for method ValidateDeleteEligibility not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoiceSections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validateDeleteEligibility` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + invoiceSectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceSectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.ValidateDeleteEligibility(req.Context(), billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DeleteInvoiceSectionEligibilityResult, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/fake/operations_server.go b/sdk/resourcemanager/billing/armbilling/fake/operations_server.go index ae011b83e691..b72acbab8efc 100644 --- a/sdk/resourcemanager/billing/armbilling/fake/operations_server.go +++ b/sdk/resourcemanager/billing/armbilling/fake/operations_server.go @@ -11,12 +11,13 @@ package fake import ( "errors" "fmt" + "net/http" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" - "net/http" ) // OperationsServer is a fake server for instances of the armbilling.OperationsClient type. diff --git a/sdk/resourcemanager/billing/armbilling/fake/partnertransfers_server.go b/sdk/resourcemanager/billing/armbilling/fake/partnertransfers_server.go new file mode 100644 index 000000000000..2ddfff374544 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/fake/partnertransfers_server.go @@ -0,0 +1,263 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "regexp" + + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// PartnerTransfersServer is a fake server for instances of the armbilling.PartnerTransfersClient type. +type PartnerTransfersServer struct { + // Cancel is the fake for method PartnerTransfersClient.Cancel + // HTTP status codes to indicate success: http.StatusOK + Cancel func(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, transferName string, options *armbilling.PartnerTransfersClientCancelOptions) (resp azfake.Responder[armbilling.PartnerTransfersClientCancelResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method PartnerTransfersClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, transferName string, options *armbilling.PartnerTransfersClientGetOptions) (resp azfake.Responder[armbilling.PartnerTransfersClientGetResponse], errResp azfake.ErrorResponder) + + // Initiate is the fake for method PartnerTransfersClient.Initiate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + Initiate func(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, transferName string, parameters armbilling.PartnerInitiateTransferRequest, options *armbilling.PartnerTransfersClientInitiateOptions) (resp azfake.Responder[armbilling.PartnerTransfersClientInitiateResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method PartnerTransfersClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(billingAccountName string, billingProfileName string, customerName string, options *armbilling.PartnerTransfersClientListOptions) (resp azfake.PagerResponder[armbilling.PartnerTransfersClientListResponse]) +} + +// NewPartnerTransfersServerTransport creates a new instance of PartnerTransfersServerTransport with the provided implementation. +// The returned PartnerTransfersServerTransport instance is connected to an instance of armbilling.PartnerTransfersClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewPartnerTransfersServerTransport(srv *PartnerTransfersServer) *PartnerTransfersServerTransport { + return &PartnerTransfersServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armbilling.PartnerTransfersClientListResponse]](), + } +} + +// PartnerTransfersServerTransport connects instances of armbilling.PartnerTransfersClient to instances of PartnerTransfersServer. +// Don't use this type directly, use NewPartnerTransfersServerTransport instead. +type PartnerTransfersServerTransport struct { + srv *PartnerTransfersServer + newListPager *tracker[azfake.PagerResponder[armbilling.PartnerTransfersClientListResponse]] +} + +// Do implements the policy.Transporter interface for PartnerTransfersServerTransport. +func (p *PartnerTransfersServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "PartnerTransfersClient.Cancel": + resp, err = p.dispatchCancel(req) + case "PartnerTransfersClient.Get": + resp, err = p.dispatchGet(req) + case "PartnerTransfersClient.Initiate": + resp, err = p.dispatchInitiate(req) + case "PartnerTransfersClient.NewListPager": + resp, err = p.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (p *PartnerTransfersServerTransport) dispatchCancel(req *http.Request) (*http.Response, error) { + if p.srv.Cancel == nil { + return nil, &nonRetriableError{errors.New("fake for method Cancel not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/transfers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/cancel` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) + if err != nil { + return nil, err + } + transferNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("transferName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Cancel(req.Context(), billingAccountNameParam, billingProfileNameParam, customerNameParam, transferNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PartnerTransferDetails, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PartnerTransfersServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if p.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/transfers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) + if err != nil { + return nil, err + } + transferNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("transferName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Get(req.Context(), billingAccountNameParam, billingProfileNameParam, customerNameParam, transferNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PartnerTransferDetails, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PartnerTransfersServerTransport) dispatchInitiate(req *http.Request) (*http.Response, error) { + if p.srv.Initiate == nil { + return nil, &nonRetriableError{errors.New("fake for method Initiate not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/transfers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.PartnerInitiateTransferRequest](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) + if err != nil { + return nil, err + } + transferNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("transferName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Initiate(req.Context(), billingAccountNameParam, billingProfileNameParam, customerNameParam, transferNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PartnerTransferDetails, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PartnerTransfersServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := p.newListPager.get(req) + if newListPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/transfers` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) + if err != nil { + return nil, err + } + resp := p.srv.NewListPager(billingAccountNameParam, billingProfileNameParam, customerNameParam, nil) + newListPager = &resp + p.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armbilling.PartnerTransfersClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + p.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/fake/paymentmethods_server.go b/sdk/resourcemanager/billing/armbilling/fake/paymentmethods_server.go new file mode 100644 index 000000000000..4dbc9ad461ed --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/fake/paymentmethods_server.go @@ -0,0 +1,346 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "regexp" + + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// PaymentMethodsServer is a fake server for instances of the armbilling.PaymentMethodsClient type. +type PaymentMethodsServer struct { + // DeleteByUser is the fake for method PaymentMethodsClient.DeleteByUser + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + DeleteByUser func(ctx context.Context, paymentMethodName string, options *armbilling.PaymentMethodsClientDeleteByUserOptions) (resp azfake.Responder[armbilling.PaymentMethodsClientDeleteByUserResponse], errResp azfake.ErrorResponder) + + // GetByBillingAccount is the fake for method PaymentMethodsClient.GetByBillingAccount + // HTTP status codes to indicate success: http.StatusOK + GetByBillingAccount func(ctx context.Context, billingAccountName string, paymentMethodName string, options *armbilling.PaymentMethodsClientGetByBillingAccountOptions) (resp azfake.Responder[armbilling.PaymentMethodsClientGetByBillingAccountResponse], errResp azfake.ErrorResponder) + + // GetByBillingProfile is the fake for method PaymentMethodsClient.GetByBillingProfile + // HTTP status codes to indicate success: http.StatusOK + GetByBillingProfile func(ctx context.Context, billingAccountName string, billingProfileName string, paymentMethodName string, options *armbilling.PaymentMethodsClientGetByBillingProfileOptions) (resp azfake.Responder[armbilling.PaymentMethodsClientGetByBillingProfileResponse], errResp azfake.ErrorResponder) + + // GetByUser is the fake for method PaymentMethodsClient.GetByUser + // HTTP status codes to indicate success: http.StatusOK + GetByUser func(ctx context.Context, paymentMethodName string, options *armbilling.PaymentMethodsClientGetByUserOptions) (resp azfake.Responder[armbilling.PaymentMethodsClientGetByUserResponse], errResp azfake.ErrorResponder) + + // NewListByBillingAccountPager is the fake for method PaymentMethodsClient.NewListByBillingAccountPager + // HTTP status codes to indicate success: http.StatusOK + NewListByBillingAccountPager func(billingAccountName string, options *armbilling.PaymentMethodsClientListByBillingAccountOptions) (resp azfake.PagerResponder[armbilling.PaymentMethodsClientListByBillingAccountResponse]) + + // NewListByBillingProfilePager is the fake for method PaymentMethodsClient.NewListByBillingProfilePager + // HTTP status codes to indicate success: http.StatusOK + NewListByBillingProfilePager func(billingAccountName string, billingProfileName string, options *armbilling.PaymentMethodsClientListByBillingProfileOptions) (resp azfake.PagerResponder[armbilling.PaymentMethodsClientListByBillingProfileResponse]) + + // NewListByUserPager is the fake for method PaymentMethodsClient.NewListByUserPager + // HTTP status codes to indicate success: http.StatusOK + NewListByUserPager func(options *armbilling.PaymentMethodsClientListByUserOptions) (resp azfake.PagerResponder[armbilling.PaymentMethodsClientListByUserResponse]) +} + +// NewPaymentMethodsServerTransport creates a new instance of PaymentMethodsServerTransport with the provided implementation. +// The returned PaymentMethodsServerTransport instance is connected to an instance of armbilling.PaymentMethodsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewPaymentMethodsServerTransport(srv *PaymentMethodsServer) *PaymentMethodsServerTransport { + return &PaymentMethodsServerTransport{ + srv: srv, + newListByBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.PaymentMethodsClientListByBillingAccountResponse]](), + newListByBillingProfilePager: newTracker[azfake.PagerResponder[armbilling.PaymentMethodsClientListByBillingProfileResponse]](), + newListByUserPager: newTracker[azfake.PagerResponder[armbilling.PaymentMethodsClientListByUserResponse]](), + } +} + +// PaymentMethodsServerTransport connects instances of armbilling.PaymentMethodsClient to instances of PaymentMethodsServer. +// Don't use this type directly, use NewPaymentMethodsServerTransport instead. +type PaymentMethodsServerTransport struct { + srv *PaymentMethodsServer + newListByBillingAccountPager *tracker[azfake.PagerResponder[armbilling.PaymentMethodsClientListByBillingAccountResponse]] + newListByBillingProfilePager *tracker[azfake.PagerResponder[armbilling.PaymentMethodsClientListByBillingProfileResponse]] + newListByUserPager *tracker[azfake.PagerResponder[armbilling.PaymentMethodsClientListByUserResponse]] +} + +// Do implements the policy.Transporter interface for PaymentMethodsServerTransport. +func (p *PaymentMethodsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "PaymentMethodsClient.DeleteByUser": + resp, err = p.dispatchDeleteByUser(req) + case "PaymentMethodsClient.GetByBillingAccount": + resp, err = p.dispatchGetByBillingAccount(req) + case "PaymentMethodsClient.GetByBillingProfile": + resp, err = p.dispatchGetByBillingProfile(req) + case "PaymentMethodsClient.GetByUser": + resp, err = p.dispatchGetByUser(req) + case "PaymentMethodsClient.NewListByBillingAccountPager": + resp, err = p.dispatchNewListByBillingAccountPager(req) + case "PaymentMethodsClient.NewListByBillingProfilePager": + resp, err = p.dispatchNewListByBillingProfilePager(req) + case "PaymentMethodsClient.NewListByUserPager": + resp, err = p.dispatchNewListByUserPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (p *PaymentMethodsServerTransport) dispatchDeleteByUser(req *http.Request) (*http.Response, error) { + if p.srv.DeleteByUser == nil { + return nil, &nonRetriableError{errors.New("fake for method DeleteByUser not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/paymentMethods/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + paymentMethodNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("paymentMethodName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.DeleteByUser(req.Context(), paymentMethodNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PaymentMethodsServerTransport) dispatchGetByBillingAccount(req *http.Request) (*http.Response, error) { + if p.srv.GetByBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByBillingAccount not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/paymentMethods/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + paymentMethodNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("paymentMethodName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.GetByBillingAccount(req.Context(), billingAccountNameParam, paymentMethodNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PaymentMethod, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PaymentMethodsServerTransport) dispatchGetByBillingProfile(req *http.Request) (*http.Response, error) { + if p.srv.GetByBillingProfile == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByBillingProfile not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/paymentMethodLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + paymentMethodNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("paymentMethodName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.GetByBillingProfile(req.Context(), billingAccountNameParam, billingProfileNameParam, paymentMethodNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PaymentMethodLink, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PaymentMethodsServerTransport) dispatchGetByUser(req *http.Request) (*http.Response, error) { + if p.srv.GetByUser == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByUser not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/paymentMethods/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + paymentMethodNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("paymentMethodName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.GetByUser(req.Context(), paymentMethodNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PaymentMethod, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PaymentMethodsServerTransport) dispatchNewListByBillingAccountPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListByBillingAccountPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByBillingAccountPager not implemented")} + } + newListByBillingAccountPager := p.newListByBillingAccountPager.get(req) + if newListByBillingAccountPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/paymentMethods` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + resp := p.srv.NewListByBillingAccountPager(billingAccountNameParam, nil) + newListByBillingAccountPager = &resp + p.newListByBillingAccountPager.add(req, newListByBillingAccountPager) + server.PagerResponderInjectNextLinks(newListByBillingAccountPager, req, func(page *armbilling.PaymentMethodsClientListByBillingAccountResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByBillingAccountPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListByBillingAccountPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByBillingAccountPager) { + p.newListByBillingAccountPager.remove(req) + } + return resp, nil +} + +func (p *PaymentMethodsServerTransport) dispatchNewListByBillingProfilePager(req *http.Request) (*http.Response, error) { + if p.srv.NewListByBillingProfilePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByBillingProfilePager not implemented")} + } + newListByBillingProfilePager := p.newListByBillingProfilePager.get(req) + if newListByBillingProfilePager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/paymentMethodLinks` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + resp := p.srv.NewListByBillingProfilePager(billingAccountNameParam, billingProfileNameParam, nil) + newListByBillingProfilePager = &resp + p.newListByBillingProfilePager.add(req, newListByBillingProfilePager) + server.PagerResponderInjectNextLinks(newListByBillingProfilePager, req, func(page *armbilling.PaymentMethodsClientListByBillingProfileResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByBillingProfilePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListByBillingProfilePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByBillingProfilePager) { + p.newListByBillingProfilePager.remove(req) + } + return resp, nil +} + +func (p *PaymentMethodsServerTransport) dispatchNewListByUserPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListByUserPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByUserPager not implemented")} + } + newListByUserPager := p.newListByUserPager.get(req) + if newListByUserPager == nil { + resp := p.srv.NewListByUserPager(nil) + newListByUserPager = &resp + p.newListByUserPager.add(req, newListByUserPager) + server.PagerResponderInjectNextLinks(newListByUserPager, req, func(page *armbilling.PaymentMethodsClientListByUserResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByUserPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListByUserPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByUserPager) { + p.newListByUserPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/fake/periods_server.go b/sdk/resourcemanager/billing/armbilling/fake/periods_server.go deleted file mode 100644 index 0bb3c5c0d5d2..000000000000 --- a/sdk/resourcemanager/billing/armbilling/fake/periods_server.go +++ /dev/null @@ -1,174 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "context" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" - "net/http" - "net/url" - "regexp" - "strconv" -) - -// PeriodsServer is a fake server for instances of the armbilling.PeriodsClient type. -type PeriodsServer struct { - // Get is the fake for method PeriodsClient.Get - // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, billingPeriodName string, options *armbilling.PeriodsClientGetOptions) (resp azfake.Responder[armbilling.PeriodsClientGetResponse], errResp azfake.ErrorResponder) - - // NewListPager is the fake for method PeriodsClient.NewListPager - // HTTP status codes to indicate success: http.StatusOK - NewListPager func(options *armbilling.PeriodsClientListOptions) (resp azfake.PagerResponder[armbilling.PeriodsClientListResponse]) -} - -// NewPeriodsServerTransport creates a new instance of PeriodsServerTransport with the provided implementation. -// The returned PeriodsServerTransport instance is connected to an instance of armbilling.PeriodsClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewPeriodsServerTransport(srv *PeriodsServer) *PeriodsServerTransport { - return &PeriodsServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armbilling.PeriodsClientListResponse]](), - } -} - -// PeriodsServerTransport connects instances of armbilling.PeriodsClient to instances of PeriodsServer. -// Don't use this type directly, use NewPeriodsServerTransport instead. -type PeriodsServerTransport struct { - srv *PeriodsServer - newListPager *tracker[azfake.PagerResponder[armbilling.PeriodsClientListResponse]] -} - -// Do implements the policy.Transporter interface for PeriodsServerTransport. -func (p *PeriodsServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - var resp *http.Response - var err error - - switch method { - case "PeriodsClient.Get": - resp, err = p.dispatchGet(req) - case "PeriodsClient.NewListPager": - resp, err = p.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } - - if err != nil { - return nil, err - } - - return resp, nil -} - -func (p *PeriodsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if p.srv.Get == nil { - return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Billing/billingPeriods/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - billingPeriodNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingPeriodName")]) - if err != nil { - return nil, err - } - respr, errRespr := p.srv.Get(req.Context(), billingPeriodNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Period, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (p *PeriodsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { - if p.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} - } - newListPager := p.newListPager.get(req) - if newListPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Billing/billingPeriods` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - qp := req.URL.Query() - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) - if err != nil { - return nil, err - } - filterParam := getOptional(filterUnescaped) - skiptokenUnescaped, err := url.QueryUnescape(qp.Get("$skiptoken")) - if err != nil { - return nil, err - } - skiptokenParam := getOptional(skiptokenUnescaped) - topUnescaped, err := url.QueryUnescape(qp.Get("$top")) - if err != nil { - return nil, err - } - topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { - p, parseErr := strconv.ParseInt(v, 10, 32) - if parseErr != nil { - return 0, parseErr - } - return int32(p), nil - }) - if err != nil { - return nil, err - } - var options *armbilling.PeriodsClientListOptions - if filterParam != nil || skiptokenParam != nil || topParam != nil { - options = &armbilling.PeriodsClientListOptions{ - Filter: filterParam, - Skiptoken: skiptokenParam, - Top: topParam, - } - } - resp := p.srv.NewListPager(options) - newListPager = &resp - p.newListPager.add(req, newListPager) - server.PagerResponderInjectNextLinks(newListPager, req, func(page *armbilling.PeriodsClientListResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - p.newListPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListPager) { - p.newListPager.remove(req) - } - return resp, nil -} diff --git a/sdk/resourcemanager/billing/armbilling/fake/permissions_server.go b/sdk/resourcemanager/billing/armbilling/fake/permissions_server.go index 0e59633800aa..f0dda8ebf627 100644 --- a/sdk/resourcemanager/billing/armbilling/fake/permissions_server.go +++ b/sdk/resourcemanager/billing/armbilling/fake/permissions_server.go @@ -9,20 +9,46 @@ package fake import ( + "context" "errors" "fmt" + "net/http" + "net/url" + "regexp" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" - "net/http" - "net/url" - "regexp" ) // PermissionsServer is a fake server for instances of the armbilling.PermissionsClient type. type PermissionsServer struct { + // CheckAccessByBillingAccount is the fake for method PermissionsClient.CheckAccessByBillingAccount + // HTTP status codes to indicate success: http.StatusOK + CheckAccessByBillingAccount func(ctx context.Context, billingAccountName string, parameters armbilling.CheckAccessRequest, options *armbilling.PermissionsClientCheckAccessByBillingAccountOptions) (resp azfake.Responder[armbilling.PermissionsClientCheckAccessByBillingAccountResponse], errResp azfake.ErrorResponder) + + // CheckAccessByBillingProfile is the fake for method PermissionsClient.CheckAccessByBillingProfile + // HTTP status codes to indicate success: http.StatusOK + CheckAccessByBillingProfile func(ctx context.Context, billingAccountName string, billingProfileName string, parameters armbilling.CheckAccessRequest, options *armbilling.PermissionsClientCheckAccessByBillingProfileOptions) (resp azfake.Responder[armbilling.PermissionsClientCheckAccessByBillingProfileResponse], errResp azfake.ErrorResponder) + + // CheckAccessByCustomer is the fake for method PermissionsClient.CheckAccessByCustomer + // HTTP status codes to indicate success: http.StatusOK + CheckAccessByCustomer func(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, parameters armbilling.CheckAccessRequest, options *armbilling.PermissionsClientCheckAccessByCustomerOptions) (resp azfake.Responder[armbilling.PermissionsClientCheckAccessByCustomerResponse], errResp azfake.ErrorResponder) + + // CheckAccessByDepartment is the fake for method PermissionsClient.CheckAccessByDepartment + // HTTP status codes to indicate success: http.StatusOK + CheckAccessByDepartment func(ctx context.Context, billingAccountName string, departmentName string, parameters armbilling.CheckAccessRequest, options *armbilling.PermissionsClientCheckAccessByDepartmentOptions) (resp azfake.Responder[armbilling.PermissionsClientCheckAccessByDepartmentResponse], errResp azfake.ErrorResponder) + + // CheckAccessByEnrollmentAccount is the fake for method PermissionsClient.CheckAccessByEnrollmentAccount + // HTTP status codes to indicate success: http.StatusOK + CheckAccessByEnrollmentAccount func(ctx context.Context, billingAccountName string, enrollmentAccountName string, parameters armbilling.CheckAccessRequest, options *armbilling.PermissionsClientCheckAccessByEnrollmentAccountOptions) (resp azfake.Responder[armbilling.PermissionsClientCheckAccessByEnrollmentAccountResponse], errResp azfake.ErrorResponder) + + // CheckAccessByInvoiceSection is the fake for method PermissionsClient.CheckAccessByInvoiceSection + // HTTP status codes to indicate success: http.StatusOK + CheckAccessByInvoiceSection func(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, parameters armbilling.CheckAccessRequest, options *armbilling.PermissionsClientCheckAccessByInvoiceSectionOptions) (resp azfake.Responder[armbilling.PermissionsClientCheckAccessByInvoiceSectionResponse], errResp azfake.ErrorResponder) + // NewListByBillingAccountPager is the fake for method PermissionsClient.NewListByBillingAccountPager // HTTP status codes to indicate success: http.StatusOK NewListByBillingAccountPager func(billingAccountName string, options *armbilling.PermissionsClientListByBillingAccountOptions) (resp azfake.PagerResponder[armbilling.PermissionsClientListByBillingAccountResponse]) @@ -33,11 +59,23 @@ type PermissionsServer struct { // NewListByCustomerPager is the fake for method PermissionsClient.NewListByCustomerPager // HTTP status codes to indicate success: http.StatusOK - NewListByCustomerPager func(billingAccountName string, customerName string, options *armbilling.PermissionsClientListByCustomerOptions) (resp azfake.PagerResponder[armbilling.PermissionsClientListByCustomerResponse]) + NewListByCustomerPager func(billingAccountName string, billingProfileName string, customerName string, options *armbilling.PermissionsClientListByCustomerOptions) (resp azfake.PagerResponder[armbilling.PermissionsClientListByCustomerResponse]) + + // NewListByCustomerAtBillingAccountPager is the fake for method PermissionsClient.NewListByCustomerAtBillingAccountPager + // HTTP status codes to indicate success: http.StatusOK + NewListByCustomerAtBillingAccountPager func(billingAccountName string, customerName string, options *armbilling.PermissionsClientListByCustomerAtBillingAccountOptions) (resp azfake.PagerResponder[armbilling.PermissionsClientListByCustomerAtBillingAccountResponse]) + + // NewListByDepartmentPager is the fake for method PermissionsClient.NewListByDepartmentPager + // HTTP status codes to indicate success: http.StatusOK + NewListByDepartmentPager func(billingAccountName string, departmentName string, options *armbilling.PermissionsClientListByDepartmentOptions) (resp azfake.PagerResponder[armbilling.PermissionsClientListByDepartmentResponse]) + + // NewListByEnrollmentAccountPager is the fake for method PermissionsClient.NewListByEnrollmentAccountPager + // HTTP status codes to indicate success: http.StatusOK + NewListByEnrollmentAccountPager func(billingAccountName string, enrollmentAccountName string, options *armbilling.PermissionsClientListByEnrollmentAccountOptions) (resp azfake.PagerResponder[armbilling.PermissionsClientListByEnrollmentAccountResponse]) - // NewListByInvoiceSectionsPager is the fake for method PermissionsClient.NewListByInvoiceSectionsPager + // NewListByInvoiceSectionPager is the fake for method PermissionsClient.NewListByInvoiceSectionPager // HTTP status codes to indicate success: http.StatusOK - NewListByInvoiceSectionsPager func(billingAccountName string, billingProfileName string, invoiceSectionName string, options *armbilling.PermissionsClientListByInvoiceSectionsOptions) (resp azfake.PagerResponder[armbilling.PermissionsClientListByInvoiceSectionsResponse]) + NewListByInvoiceSectionPager func(billingAccountName string, billingProfileName string, invoiceSectionName string, options *armbilling.PermissionsClientListByInvoiceSectionOptions) (resp azfake.PagerResponder[armbilling.PermissionsClientListByInvoiceSectionResponse]) } // NewPermissionsServerTransport creates a new instance of PermissionsServerTransport with the provided implementation. @@ -45,22 +83,28 @@ type PermissionsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewPermissionsServerTransport(srv *PermissionsServer) *PermissionsServerTransport { return &PermissionsServerTransport{ - srv: srv, - newListByBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.PermissionsClientListByBillingAccountResponse]](), - newListByBillingProfilePager: newTracker[azfake.PagerResponder[armbilling.PermissionsClientListByBillingProfileResponse]](), - newListByCustomerPager: newTracker[azfake.PagerResponder[armbilling.PermissionsClientListByCustomerResponse]](), - newListByInvoiceSectionsPager: newTracker[azfake.PagerResponder[armbilling.PermissionsClientListByInvoiceSectionsResponse]](), + srv: srv, + newListByBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.PermissionsClientListByBillingAccountResponse]](), + newListByBillingProfilePager: newTracker[azfake.PagerResponder[armbilling.PermissionsClientListByBillingProfileResponse]](), + newListByCustomerPager: newTracker[azfake.PagerResponder[armbilling.PermissionsClientListByCustomerResponse]](), + newListByCustomerAtBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.PermissionsClientListByCustomerAtBillingAccountResponse]](), + newListByDepartmentPager: newTracker[azfake.PagerResponder[armbilling.PermissionsClientListByDepartmentResponse]](), + newListByEnrollmentAccountPager: newTracker[azfake.PagerResponder[armbilling.PermissionsClientListByEnrollmentAccountResponse]](), + newListByInvoiceSectionPager: newTracker[azfake.PagerResponder[armbilling.PermissionsClientListByInvoiceSectionResponse]](), } } // PermissionsServerTransport connects instances of armbilling.PermissionsClient to instances of PermissionsServer. // Don't use this type directly, use NewPermissionsServerTransport instead. type PermissionsServerTransport struct { - srv *PermissionsServer - newListByBillingAccountPager *tracker[azfake.PagerResponder[armbilling.PermissionsClientListByBillingAccountResponse]] - newListByBillingProfilePager *tracker[azfake.PagerResponder[armbilling.PermissionsClientListByBillingProfileResponse]] - newListByCustomerPager *tracker[azfake.PagerResponder[armbilling.PermissionsClientListByCustomerResponse]] - newListByInvoiceSectionsPager *tracker[azfake.PagerResponder[armbilling.PermissionsClientListByInvoiceSectionsResponse]] + srv *PermissionsServer + newListByBillingAccountPager *tracker[azfake.PagerResponder[armbilling.PermissionsClientListByBillingAccountResponse]] + newListByBillingProfilePager *tracker[azfake.PagerResponder[armbilling.PermissionsClientListByBillingProfileResponse]] + newListByCustomerPager *tracker[azfake.PagerResponder[armbilling.PermissionsClientListByCustomerResponse]] + newListByCustomerAtBillingAccountPager *tracker[azfake.PagerResponder[armbilling.PermissionsClientListByCustomerAtBillingAccountResponse]] + newListByDepartmentPager *tracker[azfake.PagerResponder[armbilling.PermissionsClientListByDepartmentResponse]] + newListByEnrollmentAccountPager *tracker[azfake.PagerResponder[armbilling.PermissionsClientListByEnrollmentAccountResponse]] + newListByInvoiceSectionPager *tracker[azfake.PagerResponder[armbilling.PermissionsClientListByInvoiceSectionResponse]] } // Do implements the policy.Transporter interface for PermissionsServerTransport. @@ -75,14 +119,32 @@ func (p *PermissionsServerTransport) Do(req *http.Request) (*http.Response, erro var err error switch method { + case "PermissionsClient.CheckAccessByBillingAccount": + resp, err = p.dispatchCheckAccessByBillingAccount(req) + case "PermissionsClient.CheckAccessByBillingProfile": + resp, err = p.dispatchCheckAccessByBillingProfile(req) + case "PermissionsClient.CheckAccessByCustomer": + resp, err = p.dispatchCheckAccessByCustomer(req) + case "PermissionsClient.CheckAccessByDepartment": + resp, err = p.dispatchCheckAccessByDepartment(req) + case "PermissionsClient.CheckAccessByEnrollmentAccount": + resp, err = p.dispatchCheckAccessByEnrollmentAccount(req) + case "PermissionsClient.CheckAccessByInvoiceSection": + resp, err = p.dispatchCheckAccessByInvoiceSection(req) case "PermissionsClient.NewListByBillingAccountPager": resp, err = p.dispatchNewListByBillingAccountPager(req) case "PermissionsClient.NewListByBillingProfilePager": resp, err = p.dispatchNewListByBillingProfilePager(req) case "PermissionsClient.NewListByCustomerPager": resp, err = p.dispatchNewListByCustomerPager(req) - case "PermissionsClient.NewListByInvoiceSectionsPager": - resp, err = p.dispatchNewListByInvoiceSectionsPager(req) + case "PermissionsClient.NewListByCustomerAtBillingAccountPager": + resp, err = p.dispatchNewListByCustomerAtBillingAccountPager(req) + case "PermissionsClient.NewListByDepartmentPager": + resp, err = p.dispatchNewListByDepartmentPager(req) + case "PermissionsClient.NewListByEnrollmentAccountPager": + resp, err = p.dispatchNewListByEnrollmentAccountPager(req) + case "PermissionsClient.NewListByInvoiceSectionPager": + resp, err = p.dispatchNewListByInvoiceSectionPager(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -94,6 +156,232 @@ func (p *PermissionsServerTransport) Do(req *http.Request) (*http.Response, erro return resp, nil } +func (p *PermissionsServerTransport) dispatchCheckAccessByBillingAccount(req *http.Request) (*http.Response, error) { + if p.srv.CheckAccessByBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckAccessByBillingAccount not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/checkAccess` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.CheckAccessRequest](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.CheckAccessByBillingAccount(req.Context(), billingAccountNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CheckAccessResponseArray, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PermissionsServerTransport) dispatchCheckAccessByBillingProfile(req *http.Request) (*http.Response, error) { + if p.srv.CheckAccessByBillingProfile == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckAccessByBillingProfile not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/checkAccess` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.CheckAccessRequest](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.CheckAccessByBillingProfile(req.Context(), billingAccountNameParam, billingProfileNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CheckAccessResponseArray, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PermissionsServerTransport) dispatchCheckAccessByCustomer(req *http.Request) (*http.Response, error) { + if p.srv.CheckAccessByCustomer == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckAccessByCustomer not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/checkAccess` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.CheckAccessRequest](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.CheckAccessByCustomer(req.Context(), billingAccountNameParam, billingProfileNameParam, customerNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CheckAccessResponseArray, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PermissionsServerTransport) dispatchCheckAccessByDepartment(req *http.Request) (*http.Response, error) { + if p.srv.CheckAccessByDepartment == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckAccessByDepartment not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/departments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/checkAccess` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.CheckAccessRequest](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + departmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("departmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.CheckAccessByDepartment(req.Context(), billingAccountNameParam, departmentNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CheckAccessResponseArray, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PermissionsServerTransport) dispatchCheckAccessByEnrollmentAccount(req *http.Request) (*http.Response, error) { + if p.srv.CheckAccessByEnrollmentAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckAccessByEnrollmentAccount not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enrollmentAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/checkAccess` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.CheckAccessRequest](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + enrollmentAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enrollmentAccountName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.CheckAccessByEnrollmentAccount(req.Context(), billingAccountNameParam, enrollmentAccountNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CheckAccessResponseArray, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PermissionsServerTransport) dispatchCheckAccessByInvoiceSection(req *http.Request) (*http.Response, error) { + if p.srv.CheckAccessByInvoiceSection == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckAccessByInvoiceSection not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoiceSections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/checkAccess` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.CheckAccessRequest](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + invoiceSectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceSectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.CheckAccessByInvoiceSection(req.Context(), billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CheckAccessResponseArray, req) + if err != nil { + return nil, err + } + return resp, nil +} + func (p *PermissionsServerTransport) dispatchNewListByBillingAccountPager(req *http.Request) (*http.Response, error) { if p.srv.NewListByBillingAccountPager == nil { return nil, &nonRetriableError{errors.New("fake for method NewListByBillingAccountPager not implemented")} @@ -178,21 +466,25 @@ func (p *PermissionsServerTransport) dispatchNewListByCustomerPager(req *http.Re } newListByCustomerPager := p.newListByCustomerPager.get(req) if newListByCustomerPager == nil { - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingPermissions` + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingPermissions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) if err != nil { return nil, err } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) if err != nil { return nil, err } - resp := p.srv.NewListByCustomerPager(billingAccountNameParam, customerNameParam, nil) + resp := p.srv.NewListByCustomerPager(billingAccountNameParam, billingProfileNameParam, customerNameParam, nil) newListByCustomerPager = &resp p.newListByCustomerPager.add(req, newListByCustomerPager) server.PagerResponderInjectNextLinks(newListByCustomerPager, req, func(page *armbilling.PermissionsClientListByCustomerResponse, createLink func() string) { @@ -213,12 +505,135 @@ func (p *PermissionsServerTransport) dispatchNewListByCustomerPager(req *http.Re return resp, nil } -func (p *PermissionsServerTransport) dispatchNewListByInvoiceSectionsPager(req *http.Request) (*http.Response, error) { - if p.srv.NewListByInvoiceSectionsPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListByInvoiceSectionsPager not implemented")} +func (p *PermissionsServerTransport) dispatchNewListByCustomerAtBillingAccountPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListByCustomerAtBillingAccountPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByCustomerAtBillingAccountPager not implemented")} + } + newListByCustomerAtBillingAccountPager := p.newListByCustomerAtBillingAccountPager.get(req) + if newListByCustomerAtBillingAccountPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingPermissions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) + if err != nil { + return nil, err + } + resp := p.srv.NewListByCustomerAtBillingAccountPager(billingAccountNameParam, customerNameParam, nil) + newListByCustomerAtBillingAccountPager = &resp + p.newListByCustomerAtBillingAccountPager.add(req, newListByCustomerAtBillingAccountPager) + server.PagerResponderInjectNextLinks(newListByCustomerAtBillingAccountPager, req, func(page *armbilling.PermissionsClientListByCustomerAtBillingAccountResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByCustomerAtBillingAccountPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListByCustomerAtBillingAccountPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByCustomerAtBillingAccountPager) { + p.newListByCustomerAtBillingAccountPager.remove(req) + } + return resp, nil +} + +func (p *PermissionsServerTransport) dispatchNewListByDepartmentPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListByDepartmentPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByDepartmentPager not implemented")} + } + newListByDepartmentPager := p.newListByDepartmentPager.get(req) + if newListByDepartmentPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/departments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingPermissions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + departmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("departmentName")]) + if err != nil { + return nil, err + } + resp := p.srv.NewListByDepartmentPager(billingAccountNameParam, departmentNameParam, nil) + newListByDepartmentPager = &resp + p.newListByDepartmentPager.add(req, newListByDepartmentPager) + server.PagerResponderInjectNextLinks(newListByDepartmentPager, req, func(page *armbilling.PermissionsClientListByDepartmentResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByDepartmentPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListByDepartmentPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByDepartmentPager) { + p.newListByDepartmentPager.remove(req) + } + return resp, nil +} + +func (p *PermissionsServerTransport) dispatchNewListByEnrollmentAccountPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListByEnrollmentAccountPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByEnrollmentAccountPager not implemented")} + } + newListByEnrollmentAccountPager := p.newListByEnrollmentAccountPager.get(req) + if newListByEnrollmentAccountPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enrollmentAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingPermissions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + enrollmentAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enrollmentAccountName")]) + if err != nil { + return nil, err + } + resp := p.srv.NewListByEnrollmentAccountPager(billingAccountNameParam, enrollmentAccountNameParam, nil) + newListByEnrollmentAccountPager = &resp + p.newListByEnrollmentAccountPager.add(req, newListByEnrollmentAccountPager) + server.PagerResponderInjectNextLinks(newListByEnrollmentAccountPager, req, func(page *armbilling.PermissionsClientListByEnrollmentAccountResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByEnrollmentAccountPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListByEnrollmentAccountPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByEnrollmentAccountPager) { + p.newListByEnrollmentAccountPager.remove(req) + } + return resp, nil +} + +func (p *PermissionsServerTransport) dispatchNewListByInvoiceSectionPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListByInvoiceSectionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByInvoiceSectionPager not implemented")} } - newListByInvoiceSectionsPager := p.newListByInvoiceSectionsPager.get(req) - if newListByInvoiceSectionsPager == nil { + newListByInvoiceSectionPager := p.newListByInvoiceSectionPager.get(req) + if newListByInvoiceSectionPager == nil { const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoiceSections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingPermissions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) @@ -237,23 +652,23 @@ func (p *PermissionsServerTransport) dispatchNewListByInvoiceSectionsPager(req * if err != nil { return nil, err } - resp := p.srv.NewListByInvoiceSectionsPager(billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, nil) - newListByInvoiceSectionsPager = &resp - p.newListByInvoiceSectionsPager.add(req, newListByInvoiceSectionsPager) - server.PagerResponderInjectNextLinks(newListByInvoiceSectionsPager, req, func(page *armbilling.PermissionsClientListByInvoiceSectionsResponse, createLink func() string) { + resp := p.srv.NewListByInvoiceSectionPager(billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, nil) + newListByInvoiceSectionPager = &resp + p.newListByInvoiceSectionPager.add(req, newListByInvoiceSectionPager) + server.PagerResponderInjectNextLinks(newListByInvoiceSectionPager, req, func(page *armbilling.PermissionsClientListByInvoiceSectionResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } - resp, err := server.PagerResponderNext(newListByInvoiceSectionsPager, req) + resp, err := server.PagerResponderNext(newListByInvoiceSectionPager, req) if err != nil { return nil, err } if !contains([]int{http.StatusOK}, resp.StatusCode) { - p.newListByInvoiceSectionsPager.remove(req) + p.newListByInvoiceSectionPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } - if !server.PagerResponderMore(newListByInvoiceSectionsPager) { - p.newListByInvoiceSectionsPager.remove(req) + if !server.PagerResponderMore(newListByInvoiceSectionPager) { + p.newListByInvoiceSectionPager.remove(req) } return resp, nil } diff --git a/sdk/resourcemanager/billing/armbilling/fake/policies_server.go b/sdk/resourcemanager/billing/armbilling/fake/policies_server.go index 29c387154a4d..592bda54a4f6 100644 --- a/sdk/resourcemanager/billing/armbilling/fake/policies_server.go +++ b/sdk/resourcemanager/billing/armbilling/fake/policies_server.go @@ -12,45 +12,76 @@ import ( "context" "errors" "fmt" + "net/http" + "net/url" + "regexp" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" - "net/http" - "net/url" - "regexp" ) // PoliciesServer is a fake server for instances of the armbilling.PoliciesClient type. type PoliciesServer struct { + // BeginCreateOrUpdateByBillingAccount is the fake for method PoliciesClient.BeginCreateOrUpdateByBillingAccount + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdateByBillingAccount func(ctx context.Context, billingAccountName string, parameters armbilling.AccountPolicy, options *armbilling.PoliciesClientBeginCreateOrUpdateByBillingAccountOptions) (resp azfake.PollerResponder[armbilling.PoliciesClientCreateOrUpdateByBillingAccountResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdateByBillingProfile is the fake for method PoliciesClient.BeginCreateOrUpdateByBillingProfile + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdateByBillingProfile func(ctx context.Context, billingAccountName string, billingProfileName string, parameters armbilling.ProfilePolicy, options *armbilling.PoliciesClientBeginCreateOrUpdateByBillingProfileOptions) (resp azfake.PollerResponder[armbilling.PoliciesClientCreateOrUpdateByBillingProfileResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdateByCustomer is the fake for method PoliciesClient.BeginCreateOrUpdateByCustomer + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdateByCustomer func(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, parameters armbilling.CustomerPolicy, options *armbilling.PoliciesClientBeginCreateOrUpdateByCustomerOptions) (resp azfake.PollerResponder[armbilling.PoliciesClientCreateOrUpdateByCustomerResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdateByCustomerAtBillingAccount is the fake for method PoliciesClient.BeginCreateOrUpdateByCustomerAtBillingAccount + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdateByCustomerAtBillingAccount func(ctx context.Context, billingAccountName string, customerName string, parameters armbilling.CustomerPolicy, options *armbilling.PoliciesClientBeginCreateOrUpdateByCustomerAtBillingAccountOptions) (resp azfake.PollerResponder[armbilling.PoliciesClientCreateOrUpdateByCustomerAtBillingAccountResponse], errResp azfake.ErrorResponder) + + // GetByBillingAccount is the fake for method PoliciesClient.GetByBillingAccount + // HTTP status codes to indicate success: http.StatusOK + GetByBillingAccount func(ctx context.Context, billingAccountName string, options *armbilling.PoliciesClientGetByBillingAccountOptions) (resp azfake.Responder[armbilling.PoliciesClientGetByBillingAccountResponse], errResp azfake.ErrorResponder) + // GetByBillingProfile is the fake for method PoliciesClient.GetByBillingProfile // HTTP status codes to indicate success: http.StatusOK GetByBillingProfile func(ctx context.Context, billingAccountName string, billingProfileName string, options *armbilling.PoliciesClientGetByBillingProfileOptions) (resp azfake.Responder[armbilling.PoliciesClientGetByBillingProfileResponse], errResp azfake.ErrorResponder) // GetByCustomer is the fake for method PoliciesClient.GetByCustomer // HTTP status codes to indicate success: http.StatusOK - GetByCustomer func(ctx context.Context, billingAccountName string, customerName string, options *armbilling.PoliciesClientGetByCustomerOptions) (resp azfake.Responder[armbilling.PoliciesClientGetByCustomerResponse], errResp azfake.ErrorResponder) + GetByCustomer func(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, policyName armbilling.ServiceDefinedResourceName, options *armbilling.PoliciesClientGetByCustomerOptions) (resp azfake.Responder[armbilling.PoliciesClientGetByCustomerResponse], errResp azfake.ErrorResponder) - // Update is the fake for method PoliciesClient.Update + // GetByCustomerAtBillingAccount is the fake for method PoliciesClient.GetByCustomerAtBillingAccount // HTTP status codes to indicate success: http.StatusOK - Update func(ctx context.Context, billingAccountName string, billingProfileName string, parameters armbilling.Policy, options *armbilling.PoliciesClientUpdateOptions) (resp azfake.Responder[armbilling.PoliciesClientUpdateResponse], errResp azfake.ErrorResponder) + GetByCustomerAtBillingAccount func(ctx context.Context, billingAccountName string, customerName string, options *armbilling.PoliciesClientGetByCustomerAtBillingAccountOptions) (resp azfake.Responder[armbilling.PoliciesClientGetByCustomerAtBillingAccountResponse], errResp azfake.ErrorResponder) - // UpdateCustomer is the fake for method PoliciesClient.UpdateCustomer + // GetBySubscription is the fake for method PoliciesClient.GetBySubscription // HTTP status codes to indicate success: http.StatusOK - UpdateCustomer func(ctx context.Context, billingAccountName string, customerName string, parameters armbilling.CustomerPolicy, options *armbilling.PoliciesClientUpdateCustomerOptions) (resp azfake.Responder[armbilling.PoliciesClientUpdateCustomerResponse], errResp azfake.ErrorResponder) + GetBySubscription func(ctx context.Context, options *armbilling.PoliciesClientGetBySubscriptionOptions) (resp azfake.Responder[armbilling.PoliciesClientGetBySubscriptionResponse], errResp azfake.ErrorResponder) } // NewPoliciesServerTransport creates a new instance of PoliciesServerTransport with the provided implementation. // The returned PoliciesServerTransport instance is connected to an instance of armbilling.PoliciesClient via the // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewPoliciesServerTransport(srv *PoliciesServer) *PoliciesServerTransport { - return &PoliciesServerTransport{srv: srv} + return &PoliciesServerTransport{ + srv: srv, + beginCreateOrUpdateByBillingAccount: newTracker[azfake.PollerResponder[armbilling.PoliciesClientCreateOrUpdateByBillingAccountResponse]](), + beginCreateOrUpdateByBillingProfile: newTracker[azfake.PollerResponder[armbilling.PoliciesClientCreateOrUpdateByBillingProfileResponse]](), + beginCreateOrUpdateByCustomer: newTracker[azfake.PollerResponder[armbilling.PoliciesClientCreateOrUpdateByCustomerResponse]](), + beginCreateOrUpdateByCustomerAtBillingAccount: newTracker[azfake.PollerResponder[armbilling.PoliciesClientCreateOrUpdateByCustomerAtBillingAccountResponse]](), + } } // PoliciesServerTransport connects instances of armbilling.PoliciesClient to instances of PoliciesServer. // Don't use this type directly, use NewPoliciesServerTransport instead. type PoliciesServerTransport struct { - srv *PoliciesServer + srv *PoliciesServer + beginCreateOrUpdateByBillingAccount *tracker[azfake.PollerResponder[armbilling.PoliciesClientCreateOrUpdateByBillingAccountResponse]] + beginCreateOrUpdateByBillingProfile *tracker[azfake.PollerResponder[armbilling.PoliciesClientCreateOrUpdateByBillingProfileResponse]] + beginCreateOrUpdateByCustomer *tracker[azfake.PollerResponder[armbilling.PoliciesClientCreateOrUpdateByCustomerResponse]] + beginCreateOrUpdateByCustomerAtBillingAccount *tracker[azfake.PollerResponder[armbilling.PoliciesClientCreateOrUpdateByCustomerAtBillingAccountResponse]] } // Do implements the policy.Transporter interface for PoliciesServerTransport. @@ -65,14 +96,24 @@ func (p *PoliciesServerTransport) Do(req *http.Request) (*http.Response, error) var err error switch method { + case "PoliciesClient.BeginCreateOrUpdateByBillingAccount": + resp, err = p.dispatchBeginCreateOrUpdateByBillingAccount(req) + case "PoliciesClient.BeginCreateOrUpdateByBillingProfile": + resp, err = p.dispatchBeginCreateOrUpdateByBillingProfile(req) + case "PoliciesClient.BeginCreateOrUpdateByCustomer": + resp, err = p.dispatchBeginCreateOrUpdateByCustomer(req) + case "PoliciesClient.BeginCreateOrUpdateByCustomerAtBillingAccount": + resp, err = p.dispatchBeginCreateOrUpdateByCustomerAtBillingAccount(req) + case "PoliciesClient.GetByBillingAccount": + resp, err = p.dispatchGetByBillingAccount(req) case "PoliciesClient.GetByBillingProfile": resp, err = p.dispatchGetByBillingProfile(req) case "PoliciesClient.GetByCustomer": resp, err = p.dispatchGetByCustomer(req) - case "PoliciesClient.Update": - resp, err = p.dispatchUpdate(req) - case "PoliciesClient.UpdateCustomer": - resp, err = p.dispatchUpdateCustomer(req) + case "PoliciesClient.GetByCustomerAtBillingAccount": + resp, err = p.dispatchGetByCustomerAtBillingAccount(req) + case "PoliciesClient.GetBySubscription": + resp, err = p.dispatchGetBySubscription(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -84,6 +125,227 @@ func (p *PoliciesServerTransport) Do(req *http.Request) (*http.Response, error) return resp, nil } +func (p *PoliciesServerTransport) dispatchBeginCreateOrUpdateByBillingAccount(req *http.Request) (*http.Response, error) { + if p.srv.BeginCreateOrUpdateByBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdateByBillingAccount not implemented")} + } + beginCreateOrUpdateByBillingAccount := p.beginCreateOrUpdateByBillingAccount.get(req) + if beginCreateOrUpdateByBillingAccount == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/default` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.AccountPolicy](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginCreateOrUpdateByBillingAccount(req.Context(), billingAccountNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdateByBillingAccount = &respr + p.beginCreateOrUpdateByBillingAccount.add(req, beginCreateOrUpdateByBillingAccount) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdateByBillingAccount, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + p.beginCreateOrUpdateByBillingAccount.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdateByBillingAccount) { + p.beginCreateOrUpdateByBillingAccount.remove(req) + } + + return resp, nil +} + +func (p *PoliciesServerTransport) dispatchBeginCreateOrUpdateByBillingProfile(req *http.Request) (*http.Response, error) { + if p.srv.BeginCreateOrUpdateByBillingProfile == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdateByBillingProfile not implemented")} + } + beginCreateOrUpdateByBillingProfile := p.beginCreateOrUpdateByBillingProfile.get(req) + if beginCreateOrUpdateByBillingProfile == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/default` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.ProfilePolicy](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginCreateOrUpdateByBillingProfile(req.Context(), billingAccountNameParam, billingProfileNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdateByBillingProfile = &respr + p.beginCreateOrUpdateByBillingProfile.add(req, beginCreateOrUpdateByBillingProfile) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdateByBillingProfile, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + p.beginCreateOrUpdateByBillingProfile.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdateByBillingProfile) { + p.beginCreateOrUpdateByBillingProfile.remove(req) + } + + return resp, nil +} + +func (p *PoliciesServerTransport) dispatchBeginCreateOrUpdateByCustomer(req *http.Request) (*http.Response, error) { + if p.srv.BeginCreateOrUpdateByCustomer == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdateByCustomer not implemented")} + } + beginCreateOrUpdateByCustomer := p.beginCreateOrUpdateByCustomer.get(req) + if beginCreateOrUpdateByCustomer == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/default` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.CustomerPolicy](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginCreateOrUpdateByCustomer(req.Context(), billingAccountNameParam, billingProfileNameParam, customerNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdateByCustomer = &respr + p.beginCreateOrUpdateByCustomer.add(req, beginCreateOrUpdateByCustomer) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdateByCustomer, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + p.beginCreateOrUpdateByCustomer.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdateByCustomer) { + p.beginCreateOrUpdateByCustomer.remove(req) + } + + return resp, nil +} + +func (p *PoliciesServerTransport) dispatchBeginCreateOrUpdateByCustomerAtBillingAccount(req *http.Request) (*http.Response, error) { + if p.srv.BeginCreateOrUpdateByCustomerAtBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdateByCustomerAtBillingAccount not implemented")} + } + beginCreateOrUpdateByCustomerAtBillingAccount := p.beginCreateOrUpdateByCustomerAtBillingAccount.get(req) + if beginCreateOrUpdateByCustomerAtBillingAccount == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/default` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.CustomerPolicy](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginCreateOrUpdateByCustomerAtBillingAccount(req.Context(), billingAccountNameParam, customerNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdateByCustomerAtBillingAccount = &respr + p.beginCreateOrUpdateByCustomerAtBillingAccount.add(req, beginCreateOrUpdateByCustomerAtBillingAccount) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdateByCustomerAtBillingAccount, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + p.beginCreateOrUpdateByCustomerAtBillingAccount.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdateByCustomerAtBillingAccount) { + p.beginCreateOrUpdateByCustomerAtBillingAccount.remove(req) + } + + return resp, nil +} + +func (p *PoliciesServerTransport) dispatchGetByBillingAccount(req *http.Request) (*http.Response, error) { + if p.srv.GetByBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByBillingAccount not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/default` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.GetByBillingAccount(req.Context(), billingAccountNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AccountPolicy, req) + if err != nil { + return nil, err + } + return resp, nil +} + func (p *PoliciesServerTransport) dispatchGetByBillingProfile(req *http.Request) (*http.Response, error) { if p.srv.GetByBillingProfile == nil { return nil, &nonRetriableError{errors.New("fake for method GetByBillingProfile not implemented")} @@ -110,7 +372,7 @@ func (p *PoliciesServerTransport) dispatchGetByBillingProfile(req *http.Request) if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Policy, req) + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ProfilePolicy, req) if err != nil { return nil, err } @@ -121,21 +383,35 @@ func (p *PoliciesServerTransport) dispatchGetByCustomer(req *http.Request) (*htt if p.srv.GetByCustomer == nil { return nil, &nonRetriableError{errors.New("fake for method GetByCustomer not implemented")} } - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/default` + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) if err != nil { return nil, err } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) if err != nil { return nil, err } - respr, errRespr := p.srv.GetByCustomer(req.Context(), billingAccountNameParam, customerNameParam, nil) + policyNameParam, err := parseWithCast(matches[regex.SubexpIndex("policyName")], func(v string) (armbilling.ServiceDefinedResourceName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armbilling.ServiceDefinedResourceName(p), nil + }) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.GetByCustomer(req.Context(), billingAccountNameParam, billingProfileNameParam, customerNameParam, policyNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -150,29 +426,25 @@ func (p *PoliciesServerTransport) dispatchGetByCustomer(req *http.Request) (*htt return resp, nil } -func (p *PoliciesServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { - if p.srv.Update == nil { - return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} +func (p *PoliciesServerTransport) dispatchGetByCustomerAtBillingAccount(req *http.Request) (*http.Response, error) { + if p.srv.GetByCustomerAtBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByCustomerAtBillingAccount not implemented")} } - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/default` + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/default` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armbilling.Policy](req) - if err != nil { - return nil, err - } billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) if err != nil { return nil, err } - billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) if err != nil { return nil, err } - respr, errRespr := p.srv.Update(req.Context(), billingAccountNameParam, billingProfileNameParam, body, nil) + respr, errRespr := p.srv.GetByCustomerAtBillingAccount(req.Context(), billingAccountNameParam, customerNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -180,36 +452,24 @@ func (p *PoliciesServerTransport) dispatchUpdate(req *http.Request) (*http.Respo if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Policy, req) + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CustomerPolicy, req) if err != nil { return nil, err } return resp, nil } -func (p *PoliciesServerTransport) dispatchUpdateCustomer(req *http.Request) (*http.Response, error) { - if p.srv.UpdateCustomer == nil { - return nil, &nonRetriableError{errors.New("fake for method UpdateCustomer not implemented")} +func (p *PoliciesServerTransport) dispatchGetBySubscription(req *http.Request) (*http.Response, error) { + if p.srv.GetBySubscription == nil { + return nil, &nonRetriableError{errors.New("fake for method GetBySubscription not implemented")} } - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/default` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Billing/policies/default` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armbilling.CustomerPolicy](req) - if err != nil { - return nil, err - } - billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) - if err != nil { - return nil, err - } - customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) - if err != nil { - return nil, err - } - respr, errRespr := p.srv.UpdateCustomer(req.Context(), billingAccountNameParam, customerNameParam, body, nil) + respr, errRespr := p.srv.GetBySubscription(req.Context(), nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -217,7 +477,7 @@ func (p *PoliciesServerTransport) dispatchUpdateCustomer(req *http.Request) (*ht if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CustomerPolicy, req) + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SubscriptionPolicy, req) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/billing/armbilling/fake/products_server.go b/sdk/resourcemanager/billing/armbilling/fake/products_server.go index cd2537847937..e29885ad9752 100644 --- a/sdk/resourcemanager/billing/armbilling/fake/products_server.go +++ b/sdk/resourcemanager/billing/armbilling/fake/products_server.go @@ -12,15 +12,16 @@ import ( "context" "errors" "fmt" + "net/http" + "net/url" + "regexp" + "strconv" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" - "net/http" - "net/url" - "regexp" - "strconv" ) // ProductsServer is a fake server for instances of the armbilling.ProductsClient type. @@ -45,17 +46,17 @@ type ProductsServer struct { // HTTP status codes to indicate success: http.StatusOK NewListByInvoiceSectionPager func(billingAccountName string, billingProfileName string, invoiceSectionName string, options *armbilling.ProductsClientListByInvoiceSectionOptions) (resp azfake.PagerResponder[armbilling.ProductsClientListByInvoiceSectionResponse]) - // Move is the fake for method ProductsClient.Move + // BeginMove is the fake for method ProductsClient.BeginMove // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - Move func(ctx context.Context, billingAccountName string, productName string, parameters armbilling.TransferProductRequestProperties, options *armbilling.ProductsClientMoveOptions) (resp azfake.Responder[armbilling.ProductsClientMoveResponse], errResp azfake.ErrorResponder) + BeginMove func(ctx context.Context, billingAccountName string, productName string, parameters armbilling.MoveProductRequest, options *armbilling.ProductsClientBeginMoveOptions) (resp azfake.PollerResponder[armbilling.ProductsClientMoveResponse], errResp azfake.ErrorResponder) // Update is the fake for method ProductsClient.Update // HTTP status codes to indicate success: http.StatusOK - Update func(ctx context.Context, billingAccountName string, productName string, parameters armbilling.Product, options *armbilling.ProductsClientUpdateOptions) (resp azfake.Responder[armbilling.ProductsClientUpdateResponse], errResp azfake.ErrorResponder) + Update func(ctx context.Context, billingAccountName string, productName string, parameters armbilling.ProductPatch, options *armbilling.ProductsClientUpdateOptions) (resp azfake.Responder[armbilling.ProductsClientUpdateResponse], errResp azfake.ErrorResponder) - // ValidateMove is the fake for method ProductsClient.ValidateMove + // ValidateMoveEligibility is the fake for method ProductsClient.ValidateMoveEligibility // HTTP status codes to indicate success: http.StatusOK - ValidateMove func(ctx context.Context, billingAccountName string, productName string, parameters armbilling.TransferProductRequestProperties, options *armbilling.ProductsClientValidateMoveOptions) (resp azfake.Responder[armbilling.ProductsClientValidateMoveResponse], errResp azfake.ErrorResponder) + ValidateMoveEligibility func(ctx context.Context, billingAccountName string, productName string, parameters armbilling.MoveProductRequest, options *armbilling.ProductsClientValidateMoveEligibilityOptions) (resp azfake.Responder[armbilling.ProductsClientValidateMoveEligibilityResponse], errResp azfake.ErrorResponder) } // NewProductsServerTransport creates a new instance of ProductsServerTransport with the provided implementation. @@ -68,6 +69,7 @@ func NewProductsServerTransport(srv *ProductsServer) *ProductsServerTransport { newListByBillingProfilePager: newTracker[azfake.PagerResponder[armbilling.ProductsClientListByBillingProfileResponse]](), newListByCustomerPager: newTracker[azfake.PagerResponder[armbilling.ProductsClientListByCustomerResponse]](), newListByInvoiceSectionPager: newTracker[azfake.PagerResponder[armbilling.ProductsClientListByInvoiceSectionResponse]](), + beginMove: newTracker[azfake.PollerResponder[armbilling.ProductsClientMoveResponse]](), } } @@ -79,6 +81,7 @@ type ProductsServerTransport struct { newListByBillingProfilePager *tracker[azfake.PagerResponder[armbilling.ProductsClientListByBillingProfileResponse]] newListByCustomerPager *tracker[azfake.PagerResponder[armbilling.ProductsClientListByCustomerResponse]] newListByInvoiceSectionPager *tracker[azfake.PagerResponder[armbilling.ProductsClientListByInvoiceSectionResponse]] + beginMove *tracker[azfake.PollerResponder[armbilling.ProductsClientMoveResponse]] } // Do implements the policy.Transporter interface for ProductsServerTransport. @@ -103,12 +106,12 @@ func (p *ProductsServerTransport) Do(req *http.Request) (*http.Response, error) resp, err = p.dispatchNewListByCustomerPager(req) case "ProductsClient.NewListByInvoiceSectionPager": resp, err = p.dispatchNewListByInvoiceSectionPager(req) - case "ProductsClient.Move": - resp, err = p.dispatchMove(req) + case "ProductsClient.BeginMove": + resp, err = p.dispatchBeginMove(req) case "ProductsClient.Update": resp, err = p.dispatchUpdate(req) - case "ProductsClient.ValidateMove": - resp, err = p.dispatchValidateMove(req) + case "ProductsClient.ValidateMoveEligibility": + resp, err = p.dispatchValidateMoveEligibility(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -170,15 +173,66 @@ func (p *ProductsServerTransport) dispatchNewListByBillingAccountPager(req *http if err != nil { return nil, err } - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) if err != nil { return nil, err } filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) var options *armbilling.ProductsClientListByBillingAccountOptions - if filterParam != nil { + if filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { options = &armbilling.ProductsClientListByBillingAccountOptions{ - Filter: filterParam, + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, } } resp := p.srv.NewListByBillingAccountPager(billingAccountNameParam, options) @@ -223,15 +277,66 @@ func (p *ProductsServerTransport) dispatchNewListByBillingProfilePager(req *http if err != nil { return nil, err } - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) if err != nil { return nil, err } filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) var options *armbilling.ProductsClientListByBillingProfileOptions - if filterParam != nil { + if filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { options = &armbilling.ProductsClientListByBillingProfileOptions{ - Filter: filterParam, + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, } } resp := p.srv.NewListByBillingProfilePager(billingAccountNameParam, billingProfileNameParam, options) @@ -267,6 +372,7 @@ func (p *ProductsServerTransport) dispatchNewListByCustomerPager(req *http.Reque if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } + qp := req.URL.Query() billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) if err != nil { return nil, err @@ -275,7 +381,69 @@ func (p *ProductsServerTransport) dispatchNewListByCustomerPager(req *http.Reque if err != nil { return nil, err } - resp := p.srv.NewListByCustomerPager(billingAccountNameParam, customerNameParam, nil) + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.ProductsClientListByCustomerOptions + if filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.ProductsClientListByCustomerOptions{ + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := p.srv.NewListByCustomerPager(billingAccountNameParam, customerNameParam, options) newListByCustomerPager = &resp p.newListByCustomerPager.add(req, newListByCustomerPager) server.PagerResponderInjectNextLinks(newListByCustomerPager, req, func(page *armbilling.ProductsClientListByCustomerResponse, createLink func() string) { @@ -321,15 +489,66 @@ func (p *ProductsServerTransport) dispatchNewListByInvoiceSectionPager(req *http if err != nil { return nil, err } - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) if err != nil { return nil, err } filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) var options *armbilling.ProductsClientListByInvoiceSectionOptions - if filterParam != nil { + if filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { options = &armbilling.ProductsClientListByInvoiceSectionOptions{ - Filter: filterParam, + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, } } resp := p.srv.NewListByInvoiceSectionPager(billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, options) @@ -353,46 +572,51 @@ func (p *ProductsServerTransport) dispatchNewListByInvoiceSectionPager(req *http return resp, nil } -func (p *ProductsServerTransport) dispatchMove(req *http.Request) (*http.Response, error) { - if p.srv.Move == nil { - return nil, &nonRetriableError{errors.New("fake for method Move not implemented")} - } - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/move` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armbilling.TransferProductRequestProperties](req) - if err != nil { - return nil, err - } - billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) - if err != nil { - return nil, err - } - productNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("productName")]) - if err != nil { - return nil, err - } - respr, errRespr := p.srv.Move(req.Context(), billingAccountNameParam, productNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr +func (p *ProductsServerTransport) dispatchBeginMove(req *http.Request) (*http.Response, error) { + if p.srv.BeginMove == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginMove not implemented")} } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusAccepted}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", respContent.HTTPStatus)} + beginMove := p.beginMove.get(req) + if beginMove == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/move` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.MoveProductRequest](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + productNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("productName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginMove(req.Context(), billingAccountNameParam, productNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginMove = &respr + p.beginMove.add(req, beginMove) } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Product, req) + + resp, err := server.PollerResponderNext(beginMove, req) if err != nil { return nil, err } - if val := server.GetResponse(respr).Location; val != nil { - resp.Header.Set("Location", *val) + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + p.beginMove.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } - if val := server.GetResponse(respr).RetryAfter; val != nil { - resp.Header.Set("Retry-After", strconv.FormatInt(int64(*val), 10)) + if !server.PollerResponderMore(beginMove) { + p.beginMove.remove(req) } + return resp, nil } @@ -406,7 +630,7 @@ func (p *ProductsServerTransport) dispatchUpdate(req *http.Request) (*http.Respo if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armbilling.Product](req) + body, err := server.UnmarshalRequestAsJSON[armbilling.ProductPatch](req) if err != nil { return nil, err } @@ -433,9 +657,9 @@ func (p *ProductsServerTransport) dispatchUpdate(req *http.Request) (*http.Respo return resp, nil } -func (p *ProductsServerTransport) dispatchValidateMove(req *http.Request) (*http.Response, error) { - if p.srv.ValidateMove == nil { - return nil, &nonRetriableError{errors.New("fake for method ValidateMove not implemented")} +func (p *ProductsServerTransport) dispatchValidateMoveEligibility(req *http.Request) (*http.Response, error) { + if p.srv.ValidateMoveEligibility == nil { + return nil, &nonRetriableError{errors.New("fake for method ValidateMoveEligibility not implemented")} } const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validateMoveEligibility` regex := regexp.MustCompile(regexStr) @@ -443,7 +667,7 @@ func (p *ProductsServerTransport) dispatchValidateMove(req *http.Request) (*http if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armbilling.TransferProductRequestProperties](req) + body, err := server.UnmarshalRequestAsJSON[armbilling.MoveProductRequest](req) if err != nil { return nil, err } @@ -455,7 +679,7 @@ func (p *ProductsServerTransport) dispatchValidateMove(req *http.Request) (*http if err != nil { return nil, err } - respr, errRespr := p.srv.ValidateMove(req.Context(), billingAccountNameParam, productNameParam, body, nil) + respr, errRespr := p.srv.ValidateMoveEligibility(req.Context(), billingAccountNameParam, productNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -463,7 +687,7 @@ func (p *ProductsServerTransport) dispatchValidateMove(req *http.Request) (*http if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ValidateProductTransferEligibilityResult, req) + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).MoveProductEligibilityResult, req) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/billing/armbilling/fake/profiles_server.go b/sdk/resourcemanager/billing/armbilling/fake/profiles_server.go index da4f83dba8f6..28d7ec31e832 100644 --- a/sdk/resourcemanager/billing/armbilling/fake/profiles_server.go +++ b/sdk/resourcemanager/billing/armbilling/fake/profiles_server.go @@ -12,22 +12,28 @@ import ( "context" "errors" "fmt" + "net/http" + "net/url" + "regexp" + "strconv" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" - "net/http" - "net/url" - "regexp" ) // ProfilesServer is a fake server for instances of the armbilling.ProfilesClient type. type ProfilesServer struct { // BeginCreateOrUpdate is the fake for method ProfilesClient.BeginCreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted BeginCreateOrUpdate func(ctx context.Context, billingAccountName string, billingProfileName string, parameters armbilling.Profile, options *armbilling.ProfilesClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armbilling.ProfilesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + // BeginDelete is the fake for method ProfilesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, billingAccountName string, billingProfileName string, options *armbilling.ProfilesClientBeginDeleteOptions) (resp azfake.PollerResponder[armbilling.ProfilesClientDeleteResponse], errResp azfake.ErrorResponder) + // Get is the fake for method ProfilesClient.Get // HTTP status codes to indicate success: http.StatusOK Get func(ctx context.Context, billingAccountName string, billingProfileName string, options *armbilling.ProfilesClientGetOptions) (resp azfake.Responder[armbilling.ProfilesClientGetResponse], errResp azfake.ErrorResponder) @@ -35,6 +41,10 @@ type ProfilesServer struct { // NewListByBillingAccountPager is the fake for method ProfilesClient.NewListByBillingAccountPager // HTTP status codes to indicate success: http.StatusOK NewListByBillingAccountPager func(billingAccountName string, options *armbilling.ProfilesClientListByBillingAccountOptions) (resp azfake.PagerResponder[armbilling.ProfilesClientListByBillingAccountResponse]) + + // ValidateDeleteEligibility is the fake for method ProfilesClient.ValidateDeleteEligibility + // HTTP status codes to indicate success: http.StatusOK + ValidateDeleteEligibility func(ctx context.Context, billingAccountName string, billingProfileName string, options *armbilling.ProfilesClientValidateDeleteEligibilityOptions) (resp azfake.Responder[armbilling.ProfilesClientValidateDeleteEligibilityResponse], errResp azfake.ErrorResponder) } // NewProfilesServerTransport creates a new instance of ProfilesServerTransport with the provided implementation. @@ -44,6 +54,7 @@ func NewProfilesServerTransport(srv *ProfilesServer) *ProfilesServerTransport { return &ProfilesServerTransport{ srv: srv, beginCreateOrUpdate: newTracker[azfake.PollerResponder[armbilling.ProfilesClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armbilling.ProfilesClientDeleteResponse]](), newListByBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.ProfilesClientListByBillingAccountResponse]](), } } @@ -53,6 +64,7 @@ func NewProfilesServerTransport(srv *ProfilesServer) *ProfilesServerTransport { type ProfilesServerTransport struct { srv *ProfilesServer beginCreateOrUpdate *tracker[azfake.PollerResponder[armbilling.ProfilesClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armbilling.ProfilesClientDeleteResponse]] newListByBillingAccountPager *tracker[azfake.PagerResponder[armbilling.ProfilesClientListByBillingAccountResponse]] } @@ -70,10 +82,14 @@ func (p *ProfilesServerTransport) Do(req *http.Request) (*http.Response, error) switch method { case "ProfilesClient.BeginCreateOrUpdate": resp, err = p.dispatchBeginCreateOrUpdate(req) + case "ProfilesClient.BeginDelete": + resp, err = p.dispatchBeginDelete(req) case "ProfilesClient.Get": resp, err = p.dispatchGet(req) case "ProfilesClient.NewListByBillingAccountPager": resp, err = p.dispatchNewListByBillingAccountPager(req) + case "ProfilesClient.ValidateDeleteEligibility": + resp, err = p.dispatchValidateDeleteEligibility(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -122,9 +138,9 @@ func (p *ProfilesServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) return nil, err } - if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { p.beginCreateOrUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} } if !server.PollerResponderMore(beginCreateOrUpdate) { p.beginCreateOrUpdate.remove(req) @@ -133,6 +149,50 @@ func (p *ProfilesServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) return resp, nil } +func (p *ProfilesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if p.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := p.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginDelete(req.Context(), billingAccountNameParam, billingProfileNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + p.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + p.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + p.beginDelete.remove(req) + } + + return resp, nil +} + func (p *ProfilesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if p.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} @@ -143,7 +203,6 @@ func (p *ProfilesServerTransport) dispatchGet(req *http.Request) (*http.Response if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - qp := req.URL.Query() billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) if err != nil { return nil, err @@ -152,18 +211,7 @@ func (p *ProfilesServerTransport) dispatchGet(req *http.Request) (*http.Response if err != nil { return nil, err } - expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) - if err != nil { - return nil, err - } - expandParam := getOptional(expandUnescaped) - var options *armbilling.ProfilesClientGetOptions - if expandParam != nil { - options = &armbilling.ProfilesClientGetOptions{ - Expand: expandParam, - } - } - respr, errRespr := p.srv.Get(req.Context(), billingAccountNameParam, billingProfileNameParam, options) + respr, errRespr := p.srv.Get(req.Context(), billingAccountNameParam, billingProfileNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -195,15 +243,75 @@ func (p *ProfilesServerTransport) dispatchNewListByBillingAccountPager(req *http if err != nil { return nil, err } - expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + includeDeletedUnescaped, err := url.QueryUnescape(qp.Get("includeDeleted")) + if err != nil { + return nil, err + } + includeDeletedParam, err := parseOptional(includeDeletedUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) if err != nil { return nil, err } - expandParam := getOptional(expandUnescaped) + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) var options *armbilling.ProfilesClientListByBillingAccountOptions - if expandParam != nil { + if includeDeletedParam != nil || filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { options = &armbilling.ProfilesClientListByBillingAccountOptions{ - Expand: expandParam, + IncludeDeleted: includeDeletedParam, + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, } } resp := p.srv.NewListByBillingAccountPager(billingAccountNameParam, options) @@ -226,3 +334,36 @@ func (p *ProfilesServerTransport) dispatchNewListByBillingAccountPager(req *http } return resp, nil } + +func (p *ProfilesServerTransport) dispatchValidateDeleteEligibility(req *http.Request) (*http.Response, error) { + if p.srv.ValidateDeleteEligibility == nil { + return nil, &nonRetriableError{errors.New("fake for method ValidateDeleteEligibility not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validateDeleteEligibility` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.ValidateDeleteEligibility(req.Context(), billingAccountNameParam, billingProfileNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DeleteBillingProfileEligibilityResult, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/fake/property_server.go b/sdk/resourcemanager/billing/armbilling/fake/property_server.go index a8bd0dc73bfe..6792a4eab9eb 100644 --- a/sdk/resourcemanager/billing/armbilling/fake/property_server.go +++ b/sdk/resourcemanager/billing/armbilling/fake/property_server.go @@ -12,12 +12,15 @@ import ( "context" "errors" "fmt" + "net/http" + "net/url" + "regexp" + "strconv" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" - "net/http" - "regexp" ) // PropertyServer is a fake server for instances of the armbilling.PropertyClient type. @@ -81,7 +84,31 @@ func (p *PropertyServerTransport) dispatchGet(req *http.Request) (*http.Response if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := p.srv.Get(req.Context(), nil) + qp := req.URL.Query() + includeBillingCountryUnescaped, err := url.QueryUnescape(qp.Get("includeBillingCountry")) + if err != nil { + return nil, err + } + includeBillingCountryParam, err := parseOptional(includeBillingCountryUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + includeTransitionStatusUnescaped, err := url.QueryUnescape(qp.Get("includeTransitionStatus")) + if err != nil { + return nil, err + } + includeTransitionStatusParam, err := parseOptional(includeTransitionStatusUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + var options *armbilling.PropertyClientGetOptions + if includeBillingCountryParam != nil || includeTransitionStatusParam != nil { + options = &armbilling.PropertyClientGetOptions{ + IncludeBillingCountry: includeBillingCountryParam, + IncludeTransitionStatus: includeTransitionStatusParam, + } + } + respr, errRespr := p.srv.Get(req.Context(), options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/billing/armbilling/fake/recipienttransfers_server.go b/sdk/resourcemanager/billing/armbilling/fake/recipienttransfers_server.go new file mode 100644 index 000000000000..b4f0d52e7641 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/fake/recipienttransfers_server.go @@ -0,0 +1,248 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "regexp" + + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// RecipientTransfersServer is a fake server for instances of the armbilling.RecipientTransfersClient type. +type RecipientTransfersServer struct { + // Accept is the fake for method RecipientTransfersClient.Accept + // HTTP status codes to indicate success: http.StatusOK + Accept func(ctx context.Context, transferName string, parameters armbilling.AcceptTransferRequest, options *armbilling.RecipientTransfersClientAcceptOptions) (resp azfake.Responder[armbilling.RecipientTransfersClientAcceptResponse], errResp azfake.ErrorResponder) + + // Decline is the fake for method RecipientTransfersClient.Decline + // HTTP status codes to indicate success: http.StatusOK + Decline func(ctx context.Context, transferName string, options *armbilling.RecipientTransfersClientDeclineOptions) (resp azfake.Responder[armbilling.RecipientTransfersClientDeclineResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method RecipientTransfersClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, transferName string, options *armbilling.RecipientTransfersClientGetOptions) (resp azfake.Responder[armbilling.RecipientTransfersClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method RecipientTransfersClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armbilling.RecipientTransfersClientListOptions) (resp azfake.PagerResponder[armbilling.RecipientTransfersClientListResponse]) + + // Validate is the fake for method RecipientTransfersClient.Validate + // HTTP status codes to indicate success: http.StatusOK + Validate func(ctx context.Context, transferName string, parameters armbilling.AcceptTransferRequest, options *armbilling.RecipientTransfersClientValidateOptions) (resp azfake.Responder[armbilling.RecipientTransfersClientValidateResponse], errResp azfake.ErrorResponder) +} + +// NewRecipientTransfersServerTransport creates a new instance of RecipientTransfersServerTransport with the provided implementation. +// The returned RecipientTransfersServerTransport instance is connected to an instance of armbilling.RecipientTransfersClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewRecipientTransfersServerTransport(srv *RecipientTransfersServer) *RecipientTransfersServerTransport { + return &RecipientTransfersServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armbilling.RecipientTransfersClientListResponse]](), + } +} + +// RecipientTransfersServerTransport connects instances of armbilling.RecipientTransfersClient to instances of RecipientTransfersServer. +// Don't use this type directly, use NewRecipientTransfersServerTransport instead. +type RecipientTransfersServerTransport struct { + srv *RecipientTransfersServer + newListPager *tracker[azfake.PagerResponder[armbilling.RecipientTransfersClientListResponse]] +} + +// Do implements the policy.Transporter interface for RecipientTransfersServerTransport. +func (r *RecipientTransfersServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "RecipientTransfersClient.Accept": + resp, err = r.dispatchAccept(req) + case "RecipientTransfersClient.Decline": + resp, err = r.dispatchDecline(req) + case "RecipientTransfersClient.Get": + resp, err = r.dispatchGet(req) + case "RecipientTransfersClient.NewListPager": + resp, err = r.dispatchNewListPager(req) + case "RecipientTransfersClient.Validate": + resp, err = r.dispatchValidate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (r *RecipientTransfersServerTransport) dispatchAccept(req *http.Request) (*http.Response, error) { + if r.srv.Accept == nil { + return nil, &nonRetriableError{errors.New("fake for method Accept not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/transfers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/accept` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.AcceptTransferRequest](req) + if err != nil { + return nil, err + } + transferNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("transferName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Accept(req.Context(), transferNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RecipientTransferDetails, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RecipientTransfersServerTransport) dispatchDecline(req *http.Request) (*http.Response, error) { + if r.srv.Decline == nil { + return nil, &nonRetriableError{errors.New("fake for method Decline not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/transfers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/decline` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + transferNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("transferName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Decline(req.Context(), transferNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RecipientTransferDetails, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RecipientTransfersServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if r.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/transfers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + transferNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("transferName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Get(req.Context(), transferNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RecipientTransferDetails, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RecipientTransfersServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := r.newListPager.get(req) + if newListPager == nil { + resp := r.srv.NewListPager(nil) + newListPager = &resp + r.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armbilling.RecipientTransfersClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + r.newListPager.remove(req) + } + return resp, nil +} + +func (r *RecipientTransfersServerTransport) dispatchValidate(req *http.Request) (*http.Response, error) { + if r.srv.Validate == nil { + return nil, &nonRetriableError{errors.New("fake for method Validate not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/transfers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validate` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.AcceptTransferRequest](req) + if err != nil { + return nil, err + } + transferNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("transferName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Validate(req.Context(), transferNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ValidateTransferListResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/fake/requests_server.go b/sdk/resourcemanager/billing/armbilling/fake/requests_server.go new file mode 100644 index 000000000000..2d090fc77e29 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/fake/requests_server.go @@ -0,0 +1,703 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "regexp" + "strconv" + + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// RequestsServer is a fake server for instances of the armbilling.RequestsClient type. +type RequestsServer struct { + // BeginCreateOrUpdate is the fake for method RequestsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, billingRequestName string, parameters armbilling.Request, options *armbilling.RequestsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armbilling.RequestsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method RequestsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, billingRequestName string, options *armbilling.RequestsClientGetOptions) (resp azfake.Responder[armbilling.RequestsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByBillingAccountPager is the fake for method RequestsClient.NewListByBillingAccountPager + // HTTP status codes to indicate success: http.StatusOK + NewListByBillingAccountPager func(billingAccountName string, options *armbilling.RequestsClientListByBillingAccountOptions) (resp azfake.PagerResponder[armbilling.RequestsClientListByBillingAccountResponse]) + + // NewListByBillingProfilePager is the fake for method RequestsClient.NewListByBillingProfilePager + // HTTP status codes to indicate success: http.StatusOK + NewListByBillingProfilePager func(billingAccountName string, billingProfileName string, options *armbilling.RequestsClientListByBillingProfileOptions) (resp azfake.PagerResponder[armbilling.RequestsClientListByBillingProfileResponse]) + + // NewListByCustomerPager is the fake for method RequestsClient.NewListByCustomerPager + // HTTP status codes to indicate success: http.StatusOK + NewListByCustomerPager func(billingAccountName string, billingProfileName string, customerName string, options *armbilling.RequestsClientListByCustomerOptions) (resp azfake.PagerResponder[armbilling.RequestsClientListByCustomerResponse]) + + // NewListByInvoiceSectionPager is the fake for method RequestsClient.NewListByInvoiceSectionPager + // HTTP status codes to indicate success: http.StatusOK + NewListByInvoiceSectionPager func(billingAccountName string, billingProfileName string, invoiceSectionName string, options *armbilling.RequestsClientListByInvoiceSectionOptions) (resp azfake.PagerResponder[armbilling.RequestsClientListByInvoiceSectionResponse]) + + // NewListByUserPager is the fake for method RequestsClient.NewListByUserPager + // HTTP status codes to indicate success: http.StatusOK + NewListByUserPager func(options *armbilling.RequestsClientListByUserOptions) (resp azfake.PagerResponder[armbilling.RequestsClientListByUserResponse]) +} + +// NewRequestsServerTransport creates a new instance of RequestsServerTransport with the provided implementation. +// The returned RequestsServerTransport instance is connected to an instance of armbilling.RequestsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewRequestsServerTransport(srv *RequestsServer) *RequestsServerTransport { + return &RequestsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armbilling.RequestsClientCreateOrUpdateResponse]](), + newListByBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.RequestsClientListByBillingAccountResponse]](), + newListByBillingProfilePager: newTracker[azfake.PagerResponder[armbilling.RequestsClientListByBillingProfileResponse]](), + newListByCustomerPager: newTracker[azfake.PagerResponder[armbilling.RequestsClientListByCustomerResponse]](), + newListByInvoiceSectionPager: newTracker[azfake.PagerResponder[armbilling.RequestsClientListByInvoiceSectionResponse]](), + newListByUserPager: newTracker[azfake.PagerResponder[armbilling.RequestsClientListByUserResponse]](), + } +} + +// RequestsServerTransport connects instances of armbilling.RequestsClient to instances of RequestsServer. +// Don't use this type directly, use NewRequestsServerTransport instead. +type RequestsServerTransport struct { + srv *RequestsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armbilling.RequestsClientCreateOrUpdateResponse]] + newListByBillingAccountPager *tracker[azfake.PagerResponder[armbilling.RequestsClientListByBillingAccountResponse]] + newListByBillingProfilePager *tracker[azfake.PagerResponder[armbilling.RequestsClientListByBillingProfileResponse]] + newListByCustomerPager *tracker[azfake.PagerResponder[armbilling.RequestsClientListByCustomerResponse]] + newListByInvoiceSectionPager *tracker[azfake.PagerResponder[armbilling.RequestsClientListByInvoiceSectionResponse]] + newListByUserPager *tracker[azfake.PagerResponder[armbilling.RequestsClientListByUserResponse]] +} + +// Do implements the policy.Transporter interface for RequestsServerTransport. +func (r *RequestsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "RequestsClient.BeginCreateOrUpdate": + resp, err = r.dispatchBeginCreateOrUpdate(req) + case "RequestsClient.Get": + resp, err = r.dispatchGet(req) + case "RequestsClient.NewListByBillingAccountPager": + resp, err = r.dispatchNewListByBillingAccountPager(req) + case "RequestsClient.NewListByBillingProfilePager": + resp, err = r.dispatchNewListByBillingProfilePager(req) + case "RequestsClient.NewListByCustomerPager": + resp, err = r.dispatchNewListByCustomerPager(req) + case "RequestsClient.NewListByInvoiceSectionPager": + resp, err = r.dispatchNewListByInvoiceSectionPager(req) + case "RequestsClient.NewListByUserPager": + resp, err = r.dispatchNewListByUserPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (r *RequestsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if r.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := r.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/providers/Microsoft\.Billing/billingRequests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.Request](req) + if err != nil { + return nil, err + } + billingRequestNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingRequestName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginCreateOrUpdate(req.Context(), billingRequestNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + r.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + r.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + r.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (r *RequestsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if r.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingRequests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingRequestNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingRequestName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Get(req.Context(), billingRequestNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Request, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RequestsServerTransport) dispatchNewListByBillingAccountPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListByBillingAccountPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByBillingAccountPager not implemented")} + } + newListByBillingAccountPager := r.newListByBillingAccountPager.get(req) + if newListByBillingAccountPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRequests` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.RequestsClientListByBillingAccountOptions + if filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.RequestsClientListByBillingAccountOptions{ + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := r.srv.NewListByBillingAccountPager(billingAccountNameParam, options) + newListByBillingAccountPager = &resp + r.newListByBillingAccountPager.add(req, newListByBillingAccountPager) + server.PagerResponderInjectNextLinks(newListByBillingAccountPager, req, func(page *armbilling.RequestsClientListByBillingAccountResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByBillingAccountPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListByBillingAccountPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByBillingAccountPager) { + r.newListByBillingAccountPager.remove(req) + } + return resp, nil +} + +func (r *RequestsServerTransport) dispatchNewListByBillingProfilePager(req *http.Request) (*http.Response, error) { + if r.srv.NewListByBillingProfilePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByBillingProfilePager not implemented")} + } + newListByBillingProfilePager := r.newListByBillingProfilePager.get(req) + if newListByBillingProfilePager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRequests` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.RequestsClientListByBillingProfileOptions + if filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.RequestsClientListByBillingProfileOptions{ + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := r.srv.NewListByBillingProfilePager(billingAccountNameParam, billingProfileNameParam, options) + newListByBillingProfilePager = &resp + r.newListByBillingProfilePager.add(req, newListByBillingProfilePager) + server.PagerResponderInjectNextLinks(newListByBillingProfilePager, req, func(page *armbilling.RequestsClientListByBillingProfileResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByBillingProfilePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListByBillingProfilePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByBillingProfilePager) { + r.newListByBillingProfilePager.remove(req) + } + return resp, nil +} + +func (r *RequestsServerTransport) dispatchNewListByCustomerPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListByCustomerPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByCustomerPager not implemented")} + } + newListByCustomerPager := r.newListByCustomerPager.get(req) + if newListByCustomerPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRequests` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.RequestsClientListByCustomerOptions + if filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.RequestsClientListByCustomerOptions{ + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := r.srv.NewListByCustomerPager(billingAccountNameParam, billingProfileNameParam, customerNameParam, options) + newListByCustomerPager = &resp + r.newListByCustomerPager.add(req, newListByCustomerPager) + server.PagerResponderInjectNextLinks(newListByCustomerPager, req, func(page *armbilling.RequestsClientListByCustomerResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByCustomerPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListByCustomerPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByCustomerPager) { + r.newListByCustomerPager.remove(req) + } + return resp, nil +} + +func (r *RequestsServerTransport) dispatchNewListByInvoiceSectionPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListByInvoiceSectionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByInvoiceSectionPager not implemented")} + } + newListByInvoiceSectionPager := r.newListByInvoiceSectionPager.get(req) + if newListByInvoiceSectionPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoiceSections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRequests` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + invoiceSectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceSectionName")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.RequestsClientListByInvoiceSectionOptions + if filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.RequestsClientListByInvoiceSectionOptions{ + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := r.srv.NewListByInvoiceSectionPager(billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, options) + newListByInvoiceSectionPager = &resp + r.newListByInvoiceSectionPager.add(req, newListByInvoiceSectionPager) + server.PagerResponderInjectNextLinks(newListByInvoiceSectionPager, req, func(page *armbilling.RequestsClientListByInvoiceSectionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByInvoiceSectionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListByInvoiceSectionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByInvoiceSectionPager) { + r.newListByInvoiceSectionPager.remove(req) + } + return resp, nil +} + +func (r *RequestsServerTransport) dispatchNewListByUserPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListByUserPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByUserPager not implemented")} + } + newListByUserPager := r.newListByUserPager.get(req) + if newListByUserPager == nil { + qp := req.URL.Query() + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.RequestsClientListByUserOptions + if filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.RequestsClientListByUserOptions{ + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := r.srv.NewListByUserPager(options) + newListByUserPager = &resp + r.newListByUserPager.add(req, newListByUserPager) + server.PagerResponderInjectNextLinks(newListByUserPager, req, func(page *armbilling.RequestsClientListByUserResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByUserPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListByUserPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByUserPager) { + r.newListByUserPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/fake/reservationorders_server.go b/sdk/resourcemanager/billing/armbilling/fake/reservationorders_server.go new file mode 100644 index 000000000000..092128c0558e --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/fake/reservationorders_server.go @@ -0,0 +1,195 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "regexp" + "strconv" + + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// ReservationOrdersServer is a fake server for instances of the armbilling.ReservationOrdersClient type. +type ReservationOrdersServer struct { + // GetByBillingAccount is the fake for method ReservationOrdersClient.GetByBillingAccount + // HTTP status codes to indicate success: http.StatusOK + GetByBillingAccount func(ctx context.Context, billingAccountName string, reservationOrderID string, options *armbilling.ReservationOrdersClientGetByBillingAccountOptions) (resp azfake.Responder[armbilling.ReservationOrdersClientGetByBillingAccountResponse], errResp azfake.ErrorResponder) + + // NewListByBillingAccountPager is the fake for method ReservationOrdersClient.NewListByBillingAccountPager + // HTTP status codes to indicate success: http.StatusOK + NewListByBillingAccountPager func(billingAccountName string, options *armbilling.ReservationOrdersClientListByBillingAccountOptions) (resp azfake.PagerResponder[armbilling.ReservationOrdersClientListByBillingAccountResponse]) +} + +// NewReservationOrdersServerTransport creates a new instance of ReservationOrdersServerTransport with the provided implementation. +// The returned ReservationOrdersServerTransport instance is connected to an instance of armbilling.ReservationOrdersClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewReservationOrdersServerTransport(srv *ReservationOrdersServer) *ReservationOrdersServerTransport { + return &ReservationOrdersServerTransport{ + srv: srv, + newListByBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.ReservationOrdersClientListByBillingAccountResponse]](), + } +} + +// ReservationOrdersServerTransport connects instances of armbilling.ReservationOrdersClient to instances of ReservationOrdersServer. +// Don't use this type directly, use NewReservationOrdersServerTransport instead. +type ReservationOrdersServerTransport struct { + srv *ReservationOrdersServer + newListByBillingAccountPager *tracker[azfake.PagerResponder[armbilling.ReservationOrdersClientListByBillingAccountResponse]] +} + +// Do implements the policy.Transporter interface for ReservationOrdersServerTransport. +func (r *ReservationOrdersServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "ReservationOrdersClient.GetByBillingAccount": + resp, err = r.dispatchGetByBillingAccount(req) + case "ReservationOrdersClient.NewListByBillingAccountPager": + resp, err = r.dispatchNewListByBillingAccountPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (r *ReservationOrdersServerTransport) dispatchGetByBillingAccount(req *http.Request) (*http.Response, error) { + if r.srv.GetByBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByBillingAccount not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/reservationOrders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + reservationOrderIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationOrderId")]) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) + var options *armbilling.ReservationOrdersClientGetByBillingAccountOptions + if expandParam != nil { + options = &armbilling.ReservationOrdersClientGetByBillingAccountOptions{ + Expand: expandParam, + } + } + respr, errRespr := r.srv.GetByBillingAccount(req.Context(), billingAccountNameParam, reservationOrderIDParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ReservationOrder, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ReservationOrdersServerTransport) dispatchNewListByBillingAccountPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListByBillingAccountPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByBillingAccountPager not implemented")} + } + newListByBillingAccountPager := r.newListByBillingAccountPager.get(req) + if newListByBillingAccountPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/reservationOrders` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + skiptokenUnescaped, err := url.QueryUnescape(qp.Get("skiptoken")) + if err != nil { + return nil, err + } + skiptokenParam, err := parseOptional(skiptokenUnescaped, func(v string) (float32, error) { + p, parseErr := strconv.ParseFloat(v, 32) + if parseErr != nil { + return 0, parseErr + } + return float32(p), nil + }) + if err != nil { + return nil, err + } + var options *armbilling.ReservationOrdersClientListByBillingAccountOptions + if filterParam != nil || orderByParam != nil || skiptokenParam != nil { + options = &armbilling.ReservationOrdersClientListByBillingAccountOptions{ + Filter: filterParam, + OrderBy: orderByParam, + Skiptoken: skiptokenParam, + } + } + resp := r.srv.NewListByBillingAccountPager(billingAccountNameParam, options) + newListByBillingAccountPager = &resp + r.newListByBillingAccountPager.add(req, newListByBillingAccountPager) + server.PagerResponderInjectNextLinks(newListByBillingAccountPager, req, func(page *armbilling.ReservationOrdersClientListByBillingAccountResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByBillingAccountPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListByBillingAccountPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByBillingAccountPager) { + r.newListByBillingAccountPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/fake/reservations_server.go b/sdk/resourcemanager/billing/armbilling/fake/reservations_server.go index 2c4ba1fdcb75..4a9960f14ca4 100644 --- a/sdk/resourcemanager/billing/armbilling/fake/reservations_server.go +++ b/sdk/resourcemanager/billing/armbilling/fake/reservations_server.go @@ -9,20 +9,27 @@ package fake import ( + "context" "errors" "fmt" + "net/http" + "net/url" + "regexp" + "strconv" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" - "net/http" - "net/url" - "regexp" ) // ReservationsServer is a fake server for instances of the armbilling.ReservationsClient type. type ReservationsServer struct { + // GetByReservationOrder is the fake for method ReservationsClient.GetByReservationOrder + // HTTP status codes to indicate success: http.StatusOK + GetByReservationOrder func(ctx context.Context, billingAccountName string, reservationOrderID string, reservationID string, options *armbilling.ReservationsClientGetByReservationOrderOptions) (resp azfake.Responder[armbilling.ReservationsClientGetByReservationOrderResponse], errResp azfake.ErrorResponder) + // NewListByBillingAccountPager is the fake for method ReservationsClient.NewListByBillingAccountPager // HTTP status codes to indicate success: http.StatusOK NewListByBillingAccountPager func(billingAccountName string, options *armbilling.ReservationsClientListByBillingAccountOptions) (resp azfake.PagerResponder[armbilling.ReservationsClientListByBillingAccountResponse]) @@ -30,6 +37,14 @@ type ReservationsServer struct { // NewListByBillingProfilePager is the fake for method ReservationsClient.NewListByBillingProfilePager // HTTP status codes to indicate success: http.StatusOK NewListByBillingProfilePager func(billingAccountName string, billingProfileName string, options *armbilling.ReservationsClientListByBillingProfileOptions) (resp azfake.PagerResponder[armbilling.ReservationsClientListByBillingProfileResponse]) + + // NewListByReservationOrderPager is the fake for method ReservationsClient.NewListByReservationOrderPager + // HTTP status codes to indicate success: http.StatusOK + NewListByReservationOrderPager func(billingAccountName string, reservationOrderID string, options *armbilling.ReservationsClientListByReservationOrderOptions) (resp azfake.PagerResponder[armbilling.ReservationsClientListByReservationOrderResponse]) + + // BeginUpdateByBillingAccount is the fake for method ReservationsClient.BeginUpdateByBillingAccount + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdateByBillingAccount func(ctx context.Context, billingAccountName string, reservationOrderID string, reservationID string, body armbilling.Patch, options *armbilling.ReservationsClientBeginUpdateByBillingAccountOptions) (resp azfake.PollerResponder[armbilling.ReservationsClientUpdateByBillingAccountResponse], errResp azfake.ErrorResponder) } // NewReservationsServerTransport creates a new instance of ReservationsServerTransport with the provided implementation. @@ -37,18 +52,22 @@ type ReservationsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewReservationsServerTransport(srv *ReservationsServer) *ReservationsServerTransport { return &ReservationsServerTransport{ - srv: srv, - newListByBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.ReservationsClientListByBillingAccountResponse]](), - newListByBillingProfilePager: newTracker[azfake.PagerResponder[armbilling.ReservationsClientListByBillingProfileResponse]](), + srv: srv, + newListByBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.ReservationsClientListByBillingAccountResponse]](), + newListByBillingProfilePager: newTracker[azfake.PagerResponder[armbilling.ReservationsClientListByBillingProfileResponse]](), + newListByReservationOrderPager: newTracker[azfake.PagerResponder[armbilling.ReservationsClientListByReservationOrderResponse]](), + beginUpdateByBillingAccount: newTracker[azfake.PollerResponder[armbilling.ReservationsClientUpdateByBillingAccountResponse]](), } } // ReservationsServerTransport connects instances of armbilling.ReservationsClient to instances of ReservationsServer. // Don't use this type directly, use NewReservationsServerTransport instead. type ReservationsServerTransport struct { - srv *ReservationsServer - newListByBillingAccountPager *tracker[azfake.PagerResponder[armbilling.ReservationsClientListByBillingAccountResponse]] - newListByBillingProfilePager *tracker[azfake.PagerResponder[armbilling.ReservationsClientListByBillingProfileResponse]] + srv *ReservationsServer + newListByBillingAccountPager *tracker[azfake.PagerResponder[armbilling.ReservationsClientListByBillingAccountResponse]] + newListByBillingProfilePager *tracker[azfake.PagerResponder[armbilling.ReservationsClientListByBillingProfileResponse]] + newListByReservationOrderPager *tracker[azfake.PagerResponder[armbilling.ReservationsClientListByReservationOrderResponse]] + beginUpdateByBillingAccount *tracker[azfake.PollerResponder[armbilling.ReservationsClientUpdateByBillingAccountResponse]] } // Do implements the policy.Transporter interface for ReservationsServerTransport. @@ -63,10 +82,16 @@ func (r *ReservationsServerTransport) Do(req *http.Request) (*http.Response, err var err error switch method { + case "ReservationsClient.GetByReservationOrder": + resp, err = r.dispatchGetByReservationOrder(req) case "ReservationsClient.NewListByBillingAccountPager": resp, err = r.dispatchNewListByBillingAccountPager(req) case "ReservationsClient.NewListByBillingProfilePager": resp, err = r.dispatchNewListByBillingProfilePager(req) + case "ReservationsClient.NewListByReservationOrderPager": + resp, err = r.dispatchNewListByReservationOrderPager(req) + case "ReservationsClient.BeginUpdateByBillingAccount": + resp, err = r.dispatchBeginUpdateByBillingAccount(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -78,6 +103,55 @@ func (r *ReservationsServerTransport) Do(req *http.Request) (*http.Response, err return resp, nil } +func (r *ReservationsServerTransport) dispatchGetByReservationOrder(req *http.Request) (*http.Response, error) { + if r.srv.GetByReservationOrder == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByReservationOrder not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/reservationOrders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/reservations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + reservationOrderIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationOrderId")]) + if err != nil { + return nil, err + } + reservationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationId")]) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) + var options *armbilling.ReservationsClientGetByReservationOrderOptions + if expandParam != nil { + options = &armbilling.ReservationsClientGetByReservationOrderOptions{ + Expand: expandParam, + } + } + respr, errRespr := r.srv.GetByReservationOrder(req.Context(), billingAccountNameParam, reservationOrderIDParam, reservationIDParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Reservation, req) + if err != nil { + return nil, err + } + return resp, nil +} + func (r *ReservationsServerTransport) dispatchNewListByBillingAccountPager(req *http.Request) (*http.Response, error) { if r.srv.NewListByBillingAccountPager == nil { return nil, &nonRetriableError{errors.New("fake for method NewListByBillingAccountPager not implemented")} @@ -95,16 +169,30 @@ func (r *ReservationsServerTransport) dispatchNewListByBillingAccountPager(req * if err != nil { return nil, err } - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) if err != nil { return nil, err } filterParam := getOptional(filterUnescaped) - orderbyUnescaped, err := url.QueryUnescape(qp.Get("$orderby")) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + skiptokenUnescaped, err := url.QueryUnescape(qp.Get("skiptoken")) + if err != nil { + return nil, err + } + skiptokenParam, err := parseOptional(skiptokenUnescaped, func(v string) (float32, error) { + p, parseErr := strconv.ParseFloat(v, 32) + if parseErr != nil { + return 0, parseErr + } + return float32(p), nil + }) if err != nil { return nil, err } - orderbyParam := getOptional(orderbyUnescaped) refreshSummaryUnescaped, err := url.QueryUnescape(qp.Get("refreshSummary")) if err != nil { return nil, err @@ -115,13 +203,29 @@ func (r *ReservationsServerTransport) dispatchNewListByBillingAccountPager(req * return nil, err } selectedStateParam := getOptional(selectedStateUnescaped) + takeUnescaped, err := url.QueryUnescape(qp.Get("take")) + if err != nil { + return nil, err + } + takeParam, err := parseOptional(takeUnescaped, func(v string) (float32, error) { + p, parseErr := strconv.ParseFloat(v, 32) + if parseErr != nil { + return 0, parseErr + } + return float32(p), nil + }) + if err != nil { + return nil, err + } var options *armbilling.ReservationsClientListByBillingAccountOptions - if filterParam != nil || orderbyParam != nil || refreshSummaryParam != nil || selectedStateParam != nil { + if filterParam != nil || orderByParam != nil || skiptokenParam != nil || refreshSummaryParam != nil || selectedStateParam != nil || takeParam != nil { options = &armbilling.ReservationsClientListByBillingAccountOptions{ Filter: filterParam, - Orderby: orderbyParam, + OrderBy: orderByParam, + Skiptoken: skiptokenParam, RefreshSummary: refreshSummaryParam, SelectedState: selectedStateParam, + Take: takeParam, } } resp := r.srv.NewListByBillingAccountPager(billingAccountNameParam, options) @@ -166,16 +270,30 @@ func (r *ReservationsServerTransport) dispatchNewListByBillingProfilePager(req * if err != nil { return nil, err } - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) if err != nil { return nil, err } filterParam := getOptional(filterUnescaped) - orderbyUnescaped, err := url.QueryUnescape(qp.Get("$orderby")) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + skiptokenUnescaped, err := url.QueryUnescape(qp.Get("skiptoken")) + if err != nil { + return nil, err + } + skiptokenParam, err := parseOptional(skiptokenUnescaped, func(v string) (float32, error) { + p, parseErr := strconv.ParseFloat(v, 32) + if parseErr != nil { + return 0, parseErr + } + return float32(p), nil + }) if err != nil { return nil, err } - orderbyParam := getOptional(orderbyUnescaped) refreshSummaryUnescaped, err := url.QueryUnescape(qp.Get("refreshSummary")) if err != nil { return nil, err @@ -186,13 +304,29 @@ func (r *ReservationsServerTransport) dispatchNewListByBillingProfilePager(req * return nil, err } selectedStateParam := getOptional(selectedStateUnescaped) + takeUnescaped, err := url.QueryUnescape(qp.Get("take")) + if err != nil { + return nil, err + } + takeParam, err := parseOptional(takeUnescaped, func(v string) (float32, error) { + p, parseErr := strconv.ParseFloat(v, 32) + if parseErr != nil { + return 0, parseErr + } + return float32(p), nil + }) + if err != nil { + return nil, err + } var options *armbilling.ReservationsClientListByBillingProfileOptions - if filterParam != nil || orderbyParam != nil || refreshSummaryParam != nil || selectedStateParam != nil { + if filterParam != nil || orderByParam != nil || skiptokenParam != nil || refreshSummaryParam != nil || selectedStateParam != nil || takeParam != nil { options = &armbilling.ReservationsClientListByBillingProfileOptions{ Filter: filterParam, - Orderby: orderbyParam, + OrderBy: orderByParam, + Skiptoken: skiptokenParam, RefreshSummary: refreshSummaryParam, SelectedState: selectedStateParam, + Take: takeParam, } } resp := r.srv.NewListByBillingProfilePager(billingAccountNameParam, billingProfileNameParam, options) @@ -215,3 +349,96 @@ func (r *ReservationsServerTransport) dispatchNewListByBillingProfilePager(req * } return resp, nil } + +func (r *ReservationsServerTransport) dispatchNewListByReservationOrderPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListByReservationOrderPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByReservationOrderPager not implemented")} + } + newListByReservationOrderPager := r.newListByReservationOrderPager.get(req) + if newListByReservationOrderPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/reservationOrders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/reservations` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + reservationOrderIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationOrderId")]) + if err != nil { + return nil, err + } + resp := r.srv.NewListByReservationOrderPager(billingAccountNameParam, reservationOrderIDParam, nil) + newListByReservationOrderPager = &resp + r.newListByReservationOrderPager.add(req, newListByReservationOrderPager) + server.PagerResponderInjectNextLinks(newListByReservationOrderPager, req, func(page *armbilling.ReservationsClientListByReservationOrderResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByReservationOrderPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListByReservationOrderPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByReservationOrderPager) { + r.newListByReservationOrderPager.remove(req) + } + return resp, nil +} + +func (r *ReservationsServerTransport) dispatchBeginUpdateByBillingAccount(req *http.Request) (*http.Response, error) { + if r.srv.BeginUpdateByBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdateByBillingAccount not implemented")} + } + beginUpdateByBillingAccount := r.beginUpdateByBillingAccount.get(req) + if beginUpdateByBillingAccount == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/reservationOrders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/reservations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.Patch](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + reservationOrderIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationOrderId")]) + if err != nil { + return nil, err + } + reservationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationId")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginUpdateByBillingAccount(req.Context(), billingAccountNameParam, reservationOrderIDParam, reservationIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdateByBillingAccount = &respr + r.beginUpdateByBillingAccount.add(req, beginUpdateByBillingAccount) + } + + resp, err := server.PollerResponderNext(beginUpdateByBillingAccount, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + r.beginUpdateByBillingAccount.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdateByBillingAccount) { + r.beginUpdateByBillingAccount.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/fake/roleassignments_server.go b/sdk/resourcemanager/billing/armbilling/fake/roleassignments_server.go index 190969679115..6cd5e183100a 100644 --- a/sdk/resourcemanager/billing/armbilling/fake/roleassignments_server.go +++ b/sdk/resourcemanager/billing/armbilling/fake/roleassignments_server.go @@ -12,28 +12,70 @@ import ( "context" "errors" "fmt" + "net/http" + "net/url" + "regexp" + "strconv" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" - "net/http" - "net/url" - "regexp" ) // RoleAssignmentsServer is a fake server for instances of the armbilling.RoleAssignmentsClient type. type RoleAssignmentsServer struct { + // BeginCreateByBillingAccount is the fake for method RoleAssignmentsClient.BeginCreateByBillingAccount + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginCreateByBillingAccount func(ctx context.Context, billingAccountName string, parameters armbilling.RoleAssignmentProperties, options *armbilling.RoleAssignmentsClientBeginCreateByBillingAccountOptions) (resp azfake.PollerResponder[armbilling.RoleAssignmentsClientCreateByBillingAccountResponse], errResp azfake.ErrorResponder) + + // BeginCreateByBillingProfile is the fake for method RoleAssignmentsClient.BeginCreateByBillingProfile + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginCreateByBillingProfile func(ctx context.Context, billingAccountName string, billingProfileName string, parameters armbilling.RoleAssignmentProperties, options *armbilling.RoleAssignmentsClientBeginCreateByBillingProfileOptions) (resp azfake.PollerResponder[armbilling.RoleAssignmentsClientCreateByBillingProfileResponse], errResp azfake.ErrorResponder) + + // BeginCreateByCustomer is the fake for method RoleAssignmentsClient.BeginCreateByCustomer + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginCreateByCustomer func(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, parameters armbilling.RoleAssignmentProperties, options *armbilling.RoleAssignmentsClientBeginCreateByCustomerOptions) (resp azfake.PollerResponder[armbilling.RoleAssignmentsClientCreateByCustomerResponse], errResp azfake.ErrorResponder) + + // BeginCreateByInvoiceSection is the fake for method RoleAssignmentsClient.BeginCreateByInvoiceSection + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginCreateByInvoiceSection func(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, parameters armbilling.RoleAssignmentProperties, options *armbilling.RoleAssignmentsClientBeginCreateByInvoiceSectionOptions) (resp azfake.PollerResponder[armbilling.RoleAssignmentsClientCreateByInvoiceSectionResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdateByBillingAccount is the fake for method RoleAssignmentsClient.BeginCreateOrUpdateByBillingAccount + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdateByBillingAccount func(ctx context.Context, billingAccountName string, billingRoleAssignmentName string, parameters armbilling.RoleAssignment, options *armbilling.RoleAssignmentsClientBeginCreateOrUpdateByBillingAccountOptions) (resp azfake.PollerResponder[armbilling.RoleAssignmentsClientCreateOrUpdateByBillingAccountResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdateByDepartment is the fake for method RoleAssignmentsClient.BeginCreateOrUpdateByDepartment + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdateByDepartment func(ctx context.Context, billingAccountName string, departmentName string, billingRoleAssignmentName string, parameters armbilling.RoleAssignment, options *armbilling.RoleAssignmentsClientBeginCreateOrUpdateByDepartmentOptions) (resp azfake.PollerResponder[armbilling.RoleAssignmentsClientCreateOrUpdateByDepartmentResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdateByEnrollmentAccount is the fake for method RoleAssignmentsClient.BeginCreateOrUpdateByEnrollmentAccount + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdateByEnrollmentAccount func(ctx context.Context, billingAccountName string, enrollmentAccountName string, billingRoleAssignmentName string, parameters armbilling.RoleAssignment, options *armbilling.RoleAssignmentsClientBeginCreateOrUpdateByEnrollmentAccountOptions) (resp azfake.PollerResponder[armbilling.RoleAssignmentsClientCreateOrUpdateByEnrollmentAccountResponse], errResp azfake.ErrorResponder) + // DeleteByBillingAccount is the fake for method RoleAssignmentsClient.DeleteByBillingAccount - // HTTP status codes to indicate success: http.StatusOK + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent DeleteByBillingAccount func(ctx context.Context, billingAccountName string, billingRoleAssignmentName string, options *armbilling.RoleAssignmentsClientDeleteByBillingAccountOptions) (resp azfake.Responder[armbilling.RoleAssignmentsClientDeleteByBillingAccountResponse], errResp azfake.ErrorResponder) // DeleteByBillingProfile is the fake for method RoleAssignmentsClient.DeleteByBillingProfile - // HTTP status codes to indicate success: http.StatusOK + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent DeleteByBillingProfile func(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleAssignmentName string, options *armbilling.RoleAssignmentsClientDeleteByBillingProfileOptions) (resp azfake.Responder[armbilling.RoleAssignmentsClientDeleteByBillingProfileResponse], errResp azfake.ErrorResponder) + // DeleteByCustomer is the fake for method RoleAssignmentsClient.DeleteByCustomer + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + DeleteByCustomer func(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, billingRoleAssignmentName string, options *armbilling.RoleAssignmentsClientDeleteByCustomerOptions) (resp azfake.Responder[armbilling.RoleAssignmentsClientDeleteByCustomerResponse], errResp azfake.ErrorResponder) + + // DeleteByDepartment is the fake for method RoleAssignmentsClient.DeleteByDepartment + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + DeleteByDepartment func(ctx context.Context, billingAccountName string, departmentName string, billingRoleAssignmentName string, options *armbilling.RoleAssignmentsClientDeleteByDepartmentOptions) (resp azfake.Responder[armbilling.RoleAssignmentsClientDeleteByDepartmentResponse], errResp azfake.ErrorResponder) + + // DeleteByEnrollmentAccount is the fake for method RoleAssignmentsClient.DeleteByEnrollmentAccount + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + DeleteByEnrollmentAccount func(ctx context.Context, billingAccountName string, enrollmentAccountName string, billingRoleAssignmentName string, options *armbilling.RoleAssignmentsClientDeleteByEnrollmentAccountOptions) (resp azfake.Responder[armbilling.RoleAssignmentsClientDeleteByEnrollmentAccountResponse], errResp azfake.ErrorResponder) + // DeleteByInvoiceSection is the fake for method RoleAssignmentsClient.DeleteByInvoiceSection - // HTTP status codes to indicate success: http.StatusOK + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent DeleteByInvoiceSection func(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, billingRoleAssignmentName string, options *armbilling.RoleAssignmentsClientDeleteByInvoiceSectionOptions) (resp azfake.Responder[armbilling.RoleAssignmentsClientDeleteByInvoiceSectionResponse], errResp azfake.ErrorResponder) // GetByBillingAccount is the fake for method RoleAssignmentsClient.GetByBillingAccount @@ -44,6 +86,18 @@ type RoleAssignmentsServer struct { // HTTP status codes to indicate success: http.StatusOK GetByBillingProfile func(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleAssignmentName string, options *armbilling.RoleAssignmentsClientGetByBillingProfileOptions) (resp azfake.Responder[armbilling.RoleAssignmentsClientGetByBillingProfileResponse], errResp azfake.ErrorResponder) + // GetByCustomer is the fake for method RoleAssignmentsClient.GetByCustomer + // HTTP status codes to indicate success: http.StatusOK + GetByCustomer func(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, billingRoleAssignmentName string, options *armbilling.RoleAssignmentsClientGetByCustomerOptions) (resp azfake.Responder[armbilling.RoleAssignmentsClientGetByCustomerResponse], errResp azfake.ErrorResponder) + + // GetByDepartment is the fake for method RoleAssignmentsClient.GetByDepartment + // HTTP status codes to indicate success: http.StatusOK + GetByDepartment func(ctx context.Context, billingAccountName string, departmentName string, billingRoleAssignmentName string, options *armbilling.RoleAssignmentsClientGetByDepartmentOptions) (resp azfake.Responder[armbilling.RoleAssignmentsClientGetByDepartmentResponse], errResp azfake.ErrorResponder) + + // GetByEnrollmentAccount is the fake for method RoleAssignmentsClient.GetByEnrollmentAccount + // HTTP status codes to indicate success: http.StatusOK + GetByEnrollmentAccount func(ctx context.Context, billingAccountName string, enrollmentAccountName string, billingRoleAssignmentName string, options *armbilling.RoleAssignmentsClientGetByEnrollmentAccountOptions) (resp azfake.Responder[armbilling.RoleAssignmentsClientGetByEnrollmentAccountResponse], errResp azfake.ErrorResponder) + // GetByInvoiceSection is the fake for method RoleAssignmentsClient.GetByInvoiceSection // HTTP status codes to indicate success: http.StatusOK GetByInvoiceSection func(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, billingRoleAssignmentName string, options *armbilling.RoleAssignmentsClientGetByInvoiceSectionOptions) (resp azfake.Responder[armbilling.RoleAssignmentsClientGetByInvoiceSectionResponse], errResp azfake.ErrorResponder) @@ -56,9 +110,37 @@ type RoleAssignmentsServer struct { // HTTP status codes to indicate success: http.StatusOK NewListByBillingProfilePager func(billingAccountName string, billingProfileName string, options *armbilling.RoleAssignmentsClientListByBillingProfileOptions) (resp azfake.PagerResponder[armbilling.RoleAssignmentsClientListByBillingProfileResponse]) + // NewListByCustomerPager is the fake for method RoleAssignmentsClient.NewListByCustomerPager + // HTTP status codes to indicate success: http.StatusOK + NewListByCustomerPager func(billingAccountName string, billingProfileName string, customerName string, options *armbilling.RoleAssignmentsClientListByCustomerOptions) (resp azfake.PagerResponder[armbilling.RoleAssignmentsClientListByCustomerResponse]) + + // NewListByDepartmentPager is the fake for method RoleAssignmentsClient.NewListByDepartmentPager + // HTTP status codes to indicate success: http.StatusOK + NewListByDepartmentPager func(billingAccountName string, departmentName string, options *armbilling.RoleAssignmentsClientListByDepartmentOptions) (resp azfake.PagerResponder[armbilling.RoleAssignmentsClientListByDepartmentResponse]) + + // NewListByEnrollmentAccountPager is the fake for method RoleAssignmentsClient.NewListByEnrollmentAccountPager + // HTTP status codes to indicate success: http.StatusOK + NewListByEnrollmentAccountPager func(billingAccountName string, enrollmentAccountName string, options *armbilling.RoleAssignmentsClientListByEnrollmentAccountOptions) (resp azfake.PagerResponder[armbilling.RoleAssignmentsClientListByEnrollmentAccountResponse]) + // NewListByInvoiceSectionPager is the fake for method RoleAssignmentsClient.NewListByInvoiceSectionPager // HTTP status codes to indicate success: http.StatusOK NewListByInvoiceSectionPager func(billingAccountName string, billingProfileName string, invoiceSectionName string, options *armbilling.RoleAssignmentsClientListByInvoiceSectionOptions) (resp azfake.PagerResponder[armbilling.RoleAssignmentsClientListByInvoiceSectionResponse]) + + // BeginResolveByBillingAccount is the fake for method RoleAssignmentsClient.BeginResolveByBillingAccount + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginResolveByBillingAccount func(ctx context.Context, billingAccountName string, options *armbilling.RoleAssignmentsClientBeginResolveByBillingAccountOptions) (resp azfake.PollerResponder[armbilling.RoleAssignmentsClientResolveByBillingAccountResponse], errResp azfake.ErrorResponder) + + // BeginResolveByBillingProfile is the fake for method RoleAssignmentsClient.BeginResolveByBillingProfile + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginResolveByBillingProfile func(ctx context.Context, billingAccountName string, billingProfileName string, options *armbilling.RoleAssignmentsClientBeginResolveByBillingProfileOptions) (resp azfake.PollerResponder[armbilling.RoleAssignmentsClientResolveByBillingProfileResponse], errResp azfake.ErrorResponder) + + // BeginResolveByCustomer is the fake for method RoleAssignmentsClient.BeginResolveByCustomer + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginResolveByCustomer func(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, options *armbilling.RoleAssignmentsClientBeginResolveByCustomerOptions) (resp azfake.PollerResponder[armbilling.RoleAssignmentsClientResolveByCustomerResponse], errResp azfake.ErrorResponder) + + // BeginResolveByInvoiceSection is the fake for method RoleAssignmentsClient.BeginResolveByInvoiceSection + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginResolveByInvoiceSection func(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, options *armbilling.RoleAssignmentsClientBeginResolveByInvoiceSectionOptions) (resp azfake.PollerResponder[armbilling.RoleAssignmentsClientResolveByInvoiceSectionResponse], errResp azfake.ErrorResponder) } // NewRoleAssignmentsServerTransport creates a new instance of RoleAssignmentsServerTransport with the provided implementation. @@ -66,20 +148,48 @@ type RoleAssignmentsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewRoleAssignmentsServerTransport(srv *RoleAssignmentsServer) *RoleAssignmentsServerTransport { return &RoleAssignmentsServerTransport{ - srv: srv, - newListByBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.RoleAssignmentsClientListByBillingAccountResponse]](), - newListByBillingProfilePager: newTracker[azfake.PagerResponder[armbilling.RoleAssignmentsClientListByBillingProfileResponse]](), - newListByInvoiceSectionPager: newTracker[azfake.PagerResponder[armbilling.RoleAssignmentsClientListByInvoiceSectionResponse]](), + srv: srv, + beginCreateByBillingAccount: newTracker[azfake.PollerResponder[armbilling.RoleAssignmentsClientCreateByBillingAccountResponse]](), + beginCreateByBillingProfile: newTracker[azfake.PollerResponder[armbilling.RoleAssignmentsClientCreateByBillingProfileResponse]](), + beginCreateByCustomer: newTracker[azfake.PollerResponder[armbilling.RoleAssignmentsClientCreateByCustomerResponse]](), + beginCreateByInvoiceSection: newTracker[azfake.PollerResponder[armbilling.RoleAssignmentsClientCreateByInvoiceSectionResponse]](), + beginCreateOrUpdateByBillingAccount: newTracker[azfake.PollerResponder[armbilling.RoleAssignmentsClientCreateOrUpdateByBillingAccountResponse]](), + beginCreateOrUpdateByDepartment: newTracker[azfake.PollerResponder[armbilling.RoleAssignmentsClientCreateOrUpdateByDepartmentResponse]](), + beginCreateOrUpdateByEnrollmentAccount: newTracker[azfake.PollerResponder[armbilling.RoleAssignmentsClientCreateOrUpdateByEnrollmentAccountResponse]](), + newListByBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.RoleAssignmentsClientListByBillingAccountResponse]](), + newListByBillingProfilePager: newTracker[azfake.PagerResponder[armbilling.RoleAssignmentsClientListByBillingProfileResponse]](), + newListByCustomerPager: newTracker[azfake.PagerResponder[armbilling.RoleAssignmentsClientListByCustomerResponse]](), + newListByDepartmentPager: newTracker[azfake.PagerResponder[armbilling.RoleAssignmentsClientListByDepartmentResponse]](), + newListByEnrollmentAccountPager: newTracker[azfake.PagerResponder[armbilling.RoleAssignmentsClientListByEnrollmentAccountResponse]](), + newListByInvoiceSectionPager: newTracker[azfake.PagerResponder[armbilling.RoleAssignmentsClientListByInvoiceSectionResponse]](), + beginResolveByBillingAccount: newTracker[azfake.PollerResponder[armbilling.RoleAssignmentsClientResolveByBillingAccountResponse]](), + beginResolveByBillingProfile: newTracker[azfake.PollerResponder[armbilling.RoleAssignmentsClientResolveByBillingProfileResponse]](), + beginResolveByCustomer: newTracker[azfake.PollerResponder[armbilling.RoleAssignmentsClientResolveByCustomerResponse]](), + beginResolveByInvoiceSection: newTracker[azfake.PollerResponder[armbilling.RoleAssignmentsClientResolveByInvoiceSectionResponse]](), } } // RoleAssignmentsServerTransport connects instances of armbilling.RoleAssignmentsClient to instances of RoleAssignmentsServer. // Don't use this type directly, use NewRoleAssignmentsServerTransport instead. type RoleAssignmentsServerTransport struct { - srv *RoleAssignmentsServer - newListByBillingAccountPager *tracker[azfake.PagerResponder[armbilling.RoleAssignmentsClientListByBillingAccountResponse]] - newListByBillingProfilePager *tracker[azfake.PagerResponder[armbilling.RoleAssignmentsClientListByBillingProfileResponse]] - newListByInvoiceSectionPager *tracker[azfake.PagerResponder[armbilling.RoleAssignmentsClientListByInvoiceSectionResponse]] + srv *RoleAssignmentsServer + beginCreateByBillingAccount *tracker[azfake.PollerResponder[armbilling.RoleAssignmentsClientCreateByBillingAccountResponse]] + beginCreateByBillingProfile *tracker[azfake.PollerResponder[armbilling.RoleAssignmentsClientCreateByBillingProfileResponse]] + beginCreateByCustomer *tracker[azfake.PollerResponder[armbilling.RoleAssignmentsClientCreateByCustomerResponse]] + beginCreateByInvoiceSection *tracker[azfake.PollerResponder[armbilling.RoleAssignmentsClientCreateByInvoiceSectionResponse]] + beginCreateOrUpdateByBillingAccount *tracker[azfake.PollerResponder[armbilling.RoleAssignmentsClientCreateOrUpdateByBillingAccountResponse]] + beginCreateOrUpdateByDepartment *tracker[azfake.PollerResponder[armbilling.RoleAssignmentsClientCreateOrUpdateByDepartmentResponse]] + beginCreateOrUpdateByEnrollmentAccount *tracker[azfake.PollerResponder[armbilling.RoleAssignmentsClientCreateOrUpdateByEnrollmentAccountResponse]] + newListByBillingAccountPager *tracker[azfake.PagerResponder[armbilling.RoleAssignmentsClientListByBillingAccountResponse]] + newListByBillingProfilePager *tracker[azfake.PagerResponder[armbilling.RoleAssignmentsClientListByBillingProfileResponse]] + newListByCustomerPager *tracker[azfake.PagerResponder[armbilling.RoleAssignmentsClientListByCustomerResponse]] + newListByDepartmentPager *tracker[azfake.PagerResponder[armbilling.RoleAssignmentsClientListByDepartmentResponse]] + newListByEnrollmentAccountPager *tracker[azfake.PagerResponder[armbilling.RoleAssignmentsClientListByEnrollmentAccountResponse]] + newListByInvoiceSectionPager *tracker[azfake.PagerResponder[armbilling.RoleAssignmentsClientListByInvoiceSectionResponse]] + beginResolveByBillingAccount *tracker[azfake.PollerResponder[armbilling.RoleAssignmentsClientResolveByBillingAccountResponse]] + beginResolveByBillingProfile *tracker[azfake.PollerResponder[armbilling.RoleAssignmentsClientResolveByBillingProfileResponse]] + beginResolveByCustomer *tracker[azfake.PollerResponder[armbilling.RoleAssignmentsClientResolveByCustomerResponse]] + beginResolveByInvoiceSection *tracker[azfake.PollerResponder[armbilling.RoleAssignmentsClientResolveByInvoiceSectionResponse]] } // Do implements the policy.Transporter interface for RoleAssignmentsServerTransport. @@ -94,24 +204,64 @@ func (r *RoleAssignmentsServerTransport) Do(req *http.Request) (*http.Response, var err error switch method { + case "RoleAssignmentsClient.BeginCreateByBillingAccount": + resp, err = r.dispatchBeginCreateByBillingAccount(req) + case "RoleAssignmentsClient.BeginCreateByBillingProfile": + resp, err = r.dispatchBeginCreateByBillingProfile(req) + case "RoleAssignmentsClient.BeginCreateByCustomer": + resp, err = r.dispatchBeginCreateByCustomer(req) + case "RoleAssignmentsClient.BeginCreateByInvoiceSection": + resp, err = r.dispatchBeginCreateByInvoiceSection(req) + case "RoleAssignmentsClient.BeginCreateOrUpdateByBillingAccount": + resp, err = r.dispatchBeginCreateOrUpdateByBillingAccount(req) + case "RoleAssignmentsClient.BeginCreateOrUpdateByDepartment": + resp, err = r.dispatchBeginCreateOrUpdateByDepartment(req) + case "RoleAssignmentsClient.BeginCreateOrUpdateByEnrollmentAccount": + resp, err = r.dispatchBeginCreateOrUpdateByEnrollmentAccount(req) case "RoleAssignmentsClient.DeleteByBillingAccount": resp, err = r.dispatchDeleteByBillingAccount(req) case "RoleAssignmentsClient.DeleteByBillingProfile": resp, err = r.dispatchDeleteByBillingProfile(req) + case "RoleAssignmentsClient.DeleteByCustomer": + resp, err = r.dispatchDeleteByCustomer(req) + case "RoleAssignmentsClient.DeleteByDepartment": + resp, err = r.dispatchDeleteByDepartment(req) + case "RoleAssignmentsClient.DeleteByEnrollmentAccount": + resp, err = r.dispatchDeleteByEnrollmentAccount(req) case "RoleAssignmentsClient.DeleteByInvoiceSection": resp, err = r.dispatchDeleteByInvoiceSection(req) case "RoleAssignmentsClient.GetByBillingAccount": resp, err = r.dispatchGetByBillingAccount(req) case "RoleAssignmentsClient.GetByBillingProfile": resp, err = r.dispatchGetByBillingProfile(req) + case "RoleAssignmentsClient.GetByCustomer": + resp, err = r.dispatchGetByCustomer(req) + case "RoleAssignmentsClient.GetByDepartment": + resp, err = r.dispatchGetByDepartment(req) + case "RoleAssignmentsClient.GetByEnrollmentAccount": + resp, err = r.dispatchGetByEnrollmentAccount(req) case "RoleAssignmentsClient.GetByInvoiceSection": resp, err = r.dispatchGetByInvoiceSection(req) case "RoleAssignmentsClient.NewListByBillingAccountPager": resp, err = r.dispatchNewListByBillingAccountPager(req) case "RoleAssignmentsClient.NewListByBillingProfilePager": resp, err = r.dispatchNewListByBillingProfilePager(req) + case "RoleAssignmentsClient.NewListByCustomerPager": + resp, err = r.dispatchNewListByCustomerPager(req) + case "RoleAssignmentsClient.NewListByDepartmentPager": + resp, err = r.dispatchNewListByDepartmentPager(req) + case "RoleAssignmentsClient.NewListByEnrollmentAccountPager": + resp, err = r.dispatchNewListByEnrollmentAccountPager(req) case "RoleAssignmentsClient.NewListByInvoiceSectionPager": resp, err = r.dispatchNewListByInvoiceSectionPager(req) + case "RoleAssignmentsClient.BeginResolveByBillingAccount": + resp, err = r.dispatchBeginResolveByBillingAccount(req) + case "RoleAssignmentsClient.BeginResolveByBillingProfile": + resp, err = r.dispatchBeginResolveByBillingProfile(req) + case "RoleAssignmentsClient.BeginResolveByCustomer": + resp, err = r.dispatchBeginResolveByCustomer(req) + case "RoleAssignmentsClient.BeginResolveByInvoiceSection": + resp, err = r.dispatchBeginResolveByInvoiceSection(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -123,6 +273,354 @@ func (r *RoleAssignmentsServerTransport) Do(req *http.Request) (*http.Response, return resp, nil } +func (r *RoleAssignmentsServerTransport) dispatchBeginCreateByBillingAccount(req *http.Request) (*http.Response, error) { + if r.srv.BeginCreateByBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateByBillingAccount not implemented")} + } + beginCreateByBillingAccount := r.beginCreateByBillingAccount.get(req) + if beginCreateByBillingAccount == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/createBillingRoleAssignment` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.RoleAssignmentProperties](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginCreateByBillingAccount(req.Context(), billingAccountNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateByBillingAccount = &respr + r.beginCreateByBillingAccount.add(req, beginCreateByBillingAccount) + } + + resp, err := server.PollerResponderNext(beginCreateByBillingAccount, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + r.beginCreateByBillingAccount.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateByBillingAccount) { + r.beginCreateByBillingAccount.remove(req) + } + + return resp, nil +} + +func (r *RoleAssignmentsServerTransport) dispatchBeginCreateByBillingProfile(req *http.Request) (*http.Response, error) { + if r.srv.BeginCreateByBillingProfile == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateByBillingProfile not implemented")} + } + beginCreateByBillingProfile := r.beginCreateByBillingProfile.get(req) + if beginCreateByBillingProfile == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/createBillingRoleAssignment` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.RoleAssignmentProperties](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginCreateByBillingProfile(req.Context(), billingAccountNameParam, billingProfileNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateByBillingProfile = &respr + r.beginCreateByBillingProfile.add(req, beginCreateByBillingProfile) + } + + resp, err := server.PollerResponderNext(beginCreateByBillingProfile, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + r.beginCreateByBillingProfile.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateByBillingProfile) { + r.beginCreateByBillingProfile.remove(req) + } + + return resp, nil +} + +func (r *RoleAssignmentsServerTransport) dispatchBeginCreateByCustomer(req *http.Request) (*http.Response, error) { + if r.srv.BeginCreateByCustomer == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateByCustomer not implemented")} + } + beginCreateByCustomer := r.beginCreateByCustomer.get(req) + if beginCreateByCustomer == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/createBillingRoleAssignment` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.RoleAssignmentProperties](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginCreateByCustomer(req.Context(), billingAccountNameParam, billingProfileNameParam, customerNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateByCustomer = &respr + r.beginCreateByCustomer.add(req, beginCreateByCustomer) + } + + resp, err := server.PollerResponderNext(beginCreateByCustomer, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + r.beginCreateByCustomer.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateByCustomer) { + r.beginCreateByCustomer.remove(req) + } + + return resp, nil +} + +func (r *RoleAssignmentsServerTransport) dispatchBeginCreateByInvoiceSection(req *http.Request) (*http.Response, error) { + if r.srv.BeginCreateByInvoiceSection == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateByInvoiceSection not implemented")} + } + beginCreateByInvoiceSection := r.beginCreateByInvoiceSection.get(req) + if beginCreateByInvoiceSection == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoiceSections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/createBillingRoleAssignment` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.RoleAssignmentProperties](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + invoiceSectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceSectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginCreateByInvoiceSection(req.Context(), billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateByInvoiceSection = &respr + r.beginCreateByInvoiceSection.add(req, beginCreateByInvoiceSection) + } + + resp, err := server.PollerResponderNext(beginCreateByInvoiceSection, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + r.beginCreateByInvoiceSection.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateByInvoiceSection) { + r.beginCreateByInvoiceSection.remove(req) + } + + return resp, nil +} + +func (r *RoleAssignmentsServerTransport) dispatchBeginCreateOrUpdateByBillingAccount(req *http.Request) (*http.Response, error) { + if r.srv.BeginCreateOrUpdateByBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdateByBillingAccount not implemented")} + } + beginCreateOrUpdateByBillingAccount := r.beginCreateOrUpdateByBillingAccount.get(req) + if beginCreateOrUpdateByBillingAccount == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.RoleAssignment](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingRoleAssignmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingRoleAssignmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginCreateOrUpdateByBillingAccount(req.Context(), billingAccountNameParam, billingRoleAssignmentNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdateByBillingAccount = &respr + r.beginCreateOrUpdateByBillingAccount.add(req, beginCreateOrUpdateByBillingAccount) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdateByBillingAccount, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + r.beginCreateOrUpdateByBillingAccount.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdateByBillingAccount) { + r.beginCreateOrUpdateByBillingAccount.remove(req) + } + + return resp, nil +} + +func (r *RoleAssignmentsServerTransport) dispatchBeginCreateOrUpdateByDepartment(req *http.Request) (*http.Response, error) { + if r.srv.BeginCreateOrUpdateByDepartment == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdateByDepartment not implemented")} + } + beginCreateOrUpdateByDepartment := r.beginCreateOrUpdateByDepartment.get(req) + if beginCreateOrUpdateByDepartment == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/departments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.RoleAssignment](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + departmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("departmentName")]) + if err != nil { + return nil, err + } + billingRoleAssignmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingRoleAssignmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginCreateOrUpdateByDepartment(req.Context(), billingAccountNameParam, departmentNameParam, billingRoleAssignmentNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdateByDepartment = &respr + r.beginCreateOrUpdateByDepartment.add(req, beginCreateOrUpdateByDepartment) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdateByDepartment, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + r.beginCreateOrUpdateByDepartment.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdateByDepartment) { + r.beginCreateOrUpdateByDepartment.remove(req) + } + + return resp, nil +} + +func (r *RoleAssignmentsServerTransport) dispatchBeginCreateOrUpdateByEnrollmentAccount(req *http.Request) (*http.Response, error) { + if r.srv.BeginCreateOrUpdateByEnrollmentAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdateByEnrollmentAccount not implemented")} + } + beginCreateOrUpdateByEnrollmentAccount := r.beginCreateOrUpdateByEnrollmentAccount.get(req) + if beginCreateOrUpdateByEnrollmentAccount == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enrollmentAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.RoleAssignment](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + enrollmentAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enrollmentAccountName")]) + if err != nil { + return nil, err + } + billingRoleAssignmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingRoleAssignmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginCreateOrUpdateByEnrollmentAccount(req.Context(), billingAccountNameParam, enrollmentAccountNameParam, billingRoleAssignmentNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdateByEnrollmentAccount = &respr + r.beginCreateOrUpdateByEnrollmentAccount.add(req, beginCreateOrUpdateByEnrollmentAccount) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdateByEnrollmentAccount, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + r.beginCreateOrUpdateByEnrollmentAccount.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdateByEnrollmentAccount) { + r.beginCreateOrUpdateByEnrollmentAccount.remove(req) + } + + return resp, nil +} + func (r *RoleAssignmentsServerTransport) dispatchDeleteByBillingAccount(req *http.Request) (*http.Response, error) { if r.srv.DeleteByBillingAccount == nil { return nil, &nonRetriableError{errors.New("fake for method DeleteByBillingAccount not implemented")} @@ -146,10 +644,10 @@ func (r *RoleAssignmentsServerTransport) dispatchDeleteByBillingAccount(req *htt return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RoleAssignment, req) + resp, err := server.NewResponse(respContent, req, nil) if err != nil { return nil, err } @@ -183,10 +681,125 @@ func (r *RoleAssignmentsServerTransport) dispatchDeleteByBillingProfile(req *htt return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RoleAssignment, req) + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RoleAssignmentsServerTransport) dispatchDeleteByCustomer(req *http.Request) (*http.Response, error) { + if r.srv.DeleteByCustomer == nil { + return nil, &nonRetriableError{errors.New("fake for method DeleteByCustomer not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) + if err != nil { + return nil, err + } + billingRoleAssignmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingRoleAssignmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.DeleteByCustomer(req.Context(), billingAccountNameParam, billingProfileNameParam, customerNameParam, billingRoleAssignmentNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RoleAssignmentsServerTransport) dispatchDeleteByDepartment(req *http.Request) (*http.Response, error) { + if r.srv.DeleteByDepartment == nil { + return nil, &nonRetriableError{errors.New("fake for method DeleteByDepartment not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/departments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + departmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("departmentName")]) + if err != nil { + return nil, err + } + billingRoleAssignmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingRoleAssignmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.DeleteByDepartment(req.Context(), billingAccountNameParam, departmentNameParam, billingRoleAssignmentNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RoleAssignmentsServerTransport) dispatchDeleteByEnrollmentAccount(req *http.Request) (*http.Response, error) { + if r.srv.DeleteByEnrollmentAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method DeleteByEnrollmentAccount not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enrollmentAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + enrollmentAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enrollmentAccountName")]) + if err != nil { + return nil, err + } + billingRoleAssignmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingRoleAssignmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.DeleteByEnrollmentAccount(req.Context(), billingAccountNameParam, enrollmentAccountNameParam, billingRoleAssignmentNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) if err != nil { return nil, err } @@ -224,10 +837,10 @@ func (r *RoleAssignmentsServerTransport) dispatchDeleteByInvoiceSection(req *htt return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RoleAssignment, req) + resp, err := server.NewResponse(respContent, req, nil) if err != nil { return nil, err } @@ -304,6 +917,121 @@ func (r *RoleAssignmentsServerTransport) dispatchGetByBillingProfile(req *http.R return resp, nil } +func (r *RoleAssignmentsServerTransport) dispatchGetByCustomer(req *http.Request) (*http.Response, error) { + if r.srv.GetByCustomer == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByCustomer not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) + if err != nil { + return nil, err + } + billingRoleAssignmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingRoleAssignmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetByCustomer(req.Context(), billingAccountNameParam, billingProfileNameParam, customerNameParam, billingRoleAssignmentNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RoleAssignment, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RoleAssignmentsServerTransport) dispatchGetByDepartment(req *http.Request) (*http.Response, error) { + if r.srv.GetByDepartment == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByDepartment not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/departments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + departmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("departmentName")]) + if err != nil { + return nil, err + } + billingRoleAssignmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingRoleAssignmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetByDepartment(req.Context(), billingAccountNameParam, departmentNameParam, billingRoleAssignmentNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RoleAssignment, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RoleAssignmentsServerTransport) dispatchGetByEnrollmentAccount(req *http.Request) (*http.Response, error) { + if r.srv.GetByEnrollmentAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByEnrollmentAccount not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enrollmentAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + enrollmentAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enrollmentAccountName")]) + if err != nil { + return nil, err + } + billingRoleAssignmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingRoleAssignmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetByEnrollmentAccount(req.Context(), billingAccountNameParam, enrollmentAccountNameParam, billingRoleAssignmentNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RoleAssignment, req) + if err != nil { + return nil, err + } + return resp, nil +} + func (r *RoleAssignmentsServerTransport) dispatchGetByInvoiceSection(req *http.Request) (*http.Response, error) { if r.srv.GetByInvoiceSection == nil { return nil, &nonRetriableError{errors.New("fake for method GetByInvoiceSection not implemented")} @@ -357,11 +1085,53 @@ func (r *RoleAssignmentsServerTransport) dispatchNewListByBillingAccountPager(re if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } + qp := req.URL.Query() billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) if err != nil { return nil, err } - resp := r.srv.NewListByBillingAccountPager(billingAccountNameParam, nil) + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + var options *armbilling.RoleAssignmentsClientListByBillingAccountOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armbilling.RoleAssignmentsClientListByBillingAccountOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := r.srv.NewListByBillingAccountPager(billingAccountNameParam, options) newListByBillingAccountPager = &resp r.newListByBillingAccountPager.add(req, newListByBillingAccountPager) server.PagerResponderInjectNextLinks(newListByBillingAccountPager, req, func(page *armbilling.RoleAssignmentsClientListByBillingAccountResponse, createLink func() string) { @@ -394,6 +1164,7 @@ func (r *RoleAssignmentsServerTransport) dispatchNewListByBillingProfilePager(re if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } + qp := req.URL.Query() billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) if err != nil { return nil, err @@ -402,7 +1173,48 @@ func (r *RoleAssignmentsServerTransport) dispatchNewListByBillingProfilePager(re if err != nil { return nil, err } - resp := r.srv.NewListByBillingProfilePager(billingAccountNameParam, billingProfileNameParam, nil) + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + var options *armbilling.RoleAssignmentsClientListByBillingProfileOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armbilling.RoleAssignmentsClientListByBillingProfileOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := r.srv.NewListByBillingProfilePager(billingAccountNameParam, billingProfileNameParam, options) newListByBillingProfilePager = &resp r.newListByBillingProfilePager.add(req, newListByBillingProfilePager) server.PagerResponderInjectNextLinks(newListByBillingProfilePager, req, func(page *armbilling.RoleAssignmentsClientListByBillingProfileResponse, createLink func() string) { @@ -423,6 +1235,175 @@ func (r *RoleAssignmentsServerTransport) dispatchNewListByBillingProfilePager(re return resp, nil } +func (r *RoleAssignmentsServerTransport) dispatchNewListByCustomerPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListByCustomerPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByCustomerPager not implemented")} + } + newListByCustomerPager := r.newListByCustomerPager.get(req) + if newListByCustomerPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleAssignments` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + var options *armbilling.RoleAssignmentsClientListByCustomerOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armbilling.RoleAssignmentsClientListByCustomerOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := r.srv.NewListByCustomerPager(billingAccountNameParam, billingProfileNameParam, customerNameParam, options) + newListByCustomerPager = &resp + r.newListByCustomerPager.add(req, newListByCustomerPager) + server.PagerResponderInjectNextLinks(newListByCustomerPager, req, func(page *armbilling.RoleAssignmentsClientListByCustomerResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByCustomerPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListByCustomerPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByCustomerPager) { + r.newListByCustomerPager.remove(req) + } + return resp, nil +} + +func (r *RoleAssignmentsServerTransport) dispatchNewListByDepartmentPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListByDepartmentPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByDepartmentPager not implemented")} + } + newListByDepartmentPager := r.newListByDepartmentPager.get(req) + if newListByDepartmentPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/departments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleAssignments` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + departmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("departmentName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewListByDepartmentPager(billingAccountNameParam, departmentNameParam, nil) + newListByDepartmentPager = &resp + r.newListByDepartmentPager.add(req, newListByDepartmentPager) + server.PagerResponderInjectNextLinks(newListByDepartmentPager, req, func(page *armbilling.RoleAssignmentsClientListByDepartmentResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByDepartmentPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListByDepartmentPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByDepartmentPager) { + r.newListByDepartmentPager.remove(req) + } + return resp, nil +} + +func (r *RoleAssignmentsServerTransport) dispatchNewListByEnrollmentAccountPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListByEnrollmentAccountPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByEnrollmentAccountPager not implemented")} + } + newListByEnrollmentAccountPager := r.newListByEnrollmentAccountPager.get(req) + if newListByEnrollmentAccountPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enrollmentAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleAssignments` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + enrollmentAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enrollmentAccountName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewListByEnrollmentAccountPager(billingAccountNameParam, enrollmentAccountNameParam, nil) + newListByEnrollmentAccountPager = &resp + r.newListByEnrollmentAccountPager.add(req, newListByEnrollmentAccountPager) + server.PagerResponderInjectNextLinks(newListByEnrollmentAccountPager, req, func(page *armbilling.RoleAssignmentsClientListByEnrollmentAccountResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByEnrollmentAccountPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListByEnrollmentAccountPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByEnrollmentAccountPager) { + r.newListByEnrollmentAccountPager.remove(req) + } + return resp, nil +} + func (r *RoleAssignmentsServerTransport) dispatchNewListByInvoiceSectionPager(req *http.Request) (*http.Response, error) { if r.srv.NewListByInvoiceSectionPager == nil { return nil, &nonRetriableError{errors.New("fake for method NewListByInvoiceSectionPager not implemented")} @@ -435,6 +1416,7 @@ func (r *RoleAssignmentsServerTransport) dispatchNewListByInvoiceSectionPager(re if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } + qp := req.URL.Query() billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) if err != nil { return nil, err @@ -447,7 +1429,48 @@ func (r *RoleAssignmentsServerTransport) dispatchNewListByInvoiceSectionPager(re if err != nil { return nil, err } - resp := r.srv.NewListByInvoiceSectionPager(billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, nil) + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + var options *armbilling.RoleAssignmentsClientListByInvoiceSectionOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armbilling.RoleAssignmentsClientListByInvoiceSectionOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := r.srv.NewListByInvoiceSectionPager(billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, options) newListByInvoiceSectionPager = &resp r.newListByInvoiceSectionPager.add(req, newListByInvoiceSectionPager) server.PagerResponderInjectNextLinks(newListByInvoiceSectionPager, req, func(page *armbilling.RoleAssignmentsClientListByInvoiceSectionResponse, createLink func() string) { @@ -467,3 +1490,267 @@ func (r *RoleAssignmentsServerTransport) dispatchNewListByInvoiceSectionPager(re } return resp, nil } + +func (r *RoleAssignmentsServerTransport) dispatchBeginResolveByBillingAccount(req *http.Request) (*http.Response, error) { + if r.srv.BeginResolveByBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginResolveByBillingAccount not implemented")} + } + beginResolveByBillingAccount := r.beginResolveByBillingAccount.get(req) + if beginResolveByBillingAccount == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resolveBillingRoleAssignments` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + resolveScopeDisplayNamesUnescaped, err := url.QueryUnescape(qp.Get("resolveScopeDisplayNames")) + if err != nil { + return nil, err + } + resolveScopeDisplayNamesParam, err := parseOptional(resolveScopeDisplayNamesUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armbilling.RoleAssignmentsClientBeginResolveByBillingAccountOptions + if resolveScopeDisplayNamesParam != nil || filterParam != nil { + options = &armbilling.RoleAssignmentsClientBeginResolveByBillingAccountOptions{ + ResolveScopeDisplayNames: resolveScopeDisplayNamesParam, + Filter: filterParam, + } + } + respr, errRespr := r.srv.BeginResolveByBillingAccount(req.Context(), billingAccountNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginResolveByBillingAccount = &respr + r.beginResolveByBillingAccount.add(req, beginResolveByBillingAccount) + } + + resp, err := server.PollerResponderNext(beginResolveByBillingAccount, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + r.beginResolveByBillingAccount.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginResolveByBillingAccount) { + r.beginResolveByBillingAccount.remove(req) + } + + return resp, nil +} + +func (r *RoleAssignmentsServerTransport) dispatchBeginResolveByBillingProfile(req *http.Request) (*http.Response, error) { + if r.srv.BeginResolveByBillingProfile == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginResolveByBillingProfile not implemented")} + } + beginResolveByBillingProfile := r.beginResolveByBillingProfile.get(req) + if beginResolveByBillingProfile == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resolveBillingRoleAssignments` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + resolveScopeDisplayNamesUnescaped, err := url.QueryUnescape(qp.Get("resolveScopeDisplayNames")) + if err != nil { + return nil, err + } + resolveScopeDisplayNamesParam, err := parseOptional(resolveScopeDisplayNamesUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armbilling.RoleAssignmentsClientBeginResolveByBillingProfileOptions + if resolveScopeDisplayNamesParam != nil || filterParam != nil { + options = &armbilling.RoleAssignmentsClientBeginResolveByBillingProfileOptions{ + ResolveScopeDisplayNames: resolveScopeDisplayNamesParam, + Filter: filterParam, + } + } + respr, errRespr := r.srv.BeginResolveByBillingProfile(req.Context(), billingAccountNameParam, billingProfileNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginResolveByBillingProfile = &respr + r.beginResolveByBillingProfile.add(req, beginResolveByBillingProfile) + } + + resp, err := server.PollerResponderNext(beginResolveByBillingProfile, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + r.beginResolveByBillingProfile.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginResolveByBillingProfile) { + r.beginResolveByBillingProfile.remove(req) + } + + return resp, nil +} + +func (r *RoleAssignmentsServerTransport) dispatchBeginResolveByCustomer(req *http.Request) (*http.Response, error) { + if r.srv.BeginResolveByCustomer == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginResolveByCustomer not implemented")} + } + beginResolveByCustomer := r.beginResolveByCustomer.get(req) + if beginResolveByCustomer == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resolveBillingRoleAssignments` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) + if err != nil { + return nil, err + } + resolveScopeDisplayNamesUnescaped, err := url.QueryUnescape(qp.Get("resolveScopeDisplayNames")) + if err != nil { + return nil, err + } + resolveScopeDisplayNamesParam, err := parseOptional(resolveScopeDisplayNamesUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armbilling.RoleAssignmentsClientBeginResolveByCustomerOptions + if resolveScopeDisplayNamesParam != nil || filterParam != nil { + options = &armbilling.RoleAssignmentsClientBeginResolveByCustomerOptions{ + ResolveScopeDisplayNames: resolveScopeDisplayNamesParam, + Filter: filterParam, + } + } + respr, errRespr := r.srv.BeginResolveByCustomer(req.Context(), billingAccountNameParam, billingProfileNameParam, customerNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginResolveByCustomer = &respr + r.beginResolveByCustomer.add(req, beginResolveByCustomer) + } + + resp, err := server.PollerResponderNext(beginResolveByCustomer, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + r.beginResolveByCustomer.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginResolveByCustomer) { + r.beginResolveByCustomer.remove(req) + } + + return resp, nil +} + +func (r *RoleAssignmentsServerTransport) dispatchBeginResolveByInvoiceSection(req *http.Request) (*http.Response, error) { + if r.srv.BeginResolveByInvoiceSection == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginResolveByInvoiceSection not implemented")} + } + beginResolveByInvoiceSection := r.beginResolveByInvoiceSection.get(req) + if beginResolveByInvoiceSection == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoiceSections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resolveBillingRoleAssignments` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + invoiceSectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceSectionName")]) + if err != nil { + return nil, err + } + resolveScopeDisplayNamesUnescaped, err := url.QueryUnescape(qp.Get("resolveScopeDisplayNames")) + if err != nil { + return nil, err + } + resolveScopeDisplayNamesParam, err := parseOptional(resolveScopeDisplayNamesUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armbilling.RoleAssignmentsClientBeginResolveByInvoiceSectionOptions + if resolveScopeDisplayNamesParam != nil || filterParam != nil { + options = &armbilling.RoleAssignmentsClientBeginResolveByInvoiceSectionOptions{ + ResolveScopeDisplayNames: resolveScopeDisplayNamesParam, + Filter: filterParam, + } + } + respr, errRespr := r.srv.BeginResolveByInvoiceSection(req.Context(), billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginResolveByInvoiceSection = &respr + r.beginResolveByInvoiceSection.add(req, beginResolveByInvoiceSection) + } + + resp, err := server.PollerResponderNext(beginResolveByInvoiceSection, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + r.beginResolveByInvoiceSection.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginResolveByInvoiceSection) { + r.beginResolveByInvoiceSection.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/fake/roledefinition_server.go b/sdk/resourcemanager/billing/armbilling/fake/roledefinition_server.go new file mode 100644 index 000000000000..efba7d35d9a8 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/fake/roledefinition_server.go @@ -0,0 +1,625 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "regexp" + + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// RoleDefinitionServer is a fake server for instances of the armbilling.RoleDefinitionClient type. +type RoleDefinitionServer struct { + // GetByBillingAccount is the fake for method RoleDefinitionClient.GetByBillingAccount + // HTTP status codes to indicate success: http.StatusOK + GetByBillingAccount func(ctx context.Context, billingAccountName string, roleDefinitionName string, options *armbilling.RoleDefinitionClientGetByBillingAccountOptions) (resp azfake.Responder[armbilling.RoleDefinitionClientGetByBillingAccountResponse], errResp azfake.ErrorResponder) + + // GetByBillingProfile is the fake for method RoleDefinitionClient.GetByBillingProfile + // HTTP status codes to indicate success: http.StatusOK + GetByBillingProfile func(ctx context.Context, billingAccountName string, billingProfileName string, roleDefinitionName string, options *armbilling.RoleDefinitionClientGetByBillingProfileOptions) (resp azfake.Responder[armbilling.RoleDefinitionClientGetByBillingProfileResponse], errResp azfake.ErrorResponder) + + // GetByCustomer is the fake for method RoleDefinitionClient.GetByCustomer + // HTTP status codes to indicate success: http.StatusOK + GetByCustomer func(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, roleDefinitionName string, options *armbilling.RoleDefinitionClientGetByCustomerOptions) (resp azfake.Responder[armbilling.RoleDefinitionClientGetByCustomerResponse], errResp azfake.ErrorResponder) + + // GetByDepartment is the fake for method RoleDefinitionClient.GetByDepartment + // HTTP status codes to indicate success: http.StatusOK + GetByDepartment func(ctx context.Context, billingAccountName string, departmentName string, roleDefinitionName string, options *armbilling.RoleDefinitionClientGetByDepartmentOptions) (resp azfake.Responder[armbilling.RoleDefinitionClientGetByDepartmentResponse], errResp azfake.ErrorResponder) + + // GetByEnrollmentAccount is the fake for method RoleDefinitionClient.GetByEnrollmentAccount + // HTTP status codes to indicate success: http.StatusOK + GetByEnrollmentAccount func(ctx context.Context, billingAccountName string, enrollmentAccountName string, roleDefinitionName string, options *armbilling.RoleDefinitionClientGetByEnrollmentAccountOptions) (resp azfake.Responder[armbilling.RoleDefinitionClientGetByEnrollmentAccountResponse], errResp azfake.ErrorResponder) + + // GetByInvoiceSection is the fake for method RoleDefinitionClient.GetByInvoiceSection + // HTTP status codes to indicate success: http.StatusOK + GetByInvoiceSection func(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, roleDefinitionName string, options *armbilling.RoleDefinitionClientGetByInvoiceSectionOptions) (resp azfake.Responder[armbilling.RoleDefinitionClientGetByInvoiceSectionResponse], errResp azfake.ErrorResponder) + + // NewListByBillingAccountPager is the fake for method RoleDefinitionClient.NewListByBillingAccountPager + // HTTP status codes to indicate success: http.StatusOK + NewListByBillingAccountPager func(billingAccountName string, options *armbilling.RoleDefinitionClientListByBillingAccountOptions) (resp azfake.PagerResponder[armbilling.RoleDefinitionClientListByBillingAccountResponse]) + + // NewListByBillingProfilePager is the fake for method RoleDefinitionClient.NewListByBillingProfilePager + // HTTP status codes to indicate success: http.StatusOK + NewListByBillingProfilePager func(billingAccountName string, billingProfileName string, options *armbilling.RoleDefinitionClientListByBillingProfileOptions) (resp azfake.PagerResponder[armbilling.RoleDefinitionClientListByBillingProfileResponse]) + + // NewListByCustomerPager is the fake for method RoleDefinitionClient.NewListByCustomerPager + // HTTP status codes to indicate success: http.StatusOK + NewListByCustomerPager func(billingAccountName string, billingProfileName string, customerName string, options *armbilling.RoleDefinitionClientListByCustomerOptions) (resp azfake.PagerResponder[armbilling.RoleDefinitionClientListByCustomerResponse]) + + // NewListByDepartmentPager is the fake for method RoleDefinitionClient.NewListByDepartmentPager + // HTTP status codes to indicate success: http.StatusOK + NewListByDepartmentPager func(billingAccountName string, departmentName string, options *armbilling.RoleDefinitionClientListByDepartmentOptions) (resp azfake.PagerResponder[armbilling.RoleDefinitionClientListByDepartmentResponse]) + + // NewListByEnrollmentAccountPager is the fake for method RoleDefinitionClient.NewListByEnrollmentAccountPager + // HTTP status codes to indicate success: http.StatusOK + NewListByEnrollmentAccountPager func(billingAccountName string, enrollmentAccountName string, options *armbilling.RoleDefinitionClientListByEnrollmentAccountOptions) (resp azfake.PagerResponder[armbilling.RoleDefinitionClientListByEnrollmentAccountResponse]) + + // NewListByInvoiceSectionPager is the fake for method RoleDefinitionClient.NewListByInvoiceSectionPager + // HTTP status codes to indicate success: http.StatusOK + NewListByInvoiceSectionPager func(billingAccountName string, billingProfileName string, invoiceSectionName string, options *armbilling.RoleDefinitionClientListByInvoiceSectionOptions) (resp azfake.PagerResponder[armbilling.RoleDefinitionClientListByInvoiceSectionResponse]) +} + +// NewRoleDefinitionServerTransport creates a new instance of RoleDefinitionServerTransport with the provided implementation. +// The returned RoleDefinitionServerTransport instance is connected to an instance of armbilling.RoleDefinitionClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewRoleDefinitionServerTransport(srv *RoleDefinitionServer) *RoleDefinitionServerTransport { + return &RoleDefinitionServerTransport{ + srv: srv, + newListByBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByBillingAccountResponse]](), + newListByBillingProfilePager: newTracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByBillingProfileResponse]](), + newListByCustomerPager: newTracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByCustomerResponse]](), + newListByDepartmentPager: newTracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByDepartmentResponse]](), + newListByEnrollmentAccountPager: newTracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByEnrollmentAccountResponse]](), + newListByInvoiceSectionPager: newTracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByInvoiceSectionResponse]](), + } +} + +// RoleDefinitionServerTransport connects instances of armbilling.RoleDefinitionClient to instances of RoleDefinitionServer. +// Don't use this type directly, use NewRoleDefinitionServerTransport instead. +type RoleDefinitionServerTransport struct { + srv *RoleDefinitionServer + newListByBillingAccountPager *tracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByBillingAccountResponse]] + newListByBillingProfilePager *tracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByBillingProfileResponse]] + newListByCustomerPager *tracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByCustomerResponse]] + newListByDepartmentPager *tracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByDepartmentResponse]] + newListByEnrollmentAccountPager *tracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByEnrollmentAccountResponse]] + newListByInvoiceSectionPager *tracker[azfake.PagerResponder[armbilling.RoleDefinitionClientListByInvoiceSectionResponse]] +} + +// Do implements the policy.Transporter interface for RoleDefinitionServerTransport. +func (r *RoleDefinitionServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "RoleDefinitionClient.GetByBillingAccount": + resp, err = r.dispatchGetByBillingAccount(req) + case "RoleDefinitionClient.GetByBillingProfile": + resp, err = r.dispatchGetByBillingProfile(req) + case "RoleDefinitionClient.GetByCustomer": + resp, err = r.dispatchGetByCustomer(req) + case "RoleDefinitionClient.GetByDepartment": + resp, err = r.dispatchGetByDepartment(req) + case "RoleDefinitionClient.GetByEnrollmentAccount": + resp, err = r.dispatchGetByEnrollmentAccount(req) + case "RoleDefinitionClient.GetByInvoiceSection": + resp, err = r.dispatchGetByInvoiceSection(req) + case "RoleDefinitionClient.NewListByBillingAccountPager": + resp, err = r.dispatchNewListByBillingAccountPager(req) + case "RoleDefinitionClient.NewListByBillingProfilePager": + resp, err = r.dispatchNewListByBillingProfilePager(req) + case "RoleDefinitionClient.NewListByCustomerPager": + resp, err = r.dispatchNewListByCustomerPager(req) + case "RoleDefinitionClient.NewListByDepartmentPager": + resp, err = r.dispatchNewListByDepartmentPager(req) + case "RoleDefinitionClient.NewListByEnrollmentAccountPager": + resp, err = r.dispatchNewListByEnrollmentAccountPager(req) + case "RoleDefinitionClient.NewListByInvoiceSectionPager": + resp, err = r.dispatchNewListByInvoiceSectionPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (r *RoleDefinitionServerTransport) dispatchGetByBillingAccount(req *http.Request) (*http.Response, error) { + if r.srv.GetByBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByBillingAccount not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + roleDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("roleDefinitionName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetByBillingAccount(req.Context(), billingAccountNameParam, roleDefinitionNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RoleDefinition, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RoleDefinitionServerTransport) dispatchGetByBillingProfile(req *http.Request) (*http.Response, error) { + if r.srv.GetByBillingProfile == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByBillingProfile not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + roleDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("roleDefinitionName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetByBillingProfile(req.Context(), billingAccountNameParam, billingProfileNameParam, roleDefinitionNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RoleDefinition, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RoleDefinitionServerTransport) dispatchGetByCustomer(req *http.Request) (*http.Response, error) { + if r.srv.GetByCustomer == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByCustomer not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) + if err != nil { + return nil, err + } + roleDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("roleDefinitionName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetByCustomer(req.Context(), billingAccountNameParam, billingProfileNameParam, customerNameParam, roleDefinitionNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RoleDefinition, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RoleDefinitionServerTransport) dispatchGetByDepartment(req *http.Request) (*http.Response, error) { + if r.srv.GetByDepartment == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByDepartment not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/departments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + departmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("departmentName")]) + if err != nil { + return nil, err + } + roleDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("roleDefinitionName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetByDepartment(req.Context(), billingAccountNameParam, departmentNameParam, roleDefinitionNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RoleDefinition, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RoleDefinitionServerTransport) dispatchGetByEnrollmentAccount(req *http.Request) (*http.Response, error) { + if r.srv.GetByEnrollmentAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByEnrollmentAccount not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enrollmentAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + enrollmentAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enrollmentAccountName")]) + if err != nil { + return nil, err + } + roleDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("roleDefinitionName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetByEnrollmentAccount(req.Context(), billingAccountNameParam, enrollmentAccountNameParam, roleDefinitionNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RoleDefinition, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RoleDefinitionServerTransport) dispatchGetByInvoiceSection(req *http.Request) (*http.Response, error) { + if r.srv.GetByInvoiceSection == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByInvoiceSection not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoiceSections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + invoiceSectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceSectionName")]) + if err != nil { + return nil, err + } + roleDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("roleDefinitionName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetByInvoiceSection(req.Context(), billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, roleDefinitionNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RoleDefinition, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RoleDefinitionServerTransport) dispatchNewListByBillingAccountPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListByBillingAccountPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByBillingAccountPager not implemented")} + } + newListByBillingAccountPager := r.newListByBillingAccountPager.get(req) + if newListByBillingAccountPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewListByBillingAccountPager(billingAccountNameParam, nil) + newListByBillingAccountPager = &resp + r.newListByBillingAccountPager.add(req, newListByBillingAccountPager) + server.PagerResponderInjectNextLinks(newListByBillingAccountPager, req, func(page *armbilling.RoleDefinitionClientListByBillingAccountResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByBillingAccountPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListByBillingAccountPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByBillingAccountPager) { + r.newListByBillingAccountPager.remove(req) + } + return resp, nil +} + +func (r *RoleDefinitionServerTransport) dispatchNewListByBillingProfilePager(req *http.Request) (*http.Response, error) { + if r.srv.NewListByBillingProfilePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByBillingProfilePager not implemented")} + } + newListByBillingProfilePager := r.newListByBillingProfilePager.get(req) + if newListByBillingProfilePager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewListByBillingProfilePager(billingAccountNameParam, billingProfileNameParam, nil) + newListByBillingProfilePager = &resp + r.newListByBillingProfilePager.add(req, newListByBillingProfilePager) + server.PagerResponderInjectNextLinks(newListByBillingProfilePager, req, func(page *armbilling.RoleDefinitionClientListByBillingProfileResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByBillingProfilePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListByBillingProfilePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByBillingProfilePager) { + r.newListByBillingProfilePager.remove(req) + } + return resp, nil +} + +func (r *RoleDefinitionServerTransport) dispatchNewListByCustomerPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListByCustomerPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByCustomerPager not implemented")} + } + newListByCustomerPager := r.newListByCustomerPager.get(req) + if newListByCustomerPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewListByCustomerPager(billingAccountNameParam, billingProfileNameParam, customerNameParam, nil) + newListByCustomerPager = &resp + r.newListByCustomerPager.add(req, newListByCustomerPager) + server.PagerResponderInjectNextLinks(newListByCustomerPager, req, func(page *armbilling.RoleDefinitionClientListByCustomerResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByCustomerPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListByCustomerPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByCustomerPager) { + r.newListByCustomerPager.remove(req) + } + return resp, nil +} + +func (r *RoleDefinitionServerTransport) dispatchNewListByDepartmentPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListByDepartmentPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByDepartmentPager not implemented")} + } + newListByDepartmentPager := r.newListByDepartmentPager.get(req) + if newListByDepartmentPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/departments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + departmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("departmentName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewListByDepartmentPager(billingAccountNameParam, departmentNameParam, nil) + newListByDepartmentPager = &resp + r.newListByDepartmentPager.add(req, newListByDepartmentPager) + server.PagerResponderInjectNextLinks(newListByDepartmentPager, req, func(page *armbilling.RoleDefinitionClientListByDepartmentResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByDepartmentPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListByDepartmentPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByDepartmentPager) { + r.newListByDepartmentPager.remove(req) + } + return resp, nil +} + +func (r *RoleDefinitionServerTransport) dispatchNewListByEnrollmentAccountPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListByEnrollmentAccountPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByEnrollmentAccountPager not implemented")} + } + newListByEnrollmentAccountPager := r.newListByEnrollmentAccountPager.get(req) + if newListByEnrollmentAccountPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enrollmentAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + enrollmentAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enrollmentAccountName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewListByEnrollmentAccountPager(billingAccountNameParam, enrollmentAccountNameParam, nil) + newListByEnrollmentAccountPager = &resp + r.newListByEnrollmentAccountPager.add(req, newListByEnrollmentAccountPager) + server.PagerResponderInjectNextLinks(newListByEnrollmentAccountPager, req, func(page *armbilling.RoleDefinitionClientListByEnrollmentAccountResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByEnrollmentAccountPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListByEnrollmentAccountPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByEnrollmentAccountPager) { + r.newListByEnrollmentAccountPager.remove(req) + } + return resp, nil +} + +func (r *RoleDefinitionServerTransport) dispatchNewListByInvoiceSectionPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListByInvoiceSectionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByInvoiceSectionPager not implemented")} + } + newListByInvoiceSectionPager := r.newListByInvoiceSectionPager.get(req) + if newListByInvoiceSectionPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoiceSections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + invoiceSectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceSectionName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewListByInvoiceSectionPager(billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, nil) + newListByInvoiceSectionPager = &resp + r.newListByInvoiceSectionPager.add(req, newListByInvoiceSectionPager) + server.PagerResponderInjectNextLinks(newListByInvoiceSectionPager, req, func(page *armbilling.RoleDefinitionClientListByInvoiceSectionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByInvoiceSectionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListByInvoiceSectionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByInvoiceSectionPager) { + r.newListByInvoiceSectionPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/fake/roledefinitions_server.go b/sdk/resourcemanager/billing/armbilling/fake/roledefinitions_server.go deleted file mode 100644 index 325656f93b67..000000000000 --- a/sdk/resourcemanager/billing/armbilling/fake/roledefinitions_server.go +++ /dev/null @@ -1,340 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "context" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" - "net/http" - "net/url" - "regexp" -) - -// RoleDefinitionsServer is a fake server for instances of the armbilling.RoleDefinitionsClient type. -type RoleDefinitionsServer struct { - // GetByBillingAccount is the fake for method RoleDefinitionsClient.GetByBillingAccount - // HTTP status codes to indicate success: http.StatusOK - GetByBillingAccount func(ctx context.Context, billingAccountName string, billingRoleDefinitionName string, options *armbilling.RoleDefinitionsClientGetByBillingAccountOptions) (resp azfake.Responder[armbilling.RoleDefinitionsClientGetByBillingAccountResponse], errResp azfake.ErrorResponder) - - // GetByBillingProfile is the fake for method RoleDefinitionsClient.GetByBillingProfile - // HTTP status codes to indicate success: http.StatusOK - GetByBillingProfile func(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleDefinitionName string, options *armbilling.RoleDefinitionsClientGetByBillingProfileOptions) (resp azfake.Responder[armbilling.RoleDefinitionsClientGetByBillingProfileResponse], errResp azfake.ErrorResponder) - - // GetByInvoiceSection is the fake for method RoleDefinitionsClient.GetByInvoiceSection - // HTTP status codes to indicate success: http.StatusOK - GetByInvoiceSection func(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, billingRoleDefinitionName string, options *armbilling.RoleDefinitionsClientGetByInvoiceSectionOptions) (resp azfake.Responder[armbilling.RoleDefinitionsClientGetByInvoiceSectionResponse], errResp azfake.ErrorResponder) - - // NewListByBillingAccountPager is the fake for method RoleDefinitionsClient.NewListByBillingAccountPager - // HTTP status codes to indicate success: http.StatusOK - NewListByBillingAccountPager func(billingAccountName string, options *armbilling.RoleDefinitionsClientListByBillingAccountOptions) (resp azfake.PagerResponder[armbilling.RoleDefinitionsClientListByBillingAccountResponse]) - - // NewListByBillingProfilePager is the fake for method RoleDefinitionsClient.NewListByBillingProfilePager - // HTTP status codes to indicate success: http.StatusOK - NewListByBillingProfilePager func(billingAccountName string, billingProfileName string, options *armbilling.RoleDefinitionsClientListByBillingProfileOptions) (resp azfake.PagerResponder[armbilling.RoleDefinitionsClientListByBillingProfileResponse]) - - // NewListByInvoiceSectionPager is the fake for method RoleDefinitionsClient.NewListByInvoiceSectionPager - // HTTP status codes to indicate success: http.StatusOK - NewListByInvoiceSectionPager func(billingAccountName string, billingProfileName string, invoiceSectionName string, options *armbilling.RoleDefinitionsClientListByInvoiceSectionOptions) (resp azfake.PagerResponder[armbilling.RoleDefinitionsClientListByInvoiceSectionResponse]) -} - -// NewRoleDefinitionsServerTransport creates a new instance of RoleDefinitionsServerTransport with the provided implementation. -// The returned RoleDefinitionsServerTransport instance is connected to an instance of armbilling.RoleDefinitionsClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewRoleDefinitionsServerTransport(srv *RoleDefinitionsServer) *RoleDefinitionsServerTransport { - return &RoleDefinitionsServerTransport{ - srv: srv, - newListByBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.RoleDefinitionsClientListByBillingAccountResponse]](), - newListByBillingProfilePager: newTracker[azfake.PagerResponder[armbilling.RoleDefinitionsClientListByBillingProfileResponse]](), - newListByInvoiceSectionPager: newTracker[azfake.PagerResponder[armbilling.RoleDefinitionsClientListByInvoiceSectionResponse]](), - } -} - -// RoleDefinitionsServerTransport connects instances of armbilling.RoleDefinitionsClient to instances of RoleDefinitionsServer. -// Don't use this type directly, use NewRoleDefinitionsServerTransport instead. -type RoleDefinitionsServerTransport struct { - srv *RoleDefinitionsServer - newListByBillingAccountPager *tracker[azfake.PagerResponder[armbilling.RoleDefinitionsClientListByBillingAccountResponse]] - newListByBillingProfilePager *tracker[azfake.PagerResponder[armbilling.RoleDefinitionsClientListByBillingProfileResponse]] - newListByInvoiceSectionPager *tracker[azfake.PagerResponder[armbilling.RoleDefinitionsClientListByInvoiceSectionResponse]] -} - -// Do implements the policy.Transporter interface for RoleDefinitionsServerTransport. -func (r *RoleDefinitionsServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - var resp *http.Response - var err error - - switch method { - case "RoleDefinitionsClient.GetByBillingAccount": - resp, err = r.dispatchGetByBillingAccount(req) - case "RoleDefinitionsClient.GetByBillingProfile": - resp, err = r.dispatchGetByBillingProfile(req) - case "RoleDefinitionsClient.GetByInvoiceSection": - resp, err = r.dispatchGetByInvoiceSection(req) - case "RoleDefinitionsClient.NewListByBillingAccountPager": - resp, err = r.dispatchNewListByBillingAccountPager(req) - case "RoleDefinitionsClient.NewListByBillingProfilePager": - resp, err = r.dispatchNewListByBillingProfilePager(req) - case "RoleDefinitionsClient.NewListByInvoiceSectionPager": - resp, err = r.dispatchNewListByInvoiceSectionPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } - - if err != nil { - return nil, err - } - - return resp, nil -} - -func (r *RoleDefinitionsServerTransport) dispatchGetByBillingAccount(req *http.Request) (*http.Response, error) { - if r.srv.GetByBillingAccount == nil { - return nil, &nonRetriableError{errors.New("fake for method GetByBillingAccount not implemented")} - } - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) - if err != nil { - return nil, err - } - billingRoleDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingRoleDefinitionName")]) - if err != nil { - return nil, err - } - respr, errRespr := r.srv.GetByBillingAccount(req.Context(), billingAccountNameParam, billingRoleDefinitionNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RoleDefinition, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (r *RoleDefinitionsServerTransport) dispatchGetByBillingProfile(req *http.Request) (*http.Response, error) { - if r.srv.GetByBillingProfile == nil { - return nil, &nonRetriableError{errors.New("fake for method GetByBillingProfile not implemented")} - } - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) - if err != nil { - return nil, err - } - billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) - if err != nil { - return nil, err - } - billingRoleDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingRoleDefinitionName")]) - if err != nil { - return nil, err - } - respr, errRespr := r.srv.GetByBillingProfile(req.Context(), billingAccountNameParam, billingProfileNameParam, billingRoleDefinitionNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RoleDefinition, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (r *RoleDefinitionsServerTransport) dispatchGetByInvoiceSection(req *http.Request) (*http.Response, error) { - if r.srv.GetByInvoiceSection == nil { - return nil, &nonRetriableError{errors.New("fake for method GetByInvoiceSection not implemented")} - } - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoiceSections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) - if err != nil { - return nil, err - } - billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) - if err != nil { - return nil, err - } - invoiceSectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceSectionName")]) - if err != nil { - return nil, err - } - billingRoleDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingRoleDefinitionName")]) - if err != nil { - return nil, err - } - respr, errRespr := r.srv.GetByInvoiceSection(req.Context(), billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, billingRoleDefinitionNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RoleDefinition, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (r *RoleDefinitionsServerTransport) dispatchNewListByBillingAccountPager(req *http.Request) (*http.Response, error) { - if r.srv.NewListByBillingAccountPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListByBillingAccountPager not implemented")} - } - newListByBillingAccountPager := r.newListByBillingAccountPager.get(req) - if newListByBillingAccountPager == nil { - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) - if err != nil { - return nil, err - } - resp := r.srv.NewListByBillingAccountPager(billingAccountNameParam, nil) - newListByBillingAccountPager = &resp - r.newListByBillingAccountPager.add(req, newListByBillingAccountPager) - server.PagerResponderInjectNextLinks(newListByBillingAccountPager, req, func(page *armbilling.RoleDefinitionsClientListByBillingAccountResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListByBillingAccountPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - r.newListByBillingAccountPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListByBillingAccountPager) { - r.newListByBillingAccountPager.remove(req) - } - return resp, nil -} - -func (r *RoleDefinitionsServerTransport) dispatchNewListByBillingProfilePager(req *http.Request) (*http.Response, error) { - if r.srv.NewListByBillingProfilePager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListByBillingProfilePager not implemented")} - } - newListByBillingProfilePager := r.newListByBillingProfilePager.get(req) - if newListByBillingProfilePager == nil { - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) - if err != nil { - return nil, err - } - billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) - if err != nil { - return nil, err - } - resp := r.srv.NewListByBillingProfilePager(billingAccountNameParam, billingProfileNameParam, nil) - newListByBillingProfilePager = &resp - r.newListByBillingProfilePager.add(req, newListByBillingProfilePager) - server.PagerResponderInjectNextLinks(newListByBillingProfilePager, req, func(page *armbilling.RoleDefinitionsClientListByBillingProfileResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListByBillingProfilePager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - r.newListByBillingProfilePager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListByBillingProfilePager) { - r.newListByBillingProfilePager.remove(req) - } - return resp, nil -} - -func (r *RoleDefinitionsServerTransport) dispatchNewListByInvoiceSectionPager(req *http.Request) (*http.Response, error) { - if r.srv.NewListByInvoiceSectionPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListByInvoiceSectionPager not implemented")} - } - newListByInvoiceSectionPager := r.newListByInvoiceSectionPager.get(req) - if newListByInvoiceSectionPager == nil { - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoiceSections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingRoleDefinitions` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) - if err != nil { - return nil, err - } - billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) - if err != nil { - return nil, err - } - invoiceSectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceSectionName")]) - if err != nil { - return nil, err - } - resp := r.srv.NewListByInvoiceSectionPager(billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, nil) - newListByInvoiceSectionPager = &resp - r.newListByInvoiceSectionPager.add(req, newListByInvoiceSectionPager) - server.PagerResponderInjectNextLinks(newListByInvoiceSectionPager, req, func(page *armbilling.RoleDefinitionsClientListByInvoiceSectionResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListByInvoiceSectionPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - r.newListByInvoiceSectionPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListByInvoiceSectionPager) { - r.newListByInvoiceSectionPager.remove(req) - } - return resp, nil -} diff --git a/sdk/resourcemanager/billing/armbilling/fake/savingsplanorders_server.go b/sdk/resourcemanager/billing/armbilling/fake/savingsplanorders_server.go new file mode 100644 index 000000000000..264001d165e1 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/fake/savingsplanorders_server.go @@ -0,0 +1,195 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "regexp" + "strconv" + + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// SavingsPlanOrdersServer is a fake server for instances of the armbilling.SavingsPlanOrdersClient type. +type SavingsPlanOrdersServer struct { + // GetByBillingAccount is the fake for method SavingsPlanOrdersClient.GetByBillingAccount + // HTTP status codes to indicate success: http.StatusOK + GetByBillingAccount func(ctx context.Context, billingAccountName string, savingsPlanOrderID string, options *armbilling.SavingsPlanOrdersClientGetByBillingAccountOptions) (resp azfake.Responder[armbilling.SavingsPlanOrdersClientGetByBillingAccountResponse], errResp azfake.ErrorResponder) + + // NewListByBillingAccountPager is the fake for method SavingsPlanOrdersClient.NewListByBillingAccountPager + // HTTP status codes to indicate success: http.StatusOK + NewListByBillingAccountPager func(billingAccountName string, options *armbilling.SavingsPlanOrdersClientListByBillingAccountOptions) (resp azfake.PagerResponder[armbilling.SavingsPlanOrdersClientListByBillingAccountResponse]) +} + +// NewSavingsPlanOrdersServerTransport creates a new instance of SavingsPlanOrdersServerTransport with the provided implementation. +// The returned SavingsPlanOrdersServerTransport instance is connected to an instance of armbilling.SavingsPlanOrdersClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewSavingsPlanOrdersServerTransport(srv *SavingsPlanOrdersServer) *SavingsPlanOrdersServerTransport { + return &SavingsPlanOrdersServerTransport{ + srv: srv, + newListByBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.SavingsPlanOrdersClientListByBillingAccountResponse]](), + } +} + +// SavingsPlanOrdersServerTransport connects instances of armbilling.SavingsPlanOrdersClient to instances of SavingsPlanOrdersServer. +// Don't use this type directly, use NewSavingsPlanOrdersServerTransport instead. +type SavingsPlanOrdersServerTransport struct { + srv *SavingsPlanOrdersServer + newListByBillingAccountPager *tracker[azfake.PagerResponder[armbilling.SavingsPlanOrdersClientListByBillingAccountResponse]] +} + +// Do implements the policy.Transporter interface for SavingsPlanOrdersServerTransport. +func (s *SavingsPlanOrdersServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "SavingsPlanOrdersClient.GetByBillingAccount": + resp, err = s.dispatchGetByBillingAccount(req) + case "SavingsPlanOrdersClient.NewListByBillingAccountPager": + resp, err = s.dispatchNewListByBillingAccountPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SavingsPlanOrdersServerTransport) dispatchGetByBillingAccount(req *http.Request) (*http.Response, error) { + if s.srv.GetByBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByBillingAccount not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/savingsPlanOrders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + savingsPlanOrderIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("savingsPlanOrderId")]) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) + var options *armbilling.SavingsPlanOrdersClientGetByBillingAccountOptions + if expandParam != nil { + options = &armbilling.SavingsPlanOrdersClientGetByBillingAccountOptions{ + Expand: expandParam, + } + } + respr, errRespr := s.srv.GetByBillingAccount(req.Context(), billingAccountNameParam, savingsPlanOrderIDParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SavingsPlanOrderModel, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SavingsPlanOrdersServerTransport) dispatchNewListByBillingAccountPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListByBillingAccountPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByBillingAccountPager not implemented")} + } + newListByBillingAccountPager := s.newListByBillingAccountPager.get(req) + if newListByBillingAccountPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/savingsPlanOrders` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + skiptokenUnescaped, err := url.QueryUnescape(qp.Get("skiptoken")) + if err != nil { + return nil, err + } + skiptokenParam, err := parseOptional(skiptokenUnescaped, func(v string) (float32, error) { + p, parseErr := strconv.ParseFloat(v, 32) + if parseErr != nil { + return 0, parseErr + } + return float32(p), nil + }) + if err != nil { + return nil, err + } + var options *armbilling.SavingsPlanOrdersClientListByBillingAccountOptions + if filterParam != nil || orderByParam != nil || skiptokenParam != nil { + options = &armbilling.SavingsPlanOrdersClientListByBillingAccountOptions{ + Filter: filterParam, + OrderBy: orderByParam, + Skiptoken: skiptokenParam, + } + } + resp := s.srv.NewListByBillingAccountPager(billingAccountNameParam, options) + newListByBillingAccountPager = &resp + s.newListByBillingAccountPager.add(req, newListByBillingAccountPager) + server.PagerResponderInjectNextLinks(newListByBillingAccountPager, req, func(page *armbilling.SavingsPlanOrdersClientListByBillingAccountResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByBillingAccountPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListByBillingAccountPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByBillingAccountPager) { + s.newListByBillingAccountPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/fake/savingsplans_server.go b/sdk/resourcemanager/billing/armbilling/fake/savingsplans_server.go new file mode 100644 index 000000000000..13cf494113e3 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/fake/savingsplans_server.go @@ -0,0 +1,382 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "regexp" + "strconv" + + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// SavingsPlansServer is a fake server for instances of the armbilling.SavingsPlansClient type. +type SavingsPlansServer struct { + // GetByBillingAccount is the fake for method SavingsPlansClient.GetByBillingAccount + // HTTP status codes to indicate success: http.StatusOK + GetByBillingAccount func(ctx context.Context, billingAccountName string, savingsPlanOrderID string, savingsPlanID string, options *armbilling.SavingsPlansClientGetByBillingAccountOptions) (resp azfake.Responder[armbilling.SavingsPlansClientGetByBillingAccountResponse], errResp azfake.ErrorResponder) + + // NewListByBillingAccountPager is the fake for method SavingsPlansClient.NewListByBillingAccountPager + // HTTP status codes to indicate success: http.StatusOK + NewListByBillingAccountPager func(billingAccountName string, options *armbilling.SavingsPlansClientListByBillingAccountOptions) (resp azfake.PagerResponder[armbilling.SavingsPlansClientListByBillingAccountResponse]) + + // NewListBySavingsPlanOrderPager is the fake for method SavingsPlansClient.NewListBySavingsPlanOrderPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySavingsPlanOrderPager func(billingAccountName string, savingsPlanOrderID string, options *armbilling.SavingsPlansClientListBySavingsPlanOrderOptions) (resp azfake.PagerResponder[armbilling.SavingsPlansClientListBySavingsPlanOrderResponse]) + + // BeginUpdateByBillingAccount is the fake for method SavingsPlansClient.BeginUpdateByBillingAccount + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdateByBillingAccount func(ctx context.Context, billingAccountName string, savingsPlanOrderID string, savingsPlanID string, body armbilling.SavingsPlanUpdateRequest, options *armbilling.SavingsPlansClientBeginUpdateByBillingAccountOptions) (resp azfake.PollerResponder[armbilling.SavingsPlansClientUpdateByBillingAccountResponse], errResp azfake.ErrorResponder) + + // ValidateUpdateByBillingAccount is the fake for method SavingsPlansClient.ValidateUpdateByBillingAccount + // HTTP status codes to indicate success: http.StatusOK + ValidateUpdateByBillingAccount func(ctx context.Context, billingAccountName string, savingsPlanOrderID string, savingsPlanID string, body armbilling.SavingsPlanUpdateValidateRequest, options *armbilling.SavingsPlansClientValidateUpdateByBillingAccountOptions) (resp azfake.Responder[armbilling.SavingsPlansClientValidateUpdateByBillingAccountResponse], errResp azfake.ErrorResponder) +} + +// NewSavingsPlansServerTransport creates a new instance of SavingsPlansServerTransport with the provided implementation. +// The returned SavingsPlansServerTransport instance is connected to an instance of armbilling.SavingsPlansClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewSavingsPlansServerTransport(srv *SavingsPlansServer) *SavingsPlansServerTransport { + return &SavingsPlansServerTransport{ + srv: srv, + newListByBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.SavingsPlansClientListByBillingAccountResponse]](), + newListBySavingsPlanOrderPager: newTracker[azfake.PagerResponder[armbilling.SavingsPlansClientListBySavingsPlanOrderResponse]](), + beginUpdateByBillingAccount: newTracker[azfake.PollerResponder[armbilling.SavingsPlansClientUpdateByBillingAccountResponse]](), + } +} + +// SavingsPlansServerTransport connects instances of armbilling.SavingsPlansClient to instances of SavingsPlansServer. +// Don't use this type directly, use NewSavingsPlansServerTransport instead. +type SavingsPlansServerTransport struct { + srv *SavingsPlansServer + newListByBillingAccountPager *tracker[azfake.PagerResponder[armbilling.SavingsPlansClientListByBillingAccountResponse]] + newListBySavingsPlanOrderPager *tracker[azfake.PagerResponder[armbilling.SavingsPlansClientListBySavingsPlanOrderResponse]] + beginUpdateByBillingAccount *tracker[azfake.PollerResponder[armbilling.SavingsPlansClientUpdateByBillingAccountResponse]] +} + +// Do implements the policy.Transporter interface for SavingsPlansServerTransport. +func (s *SavingsPlansServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "SavingsPlansClient.GetByBillingAccount": + resp, err = s.dispatchGetByBillingAccount(req) + case "SavingsPlansClient.NewListByBillingAccountPager": + resp, err = s.dispatchNewListByBillingAccountPager(req) + case "SavingsPlansClient.NewListBySavingsPlanOrderPager": + resp, err = s.dispatchNewListBySavingsPlanOrderPager(req) + case "SavingsPlansClient.BeginUpdateByBillingAccount": + resp, err = s.dispatchBeginUpdateByBillingAccount(req) + case "SavingsPlansClient.ValidateUpdateByBillingAccount": + resp, err = s.dispatchValidateUpdateByBillingAccount(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SavingsPlansServerTransport) dispatchGetByBillingAccount(req *http.Request) (*http.Response, error) { + if s.srv.GetByBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByBillingAccount not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/savingsPlanOrders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/savingsPlans/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + savingsPlanOrderIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("savingsPlanOrderId")]) + if err != nil { + return nil, err + } + savingsPlanIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("savingsPlanId")]) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) + var options *armbilling.SavingsPlansClientGetByBillingAccountOptions + if expandParam != nil { + options = &armbilling.SavingsPlansClientGetByBillingAccountOptions{ + Expand: expandParam, + } + } + respr, errRespr := s.srv.GetByBillingAccount(req.Context(), billingAccountNameParam, savingsPlanOrderIDParam, savingsPlanIDParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SavingsPlanModel, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SavingsPlansServerTransport) dispatchNewListByBillingAccountPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListByBillingAccountPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByBillingAccountPager not implemented")} + } + newListByBillingAccountPager := s.newListByBillingAccountPager.get(req) + if newListByBillingAccountPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/savingsPlans` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + skiptokenUnescaped, err := url.QueryUnescape(qp.Get("skiptoken")) + if err != nil { + return nil, err + } + skiptokenParam, err := parseOptional(skiptokenUnescaped, func(v string) (float32, error) { + p, parseErr := strconv.ParseFloat(v, 32) + if parseErr != nil { + return 0, parseErr + } + return float32(p), nil + }) + if err != nil { + return nil, err + } + takeUnescaped, err := url.QueryUnescape(qp.Get("take")) + if err != nil { + return nil, err + } + takeParam, err := parseOptional(takeUnescaped, func(v string) (float32, error) { + p, parseErr := strconv.ParseFloat(v, 32) + if parseErr != nil { + return 0, parseErr + } + return float32(p), nil + }) + if err != nil { + return nil, err + } + selectedStateUnescaped, err := url.QueryUnescape(qp.Get("selectedState")) + if err != nil { + return nil, err + } + selectedStateParam := getOptional(selectedStateUnescaped) + refreshSummaryUnescaped, err := url.QueryUnescape(qp.Get("refreshSummary")) + if err != nil { + return nil, err + } + refreshSummaryParam := getOptional(refreshSummaryUnescaped) + var options *armbilling.SavingsPlansClientListByBillingAccountOptions + if filterParam != nil || orderByParam != nil || skiptokenParam != nil || takeParam != nil || selectedStateParam != nil || refreshSummaryParam != nil { + options = &armbilling.SavingsPlansClientListByBillingAccountOptions{ + Filter: filterParam, + OrderBy: orderByParam, + Skiptoken: skiptokenParam, + Take: takeParam, + SelectedState: selectedStateParam, + RefreshSummary: refreshSummaryParam, + } + } + resp := s.srv.NewListByBillingAccountPager(billingAccountNameParam, options) + newListByBillingAccountPager = &resp + s.newListByBillingAccountPager.add(req, newListByBillingAccountPager) + server.PagerResponderInjectNextLinks(newListByBillingAccountPager, req, func(page *armbilling.SavingsPlansClientListByBillingAccountResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByBillingAccountPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListByBillingAccountPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByBillingAccountPager) { + s.newListByBillingAccountPager.remove(req) + } + return resp, nil +} + +func (s *SavingsPlansServerTransport) dispatchNewListBySavingsPlanOrderPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListBySavingsPlanOrderPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySavingsPlanOrderPager not implemented")} + } + newListBySavingsPlanOrderPager := s.newListBySavingsPlanOrderPager.get(req) + if newListBySavingsPlanOrderPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/savingsPlanOrders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/savingsPlans` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + savingsPlanOrderIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("savingsPlanOrderId")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListBySavingsPlanOrderPager(billingAccountNameParam, savingsPlanOrderIDParam, nil) + newListBySavingsPlanOrderPager = &resp + s.newListBySavingsPlanOrderPager.add(req, newListBySavingsPlanOrderPager) + server.PagerResponderInjectNextLinks(newListBySavingsPlanOrderPager, req, func(page *armbilling.SavingsPlansClientListBySavingsPlanOrderResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBySavingsPlanOrderPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListBySavingsPlanOrderPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySavingsPlanOrderPager) { + s.newListBySavingsPlanOrderPager.remove(req) + } + return resp, nil +} + +func (s *SavingsPlansServerTransport) dispatchBeginUpdateByBillingAccount(req *http.Request) (*http.Response, error) { + if s.srv.BeginUpdateByBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdateByBillingAccount not implemented")} + } + beginUpdateByBillingAccount := s.beginUpdateByBillingAccount.get(req) + if beginUpdateByBillingAccount == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/savingsPlanOrders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/savingsPlans/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.SavingsPlanUpdateRequest](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + savingsPlanOrderIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("savingsPlanOrderId")]) + if err != nil { + return nil, err + } + savingsPlanIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("savingsPlanId")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginUpdateByBillingAccount(req.Context(), billingAccountNameParam, savingsPlanOrderIDParam, savingsPlanIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdateByBillingAccount = &respr + s.beginUpdateByBillingAccount.add(req, beginUpdateByBillingAccount) + } + + resp, err := server.PollerResponderNext(beginUpdateByBillingAccount, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + s.beginUpdateByBillingAccount.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdateByBillingAccount) { + s.beginUpdateByBillingAccount.remove(req) + } + + return resp, nil +} + +func (s *SavingsPlansServerTransport) dispatchValidateUpdateByBillingAccount(req *http.Request) (*http.Response, error) { + if s.srv.ValidateUpdateByBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method ValidateUpdateByBillingAccount not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/savingsPlanOrders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/savingsPlans/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validate` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.SavingsPlanUpdateValidateRequest](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + savingsPlanOrderIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("savingsPlanOrderId")]) + if err != nil { + return nil, err + } + savingsPlanIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("savingsPlanId")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.ValidateUpdateByBillingAccount(req.Context(), billingAccountNameParam, savingsPlanOrderIDParam, savingsPlanIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SavingsPlanValidateResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/fake/server_factory.go b/sdk/resourcemanager/billing/armbilling/fake/server_factory.go index e9f984ff3850..cdcb20d52a1a 100644 --- a/sdk/resourcemanager/billing/armbilling/fake/server_factory.go +++ b/sdk/resourcemanager/billing/armbilling/fake/server_factory.go @@ -11,35 +11,45 @@ package fake import ( "errors" "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "strings" "sync" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" ) // ServerFactory is a fake server for instances of the armbilling.ClientFactory type. type ServerFactory struct { - AccountsServer AccountsServer - AddressServer AddressServer - AgreementsServer AgreementsServer - AvailableBalancesServer AvailableBalancesServer - CustomersServer CustomersServer - EnrollmentAccountsServer EnrollmentAccountsServer - InstructionsServer InstructionsServer - InvoiceSectionsServer InvoiceSectionsServer - InvoicesServer InvoicesServer - OperationsServer OperationsServer - PeriodsServer PeriodsServer - PermissionsServer PermissionsServer - PoliciesServer PoliciesServer - ProductsServer ProductsServer - ProfilesServer ProfilesServer - PropertyServer PropertyServer - ReservationsServer ReservationsServer - RoleAssignmentsServer RoleAssignmentsServer - RoleDefinitionsServer RoleDefinitionsServer - SubscriptionsServer SubscriptionsServer - TransactionsServer TransactionsServer + AccountsServer AccountsServer + AddressServer AddressServer + AgreementsServer AgreementsServer + AssociatedTenantsServer AssociatedTenantsServer + AvailableBalancesServer AvailableBalancesServer + CustomersServer CustomersServer + DepartmentsServer DepartmentsServer + EnrollmentAccountsServer EnrollmentAccountsServer + InvoiceSectionsServer InvoiceSectionsServer + InvoicesServer InvoicesServer + OperationsServer OperationsServer + PartnerTransfersServer PartnerTransfersServer + PaymentMethodsServer PaymentMethodsServer + PermissionsServer PermissionsServer + PoliciesServer PoliciesServer + ProductsServer ProductsServer + ProfilesServer ProfilesServer + PropertyServer PropertyServer + RecipientTransfersServer RecipientTransfersServer + RequestsServer RequestsServer + ReservationOrdersServer ReservationOrdersServer + ReservationsServer ReservationsServer + RoleAssignmentsServer RoleAssignmentsServer + RoleDefinitionServer RoleDefinitionServer + SavingsPlanOrdersServer SavingsPlanOrdersServer + SavingsPlansServer SavingsPlansServer + SubscriptionsAliasesServer SubscriptionsAliasesServer + SubscriptionsServer SubscriptionsServer + TransactionsServer TransactionsServer + TransfersServer TransfersServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -54,29 +64,38 @@ func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { // ServerFactoryTransport connects instances of armbilling.ClientFactory to instances of ServerFactory. // Don't use this type directly, use NewServerFactoryTransport instead. type ServerFactoryTransport struct { - srv *ServerFactory - trMu sync.Mutex - trAccountsServer *AccountsServerTransport - trAddressServer *AddressServerTransport - trAgreementsServer *AgreementsServerTransport - trAvailableBalancesServer *AvailableBalancesServerTransport - trCustomersServer *CustomersServerTransport - trEnrollmentAccountsServer *EnrollmentAccountsServerTransport - trInstructionsServer *InstructionsServerTransport - trInvoiceSectionsServer *InvoiceSectionsServerTransport - trInvoicesServer *InvoicesServerTransport - trOperationsServer *OperationsServerTransport - trPeriodsServer *PeriodsServerTransport - trPermissionsServer *PermissionsServerTransport - trPoliciesServer *PoliciesServerTransport - trProductsServer *ProductsServerTransport - trProfilesServer *ProfilesServerTransport - trPropertyServer *PropertyServerTransport - trReservationsServer *ReservationsServerTransport - trRoleAssignmentsServer *RoleAssignmentsServerTransport - trRoleDefinitionsServer *RoleDefinitionsServerTransport - trSubscriptionsServer *SubscriptionsServerTransport - trTransactionsServer *TransactionsServerTransport + srv *ServerFactory + trMu sync.Mutex + trAccountsServer *AccountsServerTransport + trAddressServer *AddressServerTransport + trAgreementsServer *AgreementsServerTransport + trAssociatedTenantsServer *AssociatedTenantsServerTransport + trAvailableBalancesServer *AvailableBalancesServerTransport + trCustomersServer *CustomersServerTransport + trDepartmentsServer *DepartmentsServerTransport + trEnrollmentAccountsServer *EnrollmentAccountsServerTransport + trInvoiceSectionsServer *InvoiceSectionsServerTransport + trInvoicesServer *InvoicesServerTransport + trOperationsServer *OperationsServerTransport + trPartnerTransfersServer *PartnerTransfersServerTransport + trPaymentMethodsServer *PaymentMethodsServerTransport + trPermissionsServer *PermissionsServerTransport + trPoliciesServer *PoliciesServerTransport + trProductsServer *ProductsServerTransport + trProfilesServer *ProfilesServerTransport + trPropertyServer *PropertyServerTransport + trRecipientTransfersServer *RecipientTransfersServerTransport + trRequestsServer *RequestsServerTransport + trReservationOrdersServer *ReservationOrdersServerTransport + trReservationsServer *ReservationsServerTransport + trRoleAssignmentsServer *RoleAssignmentsServerTransport + trRoleDefinitionServer *RoleDefinitionServerTransport + trSavingsPlanOrdersServer *SavingsPlanOrdersServerTransport + trSavingsPlansServer *SavingsPlansServerTransport + trSubscriptionsAliasesServer *SubscriptionsAliasesServerTransport + trSubscriptionsServer *SubscriptionsServerTransport + trTransactionsServer *TransactionsServerTransport + trTransfersServer *TransfersServerTransport } // Do implements the policy.Transporter interface for ServerFactoryTransport. @@ -101,6 +120,11 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "AgreementsClient": initServer(s, &s.trAgreementsServer, func() *AgreementsServerTransport { return NewAgreementsServerTransport(&s.srv.AgreementsServer) }) resp, err = s.trAgreementsServer.Do(req) + case "AssociatedTenantsClient": + initServer(s, &s.trAssociatedTenantsServer, func() *AssociatedTenantsServerTransport { + return NewAssociatedTenantsServerTransport(&s.srv.AssociatedTenantsServer) + }) + resp, err = s.trAssociatedTenantsServer.Do(req) case "AvailableBalancesClient": initServer(s, &s.trAvailableBalancesServer, func() *AvailableBalancesServerTransport { return NewAvailableBalancesServerTransport(&s.srv.AvailableBalancesServer) @@ -109,14 +133,14 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "CustomersClient": initServer(s, &s.trCustomersServer, func() *CustomersServerTransport { return NewCustomersServerTransport(&s.srv.CustomersServer) }) resp, err = s.trCustomersServer.Do(req) + case "DepartmentsClient": + initServer(s, &s.trDepartmentsServer, func() *DepartmentsServerTransport { return NewDepartmentsServerTransport(&s.srv.DepartmentsServer) }) + resp, err = s.trDepartmentsServer.Do(req) case "EnrollmentAccountsClient": initServer(s, &s.trEnrollmentAccountsServer, func() *EnrollmentAccountsServerTransport { return NewEnrollmentAccountsServerTransport(&s.srv.EnrollmentAccountsServer) }) resp, err = s.trEnrollmentAccountsServer.Do(req) - case "InstructionsClient": - initServer(s, &s.trInstructionsServer, func() *InstructionsServerTransport { return NewInstructionsServerTransport(&s.srv.InstructionsServer) }) - resp, err = s.trInstructionsServer.Do(req) case "InvoiceSectionsClient": initServer(s, &s.trInvoiceSectionsServer, func() *InvoiceSectionsServerTransport { return NewInvoiceSectionsServerTransport(&s.srv.InvoiceSectionsServer) @@ -128,9 +152,16 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "OperationsClient": initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) resp, err = s.trOperationsServer.Do(req) - case "PeriodsClient": - initServer(s, &s.trPeriodsServer, func() *PeriodsServerTransport { return NewPeriodsServerTransport(&s.srv.PeriodsServer) }) - resp, err = s.trPeriodsServer.Do(req) + case "PartnerTransfersClient": + initServer(s, &s.trPartnerTransfersServer, func() *PartnerTransfersServerTransport { + return NewPartnerTransfersServerTransport(&s.srv.PartnerTransfersServer) + }) + resp, err = s.trPartnerTransfersServer.Do(req) + case "PaymentMethodsClient": + initServer(s, &s.trPaymentMethodsServer, func() *PaymentMethodsServerTransport { + return NewPaymentMethodsServerTransport(&s.srv.PaymentMethodsServer) + }) + resp, err = s.trPaymentMethodsServer.Do(req) case "PermissionsClient": initServer(s, &s.trPermissionsServer, func() *PermissionsServerTransport { return NewPermissionsServerTransport(&s.srv.PermissionsServer) }) resp, err = s.trPermissionsServer.Do(req) @@ -146,6 +177,19 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "PropertyClient": initServer(s, &s.trPropertyServer, func() *PropertyServerTransport { return NewPropertyServerTransport(&s.srv.PropertyServer) }) resp, err = s.trPropertyServer.Do(req) + case "RecipientTransfersClient": + initServer(s, &s.trRecipientTransfersServer, func() *RecipientTransfersServerTransport { + return NewRecipientTransfersServerTransport(&s.srv.RecipientTransfersServer) + }) + resp, err = s.trRecipientTransfersServer.Do(req) + case "RequestsClient": + initServer(s, &s.trRequestsServer, func() *RequestsServerTransport { return NewRequestsServerTransport(&s.srv.RequestsServer) }) + resp, err = s.trRequestsServer.Do(req) + case "ReservationOrdersClient": + initServer(s, &s.trReservationOrdersServer, func() *ReservationOrdersServerTransport { + return NewReservationOrdersServerTransport(&s.srv.ReservationOrdersServer) + }) + resp, err = s.trReservationOrdersServer.Do(req) case "ReservationsClient": initServer(s, &s.trReservationsServer, func() *ReservationsServerTransport { return NewReservationsServerTransport(&s.srv.ReservationsServer) }) resp, err = s.trReservationsServer.Do(req) @@ -154,11 +198,24 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { return NewRoleAssignmentsServerTransport(&s.srv.RoleAssignmentsServer) }) resp, err = s.trRoleAssignmentsServer.Do(req) - case "RoleDefinitionsClient": - initServer(s, &s.trRoleDefinitionsServer, func() *RoleDefinitionsServerTransport { - return NewRoleDefinitionsServerTransport(&s.srv.RoleDefinitionsServer) + case "RoleDefinitionClient": + initServer(s, &s.trRoleDefinitionServer, func() *RoleDefinitionServerTransport { + return NewRoleDefinitionServerTransport(&s.srv.RoleDefinitionServer) + }) + resp, err = s.trRoleDefinitionServer.Do(req) + case "SavingsPlanOrdersClient": + initServer(s, &s.trSavingsPlanOrdersServer, func() *SavingsPlanOrdersServerTransport { + return NewSavingsPlanOrdersServerTransport(&s.srv.SavingsPlanOrdersServer) + }) + resp, err = s.trSavingsPlanOrdersServer.Do(req) + case "SavingsPlansClient": + initServer(s, &s.trSavingsPlansServer, func() *SavingsPlansServerTransport { return NewSavingsPlansServerTransport(&s.srv.SavingsPlansServer) }) + resp, err = s.trSavingsPlansServer.Do(req) + case "SubscriptionsAliasesClient": + initServer(s, &s.trSubscriptionsAliasesServer, func() *SubscriptionsAliasesServerTransport { + return NewSubscriptionsAliasesServerTransport(&s.srv.SubscriptionsAliasesServer) }) - resp, err = s.trRoleDefinitionsServer.Do(req) + resp, err = s.trSubscriptionsAliasesServer.Do(req) case "SubscriptionsClient": initServer(s, &s.trSubscriptionsServer, func() *SubscriptionsServerTransport { return NewSubscriptionsServerTransport(&s.srv.SubscriptionsServer) @@ -167,6 +224,9 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "TransactionsClient": initServer(s, &s.trTransactionsServer, func() *TransactionsServerTransport { return NewTransactionsServerTransport(&s.srv.TransactionsServer) }) resp, err = s.trTransactionsServer.Do(req) + case "TransfersClient": + initServer(s, &s.trTransfersServer, func() *TransfersServerTransport { return NewTransfersServerTransport(&s.srv.TransfersServer) }) + resp, err = s.trTransfersServer.Do(req) default: err = fmt.Errorf("unhandled client %s", client) } diff --git a/sdk/resourcemanager/billing/armbilling/fake/subscriptions_server.go b/sdk/resourcemanager/billing/armbilling/fake/subscriptions_server.go index 47855f9a49da..c2cb050def6b 100644 --- a/sdk/resourcemanager/billing/armbilling/fake/subscriptions_server.go +++ b/sdk/resourcemanager/billing/armbilling/fake/subscriptions_server.go @@ -12,21 +12,35 @@ import ( "context" "errors" "fmt" + "net/http" + "net/url" + "regexp" + "strconv" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" - "net/http" - "net/url" - "regexp" ) // SubscriptionsServer is a fake server for instances of the armbilling.SubscriptionsClient type. type SubscriptionsServer struct { + // BeginCancel is the fake for method SubscriptionsClient.BeginCancel + // HTTP status codes to indicate success: http.StatusAccepted + BeginCancel func(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters armbilling.CancelSubscriptionRequest, options *armbilling.SubscriptionsClientBeginCancelOptions) (resp azfake.PollerResponder[armbilling.SubscriptionsClientCancelResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method SubscriptionsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, billingAccountName string, billingSubscriptionName string, options *armbilling.SubscriptionsClientBeginDeleteOptions) (resp azfake.PollerResponder[armbilling.SubscriptionsClientDeleteResponse], errResp azfake.ErrorResponder) + // Get is the fake for method SubscriptionsClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, billingAccountName string, options *armbilling.SubscriptionsClientGetOptions) (resp azfake.Responder[armbilling.SubscriptionsClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, billingAccountName string, billingSubscriptionName string, options *armbilling.SubscriptionsClientGetOptions) (resp azfake.Responder[armbilling.SubscriptionsClientGetResponse], errResp azfake.ErrorResponder) + + // GetByBillingProfile is the fake for method SubscriptionsClient.GetByBillingProfile + // HTTP status codes to indicate success: http.StatusOK + GetByBillingProfile func(ctx context.Context, billingAccountName string, billingProfileName string, billingSubscriptionName string, options *armbilling.SubscriptionsClientGetByBillingProfileOptions) (resp azfake.Responder[armbilling.SubscriptionsClientGetByBillingProfileResponse], errResp azfake.ErrorResponder) // NewListByBillingAccountPager is the fake for method SubscriptionsClient.NewListByBillingAccountPager // HTTP status codes to indicate success: http.StatusOK @@ -38,23 +52,39 @@ type SubscriptionsServer struct { // NewListByCustomerPager is the fake for method SubscriptionsClient.NewListByCustomerPager // HTTP status codes to indicate success: http.StatusOK - NewListByCustomerPager func(billingAccountName string, customerName string, options *armbilling.SubscriptionsClientListByCustomerOptions) (resp azfake.PagerResponder[armbilling.SubscriptionsClientListByCustomerResponse]) + NewListByCustomerPager func(billingAccountName string, billingProfileName string, customerName string, options *armbilling.SubscriptionsClientListByCustomerOptions) (resp azfake.PagerResponder[armbilling.SubscriptionsClientListByCustomerResponse]) + + // NewListByCustomerAtBillingAccountPager is the fake for method SubscriptionsClient.NewListByCustomerAtBillingAccountPager + // HTTP status codes to indicate success: http.StatusOK + NewListByCustomerAtBillingAccountPager func(billingAccountName string, customerName string, options *armbilling.SubscriptionsClientListByCustomerAtBillingAccountOptions) (resp azfake.PagerResponder[armbilling.SubscriptionsClientListByCustomerAtBillingAccountResponse]) + + // NewListByEnrollmentAccountPager is the fake for method SubscriptionsClient.NewListByEnrollmentAccountPager + // HTTP status codes to indicate success: http.StatusOK + NewListByEnrollmentAccountPager func(billingAccountName string, enrollmentAccountName string, options *armbilling.SubscriptionsClientListByEnrollmentAccountOptions) (resp azfake.PagerResponder[armbilling.SubscriptionsClientListByEnrollmentAccountResponse]) // NewListByInvoiceSectionPager is the fake for method SubscriptionsClient.NewListByInvoiceSectionPager // HTTP status codes to indicate success: http.StatusOK NewListByInvoiceSectionPager func(billingAccountName string, billingProfileName string, invoiceSectionName string, options *armbilling.SubscriptionsClientListByInvoiceSectionOptions) (resp azfake.PagerResponder[armbilling.SubscriptionsClientListByInvoiceSectionResponse]) + // BeginMerge is the fake for method SubscriptionsClient.BeginMerge + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginMerge func(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters armbilling.SubscriptionMergeRequest, options *armbilling.SubscriptionsClientBeginMergeOptions) (resp azfake.PollerResponder[armbilling.SubscriptionsClientMergeResponse], errResp azfake.ErrorResponder) + // BeginMove is the fake for method SubscriptionsClient.BeginMove // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginMove func(ctx context.Context, billingAccountName string, parameters armbilling.TransferBillingSubscriptionRequestProperties, options *armbilling.SubscriptionsClientBeginMoveOptions) (resp azfake.PollerResponder[armbilling.SubscriptionsClientMoveResponse], errResp azfake.ErrorResponder) + BeginMove func(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters armbilling.MoveBillingSubscriptionRequest, options *armbilling.SubscriptionsClientBeginMoveOptions) (resp azfake.PollerResponder[armbilling.SubscriptionsClientMoveResponse], errResp azfake.ErrorResponder) - // Update is the fake for method SubscriptionsClient.Update - // HTTP status codes to indicate success: http.StatusOK - Update func(ctx context.Context, billingAccountName string, parameters armbilling.Subscription, options *armbilling.SubscriptionsClientUpdateOptions) (resp azfake.Responder[armbilling.SubscriptionsClientUpdateResponse], errResp azfake.ErrorResponder) + // BeginSplit is the fake for method SubscriptionsClient.BeginSplit + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginSplit func(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters armbilling.SubscriptionSplitRequest, options *armbilling.SubscriptionsClientBeginSplitOptions) (resp azfake.PollerResponder[armbilling.SubscriptionsClientSplitResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method SubscriptionsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters armbilling.SubscriptionPatch, options *armbilling.SubscriptionsClientBeginUpdateOptions) (resp azfake.PollerResponder[armbilling.SubscriptionsClientUpdateResponse], errResp azfake.ErrorResponder) - // ValidateMove is the fake for method SubscriptionsClient.ValidateMove + // ValidateMoveEligibility is the fake for method SubscriptionsClient.ValidateMoveEligibility // HTTP status codes to indicate success: http.StatusOK - ValidateMove func(ctx context.Context, billingAccountName string, parameters armbilling.TransferBillingSubscriptionRequestProperties, options *armbilling.SubscriptionsClientValidateMoveOptions) (resp azfake.Responder[armbilling.SubscriptionsClientValidateMoveResponse], errResp azfake.ErrorResponder) + ValidateMoveEligibility func(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters armbilling.MoveBillingSubscriptionRequest, options *armbilling.SubscriptionsClientValidateMoveEligibilityOptions) (resp azfake.Responder[armbilling.SubscriptionsClientValidateMoveEligibilityResponse], errResp azfake.ErrorResponder) } // NewSubscriptionsServerTransport creates a new instance of SubscriptionsServerTransport with the provided implementation. @@ -62,24 +92,38 @@ type SubscriptionsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewSubscriptionsServerTransport(srv *SubscriptionsServer) *SubscriptionsServerTransport { return &SubscriptionsServerTransport{ - srv: srv, - newListByBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.SubscriptionsClientListByBillingAccountResponse]](), - newListByBillingProfilePager: newTracker[azfake.PagerResponder[armbilling.SubscriptionsClientListByBillingProfileResponse]](), - newListByCustomerPager: newTracker[azfake.PagerResponder[armbilling.SubscriptionsClientListByCustomerResponse]](), - newListByInvoiceSectionPager: newTracker[azfake.PagerResponder[armbilling.SubscriptionsClientListByInvoiceSectionResponse]](), - beginMove: newTracker[azfake.PollerResponder[armbilling.SubscriptionsClientMoveResponse]](), + srv: srv, + beginCancel: newTracker[azfake.PollerResponder[armbilling.SubscriptionsClientCancelResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armbilling.SubscriptionsClientDeleteResponse]](), + newListByBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.SubscriptionsClientListByBillingAccountResponse]](), + newListByBillingProfilePager: newTracker[azfake.PagerResponder[armbilling.SubscriptionsClientListByBillingProfileResponse]](), + newListByCustomerPager: newTracker[azfake.PagerResponder[armbilling.SubscriptionsClientListByCustomerResponse]](), + newListByCustomerAtBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.SubscriptionsClientListByCustomerAtBillingAccountResponse]](), + newListByEnrollmentAccountPager: newTracker[azfake.PagerResponder[armbilling.SubscriptionsClientListByEnrollmentAccountResponse]](), + newListByInvoiceSectionPager: newTracker[azfake.PagerResponder[armbilling.SubscriptionsClientListByInvoiceSectionResponse]](), + beginMerge: newTracker[azfake.PollerResponder[armbilling.SubscriptionsClientMergeResponse]](), + beginMove: newTracker[azfake.PollerResponder[armbilling.SubscriptionsClientMoveResponse]](), + beginSplit: newTracker[azfake.PollerResponder[armbilling.SubscriptionsClientSplitResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armbilling.SubscriptionsClientUpdateResponse]](), } } // SubscriptionsServerTransport connects instances of armbilling.SubscriptionsClient to instances of SubscriptionsServer. // Don't use this type directly, use NewSubscriptionsServerTransport instead. type SubscriptionsServerTransport struct { - srv *SubscriptionsServer - newListByBillingAccountPager *tracker[azfake.PagerResponder[armbilling.SubscriptionsClientListByBillingAccountResponse]] - newListByBillingProfilePager *tracker[azfake.PagerResponder[armbilling.SubscriptionsClientListByBillingProfileResponse]] - newListByCustomerPager *tracker[azfake.PagerResponder[armbilling.SubscriptionsClientListByCustomerResponse]] - newListByInvoiceSectionPager *tracker[azfake.PagerResponder[armbilling.SubscriptionsClientListByInvoiceSectionResponse]] - beginMove *tracker[azfake.PollerResponder[armbilling.SubscriptionsClientMoveResponse]] + srv *SubscriptionsServer + beginCancel *tracker[azfake.PollerResponder[armbilling.SubscriptionsClientCancelResponse]] + beginDelete *tracker[azfake.PollerResponder[armbilling.SubscriptionsClientDeleteResponse]] + newListByBillingAccountPager *tracker[azfake.PagerResponder[armbilling.SubscriptionsClientListByBillingAccountResponse]] + newListByBillingProfilePager *tracker[azfake.PagerResponder[armbilling.SubscriptionsClientListByBillingProfileResponse]] + newListByCustomerPager *tracker[azfake.PagerResponder[armbilling.SubscriptionsClientListByCustomerResponse]] + newListByCustomerAtBillingAccountPager *tracker[azfake.PagerResponder[armbilling.SubscriptionsClientListByCustomerAtBillingAccountResponse]] + newListByEnrollmentAccountPager *tracker[azfake.PagerResponder[armbilling.SubscriptionsClientListByEnrollmentAccountResponse]] + newListByInvoiceSectionPager *tracker[azfake.PagerResponder[armbilling.SubscriptionsClientListByInvoiceSectionResponse]] + beginMerge *tracker[azfake.PollerResponder[armbilling.SubscriptionsClientMergeResponse]] + beginMove *tracker[azfake.PollerResponder[armbilling.SubscriptionsClientMoveResponse]] + beginSplit *tracker[azfake.PollerResponder[armbilling.SubscriptionsClientSplitResponse]] + beginUpdate *tracker[azfake.PollerResponder[armbilling.SubscriptionsClientUpdateResponse]] } // Do implements the policy.Transporter interface for SubscriptionsServerTransport. @@ -94,22 +138,36 @@ func (s *SubscriptionsServerTransport) Do(req *http.Request) (*http.Response, er var err error switch method { + case "SubscriptionsClient.BeginCancel": + resp, err = s.dispatchBeginCancel(req) + case "SubscriptionsClient.BeginDelete": + resp, err = s.dispatchBeginDelete(req) case "SubscriptionsClient.Get": resp, err = s.dispatchGet(req) + case "SubscriptionsClient.GetByBillingProfile": + resp, err = s.dispatchGetByBillingProfile(req) case "SubscriptionsClient.NewListByBillingAccountPager": resp, err = s.dispatchNewListByBillingAccountPager(req) case "SubscriptionsClient.NewListByBillingProfilePager": resp, err = s.dispatchNewListByBillingProfilePager(req) case "SubscriptionsClient.NewListByCustomerPager": resp, err = s.dispatchNewListByCustomerPager(req) + case "SubscriptionsClient.NewListByCustomerAtBillingAccountPager": + resp, err = s.dispatchNewListByCustomerAtBillingAccountPager(req) + case "SubscriptionsClient.NewListByEnrollmentAccountPager": + resp, err = s.dispatchNewListByEnrollmentAccountPager(req) case "SubscriptionsClient.NewListByInvoiceSectionPager": resp, err = s.dispatchNewListByInvoiceSectionPager(req) + case "SubscriptionsClient.BeginMerge": + resp, err = s.dispatchBeginMerge(req) case "SubscriptionsClient.BeginMove": resp, err = s.dispatchBeginMove(req) - case "SubscriptionsClient.Update": - resp, err = s.dispatchUpdate(req) - case "SubscriptionsClient.ValidateMove": - resp, err = s.dispatchValidateMove(req) + case "SubscriptionsClient.BeginSplit": + resp, err = s.dispatchBeginSplit(req) + case "SubscriptionsClient.BeginUpdate": + resp, err = s.dispatchBeginUpdate(req) + case "SubscriptionsClient.ValidateMoveEligibility": + resp, err = s.dispatchValidateMoveEligibility(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -121,21 +179,178 @@ func (s *SubscriptionsServerTransport) Do(req *http.Request) (*http.Response, er return resp, nil } +func (s *SubscriptionsServerTransport) dispatchBeginCancel(req *http.Request) (*http.Response, error) { + if s.srv.BeginCancel == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCancel not implemented")} + } + beginCancel := s.beginCancel.get(req) + if beginCancel == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingSubscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/cancel` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.CancelSubscriptionRequest](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingSubscriptionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingSubscriptionName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginCancel(req.Context(), billingAccountNameParam, billingSubscriptionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCancel = &respr + s.beginCancel.add(req, beginCancel) + } + + resp, err := server.PollerResponderNext(beginCancel, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted}, resp.StatusCode) { + s.beginCancel.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCancel) { + s.beginCancel.remove(req) + } + + return resp, nil +} + +func (s *SubscriptionsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if s.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := s.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingSubscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingSubscriptionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingSubscriptionName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginDelete(req.Context(), billingAccountNameParam, billingSubscriptionNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + s.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + s.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + s.beginDelete.remove(req) + } + + return resp, nil +} + func (s *SubscriptionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if s.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingSubscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingSubscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingSubscriptionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingSubscriptionName")]) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) + var options *armbilling.SubscriptionsClientGetOptions + if expandParam != nil { + options = &armbilling.SubscriptionsClientGetOptions{ + Expand: expandParam, + } + } + respr, errRespr := s.srv.Get(req.Context(), billingAccountNameParam, billingSubscriptionNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Subscription, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SubscriptionsServerTransport) dispatchGetByBillingProfile(req *http.Request) (*http.Response, error) { + if s.srv.GetByBillingProfile == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByBillingProfile not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingSubscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) if err != nil { return nil, err } - respr, errRespr := s.srv.Get(req.Context(), billingAccountNameParam, nil) + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + billingSubscriptionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingSubscriptionName")]) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) + var options *armbilling.SubscriptionsClientGetByBillingProfileOptions + if expandParam != nil { + options = &armbilling.SubscriptionsClientGetByBillingProfileOptions{ + Expand: expandParam, + } + } + respr, errRespr := s.srv.GetByBillingProfile(req.Context(), billingAccountNameParam, billingProfileNameParam, billingSubscriptionNameParam, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -162,11 +377,107 @@ func (s *SubscriptionsServerTransport) dispatchNewListByBillingAccountPager(req if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } + qp := req.URL.Query() billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) if err != nil { return nil, err } - resp := s.srv.NewListByBillingAccountPager(billingAccountNameParam, nil) + includeDeletedUnescaped, err := url.QueryUnescape(qp.Get("includeDeleted")) + if err != nil { + return nil, err + } + includeDeletedParam, err := parseOptional(includeDeletedUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + includeTenantSubscriptionsUnescaped, err := url.QueryUnescape(qp.Get("includeTenantSubscriptions")) + if err != nil { + return nil, err + } + includeTenantSubscriptionsParam, err := parseOptional(includeTenantSubscriptionsUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + includeFailedUnescaped, err := url.QueryUnescape(qp.Get("includeFailed")) + if err != nil { + return nil, err + } + includeFailedParam, err := parseOptional(includeFailedUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.SubscriptionsClientListByBillingAccountOptions + if includeDeletedParam != nil || includeTenantSubscriptionsParam != nil || includeFailedParam != nil || expandParam != nil || filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.SubscriptionsClientListByBillingAccountOptions{ + IncludeDeleted: includeDeletedParam, + IncludeTenantSubscriptions: includeTenantSubscriptionsParam, + IncludeFailed: includeFailedParam, + Expand: expandParam, + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := s.srv.NewListByBillingAccountPager(billingAccountNameParam, options) newListByBillingAccountPager = &resp s.newListByBillingAccountPager.add(req, newListByBillingAccountPager) server.PagerResponderInjectNextLinks(newListByBillingAccountPager, req, func(page *armbilling.SubscriptionsClientListByBillingAccountResponse, createLink func() string) { @@ -199,6 +510,7 @@ func (s *SubscriptionsServerTransport) dispatchNewListByBillingProfilePager(req if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } + qp := req.URL.Query() billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) if err != nil { return nil, err @@ -207,7 +519,84 @@ func (s *SubscriptionsServerTransport) dispatchNewListByBillingProfilePager(req if err != nil { return nil, err } - resp := s.srv.NewListByBillingProfilePager(billingAccountNameParam, billingProfileNameParam, nil) + includeDeletedUnescaped, err := url.QueryUnescape(qp.Get("includeDeleted")) + if err != nil { + return nil, err + } + includeDeletedParam, err := parseOptional(includeDeletedUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.SubscriptionsClientListByBillingProfileOptions + if includeDeletedParam != nil || expandParam != nil || filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.SubscriptionsClientListByBillingProfileOptions{ + IncludeDeleted: includeDeletedParam, + Expand: expandParam, + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := s.srv.NewListByBillingProfilePager(billingAccountNameParam, billingProfileNameParam, options) newListByBillingProfilePager = &resp s.newListByBillingProfilePager.add(req, newListByBillingProfilePager) server.PagerResponderInjectNextLinks(newListByBillingProfilePager, req, func(page *armbilling.SubscriptionsClientListByBillingProfileResponse, createLink func() string) { @@ -234,67 +623,450 @@ func (s *SubscriptionsServerTransport) dispatchNewListByCustomerPager(req *http. } newListByCustomerPager := s.newListByCustomerPager.get(req) if newListByCustomerPager == nil { - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingSubscriptions` + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingSubscriptions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } + qp := req.URL.Query() billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) if err != nil { return nil, err } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) if err != nil { return nil, err } - resp := s.srv.NewListByCustomerPager(billingAccountNameParam, customerNameParam, nil) - newListByCustomerPager = &resp - s.newListByCustomerPager.add(req, newListByCustomerPager) - server.PagerResponderInjectNextLinks(newListByCustomerPager, req, func(page *armbilling.SubscriptionsClientListByCustomerResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListByCustomerPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - s.newListByCustomerPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListByCustomerPager) { - s.newListByCustomerPager.remove(req) - } - return resp, nil -} - -func (s *SubscriptionsServerTransport) dispatchNewListByInvoiceSectionPager(req *http.Request) (*http.Response, error) { - if s.srv.NewListByInvoiceSectionPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListByInvoiceSectionPager not implemented")} - } - newListByInvoiceSectionPager := s.newListByInvoiceSectionPager.get(req) - if newListByInvoiceSectionPager == nil { - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoiceSections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingSubscriptions` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + includeDeletedUnescaped, err := url.QueryUnescape(qp.Get("includeDeleted")) + if err != nil { + return nil, err } - billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + includeDeletedParam, err := parseOptional(includeDeletedUnescaped, strconv.ParseBool) if err != nil { return nil, err } - billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + expandUnescaped, err := url.QueryUnescape(qp.Get("expand")) if err != nil { return nil, err } - invoiceSectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceSectionName")]) + expandParam := getOptional(expandUnescaped) + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) if err != nil { return nil, err } - resp := s.srv.NewListByInvoiceSectionPager(billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, nil) - newListByInvoiceSectionPager = &resp + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.SubscriptionsClientListByCustomerOptions + if includeDeletedParam != nil || expandParam != nil || filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.SubscriptionsClientListByCustomerOptions{ + IncludeDeleted: includeDeletedParam, + Expand: expandParam, + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := s.srv.NewListByCustomerPager(billingAccountNameParam, billingProfileNameParam, customerNameParam, options) + newListByCustomerPager = &resp + s.newListByCustomerPager.add(req, newListByCustomerPager) + server.PagerResponderInjectNextLinks(newListByCustomerPager, req, func(page *armbilling.SubscriptionsClientListByCustomerResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByCustomerPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListByCustomerPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByCustomerPager) { + s.newListByCustomerPager.remove(req) + } + return resp, nil +} + +func (s *SubscriptionsServerTransport) dispatchNewListByCustomerAtBillingAccountPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListByCustomerAtBillingAccountPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByCustomerAtBillingAccountPager not implemented")} + } + newListByCustomerAtBillingAccountPager := s.newListByCustomerAtBillingAccountPager.get(req) + if newListByCustomerAtBillingAccountPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingSubscriptions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) + if err != nil { + return nil, err + } + includeDeletedUnescaped, err := url.QueryUnescape(qp.Get("includeDeleted")) + if err != nil { + return nil, err + } + includeDeletedParam, err := parseOptional(includeDeletedUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.SubscriptionsClientListByCustomerAtBillingAccountOptions + if includeDeletedParam != nil || expandParam != nil || filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.SubscriptionsClientListByCustomerAtBillingAccountOptions{ + IncludeDeleted: includeDeletedParam, + Expand: expandParam, + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := s.srv.NewListByCustomerAtBillingAccountPager(billingAccountNameParam, customerNameParam, options) + newListByCustomerAtBillingAccountPager = &resp + s.newListByCustomerAtBillingAccountPager.add(req, newListByCustomerAtBillingAccountPager) + server.PagerResponderInjectNextLinks(newListByCustomerAtBillingAccountPager, req, func(page *armbilling.SubscriptionsClientListByCustomerAtBillingAccountResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByCustomerAtBillingAccountPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListByCustomerAtBillingAccountPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByCustomerAtBillingAccountPager) { + s.newListByCustomerAtBillingAccountPager.remove(req) + } + return resp, nil +} + +func (s *SubscriptionsServerTransport) dispatchNewListByEnrollmentAccountPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListByEnrollmentAccountPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByEnrollmentAccountPager not implemented")} + } + newListByEnrollmentAccountPager := s.newListByEnrollmentAccountPager.get(req) + if newListByEnrollmentAccountPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enrollmentAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingSubscriptions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + enrollmentAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enrollmentAccountName")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.SubscriptionsClientListByEnrollmentAccountOptions + if filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.SubscriptionsClientListByEnrollmentAccountOptions{ + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := s.srv.NewListByEnrollmentAccountPager(billingAccountNameParam, enrollmentAccountNameParam, options) + newListByEnrollmentAccountPager = &resp + s.newListByEnrollmentAccountPager.add(req, newListByEnrollmentAccountPager) + server.PagerResponderInjectNextLinks(newListByEnrollmentAccountPager, req, func(page *armbilling.SubscriptionsClientListByEnrollmentAccountResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByEnrollmentAccountPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListByEnrollmentAccountPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByEnrollmentAccountPager) { + s.newListByEnrollmentAccountPager.remove(req) + } + return resp, nil +} + +func (s *SubscriptionsServerTransport) dispatchNewListByInvoiceSectionPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListByInvoiceSectionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByInvoiceSectionPager not implemented")} + } + newListByInvoiceSectionPager := s.newListByInvoiceSectionPager.get(req) + if newListByInvoiceSectionPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoiceSections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingSubscriptions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + invoiceSectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceSectionName")]) + if err != nil { + return nil, err + } + includeDeletedUnescaped, err := url.QueryUnescape(qp.Get("includeDeleted")) + if err != nil { + return nil, err + } + includeDeletedParam, err := parseOptional(includeDeletedUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.SubscriptionsClientListByInvoiceSectionOptions + if includeDeletedParam != nil || expandParam != nil || filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.SubscriptionsClientListByInvoiceSectionOptions{ + IncludeDeleted: includeDeletedParam, + Expand: expandParam, + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := s.srv.NewListByInvoiceSectionPager(billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, options) + newListByInvoiceSectionPager = &resp s.newListByInvoiceSectionPager.add(req, newListByInvoiceSectionPager) server.PagerResponderInjectNextLinks(newListByInvoiceSectionPager, req, func(page *armbilling.SubscriptionsClientListByInvoiceSectionResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) @@ -314,19 +1086,67 @@ func (s *SubscriptionsServerTransport) dispatchNewListByInvoiceSectionPager(req return resp, nil } +func (s *SubscriptionsServerTransport) dispatchBeginMerge(req *http.Request) (*http.Response, error) { + if s.srv.BeginMerge == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginMerge not implemented")} + } + beginMerge := s.beginMerge.get(req) + if beginMerge == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingSubscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/merge` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.SubscriptionMergeRequest](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingSubscriptionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingSubscriptionName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginMerge(req.Context(), billingAccountNameParam, billingSubscriptionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginMerge = &respr + s.beginMerge.add(req, beginMerge) + } + + resp, err := server.PollerResponderNext(beginMerge, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + s.beginMerge.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginMerge) { + s.beginMerge.remove(req) + } + + return resp, nil +} + func (s *SubscriptionsServerTransport) dispatchBeginMove(req *http.Request) (*http.Response, error) { if s.srv.BeginMove == nil { return nil, &nonRetriableError{errors.New("fake for method BeginMove not implemented")} } beginMove := s.beginMove.get(req) if beginMove == nil { - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingSubscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/move` + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingSubscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/move` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armbilling.TransferBillingSubscriptionRequestProperties](req) + body, err := server.UnmarshalRequestAsJSON[armbilling.MoveBillingSubscriptionRequest](req) if err != nil { return nil, err } @@ -334,7 +1154,11 @@ func (s *SubscriptionsServerTransport) dispatchBeginMove(req *http.Request) (*ht if err != nil { return nil, err } - respr, errRespr := s.srv.BeginMove(req.Context(), billingAccountNameParam, body, nil) + billingSubscriptionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingSubscriptionName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginMove(req.Context(), billingAccountNameParam, billingSubscriptionNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -358,50 +1182,113 @@ func (s *SubscriptionsServerTransport) dispatchBeginMove(req *http.Request) (*ht return resp, nil } -func (s *SubscriptionsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { - if s.srv.Update == nil { - return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} +func (s *SubscriptionsServerTransport) dispatchBeginSplit(req *http.Request) (*http.Response, error) { + if s.srv.BeginSplit == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginSplit not implemented")} } - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingSubscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + beginSplit := s.beginSplit.get(req) + if beginSplit == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingSubscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/split` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.SubscriptionSplitRequest](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingSubscriptionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingSubscriptionName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginSplit(req.Context(), billingAccountNameParam, billingSubscriptionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginSplit = &respr + s.beginSplit.add(req, beginSplit) } - body, err := server.UnmarshalRequestAsJSON[armbilling.Subscription](req) + + resp, err := server.PollerResponderNext(beginSplit, req) if err != nil { return nil, err } - billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) - if err != nil { - return nil, err + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + s.beginSplit.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } - respr, errRespr := s.srv.Update(req.Context(), billingAccountNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr + if !server.PollerResponderMore(beginSplit) { + s.beginSplit.remove(req) } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + + return resp, nil +} + +func (s *SubscriptionsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if s.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Subscription, req) + beginUpdate := s.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingSubscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.SubscriptionPatch](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingSubscriptionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingSubscriptionName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginUpdate(req.Context(), billingAccountNameParam, billingSubscriptionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + s.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) if err != nil { return nil, err } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + s.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + s.beginUpdate.remove(req) + } + return resp, nil } -func (s *SubscriptionsServerTransport) dispatchValidateMove(req *http.Request) (*http.Response, error) { - if s.srv.ValidateMove == nil { - return nil, &nonRetriableError{errors.New("fake for method ValidateMove not implemented")} +func (s *SubscriptionsServerTransport) dispatchValidateMoveEligibility(req *http.Request) (*http.Response, error) { + if s.srv.ValidateMoveEligibility == nil { + return nil, &nonRetriableError{errors.New("fake for method ValidateMoveEligibility not implemented")} } - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingSubscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validateMoveEligibility` + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingSubscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validateMoveEligibility` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armbilling.TransferBillingSubscriptionRequestProperties](req) + body, err := server.UnmarshalRequestAsJSON[armbilling.MoveBillingSubscriptionRequest](req) if err != nil { return nil, err } @@ -409,7 +1296,11 @@ func (s *SubscriptionsServerTransport) dispatchValidateMove(req *http.Request) ( if err != nil { return nil, err } - respr, errRespr := s.srv.ValidateMove(req.Context(), billingAccountNameParam, body, nil) + billingSubscriptionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingSubscriptionName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.ValidateMoveEligibility(req.Context(), billingAccountNameParam, billingSubscriptionNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -417,7 +1308,7 @@ func (s *SubscriptionsServerTransport) dispatchValidateMove(req *http.Request) ( if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ValidateSubscriptionTransferEligibilityResult, req) + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).MoveBillingSubscriptionEligibilityResult, req) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/billing/armbilling/fake/subscriptionsaliases_server.go b/sdk/resourcemanager/billing/armbilling/fake/subscriptionsaliases_server.go new file mode 100644 index 000000000000..55a2852f6a39 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/fake/subscriptionsaliases_server.go @@ -0,0 +1,278 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "regexp" + "strconv" + + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// SubscriptionsAliasesServer is a fake server for instances of the armbilling.SubscriptionsAliasesClient type. +type SubscriptionsAliasesServer struct { + // BeginCreateOrUpdate is the fake for method SubscriptionsAliasesClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted + BeginCreateOrUpdate func(ctx context.Context, billingAccountName string, aliasName string, parameters armbilling.SubscriptionAlias, options *armbilling.SubscriptionsAliasesClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armbilling.SubscriptionsAliasesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method SubscriptionsAliasesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, billingAccountName string, aliasName string, options *armbilling.SubscriptionsAliasesClientGetOptions) (resp azfake.Responder[armbilling.SubscriptionsAliasesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByBillingAccountPager is the fake for method SubscriptionsAliasesClient.NewListByBillingAccountPager + // HTTP status codes to indicate success: http.StatusOK + NewListByBillingAccountPager func(billingAccountName string, options *armbilling.SubscriptionsAliasesClientListByBillingAccountOptions) (resp azfake.PagerResponder[armbilling.SubscriptionsAliasesClientListByBillingAccountResponse]) +} + +// NewSubscriptionsAliasesServerTransport creates a new instance of SubscriptionsAliasesServerTransport with the provided implementation. +// The returned SubscriptionsAliasesServerTransport instance is connected to an instance of armbilling.SubscriptionsAliasesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewSubscriptionsAliasesServerTransport(srv *SubscriptionsAliasesServer) *SubscriptionsAliasesServerTransport { + return &SubscriptionsAliasesServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armbilling.SubscriptionsAliasesClientCreateOrUpdateResponse]](), + newListByBillingAccountPager: newTracker[azfake.PagerResponder[armbilling.SubscriptionsAliasesClientListByBillingAccountResponse]](), + } +} + +// SubscriptionsAliasesServerTransport connects instances of armbilling.SubscriptionsAliasesClient to instances of SubscriptionsAliasesServer. +// Don't use this type directly, use NewSubscriptionsAliasesServerTransport instead. +type SubscriptionsAliasesServerTransport struct { + srv *SubscriptionsAliasesServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armbilling.SubscriptionsAliasesClientCreateOrUpdateResponse]] + newListByBillingAccountPager *tracker[azfake.PagerResponder[armbilling.SubscriptionsAliasesClientListByBillingAccountResponse]] +} + +// Do implements the policy.Transporter interface for SubscriptionsAliasesServerTransport. +func (s *SubscriptionsAliasesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "SubscriptionsAliasesClient.BeginCreateOrUpdate": + resp, err = s.dispatchBeginCreateOrUpdate(req) + case "SubscriptionsAliasesClient.Get": + resp, err = s.dispatchGet(req) + case "SubscriptionsAliasesClient.NewListByBillingAccountPager": + resp, err = s.dispatchNewListByBillingAccountPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SubscriptionsAliasesServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if s.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := s.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingSubscriptionAliases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.SubscriptionAlias](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + aliasNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("aliasName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginCreateOrUpdate(req.Context(), billingAccountNameParam, aliasNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + s.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + s.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + s.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (s *SubscriptionsAliasesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingSubscriptionAliases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + aliasNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("aliasName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), billingAccountNameParam, aliasNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SubscriptionAlias, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SubscriptionsAliasesServerTransport) dispatchNewListByBillingAccountPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListByBillingAccountPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByBillingAccountPager not implemented")} + } + newListByBillingAccountPager := s.newListByBillingAccountPager.get(req) + if newListByBillingAccountPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingSubscriptionAliases` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + includeDeletedUnescaped, err := url.QueryUnescape(qp.Get("includeDeleted")) + if err != nil { + return nil, err + } + includeDeletedParam, err := parseOptional(includeDeletedUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.SubscriptionsAliasesClientListByBillingAccountOptions + if includeDeletedParam != nil || filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.SubscriptionsAliasesClientListByBillingAccountOptions{ + IncludeDeleted: includeDeletedParam, + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := s.srv.NewListByBillingAccountPager(billingAccountNameParam, options) + newListByBillingAccountPager = &resp + s.newListByBillingAccountPager.add(req, newListByBillingAccountPager) + server.PagerResponderInjectNextLinks(newListByBillingAccountPager, req, func(page *armbilling.SubscriptionsAliasesClientListByBillingAccountResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByBillingAccountPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListByBillingAccountPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByBillingAccountPager) { + s.newListByBillingAccountPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/fake/time_rfc3339.go b/sdk/resourcemanager/billing/armbilling/fake/time_rfc3339.go index b0535a7b63e6..ade6004b9922 100644 --- a/sdk/resourcemanager/billing/armbilling/fake/time_rfc3339.go +++ b/sdk/resourcemanager/billing/armbilling/fake/time_rfc3339.go @@ -11,20 +11,25 @@ package fake import ( "encoding/json" "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" "reflect" "regexp" "strings" "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +45,33 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +82,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +99,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/billing/armbilling/fake/transactions_server.go b/sdk/resourcemanager/billing/armbilling/fake/transactions_server.go index f5833b1c0f7c..370191bb27e1 100644 --- a/sdk/resourcemanager/billing/armbilling/fake/transactions_server.go +++ b/sdk/resourcemanager/billing/armbilling/fake/transactions_server.go @@ -9,23 +9,47 @@ package fake import ( + "context" "errors" "fmt" + "net/http" + "net/url" + "regexp" + "strconv" + "time" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" - "net/http" - "net/url" - "regexp" ) // TransactionsServer is a fake server for instances of the armbilling.TransactionsClient type. type TransactionsServer struct { + // GetTransactionSummaryByInvoice is the fake for method TransactionsClient.GetTransactionSummaryByInvoice + // HTTP status codes to indicate success: http.StatusOK + GetTransactionSummaryByInvoice func(ctx context.Context, billingAccountName string, invoiceName string, options *armbilling.TransactionsClientGetTransactionSummaryByInvoiceOptions) (resp azfake.Responder[armbilling.TransactionsClientGetTransactionSummaryByInvoiceResponse], errResp azfake.ErrorResponder) + + // NewListByBillingProfilePager is the fake for method TransactionsClient.NewListByBillingProfilePager + // HTTP status codes to indicate success: http.StatusOK + NewListByBillingProfilePager func(billingAccountName string, billingProfileName string, periodStartDate time.Time, periodEndDate time.Time, typeParam armbilling.TransactionType, options *armbilling.TransactionsClientListByBillingProfileOptions) (resp azfake.PagerResponder[armbilling.TransactionsClientListByBillingProfileResponse]) + + // NewListByCustomerPager is the fake for method TransactionsClient.NewListByCustomerPager + // HTTP status codes to indicate success: http.StatusOK + NewListByCustomerPager func(billingAccountName string, billingProfileName string, customerName string, periodStartDate time.Time, periodEndDate time.Time, typeParam armbilling.TransactionType, options *armbilling.TransactionsClientListByCustomerOptions) (resp azfake.PagerResponder[armbilling.TransactionsClientListByCustomerResponse]) + // NewListByInvoicePager is the fake for method TransactionsClient.NewListByInvoicePager // HTTP status codes to indicate success: http.StatusOK NewListByInvoicePager func(billingAccountName string, invoiceName string, options *armbilling.TransactionsClientListByInvoiceOptions) (resp azfake.PagerResponder[armbilling.TransactionsClientListByInvoiceResponse]) + + // NewListByInvoiceSectionPager is the fake for method TransactionsClient.NewListByInvoiceSectionPager + // HTTP status codes to indicate success: http.StatusOK + NewListByInvoiceSectionPager func(billingAccountName string, billingProfileName string, invoiceSectionName string, periodStartDate time.Time, periodEndDate time.Time, typeParam armbilling.TransactionType, options *armbilling.TransactionsClientListByInvoiceSectionOptions) (resp azfake.PagerResponder[armbilling.TransactionsClientListByInvoiceSectionResponse]) + + // BeginTransactionsDownloadByInvoice is the fake for method TransactionsClient.BeginTransactionsDownloadByInvoice + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginTransactionsDownloadByInvoice func(ctx context.Context, billingAccountName string, invoiceName string, options *armbilling.TransactionsClientBeginTransactionsDownloadByInvoiceOptions) (resp azfake.PollerResponder[armbilling.TransactionsClientTransactionsDownloadByInvoiceResponse], errResp azfake.ErrorResponder) } // NewTransactionsServerTransport creates a new instance of TransactionsServerTransport with the provided implementation. @@ -33,16 +57,24 @@ type TransactionsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewTransactionsServerTransport(srv *TransactionsServer) *TransactionsServerTransport { return &TransactionsServerTransport{ - srv: srv, - newListByInvoicePager: newTracker[azfake.PagerResponder[armbilling.TransactionsClientListByInvoiceResponse]](), + srv: srv, + newListByBillingProfilePager: newTracker[azfake.PagerResponder[armbilling.TransactionsClientListByBillingProfileResponse]](), + newListByCustomerPager: newTracker[azfake.PagerResponder[armbilling.TransactionsClientListByCustomerResponse]](), + newListByInvoicePager: newTracker[azfake.PagerResponder[armbilling.TransactionsClientListByInvoiceResponse]](), + newListByInvoiceSectionPager: newTracker[azfake.PagerResponder[armbilling.TransactionsClientListByInvoiceSectionResponse]](), + beginTransactionsDownloadByInvoice: newTracker[azfake.PollerResponder[armbilling.TransactionsClientTransactionsDownloadByInvoiceResponse]](), } } // TransactionsServerTransport connects instances of armbilling.TransactionsClient to instances of TransactionsServer. // Don't use this type directly, use NewTransactionsServerTransport instead. type TransactionsServerTransport struct { - srv *TransactionsServer - newListByInvoicePager *tracker[azfake.PagerResponder[armbilling.TransactionsClientListByInvoiceResponse]] + srv *TransactionsServer + newListByBillingProfilePager *tracker[azfake.PagerResponder[armbilling.TransactionsClientListByBillingProfileResponse]] + newListByCustomerPager *tracker[azfake.PagerResponder[armbilling.TransactionsClientListByCustomerResponse]] + newListByInvoicePager *tracker[azfake.PagerResponder[armbilling.TransactionsClientListByInvoiceResponse]] + newListByInvoiceSectionPager *tracker[azfake.PagerResponder[armbilling.TransactionsClientListByInvoiceSectionResponse]] + beginTransactionsDownloadByInvoice *tracker[azfake.PollerResponder[armbilling.TransactionsClientTransactionsDownloadByInvoiceResponse]] } // Do implements the policy.Transporter interface for TransactionsServerTransport. @@ -57,8 +89,18 @@ func (t *TransactionsServerTransport) Do(req *http.Request) (*http.Response, err var err error switch method { + case "TransactionsClient.GetTransactionSummaryByInvoice": + resp, err = t.dispatchGetTransactionSummaryByInvoice(req) + case "TransactionsClient.NewListByBillingProfilePager": + resp, err = t.dispatchNewListByBillingProfilePager(req) + case "TransactionsClient.NewListByCustomerPager": + resp, err = t.dispatchNewListByCustomerPager(req) case "TransactionsClient.NewListByInvoicePager": resp, err = t.dispatchNewListByInvoicePager(req) + case "TransactionsClient.NewListByInvoiceSectionPager": + resp, err = t.dispatchNewListByInvoiceSectionPager(req) + case "TransactionsClient.BeginTransactionsDownloadByInvoice": + resp, err = t.dispatchBeginTransactionsDownloadByInvoice(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -70,6 +112,321 @@ func (t *TransactionsServerTransport) Do(req *http.Request) (*http.Response, err return resp, nil } +func (t *TransactionsServerTransport) dispatchGetTransactionSummaryByInvoice(req *http.Request) (*http.Response, error) { + if t.srv.GetTransactionSummaryByInvoice == nil { + return nil, &nonRetriableError{errors.New("fake for method GetTransactionSummaryByInvoice not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/transactionSummary` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + invoiceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceName")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.TransactionsClientGetTransactionSummaryByInvoiceOptions + if filterParam != nil || searchParam != nil { + options = &armbilling.TransactionsClientGetTransactionSummaryByInvoiceOptions{ + Filter: filterParam, + Search: searchParam, + } + } + respr, errRespr := t.srv.GetTransactionSummaryByInvoice(req.Context(), billingAccountNameParam, invoiceNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TransactionSummary, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TransactionsServerTransport) dispatchNewListByBillingProfilePager(req *http.Request) (*http.Response, error) { + if t.srv.NewListByBillingProfilePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByBillingProfilePager not implemented")} + } + newListByBillingProfilePager := t.newListByBillingProfilePager.get(req) + if newListByBillingProfilePager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/transactions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + periodStartDateUnescaped, err := url.QueryUnescape(qp.Get("periodStartDate")) + if err != nil { + return nil, err + } + periodStartDateParam, err := time.Parse("2006-01-02", periodStartDateUnescaped) + if err != nil { + return nil, err + } + periodEndDateUnescaped, err := url.QueryUnescape(qp.Get("periodEndDate")) + if err != nil { + return nil, err + } + periodEndDateParam, err := time.Parse("2006-01-02", periodEndDateUnescaped) + if err != nil { + return nil, err + } + typeParamParam, err := parseWithCast(qp.Get("type"), func(v string) (armbilling.TransactionType, error) { + p, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armbilling.TransactionType(p), nil + }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.TransactionsClientListByBillingProfileOptions + if filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.TransactionsClientListByBillingProfileOptions{ + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := t.srv.NewListByBillingProfilePager(billingAccountNameParam, billingProfileNameParam, periodStartDateParam, periodEndDateParam, typeParamParam, options) + newListByBillingProfilePager = &resp + t.newListByBillingProfilePager.add(req, newListByBillingProfilePager) + server.PagerResponderInjectNextLinks(newListByBillingProfilePager, req, func(page *armbilling.TransactionsClientListByBillingProfileResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByBillingProfilePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + t.newListByBillingProfilePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByBillingProfilePager) { + t.newListByBillingProfilePager.remove(req) + } + return resp, nil +} + +func (t *TransactionsServerTransport) dispatchNewListByCustomerPager(req *http.Request) (*http.Response, error) { + if t.srv.NewListByCustomerPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByCustomerPager not implemented")} + } + newListByCustomerPager := t.newListByCustomerPager.get(req) + if newListByCustomerPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/customers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/transactions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + customerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("customerName")]) + if err != nil { + return nil, err + } + periodStartDateUnescaped, err := url.QueryUnescape(qp.Get("periodStartDate")) + if err != nil { + return nil, err + } + periodStartDateParam, err := time.Parse("2006-01-02", periodStartDateUnescaped) + if err != nil { + return nil, err + } + periodEndDateUnescaped, err := url.QueryUnescape(qp.Get("periodEndDate")) + if err != nil { + return nil, err + } + periodEndDateParam, err := time.Parse("2006-01-02", periodEndDateUnescaped) + if err != nil { + return nil, err + } + typeParamParam, err := parseWithCast(qp.Get("type"), func(v string) (armbilling.TransactionType, error) { + p, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armbilling.TransactionType(p), nil + }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.TransactionsClientListByCustomerOptions + if filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.TransactionsClientListByCustomerOptions{ + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := t.srv.NewListByCustomerPager(billingAccountNameParam, billingProfileNameParam, customerNameParam, periodStartDateParam, periodEndDateParam, typeParamParam, options) + newListByCustomerPager = &resp + t.newListByCustomerPager.add(req, newListByCustomerPager) + server.PagerResponderInjectNextLinks(newListByCustomerPager, req, func(page *armbilling.TransactionsClientListByCustomerResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByCustomerPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + t.newListByCustomerPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByCustomerPager) { + t.newListByCustomerPager.remove(req) + } + return resp, nil +} + func (t *TransactionsServerTransport) dispatchNewListByInvoicePager(req *http.Request) (*http.Response, error) { if t.srv.NewListByInvoicePager == nil { return nil, &nonRetriableError{errors.New("fake for method NewListByInvoicePager not implemented")} @@ -82,6 +439,7 @@ func (t *TransactionsServerTransport) dispatchNewListByInvoicePager(req *http.Re if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } + qp := req.URL.Query() billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) if err != nil { return nil, err @@ -90,7 +448,69 @@ func (t *TransactionsServerTransport) dispatchNewListByInvoicePager(req *http.Re if err != nil { return nil, err } - resp := t.srv.NewListByInvoicePager(billingAccountNameParam, invoiceNameParam, nil) + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.TransactionsClientListByInvoiceOptions + if filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.TransactionsClientListByInvoiceOptions{ + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := t.srv.NewListByInvoicePager(billingAccountNameParam, invoiceNameParam, options) newListByInvoicePager = &resp t.newListByInvoicePager.add(req, newListByInvoicePager) server.PagerResponderInjectNextLinks(newListByInvoicePager, req, func(page *armbilling.TransactionsClientListByInvoiceResponse, createLink func() string) { @@ -110,3 +530,181 @@ func (t *TransactionsServerTransport) dispatchNewListByInvoicePager(req *http.Re } return resp, nil } + +func (t *TransactionsServerTransport) dispatchNewListByInvoiceSectionPager(req *http.Request) (*http.Response, error) { + if t.srv.NewListByInvoiceSectionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByInvoiceSectionPager not implemented")} + } + newListByInvoiceSectionPager := t.newListByInvoiceSectionPager.get(req) + if newListByInvoiceSectionPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoiceSections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/transactions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + invoiceSectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceSectionName")]) + if err != nil { + return nil, err + } + periodStartDateUnescaped, err := url.QueryUnescape(qp.Get("periodStartDate")) + if err != nil { + return nil, err + } + periodStartDateParam, err := time.Parse("2006-01-02", periodStartDateUnescaped) + if err != nil { + return nil, err + } + periodEndDateUnescaped, err := url.QueryUnescape(qp.Get("periodEndDate")) + if err != nil { + return nil, err + } + periodEndDateParam, err := time.Parse("2006-01-02", periodEndDateUnescaped) + if err != nil { + return nil, err + } + typeParamParam, err := parseWithCast(qp.Get("type"), func(v string) (armbilling.TransactionType, error) { + p, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armbilling.TransactionType(p), nil + }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderByUnescaped, err := url.QueryUnescape(qp.Get("orderBy")) + if err != nil { + return nil, err + } + orderByParam := getOptional(orderByUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + countUnescaped, err := url.QueryUnescape(qp.Get("count")) + if err != nil { + return nil, err + } + countParam, err := parseOptional(countUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + searchUnescaped, err := url.QueryUnescape(qp.Get("search")) + if err != nil { + return nil, err + } + searchParam := getOptional(searchUnescaped) + var options *armbilling.TransactionsClientListByInvoiceSectionOptions + if filterParam != nil || orderByParam != nil || topParam != nil || skipParam != nil || countParam != nil || searchParam != nil { + options = &armbilling.TransactionsClientListByInvoiceSectionOptions{ + Filter: filterParam, + OrderBy: orderByParam, + Top: topParam, + Skip: skipParam, + Count: countParam, + Search: searchParam, + } + } + resp := t.srv.NewListByInvoiceSectionPager(billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, periodStartDateParam, periodEndDateParam, typeParamParam, options) + newListByInvoiceSectionPager = &resp + t.newListByInvoiceSectionPager.add(req, newListByInvoiceSectionPager) + server.PagerResponderInjectNextLinks(newListByInvoiceSectionPager, req, func(page *armbilling.TransactionsClientListByInvoiceSectionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByInvoiceSectionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + t.newListByInvoiceSectionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByInvoiceSectionPager) { + t.newListByInvoiceSectionPager.remove(req) + } + return resp, nil +} + +func (t *TransactionsServerTransport) dispatchBeginTransactionsDownloadByInvoice(req *http.Request) (*http.Response, error) { + if t.srv.BeginTransactionsDownloadByInvoice == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginTransactionsDownloadByInvoice not implemented")} + } + beginTransactionsDownloadByInvoice := t.beginTransactionsDownloadByInvoice.get(req) + if beginTransactionsDownloadByInvoice == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/transactionsDownload` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + invoiceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginTransactionsDownloadByInvoice(req.Context(), billingAccountNameParam, invoiceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginTransactionsDownloadByInvoice = &respr + t.beginTransactionsDownloadByInvoice.add(req, beginTransactionsDownloadByInvoice) + } + + resp, err := server.PollerResponderNext(beginTransactionsDownloadByInvoice, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + t.beginTransactionsDownloadByInvoice.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginTransactionsDownloadByInvoice) { + t.beginTransactionsDownloadByInvoice.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/fake/transfers_server.go b/sdk/resourcemanager/billing/armbilling/fake/transfers_server.go new file mode 100644 index 000000000000..fd1ccaf0faf1 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/fake/transfers_server.go @@ -0,0 +1,263 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "regexp" + + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// TransfersServer is a fake server for instances of the armbilling.TransfersClient type. +type TransfersServer struct { + // Cancel is the fake for method TransfersClient.Cancel + // HTTP status codes to indicate success: http.StatusOK + Cancel func(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, transferName string, options *armbilling.TransfersClientCancelOptions) (resp azfake.Responder[armbilling.TransfersClientCancelResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method TransfersClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, transferName string, options *armbilling.TransfersClientGetOptions) (resp azfake.Responder[armbilling.TransfersClientGetResponse], errResp azfake.ErrorResponder) + + // Initiate is the fake for method TransfersClient.Initiate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + Initiate func(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, transferName string, parameters armbilling.InitiateTransferRequest, options *armbilling.TransfersClientInitiateOptions) (resp azfake.Responder[armbilling.TransfersClientInitiateResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method TransfersClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(billingAccountName string, billingProfileName string, invoiceSectionName string, options *armbilling.TransfersClientListOptions) (resp azfake.PagerResponder[armbilling.TransfersClientListResponse]) +} + +// NewTransfersServerTransport creates a new instance of TransfersServerTransport with the provided implementation. +// The returned TransfersServerTransport instance is connected to an instance of armbilling.TransfersClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewTransfersServerTransport(srv *TransfersServer) *TransfersServerTransport { + return &TransfersServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armbilling.TransfersClientListResponse]](), + } +} + +// TransfersServerTransport connects instances of armbilling.TransfersClient to instances of TransfersServer. +// Don't use this type directly, use NewTransfersServerTransport instead. +type TransfersServerTransport struct { + srv *TransfersServer + newListPager *tracker[azfake.PagerResponder[armbilling.TransfersClientListResponse]] +} + +// Do implements the policy.Transporter interface for TransfersServerTransport. +func (t *TransfersServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "TransfersClient.Cancel": + resp, err = t.dispatchCancel(req) + case "TransfersClient.Get": + resp, err = t.dispatchGet(req) + case "TransfersClient.Initiate": + resp, err = t.dispatchInitiate(req) + case "TransfersClient.NewListPager": + resp, err = t.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (t *TransfersServerTransport) dispatchCancel(req *http.Request) (*http.Response, error) { + if t.srv.Cancel == nil { + return nil, &nonRetriableError{errors.New("fake for method Cancel not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoiceSections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/transfers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/cancel` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + invoiceSectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceSectionName")]) + if err != nil { + return nil, err + } + transferNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("transferName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Cancel(req.Context(), billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, transferNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TransferDetails, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TransfersServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if t.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoiceSections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/transfers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + invoiceSectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceSectionName")]) + if err != nil { + return nil, err + } + transferNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("transferName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Get(req.Context(), billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, transferNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TransferDetails, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TransfersServerTransport) dispatchInitiate(req *http.Request) (*http.Response, error) { + if t.srv.Initiate == nil { + return nil, &nonRetriableError{errors.New("fake for method Initiate not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoiceSections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/transfers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbilling.InitiateTransferRequest](req) + if err != nil { + return nil, err + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + invoiceSectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceSectionName")]) + if err != nil { + return nil, err + } + transferNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("transferName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Initiate(req.Context(), billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, transferNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TransferDetails, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TransfersServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if t.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := t.newListPager.get(req) + if newListPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoiceSections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/transfers` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + invoiceSectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceSectionName")]) + if err != nil { + return nil, err + } + resp := t.srv.NewListPager(billingAccountNameParam, billingProfileNameParam, invoiceSectionNameParam, nil) + newListPager = &resp + t.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armbilling.TransfersClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + t.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + t.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/instructions_client.go b/sdk/resourcemanager/billing/armbilling/instructions_client.go deleted file mode 100644 index a5014b07376e..000000000000 --- a/sdk/resourcemanager/billing/armbilling/instructions_client.go +++ /dev/null @@ -1,236 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armbilling - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// InstructionsClient contains the methods for the Instructions group. -// Don't use this type directly, use NewInstructionsClient() instead. -type InstructionsClient struct { - internal *arm.Client -} - -// NewInstructionsClient creates a new instance of InstructionsClient with the specified values. -// - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. -func NewInstructionsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*InstructionsClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &InstructionsClient{ - internal: cl, - } - return client, nil -} - -// Get - Get the instruction by name. These are custom billing instructions and are only applicable for certain customers. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-05-01 -// - billingAccountName - The ID that uniquely identifies a billing account. -// - billingProfileName - The ID that uniquely identifies a billing profile. -// - instructionName - Instruction Name. -// - options - InstructionsClientGetOptions contains the optional parameters for the InstructionsClient.Get method. -func (client *InstructionsClient) Get(ctx context.Context, billingAccountName string, billingProfileName string, instructionName string, options *InstructionsClientGetOptions) (InstructionsClientGetResponse, error) { - var err error - const operationName = "InstructionsClient.Get" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, billingAccountName, billingProfileName, instructionName, options) - if err != nil { - return InstructionsClientGetResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return InstructionsClientGetResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return InstructionsClientGetResponse{}, err - } - resp, err := client.getHandleResponse(httpResp) - return resp, err -} - -// getCreateRequest creates the Get request. -func (client *InstructionsClient) getCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, instructionName string, options *InstructionsClientGetOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions/{instructionName}" - if billingAccountName == "" { - return nil, errors.New("parameter billingAccountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) - if billingProfileName == "" { - return nil, errors.New("parameter billingProfileName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) - if instructionName == "" { - return nil, errors.New("parameter instructionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{instructionName}", url.PathEscape(instructionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *InstructionsClient) getHandleResponse(resp *http.Response) (InstructionsClientGetResponse, error) { - result := InstructionsClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Instruction); err != nil { - return InstructionsClientGetResponse{}, err - } - return result, nil -} - -// NewListByBillingProfilePager - Lists the instructions by billing profile id. -// -// Generated from API version 2020-05-01 -// - billingAccountName - The ID that uniquely identifies a billing account. -// - billingProfileName - The ID that uniquely identifies a billing profile. -// - options - InstructionsClientListByBillingProfileOptions contains the optional parameters for the InstructionsClient.NewListByBillingProfilePager -// method. -func (client *InstructionsClient) NewListByBillingProfilePager(billingAccountName string, billingProfileName string, options *InstructionsClientListByBillingProfileOptions) *runtime.Pager[InstructionsClientListByBillingProfileResponse] { - return runtime.NewPager(runtime.PagingHandler[InstructionsClientListByBillingProfileResponse]{ - More: func(page InstructionsClientListByBillingProfileResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *InstructionsClientListByBillingProfileResponse) (InstructionsClientListByBillingProfileResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "InstructionsClient.NewListByBillingProfilePager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, options) - }, nil) - if err != nil { - return InstructionsClientListByBillingProfileResponse{}, err - } - return client.listByBillingProfileHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listByBillingProfileCreateRequest creates the ListByBillingProfile request. -func (client *InstructionsClient) listByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, options *InstructionsClientListByBillingProfileOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions" - if billingAccountName == "" { - return nil, errors.New("parameter billingAccountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) - if billingProfileName == "" { - return nil, errors.New("parameter billingProfileName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByBillingProfileHandleResponse handles the ListByBillingProfile response. -func (client *InstructionsClient) listByBillingProfileHandleResponse(resp *http.Response) (InstructionsClientListByBillingProfileResponse, error) { - result := InstructionsClientListByBillingProfileResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.InstructionListResult); err != nil { - return InstructionsClientListByBillingProfileResponse{}, err - } - return result, nil -} - -// Put - Creates or updates an instruction. These are custom billing instructions and are only applicable for certain customers. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-05-01 -// - billingAccountName - The ID that uniquely identifies a billing account. -// - billingProfileName - The ID that uniquely identifies a billing profile. -// - instructionName - Instruction Name. -// - parameters - The new instruction. -// - options - InstructionsClientPutOptions contains the optional parameters for the InstructionsClient.Put method. -func (client *InstructionsClient) Put(ctx context.Context, billingAccountName string, billingProfileName string, instructionName string, parameters Instruction, options *InstructionsClientPutOptions) (InstructionsClientPutResponse, error) { - var err error - const operationName = "InstructionsClient.Put" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.putCreateRequest(ctx, billingAccountName, billingProfileName, instructionName, parameters, options) - if err != nil { - return InstructionsClientPutResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return InstructionsClientPutResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return InstructionsClientPutResponse{}, err - } - resp, err := client.putHandleResponse(httpResp) - return resp, err -} - -// putCreateRequest creates the Put request. -func (client *InstructionsClient) putCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, instructionName string, parameters Instruction, options *InstructionsClientPutOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions/{instructionName}" - if billingAccountName == "" { - return nil, errors.New("parameter billingAccountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) - if billingProfileName == "" { - return nil, errors.New("parameter billingProfileName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) - if instructionName == "" { - return nil, errors.New("parameter instructionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{instructionName}", url.PathEscape(instructionName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, parameters); err != nil { - return nil, err - } - return req, nil -} - -// putHandleResponse handles the Put response. -func (client *InstructionsClient) putHandleResponse(resp *http.Response) (InstructionsClientPutResponse, error) { - result := InstructionsClientPutResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Instruction); err != nil { - return InstructionsClientPutResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/billing/armbilling/instructions_client_example_test.go b/sdk/resourcemanager/billing/armbilling/instructions_client_example_test.go deleted file mode 100644 index 3379974e9570..000000000000 --- a/sdk/resourcemanager/billing/armbilling/instructions_client_example_test.go +++ /dev/null @@ -1,135 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armbilling_test - -import ( - "context" - "log" - - "time" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/InstructionsListByBillingProfile.json -func ExampleInstructionsClient_NewListByBillingProfilePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbilling.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewInstructionsClient().NewListByBillingProfilePager("{billingAccountName}", "{billingProfileName}", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.InstructionListResult = armbilling.InstructionListResult{ - // Value: []*armbilling.Instruction{ - // { - // Name: to.Ptr("TO1:CLIN001"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/instructions"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions/TO1:CLIN001"), - // Properties: &armbilling.InstructionProperties{ - // Amount: to.Ptr[float32](5000), - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-30T21:26:47.997Z"); return t}()), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-30T21:26:47.997Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("TO1:CLIN002"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/instructions"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions/TO1:CLIN002"), - // Properties: &armbilling.InstructionProperties{ - // Amount: to.Ptr[float32](2000), - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-30T21:26:47.997Z"); return t}()), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-30T21:26:47.997Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/Instruction.json -func ExampleInstructionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbilling.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewInstructionsClient().Get(ctx, "{billingAccountName}", "{billingProfileName}", "{instructionName}", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Instruction = armbilling.Instruction{ - // Name: to.Ptr("{instructionName}"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/instructions"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions/{instructionName}"), - // Properties: &armbilling.InstructionProperties{ - // Amount: to.Ptr[float32](5000), - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-30T21:26:47.997Z"); return t}()), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-30T21:26:47.997Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/PutInstruction.json -func ExampleInstructionsClient_Put() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbilling.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewInstructionsClient().Put(ctx, "{billingAccountName}", "{billingProfileName}", "{instructionName}", armbilling.Instruction{ - Properties: &armbilling.InstructionProperties{ - Amount: to.Ptr[float32](5000), - EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-30T21:26:47.997Z"); return t }()), - StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-30T21:26:47.997Z"); return t }()), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Instruction = armbilling.Instruction{ - // Name: to.Ptr("{instructionName}"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/instructions"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions/{instructionName}"), - // Properties: &armbilling.InstructionProperties{ - // Amount: to.Ptr[float32](5000), - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-30T21:26:47.997Z"); return t}()), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-30T21:26:47.997Z"); return t}()), - // }, - // } -} diff --git a/sdk/resourcemanager/billing/armbilling/invoices_client.go b/sdk/resourcemanager/billing/armbilling/invoices_client.go index 48d68a2e89aa..9a6643062eb3 100644 --- a/sdk/resourcemanager/billing/armbilling/invoices_client.go +++ b/sdk/resourcemanager/billing/armbilling/invoices_client.go @@ -11,13 +11,15 @@ package armbilling import ( "context" "errors" + "net/http" + "net/url" + "strconv" + "strings" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" ) // InvoicesClient contains the methods for the Invoices group. @@ -28,7 +30,7 @@ type InvoicesClient struct { } // NewInvoicesClient creates a new instance of InvoicesClient with the specified values. -// - subscriptionID - The ID that uniquely identifies an Azure subscription. +// - subscriptionID - The ID that uniquely identifies a billing subscription. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewInvoicesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*InvoicesClient, error) { @@ -43,43 +45,44 @@ func NewInvoicesClient(subscriptionID string, credential azcore.TokenCredential, return client, nil } -// BeginDownloadBillingSubscriptionInvoice - Gets a URL to download an invoice. +// BeginAmend - Regenerate an invoice by billing account name and invoice name. The operation is supported for billing accounts +// with agreement type Microsoft Customer Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. // - invoiceName - The ID that uniquely identifies an invoice. -// - downloadToken - Download token with document source and document ID. -// - options - InvoicesClientBeginDownloadBillingSubscriptionInvoiceOptions contains the optional parameters for the InvoicesClient.BeginDownloadBillingSubscriptionInvoice -// method. -func (client *InvoicesClient) BeginDownloadBillingSubscriptionInvoice(ctx context.Context, invoiceName string, downloadToken string, options *InvoicesClientBeginDownloadBillingSubscriptionInvoiceOptions) (*runtime.Poller[InvoicesClientDownloadBillingSubscriptionInvoiceResponse], error) { +// - options - InvoicesClientBeginAmendOptions contains the optional parameters for the InvoicesClient.BeginAmend method. +func (client *InvoicesClient) BeginAmend(ctx context.Context, billingAccountName string, invoiceName string, options *InvoicesClientBeginAmendOptions) (*runtime.Poller[InvoicesClientAmendResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.downloadBillingSubscriptionInvoice(ctx, invoiceName, downloadToken, options) + resp, err := client.amend(ctx, billingAccountName, invoiceName, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[InvoicesClientDownloadBillingSubscriptionInvoiceResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[InvoicesClientAmendResponse]{ FinalStateVia: runtime.FinalStateViaLocation, Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[InvoicesClientDownloadBillingSubscriptionInvoiceResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[InvoicesClientAmendResponse]{ Tracer: client.internal.Tracer(), }) } } -// DownloadBillingSubscriptionInvoice - Gets a URL to download an invoice. +// Amend - Regenerate an invoice by billing account name and invoice name. The operation is supported for billing accounts +// with agreement type Microsoft Customer Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 -func (client *InvoicesClient) downloadBillingSubscriptionInvoice(ctx context.Context, invoiceName string, downloadToken string, options *InvoicesClientBeginDownloadBillingSubscriptionInvoiceOptions) (*http.Response, error) { +// Generated from API version 2024-04-01 +func (client *InvoicesClient) amend(ctx context.Context, billingAccountName string, invoiceName string, options *InvoicesClientBeginAmendOptions) (*http.Response, error) { var err error - const operationName = "InvoicesClient.BeginDownloadBillingSubscriptionInvoice" + const operationName = "InvoicesClient.BeginAmend" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.downloadBillingSubscriptionInvoiceCreateRequest(ctx, invoiceName, downloadToken, options) + req, err := client.amendCreateRequest(ctx, billingAccountName, invoiceName, options) if err != nil { return nil, err } @@ -87,20 +90,20 @@ func (client *InvoicesClient) downloadBillingSubscriptionInvoice(ctx context.Con if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) return nil, err } return httpResp, nil } -// downloadBillingSubscriptionInvoiceCreateRequest creates the DownloadBillingSubscriptionInvoice request. -func (client *InvoicesClient) downloadBillingSubscriptionInvoiceCreateRequest(ctx context.Context, invoiceName string, downloadToken string, options *InvoicesClientBeginDownloadBillingSubscriptionInvoiceOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}/download" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") +// amendCreateRequest creates the Amend request. +func (client *InvoicesClient) amendCreateRequest(ctx context.Context, billingAccountName string, invoiceName string, options *InvoicesClientBeginAmendOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/amend" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) if invoiceName == "" { return nil, errors.New("parameter invoiceName cannot be empty") } @@ -110,53 +113,51 @@ func (client *InvoicesClient) downloadBillingSubscriptionInvoiceCreateRequest(ct return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") - reqQP.Set("downloadToken", downloadToken) + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } -// BeginDownloadInvoice - Gets a URL to download an invoice. The operation is supported for billing accounts with agreement -// type Microsoft Partner Agreement or Microsoft Customer Agreement. +// BeginDownloadByBillingAccount - Gets a URL to download an invoice document. The operation is supported for billing accounts +// with agreement type Microsoft Partner Agreement, Microsoft Customer Agreement or Enterprise Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - invoiceName - The ID that uniquely identifies an invoice. -// - downloadToken - Download token with document source and document ID. -// - options - InvoicesClientBeginDownloadInvoiceOptions contains the optional parameters for the InvoicesClient.BeginDownloadInvoice +// - options - InvoicesClientBeginDownloadByBillingAccountOptions contains the optional parameters for the InvoicesClient.BeginDownloadByBillingAccount // method. -func (client *InvoicesClient) BeginDownloadInvoice(ctx context.Context, billingAccountName string, invoiceName string, downloadToken string, options *InvoicesClientBeginDownloadInvoiceOptions) (*runtime.Poller[InvoicesClientDownloadInvoiceResponse], error) { +func (client *InvoicesClient) BeginDownloadByBillingAccount(ctx context.Context, billingAccountName string, invoiceName string, options *InvoicesClientBeginDownloadByBillingAccountOptions) (*runtime.Poller[InvoicesClientDownloadByBillingAccountResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.downloadInvoice(ctx, billingAccountName, invoiceName, downloadToken, options) + resp, err := client.downloadByBillingAccount(ctx, billingAccountName, invoiceName, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[InvoicesClientDownloadInvoiceResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[InvoicesClientDownloadByBillingAccountResponse]{ FinalStateVia: runtime.FinalStateViaLocation, Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[InvoicesClientDownloadInvoiceResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[InvoicesClientDownloadByBillingAccountResponse]{ Tracer: client.internal.Tracer(), }) } } -// DownloadInvoice - Gets a URL to download an invoice. The operation is supported for billing accounts with agreement type -// Microsoft Partner Agreement or Microsoft Customer Agreement. +// DownloadByBillingAccount - Gets a URL to download an invoice document. The operation is supported for billing accounts +// with agreement type Microsoft Partner Agreement, Microsoft Customer Agreement or Enterprise Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 -func (client *InvoicesClient) downloadInvoice(ctx context.Context, billingAccountName string, invoiceName string, downloadToken string, options *InvoicesClientBeginDownloadInvoiceOptions) (*http.Response, error) { +// Generated from API version 2024-04-01 +func (client *InvoicesClient) downloadByBillingAccount(ctx context.Context, billingAccountName string, invoiceName string, options *InvoicesClientBeginDownloadByBillingAccountOptions) (*http.Response, error) { var err error - const operationName = "InvoicesClient.BeginDownloadInvoice" + const operationName = "InvoicesClient.BeginDownloadByBillingAccount" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.downloadInvoiceCreateRequest(ctx, billingAccountName, invoiceName, downloadToken, options) + req, err := client.downloadByBillingAccountCreateRequest(ctx, billingAccountName, invoiceName, options) if err != nil { return nil, err } @@ -171,8 +172,8 @@ func (client *InvoicesClient) downloadInvoice(ctx context.Context, billingAccoun return httpResp, nil } -// downloadInvoiceCreateRequest creates the DownloadInvoice request. -func (client *InvoicesClient) downloadInvoiceCreateRequest(ctx context.Context, billingAccountName string, invoiceName string, downloadToken string, options *InvoicesClientBeginDownloadInvoiceOptions) (*policy.Request, error) { +// downloadByBillingAccountCreateRequest creates the DownloadByBillingAccount request. +func (client *InvoicesClient) downloadByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, invoiceName string, options *InvoicesClientBeginDownloadByBillingAccountOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/download" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") @@ -187,54 +188,133 @@ func (client *InvoicesClient) downloadInvoiceCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") - reqQP.Set("downloadToken", downloadToken) + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.DocumentName != nil { + reqQP.Set("documentName", *options.DocumentName) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginDownloadByBillingSubscription - Gets a URL to download an invoice by billing subscription. The operation is supported +// for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - invoiceName - The ID that uniquely identifies an invoice. +// - options - InvoicesClientBeginDownloadByBillingSubscriptionOptions contains the optional parameters for the InvoicesClient.BeginDownloadByBillingSubscription +// method. +func (client *InvoicesClient) BeginDownloadByBillingSubscription(ctx context.Context, invoiceName string, options *InvoicesClientBeginDownloadByBillingSubscriptionOptions) (*runtime.Poller[InvoicesClientDownloadByBillingSubscriptionResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.downloadByBillingSubscription(ctx, invoiceName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[InvoicesClientDownloadByBillingSubscriptionResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[InvoicesClientDownloadByBillingSubscriptionResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// DownloadByBillingSubscription - Gets a URL to download an invoice by billing subscription. The operation is supported for +// billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *InvoicesClient) downloadByBillingSubscription(ctx context.Context, invoiceName string, options *InvoicesClientBeginDownloadByBillingSubscriptionOptions) (*http.Response, error) { + var err error + const operationName = "InvoicesClient.BeginDownloadByBillingSubscription" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.downloadByBillingSubscriptionCreateRequest(ctx, invoiceName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// downloadByBillingSubscriptionCreateRequest creates the DownloadByBillingSubscription request. +func (client *InvoicesClient) downloadByBillingSubscriptionCreateRequest(ctx context.Context, invoiceName string, options *InvoicesClientBeginDownloadByBillingSubscriptionOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}/download" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if invoiceName == "" { + return nil, errors.New("parameter invoiceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{invoiceName}", url.PathEscape(invoiceName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.DocumentName != nil { + reqQP.Set("documentName", *options.DocumentName) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } -// BeginDownloadMultipleBillingProfileInvoices - Gets a URL to download multiple invoice documents (invoice pdf, tax receipts, +// BeginDownloadDocumentsByBillingAccount - Gets a URL to download multiple invoice documents (invoice pdf, tax receipts, // credit notes) as a zip file. The operation is supported for billing accounts with agreement type Microsoft Partner // Agreement or Microsoft Customer Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. -// - downloadUrls - An array of download urls for individual documents -// - options - InvoicesClientBeginDownloadMultipleBillingProfileInvoicesOptions contains the optional parameters for the InvoicesClient.BeginDownloadMultipleBillingProfileInvoices +// - parameters - A list of download details for individual documents. +// - options - InvoicesClientBeginDownloadDocumentsByBillingAccountOptions contains the optional parameters for the InvoicesClient.BeginDownloadDocumentsByBillingAccount // method. -func (client *InvoicesClient) BeginDownloadMultipleBillingProfileInvoices(ctx context.Context, billingAccountName string, downloadUrls []*string, options *InvoicesClientBeginDownloadMultipleBillingProfileInvoicesOptions) (*runtime.Poller[InvoicesClientDownloadMultipleBillingProfileInvoicesResponse], error) { +func (client *InvoicesClient) BeginDownloadDocumentsByBillingAccount(ctx context.Context, billingAccountName string, parameters []*DocumentDownloadRequest, options *InvoicesClientBeginDownloadDocumentsByBillingAccountOptions) (*runtime.Poller[InvoicesClientDownloadDocumentsByBillingAccountResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.downloadMultipleBillingProfileInvoices(ctx, billingAccountName, downloadUrls, options) + resp, err := client.downloadDocumentsByBillingAccount(ctx, billingAccountName, parameters, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[InvoicesClientDownloadMultipleBillingProfileInvoicesResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[InvoicesClientDownloadDocumentsByBillingAccountResponse]{ FinalStateVia: runtime.FinalStateViaLocation, Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[InvoicesClientDownloadMultipleBillingProfileInvoicesResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[InvoicesClientDownloadDocumentsByBillingAccountResponse]{ Tracer: client.internal.Tracer(), }) } } -// DownloadMultipleBillingProfileInvoices - Gets a URL to download multiple invoice documents (invoice pdf, tax receipts, -// credit notes) as a zip file. The operation is supported for billing accounts with agreement type Microsoft Partner +// DownloadDocumentsByBillingAccount - Gets a URL to download multiple invoice documents (invoice pdf, tax receipts, credit +// notes) as a zip file. The operation is supported for billing accounts with agreement type Microsoft Partner // Agreement or Microsoft Customer Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 -func (client *InvoicesClient) downloadMultipleBillingProfileInvoices(ctx context.Context, billingAccountName string, downloadUrls []*string, options *InvoicesClientBeginDownloadMultipleBillingProfileInvoicesOptions) (*http.Response, error) { +// Generated from API version 2024-04-01 +func (client *InvoicesClient) downloadDocumentsByBillingAccount(ctx context.Context, billingAccountName string, parameters []*DocumentDownloadRequest, options *InvoicesClientBeginDownloadDocumentsByBillingAccountOptions) (*http.Response, error) { var err error - const operationName = "InvoicesClient.BeginDownloadMultipleBillingProfileInvoices" + const operationName = "InvoicesClient.BeginDownloadDocumentsByBillingAccount" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.downloadMultipleBillingProfileInvoicesCreateRequest(ctx, billingAccountName, downloadUrls, options) + req, err := client.downloadDocumentsByBillingAccountCreateRequest(ctx, billingAccountName, parameters, options) if err != nil { return nil, err } @@ -249,8 +329,8 @@ func (client *InvoicesClient) downloadMultipleBillingProfileInvoices(ctx context return httpResp, nil } -// downloadMultipleBillingProfileInvoicesCreateRequest creates the DownloadMultipleBillingProfileInvoices request. -func (client *InvoicesClient) downloadMultipleBillingProfileInvoicesCreateRequest(ctx context.Context, billingAccountName string, downloadUrls []*string, options *InvoicesClientBeginDownloadMultipleBillingProfileInvoicesOptions) (*policy.Request, error) { +// downloadDocumentsByBillingAccountCreateRequest creates the DownloadDocumentsByBillingAccount request. +func (client *InvoicesClient) downloadDocumentsByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, parameters []*DocumentDownloadRequest, options *InvoicesClientBeginDownloadDocumentsByBillingAccountOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/downloadDocuments" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") @@ -261,53 +341,55 @@ func (client *InvoicesClient) downloadMultipleBillingProfileInvoicesCreateReques return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, downloadUrls); err != nil { + if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } return req, nil } -// BeginDownloadMultipleBillingSubscriptionInvoices - Gets a URL to download multiple invoice documents (invoice pdf, tax -// receipts, credit notes) as a zip file. +// BeginDownloadDocumentsByBillingSubscription - Gets a URL to download multiple invoice documents (invoice pdf, tax receipts, +// credit notes) as a zip file. The operation is supported for billing accounts with agreement type Microsoft Partner +// Agreement or Microsoft Customer Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 -// - downloadUrls - An array of download urls for individual documents -// - options - InvoicesClientBeginDownloadMultipleBillingSubscriptionInvoicesOptions contains the optional parameters for the -// InvoicesClient.BeginDownloadMultipleBillingSubscriptionInvoices method. -func (client *InvoicesClient) BeginDownloadMultipleBillingSubscriptionInvoices(ctx context.Context, downloadUrls []*string, options *InvoicesClientBeginDownloadMultipleBillingSubscriptionInvoicesOptions) (*runtime.Poller[InvoicesClientDownloadMultipleBillingSubscriptionInvoicesResponse], error) { +// Generated from API version 2024-04-01 +// - parameters - A list of download details for individual documents. +// - options - InvoicesClientBeginDownloadDocumentsByBillingSubscriptionOptions contains the optional parameters for the InvoicesClient.BeginDownloadDocumentsByBillingSubscription +// method. +func (client *InvoicesClient) BeginDownloadDocumentsByBillingSubscription(ctx context.Context, parameters []*DocumentDownloadRequest, options *InvoicesClientBeginDownloadDocumentsByBillingSubscriptionOptions) (*runtime.Poller[InvoicesClientDownloadDocumentsByBillingSubscriptionResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.downloadMultipleBillingSubscriptionInvoices(ctx, downloadUrls, options) + resp, err := client.downloadDocumentsByBillingSubscription(ctx, parameters, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[InvoicesClientDownloadMultipleBillingSubscriptionInvoicesResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[InvoicesClientDownloadDocumentsByBillingSubscriptionResponse]{ FinalStateVia: runtime.FinalStateViaLocation, Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[InvoicesClientDownloadMultipleBillingSubscriptionInvoicesResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[InvoicesClientDownloadDocumentsByBillingSubscriptionResponse]{ Tracer: client.internal.Tracer(), }) } } -// DownloadMultipleBillingSubscriptionInvoices - Gets a URL to download multiple invoice documents (invoice pdf, tax receipts, -// credit notes) as a zip file. +// DownloadDocumentsByBillingSubscription - Gets a URL to download multiple invoice documents (invoice pdf, tax receipts, +// credit notes) as a zip file. The operation is supported for billing accounts with agreement type Microsoft Partner +// Agreement or Microsoft Customer Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 -func (client *InvoicesClient) downloadMultipleBillingSubscriptionInvoices(ctx context.Context, downloadUrls []*string, options *InvoicesClientBeginDownloadMultipleBillingSubscriptionInvoicesOptions) (*http.Response, error) { +// Generated from API version 2024-04-01 +func (client *InvoicesClient) downloadDocumentsByBillingSubscription(ctx context.Context, parameters []*DocumentDownloadRequest, options *InvoicesClientBeginDownloadDocumentsByBillingSubscriptionOptions) (*http.Response, error) { var err error - const operationName = "InvoicesClient.BeginDownloadMultipleBillingSubscriptionInvoices" + const operationName = "InvoicesClient.BeginDownloadDocumentsByBillingSubscription" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.downloadMultipleBillingSubscriptionInvoicesCreateRequest(ctx, downloadUrls, options) + req, err := client.downloadDocumentsByBillingSubscriptionCreateRequest(ctx, parameters, options) if err != nil { return nil, err } @@ -322,8 +404,8 @@ func (client *InvoicesClient) downloadMultipleBillingSubscriptionInvoices(ctx co return httpResp, nil } -// downloadMultipleBillingSubscriptionInvoicesCreateRequest creates the DownloadMultipleBillingSubscriptionInvoices request. -func (client *InvoicesClient) downloadMultipleBillingSubscriptionInvoicesCreateRequest(ctx context.Context, downloadUrls []*string, options *InvoicesClientBeginDownloadMultipleBillingSubscriptionInvoicesOptions) (*policy.Request, error) { +// downloadDocumentsByBillingSubscriptionCreateRequest creates the DownloadDocumentsByBillingSubscription request. +func (client *InvoicesClient) downloadDocumentsByBillingSubscriptionCreateRequest(ctx context.Context, parameters []*DocumentDownloadRequest, options *InvoicesClientBeginDownloadDocumentsByBillingSubscriptionOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/downloadDocuments" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -334,30 +416,104 @@ func (client *InvoicesClient) downloadMultipleBillingSubscriptionInvoicesCreateR return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, downloadUrls); err != nil { + if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } return req, nil } -// Get - Gets an invoice by billing account name and ID. The operation is supported for billing accounts with agreement type -// Microsoft Partner Agreement or Microsoft Customer Agreement. +// BeginDownloadSummaryByBillingAccount - Gets a URL to download the summary document for an invoice. The operation is supported +// for billing accounts with agreement type Enterprise Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - invoiceName - The ID that uniquely identifies an invoice. +// - options - InvoicesClientBeginDownloadSummaryByBillingAccountOptions contains the optional parameters for the InvoicesClient.BeginDownloadSummaryByBillingAccount +// method. +func (client *InvoicesClient) BeginDownloadSummaryByBillingAccount(ctx context.Context, billingAccountName string, invoiceName string, options *InvoicesClientBeginDownloadSummaryByBillingAccountOptions) (*runtime.Poller[InvoicesClientDownloadSummaryByBillingAccountResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.downloadSummaryByBillingAccount(ctx, billingAccountName, invoiceName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[InvoicesClientDownloadSummaryByBillingAccountResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[InvoicesClientDownloadSummaryByBillingAccountResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// DownloadSummaryByBillingAccount - Gets a URL to download the summary document for an invoice. The operation is supported +// for billing accounts with agreement type Enterprise Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *InvoicesClient) downloadSummaryByBillingAccount(ctx context.Context, billingAccountName string, invoiceName string, options *InvoicesClientBeginDownloadSummaryByBillingAccountOptions) (*http.Response, error) { + var err error + const operationName = "InvoicesClient.BeginDownloadSummaryByBillingAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.downloadSummaryByBillingAccountCreateRequest(ctx, billingAccountName, invoiceName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// downloadSummaryByBillingAccountCreateRequest creates the DownloadSummaryByBillingAccount request. +func (client *InvoicesClient) downloadSummaryByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, invoiceName string, options *InvoicesClientBeginDownloadSummaryByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/downloadSummary" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if invoiceName == "" { + return nil, errors.New("parameter invoiceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{invoiceName}", url.PathEscape(invoiceName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets an invoice by ID. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement +// or Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - invoiceName - The ID that uniquely identifies an invoice. // - options - InvoicesClientGetOptions contains the optional parameters for the InvoicesClient.Get method. -func (client *InvoicesClient) Get(ctx context.Context, billingAccountName string, invoiceName string, options *InvoicesClientGetOptions) (InvoicesClientGetResponse, error) { +func (client *InvoicesClient) Get(ctx context.Context, invoiceName string, options *InvoicesClientGetOptions) (InvoicesClientGetResponse, error) { var err error const operationName = "InvoicesClient.Get" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, billingAccountName, invoiceName, options) + req, err := client.getCreateRequest(ctx, invoiceName, options) if err != nil { return InvoicesClientGetResponse{}, err } @@ -374,12 +530,8 @@ func (client *InvoicesClient) Get(ctx context.Context, billingAccountName string } // getCreateRequest creates the Get request. -func (client *InvoicesClient) getCreateRequest(ctx context.Context, billingAccountName string, invoiceName string, options *InvoicesClientGetOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}" - if billingAccountName == "" { - return nil, errors.New("parameter billingAccountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) +func (client *InvoicesClient) getCreateRequest(ctx context.Context, invoiceName string, options *InvoicesClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/default/invoices/{invoiceName}" if invoiceName == "" { return nil, errors.New("parameter invoiceName cannot be empty") } @@ -389,7 +541,7 @@ func (client *InvoicesClient) getCreateRequest(ctx context.Context, billingAccou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -404,38 +556,44 @@ func (client *InvoicesClient) getHandleResponse(resp *http.Response) (InvoicesCl return result, nil } -// GetByID - Gets an invoice by ID. The operation is supported for billing accounts with agreement type Microsoft Partner -// Agreement or Microsoft Customer Agreement. +// GetByBillingAccount - Gets an invoice by billing account name and ID. The operation is supported for all billing account +// types. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. // - invoiceName - The ID that uniquely identifies an invoice. -// - options - InvoicesClientGetByIDOptions contains the optional parameters for the InvoicesClient.GetByID method. -func (client *InvoicesClient) GetByID(ctx context.Context, invoiceName string, options *InvoicesClientGetByIDOptions) (InvoicesClientGetByIDResponse, error) { +// - options - InvoicesClientGetByBillingAccountOptions contains the optional parameters for the InvoicesClient.GetByBillingAccount +// method. +func (client *InvoicesClient) GetByBillingAccount(ctx context.Context, billingAccountName string, invoiceName string, options *InvoicesClientGetByBillingAccountOptions) (InvoicesClientGetByBillingAccountResponse, error) { var err error - const operationName = "InvoicesClient.GetByID" + const operationName = "InvoicesClient.GetByBillingAccount" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getByIDCreateRequest(ctx, invoiceName, options) + req, err := client.getByBillingAccountCreateRequest(ctx, billingAccountName, invoiceName, options) if err != nil { - return InvoicesClientGetByIDResponse{}, err + return InvoicesClientGetByBillingAccountResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return InvoicesClientGetByIDResponse{}, err + return InvoicesClientGetByBillingAccountResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return InvoicesClientGetByIDResponse{}, err + return InvoicesClientGetByBillingAccountResponse{}, err } - resp, err := client.getByIDHandleResponse(httpResp) + resp, err := client.getByBillingAccountHandleResponse(httpResp) return resp, err } -// getByIDCreateRequest creates the GetByID request. -func (client *InvoicesClient) getByIDCreateRequest(ctx context.Context, invoiceName string, options *InvoicesClientGetByIDOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/default/invoices/{invoiceName}" +// getByBillingAccountCreateRequest creates the GetByBillingAccount request. +func (client *InvoicesClient) getByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, invoiceName string, options *InvoicesClientGetByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) if invoiceName == "" { return nil, errors.New("parameter invoiceName cannot be empty") } @@ -445,52 +603,53 @@ func (client *InvoicesClient) getByIDCreateRequest(ctx context.Context, invoiceN return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } -// getByIDHandleResponse handles the GetByID response. -func (client *InvoicesClient) getByIDHandleResponse(resp *http.Response) (InvoicesClientGetByIDResponse, error) { - result := InvoicesClientGetByIDResponse{} +// getByBillingAccountHandleResponse handles the GetByBillingAccount response. +func (client *InvoicesClient) getByBillingAccountHandleResponse(resp *http.Response) (InvoicesClientGetByBillingAccountResponse, error) { + result := InvoicesClientGetByBillingAccountResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.Invoice); err != nil { - return InvoicesClientGetByIDResponse{}, err + return InvoicesClientGetByBillingAccountResponse{}, err } return result, nil } -// GetBySubscriptionAndInvoiceID - Gets an invoice by subscription ID and invoice ID. +// GetByBillingSubscription - Gets an invoice by subscription ID and invoice ID. The operation is supported for billing accounts +// with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - invoiceName - The ID that uniquely identifies an invoice. -// - options - InvoicesClientGetBySubscriptionAndInvoiceIDOptions contains the optional parameters for the InvoicesClient.GetBySubscriptionAndInvoiceID +// - options - InvoicesClientGetByBillingSubscriptionOptions contains the optional parameters for the InvoicesClient.GetByBillingSubscription // method. -func (client *InvoicesClient) GetBySubscriptionAndInvoiceID(ctx context.Context, invoiceName string, options *InvoicesClientGetBySubscriptionAndInvoiceIDOptions) (InvoicesClientGetBySubscriptionAndInvoiceIDResponse, error) { +func (client *InvoicesClient) GetByBillingSubscription(ctx context.Context, invoiceName string, options *InvoicesClientGetByBillingSubscriptionOptions) (InvoicesClientGetByBillingSubscriptionResponse, error) { var err error - const operationName = "InvoicesClient.GetBySubscriptionAndInvoiceID" + const operationName = "InvoicesClient.GetByBillingSubscription" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getBySubscriptionAndInvoiceIDCreateRequest(ctx, invoiceName, options) + req, err := client.getByBillingSubscriptionCreateRequest(ctx, invoiceName, options) if err != nil { - return InvoicesClientGetBySubscriptionAndInvoiceIDResponse{}, err + return InvoicesClientGetByBillingSubscriptionResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return InvoicesClientGetBySubscriptionAndInvoiceIDResponse{}, err + return InvoicesClientGetByBillingSubscriptionResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return InvoicesClientGetBySubscriptionAndInvoiceIDResponse{}, err + return InvoicesClientGetByBillingSubscriptionResponse{}, err } - resp, err := client.getBySubscriptionAndInvoiceIDHandleResponse(httpResp) + resp, err := client.getByBillingSubscriptionHandleResponse(httpResp) return resp, err } -// getBySubscriptionAndInvoiceIDCreateRequest creates the GetBySubscriptionAndInvoiceID request. -func (client *InvoicesClient) getBySubscriptionAndInvoiceIDCreateRequest(ctx context.Context, invoiceName string, options *InvoicesClientGetBySubscriptionAndInvoiceIDOptions) (*policy.Request, error) { +// getByBillingSubscriptionCreateRequest creates the GetByBillingSubscription request. +func (client *InvoicesClient) getByBillingSubscriptionCreateRequest(ctx context.Context, invoiceName string, options *InvoicesClientGetByBillingSubscriptionOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -505,32 +664,29 @@ func (client *InvoicesClient) getBySubscriptionAndInvoiceIDCreateRequest(ctx con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } -// getBySubscriptionAndInvoiceIDHandleResponse handles the GetBySubscriptionAndInvoiceID response. -func (client *InvoicesClient) getBySubscriptionAndInvoiceIDHandleResponse(resp *http.Response) (InvoicesClientGetBySubscriptionAndInvoiceIDResponse, error) { - result := InvoicesClientGetBySubscriptionAndInvoiceIDResponse{} +// getByBillingSubscriptionHandleResponse handles the GetByBillingSubscription response. +func (client *InvoicesClient) getByBillingSubscriptionHandleResponse(resp *http.Response) (InvoicesClientGetByBillingSubscriptionResponse, error) { + result := InvoicesClientGetByBillingSubscriptionResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.Invoice); err != nil { - return InvoicesClientGetBySubscriptionAndInvoiceIDResponse{}, err + return InvoicesClientGetByBillingSubscriptionResponse{}, err } return result, nil } // NewListByBillingAccountPager - Lists the invoices for a billing account for a given start date and end date. The operation -// is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer -// Agreement. +// is supported for all billing account types. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. -// - periodStartDate - The start date to fetch the invoices. The date should be specified in MM-DD-YYYY format. -// - periodEndDate - The end date to fetch the invoices. The date should be specified in MM-DD-YYYY format. // - options - InvoicesClientListByBillingAccountOptions contains the optional parameters for the InvoicesClient.NewListByBillingAccountPager // method. -func (client *InvoicesClient) NewListByBillingAccountPager(billingAccountName string, periodStartDate string, periodEndDate string, options *InvoicesClientListByBillingAccountOptions) *runtime.Pager[InvoicesClientListByBillingAccountResponse] { +func (client *InvoicesClient) NewListByBillingAccountPager(billingAccountName string, options *InvoicesClientListByBillingAccountOptions) *runtime.Pager[InvoicesClientListByBillingAccountResponse] { return runtime.NewPager(runtime.PagingHandler[InvoicesClientListByBillingAccountResponse]{ More: func(page InvoicesClientListByBillingAccountResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 @@ -542,7 +698,7 @@ func (client *InvoicesClient) NewListByBillingAccountPager(billingAccountName st nextLink = *page.NextLink } resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listByBillingAccountCreateRequest(ctx, billingAccountName, periodStartDate, periodEndDate, options) + return client.listByBillingAccountCreateRequest(ctx, billingAccountName, options) }, nil) if err != nil { return InvoicesClientListByBillingAccountResponse{}, err @@ -554,7 +710,7 @@ func (client *InvoicesClient) NewListByBillingAccountPager(billingAccountName st } // listByBillingAccountCreateRequest creates the ListByBillingAccount request. -func (client *InvoicesClient) listByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, periodStartDate string, periodEndDate string, options *InvoicesClientListByBillingAccountOptions) (*policy.Request, error) { +func (client *InvoicesClient) listByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, options *InvoicesClientListByBillingAccountOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") @@ -565,9 +721,31 @@ func (client *InvoicesClient) listByBillingAccountCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") - reqQP.Set("periodStartDate", periodStartDate) - reqQP.Set("periodEndDate", periodEndDate) + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.PeriodEndDate != nil { + reqQP.Set("periodEndDate", options.PeriodEndDate.Format("2006-01-02")) + } + if options != nil && options.PeriodStartDate != nil { + reqQP.Set("periodStartDate", options.PeriodStartDate.Format("2006-01-02")) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -586,14 +764,12 @@ func (client *InvoicesClient) listByBillingAccountHandleResponse(resp *http.Resp // is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer // Agreement. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingProfileName - The ID that uniquely identifies a billing profile. -// - periodStartDate - The start date to fetch the invoices. The date should be specified in MM-DD-YYYY format. -// - periodEndDate - The end date to fetch the invoices. The date should be specified in MM-DD-YYYY format. // - options - InvoicesClientListByBillingProfileOptions contains the optional parameters for the InvoicesClient.NewListByBillingProfilePager // method. -func (client *InvoicesClient) NewListByBillingProfilePager(billingAccountName string, billingProfileName string, periodStartDate string, periodEndDate string, options *InvoicesClientListByBillingProfileOptions) *runtime.Pager[InvoicesClientListByBillingProfileResponse] { +func (client *InvoicesClient) NewListByBillingProfilePager(billingAccountName string, billingProfileName string, options *InvoicesClientListByBillingProfileOptions) *runtime.Pager[InvoicesClientListByBillingProfileResponse] { return runtime.NewPager(runtime.PagingHandler[InvoicesClientListByBillingProfileResponse]{ More: func(page InvoicesClientListByBillingProfileResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 @@ -605,7 +781,7 @@ func (client *InvoicesClient) NewListByBillingProfilePager(billingAccountName st nextLink = *page.NextLink } resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, periodStartDate, periodEndDate, options) + return client.listByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, options) }, nil) if err != nil { return InvoicesClientListByBillingProfileResponse{}, err @@ -617,7 +793,7 @@ func (client *InvoicesClient) NewListByBillingProfilePager(billingAccountName st } // listByBillingProfileCreateRequest creates the ListByBillingProfile request. -func (client *InvoicesClient) listByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, periodStartDate string, periodEndDate string, options *InvoicesClientListByBillingProfileOptions) (*policy.Request, error) { +func (client *InvoicesClient) listByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, options *InvoicesClientListByBillingProfileOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoices" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") @@ -632,9 +808,31 @@ func (client *InvoicesClient) listByBillingProfileCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") - reqQP.Set("periodStartDate", periodStartDate) - reqQP.Set("periodEndDate", periodEndDate) + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.PeriodEndDate != nil { + reqQP.Set("periodEndDate", options.PeriodEndDate.Format("2006-01-02")) + } + if options != nil && options.PeriodStartDate != nil { + reqQP.Set("periodStartDate", options.PeriodStartDate.Format("2006-01-02")) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -649,14 +847,13 @@ func (client *InvoicesClient) listByBillingProfileHandleResponse(resp *http.Resp return result, nil } -// NewListByBillingSubscriptionPager - Lists the invoices for a subscription. +// NewListByBillingSubscriptionPager - Lists the invoices for a subscription. The operation is supported for billing accounts +// with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. // -// Generated from API version 2020-05-01 -// - periodStartDate - Invoice period start date. -// - periodEndDate - Invoice period end date. +// Generated from API version 2024-04-01 // - options - InvoicesClientListByBillingSubscriptionOptions contains the optional parameters for the InvoicesClient.NewListByBillingSubscriptionPager // method. -func (client *InvoicesClient) NewListByBillingSubscriptionPager(periodStartDate string, periodEndDate string, options *InvoicesClientListByBillingSubscriptionOptions) *runtime.Pager[InvoicesClientListByBillingSubscriptionResponse] { +func (client *InvoicesClient) NewListByBillingSubscriptionPager(options *InvoicesClientListByBillingSubscriptionOptions) *runtime.Pager[InvoicesClientListByBillingSubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[InvoicesClientListByBillingSubscriptionResponse]{ More: func(page InvoicesClientListByBillingSubscriptionResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 @@ -668,7 +865,7 @@ func (client *InvoicesClient) NewListByBillingSubscriptionPager(periodStartDate nextLink = *page.NextLink } resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listByBillingSubscriptionCreateRequest(ctx, periodStartDate, periodEndDate, options) + return client.listByBillingSubscriptionCreateRequest(ctx, options) }, nil) if err != nil { return InvoicesClientListByBillingSubscriptionResponse{}, err @@ -680,7 +877,7 @@ func (client *InvoicesClient) NewListByBillingSubscriptionPager(periodStartDate } // listByBillingSubscriptionCreateRequest creates the ListByBillingSubscription request. -func (client *InvoicesClient) listByBillingSubscriptionCreateRequest(ctx context.Context, periodStartDate string, periodEndDate string, options *InvoicesClientListByBillingSubscriptionOptions) (*policy.Request, error) { +func (client *InvoicesClient) listByBillingSubscriptionCreateRequest(ctx context.Context, options *InvoicesClientListByBillingSubscriptionOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -691,9 +888,31 @@ func (client *InvoicesClient) listByBillingSubscriptionCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("periodStartDate", periodStartDate) - reqQP.Set("periodEndDate", periodEndDate) - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.PeriodEndDate != nil { + reqQP.Set("periodEndDate", options.PeriodEndDate.Format("2006-01-02")) + } + if options != nil && options.PeriodStartDate != nil { + reqQP.Set("periodStartDate", options.PeriodStartDate.Format("2006-01-02")) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/billing/armbilling/invoices_client_example_test.go b/sdk/resourcemanager/billing/armbilling/invoices_client_example_test.go index 582026a17798..411810403a4a 100644 --- a/sdk/resourcemanager/billing/armbilling/invoices_client_example_test.go +++ b/sdk/resourcemanager/billing/armbilling/invoices_client_example_test.go @@ -13,13 +13,15 @@ import ( "context" "log" + "time" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingAccountInvoicesList.json -func ExampleInvoicesClient_NewListByBillingAccountPager_billingAccountInvoicesList() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesListByBillingProfile.json +func ExampleInvoicesClient_NewListByBillingProfilePager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -29,7 +31,15 @@ func ExampleInvoicesClient_NewListByBillingAccountPager_billingAccountInvoicesLi if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewInvoicesClient().NewListByBillingAccountPager("{billingAccountName}", "2018-01-01", "2018-06-30", nil) + pager := clientFactory.NewInvoicesClient().NewListByBillingProfilePager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", &armbilling.InvoicesClientListByBillingProfileOptions{PeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-01-01"); return t }()), + PeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-06-30"); return t }()), + Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -43,134 +53,145 @@ func ExampleInvoicesClient_NewListByBillingAccountPager_billingAccountInvoicesLi // page.InvoiceListResult = armbilling.InvoiceListResult{ // Value: []*armbilling.Invoice{ // { - // Name: to.Ptr("1383723"), + // Name: to.Ptr("G123456789"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/invoices"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/1383723"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/G123456789"), // Properties: &armbilling.InvoiceProperties{ - // AmountDue: &armbilling.Amount{ + // AmountDue: &armbilling.InvoicePropertiesAmountDue{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](8.53), // }, - // AzurePrepaymentApplied: &armbilling.Amount{ + // AzurePrepaymentApplied: &armbilling.InvoicePropertiesAzurePrepaymentApplied{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](25.46), // }, - // BilledAmount: &armbilling.Amount{ + // BilledAmount: &armbilling.InvoicePropertiesBilledAmount{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](33.99), // }, // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // CreditAmount: &armbilling.Amount{ + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // CreditAmount: &armbilling.InvoicePropertiesCreditAmount{ // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](1), + // Value: to.Ptr[float32](0), // }, // DocumentType: to.Ptr(armbilling.InvoiceDocumentTypeInvoice), - // Documents: []*armbilling.Document{ + // Documents: []*armbilling.InvoiceDocument{ + // { + // Name: to.Ptr("12345678"), + // Kind: to.Ptr(armbilling.InvoiceDocumentTypeInvoice), + // }, // { - // Kind: to.Ptr(armbilling.DocumentTypeInvoice), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://microsoft.com/invoice.pdf"), + // Name: to.Ptr("22345678"), + // Kind: to.Ptr(armbilling.InvoiceDocumentTypeTaxReceipt), // }}, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-16T17:32:28.000Z"); return t}()), - // FreeAzureCreditApplied: &armbilling.Amount{ + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-16T17:32:28.000Z"); return t}()), + // FreeAzureCreditApplied: &armbilling.InvoicePropertiesFreeAzureCreditApplied{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](0), // }, - // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T17:32:28.000Z"); return t}()), - // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-15T17:32:28.000Z"); return t}()), - // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T17:32:28.000Z"); return t}()), + // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T17:32:28.000Z"); return t}()), + // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-15T17:32:28.000Z"); return t}()), + // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T17:32:28.000Z"); return t}()), // IsMonthlyInvoice: to.Ptr(false), - // Payments: []*armbilling.PaymentProperties{ - // { - // Amount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](1), - // }, - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-14T17:32:28.000Z"); return t}()), - // PaymentMethodFamily: to.Ptr(armbilling.PaymentMethodFamilyCreditCard), - // PaymentMethodType: to.Ptr("visa"), - // PaymentType: to.Ptr("credited"), - // }}, // PurchaseOrderNumber: to.Ptr("123456"), + // RebillDetails: &armbilling.InvoicePropertiesRebillDetails{ + // CreditNoteDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/CreditNote2"), + // InvoiceDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/I000002"), + // RebillDetails: &armbilling.RebillDetails{ + // CreditNoteDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/CreditNote"), + // InvoiceDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/I000001"), + // }, + // }, // Status: to.Ptr(armbilling.InvoiceStatusDue), - // SubTotal: &armbilling.Amount{ + // SubTotal: &armbilling.InvoicePropertiesSubTotal{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](33.99), // }, - // TaxAmount: &armbilling.Amount{ + // TaxAmount: &armbilling.InvoicePropertiesTaxAmount{ // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](0), + // Value: to.Ptr[float32](1), // }, - // TotalAmount: &armbilling.Amount{ + // TotalAmount: &armbilling.InvoicePropertiesTotalAmount{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](7.53), // }, // }, // }, // { - // Name: to.Ptr("1383724"), + // Name: to.Ptr("G987654321"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/invoices"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/1383724"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/G987654321"), // Properties: &armbilling.InvoiceProperties{ - // AmountDue: &armbilling.Amount{ + // AmountDue: &armbilling.InvoicePropertiesAmountDue{ // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](16.53), + // Value: to.Ptr[float32](0), // }, - // AzurePrepaymentApplied: &armbilling.Amount{ + // AzurePrepaymentApplied: &armbilling.InvoicePropertiesAzurePrepaymentApplied{ // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](15.46), + // Value: to.Ptr[float32](25.46), // }, - // BilledAmount: &armbilling.Amount{ + // BilledAmount: &armbilling.InvoicePropertiesBilledAmount{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](33.99), // }, // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // CreditAmount: &armbilling.Amount{ + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // CreditAmount: &armbilling.InvoicePropertiesCreditAmount{ // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2), + // Value: to.Ptr[float32](0), // }, // DocumentType: to.Ptr(armbilling.InvoiceDocumentTypeInvoice), - // Documents: []*armbilling.Document{ + // Documents: []*armbilling.InvoiceDocument{ + // { + // Name: to.Ptr("12345678"), + // Kind: to.Ptr(armbilling.InvoiceDocumentTypeInvoice), + // }, // { - // Kind: to.Ptr(armbilling.DocumentTypeTaxReceipt), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://microsoft.com/taxreceipt.pdf"), + // Name: to.Ptr("22345678"), + // Kind: to.Ptr(armbilling.InvoiceDocumentTypeTaxReceipt), // }}, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-01T17:32:28.000Z"); return t}()), - // FreeAzureCreditApplied: &armbilling.Amount{ + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-16T17:32:28.000Z"); return t}()), + // FreeAzureCreditApplied: &armbilling.InvoicePropertiesFreeAzureCreditApplied{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](0), // }, - // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T17:32:28.000Z"); return t}()), - // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-28T17:32:28.000Z"); return t}()), - // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T17:32:28.000Z"); return t}()), - // IsMonthlyInvoice: to.Ptr(true), - // Payments: []*armbilling.PaymentProperties{ + // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-01T17:32:28.000Z"); return t}()), + // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-15T17:32:28.000Z"); return t}()), + // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-01T17:32:28.000Z"); return t}()), + // IsMonthlyInvoice: to.Ptr(false), + // Payments: []*armbilling.Payment{ // { - // Amount: &armbilling.Amount{ + // Amount: &armbilling.PaymentAmount{ // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2), + // Value: to.Ptr[float32](33.99), // }, - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-14T17:32:28.000Z"); return t}()), + // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-14T17:32:28.000Z"); return t}()), // PaymentMethodFamily: to.Ptr(armbilling.PaymentMethodFamilyCreditCard), // PaymentMethodType: to.Ptr("visa"), - // PaymentType: to.Ptr("credited"), + // PaymentType: to.Ptr("debited"), // }}, - // PurchaseOrderNumber: to.Ptr("123456"), - // Status: to.Ptr(armbilling.InvoiceStatus("PastDue")), - // SubTotal: &armbilling.Amount{ + // PurchaseOrderNumber: to.Ptr("123455"), + // RebillDetails: &armbilling.InvoicePropertiesRebillDetails{ + // CreditNoteDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/CreditNote2"), + // InvoiceDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/I000002"), + // RebillDetails: &armbilling.RebillDetails{ + // CreditNoteDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/CreditNote"), + // InvoiceDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/I000001"), + // }, + // }, + // Status: to.Ptr(armbilling.InvoiceStatusPaid), + // SubTotal: &armbilling.InvoicePropertiesSubTotal{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](33.99), // }, - // TaxAmount: &armbilling.Amount{ + // TaxAmount: &armbilling.InvoicePropertiesTaxAmount{ // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](0), + // Value: to.Ptr[float32](1), // }, - // TotalAmount: &armbilling.Amount{ + // TotalAmount: &armbilling.InvoicePropertiesTotalAmount{ // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](16.53), + // Value: to.Ptr[float32](7.53), // }, // }, // }}, @@ -178,8 +199,208 @@ func ExampleInvoicesClient_NewListByBillingAccountPager_billingAccountInvoicesLi } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingAccountInvoicesListWithRebillDetails.json -func ExampleInvoicesClient_NewListByBillingAccountPager_billingAccountInvoicesListWithRebillDetails() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesDownloadDocumentsByBillingAccount.json +func ExampleInvoicesClient_BeginDownloadDocumentsByBillingAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewInvoicesClient().BeginDownloadDocumentsByBillingAccount(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", []*armbilling.DocumentDownloadRequest{ + { + DocumentName: to.Ptr("12345678"), + InvoiceName: to.Ptr("G123456789"), + }, + { + DocumentName: to.Ptr("12345678"), + InvoiceName: to.Ptr("G987654321"), + }}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DocumentDownloadResult = armbilling.DocumentDownloadResult{ + // ExpiryTime: to.Ptr("2023-02-16T17:32:28Z"), + // URL: to.Ptr("https://myaccount.blob.core.windows.net/invoices/1383724.pdf?sv=2019-02-02&sr=b&sp=r"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesAmend.json +func ExampleInvoicesClient_BeginAmend() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewInvoicesClient().BeginAmend(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "G123456789", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesDownloadByBillingAccount.json +func ExampleInvoicesClient_BeginDownloadByBillingAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewInvoicesClient().BeginDownloadByBillingAccount(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "G123456789", &armbilling.InvoicesClientBeginDownloadByBillingAccountOptions{DocumentName: to.Ptr("12345678")}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DocumentDownloadResult = armbilling.DocumentDownloadResult{ + // ExpiryTime: to.Ptr("2023-02-16T17:32:28Z"), + // URL: to.Ptr("https://myaccount.blob.core.windows.net/invoices/1383724.pdf?sv=2019-02-02&sr=b&sp=r"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesDownloadSummaryByBillingAccount.json +func ExampleInvoicesClient_BeginDownloadSummaryByBillingAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewInvoicesClient().BeginDownloadSummaryByBillingAccount(ctx, "123456789", "G123456789", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DocumentDownloadResult = armbilling.DocumentDownloadResult{ + // ExpiryTime: to.Ptr("2023-02-16T17:32:28Z"), + // URL: to.Ptr("https://myaccount.blob.core.windows.net/invoices/1383724_summary.pdf?sv=2019-02-02&sr=b&sp=r"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesGetByBillingAccount.json +func ExampleInvoicesClient_GetByBillingAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewInvoicesClient().GetByBillingAccount(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "G123456789", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Invoice = armbilling.Invoice{ + // Name: to.Ptr("G123456789"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/invoices"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/G123456789"), + // Properties: &armbilling.InvoiceProperties{ + // AmountDue: &armbilling.InvoicePropertiesAmountDue{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](8.53), + // }, + // AzurePrepaymentApplied: &armbilling.InvoicePropertiesAzurePrepaymentApplied{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](25.46), + // }, + // BilledAmount: &armbilling.InvoicePropertiesBilledAmount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](33.99), + // }, + // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // CreditAmount: &armbilling.InvoicePropertiesCreditAmount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](0), + // }, + // DocumentType: to.Ptr(armbilling.InvoiceDocumentTypeInvoice), + // Documents: []*armbilling.InvoiceDocument{ + // { + // Name: to.Ptr("12345678"), + // Kind: to.Ptr(armbilling.InvoiceDocumentTypeInvoice), + // }, + // { + // Name: to.Ptr("22345678"), + // Kind: to.Ptr(armbilling.InvoiceDocumentTypeTaxReceipt), + // }}, + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-16T17:32:28.000Z"); return t}()), + // FreeAzureCreditApplied: &armbilling.InvoicePropertiesFreeAzureCreditApplied{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](0), + // }, + // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T17:32:28.000Z"); return t}()), + // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-15T17:32:28.000Z"); return t}()), + // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T17:32:28.000Z"); return t}()), + // IsMonthlyInvoice: to.Ptr(false), + // PurchaseOrderNumber: to.Ptr("123456"), + // RebillDetails: &armbilling.InvoicePropertiesRebillDetails{ + // CreditNoteDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/CreditNote2"), + // InvoiceDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/I000002"), + // RebillDetails: &armbilling.RebillDetails{ + // CreditNoteDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/CreditNote"), + // InvoiceDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/I000001"), + // }, + // }, + // SpecialTaxationType: to.Ptr(armbilling.SpecialTaxationTypeSubtotalLevel), + // Status: to.Ptr(armbilling.InvoiceStatusDue), + // SubTotal: &armbilling.InvoicePropertiesSubTotal{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](33.99), + // }, + // TaxAmount: &armbilling.InvoicePropertiesTaxAmount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](1), + // }, + // TotalAmount: &armbilling.InvoicePropertiesTotalAmount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](7.53), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesListByBillingAccount.json +func ExampleInvoicesClient_NewListByBillingAccountPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -189,7 +410,15 @@ func ExampleInvoicesClient_NewListByBillingAccountPager_billingAccountInvoicesLi if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewInvoicesClient().NewListByBillingAccountPager("{billingAccountName}", "2018-01-01", "2018-06-30", nil) + pager := clientFactory.NewInvoicesClient().NewListByBillingAccountPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", &armbilling.InvoicesClientListByBillingAccountOptions{PeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-01-01"); return t }()), + PeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-06-30"); return t }()), + Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -203,142 +432,145 @@ func ExampleInvoicesClient_NewListByBillingAccountPager_billingAccountInvoicesLi // page.InvoiceListResult = armbilling.InvoiceListResult{ // Value: []*armbilling.Invoice{ // { - // Name: to.Ptr("I000003"), + // Name: to.Ptr("G123456789"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/invoices"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/I000003"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/G123456789"), // Properties: &armbilling.InvoiceProperties{ - // AmountDue: &armbilling.Amount{ + // AmountDue: &armbilling.InvoicePropertiesAmountDue{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](8.53), // }, - // AzurePrepaymentApplied: &armbilling.Amount{ + // AzurePrepaymentApplied: &armbilling.InvoicePropertiesAzurePrepaymentApplied{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](25.46), // }, - // BilledAmount: &armbilling.Amount{ + // BilledAmount: &armbilling.InvoicePropertiesBilledAmount{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](33.99), // }, // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // CreditAmount: &armbilling.Amount{ + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // CreditAmount: &armbilling.InvoicePropertiesCreditAmount{ // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](1), + // Value: to.Ptr[float32](0), // }, // DocumentType: to.Ptr(armbilling.InvoiceDocumentTypeInvoice), - // Documents: []*armbilling.Document{ + // Documents: []*armbilling.InvoiceDocument{ + // { + // Name: to.Ptr("12345678"), + // Kind: to.Ptr(armbilling.InvoiceDocumentTypeInvoice), + // }, // { - // Kind: to.Ptr(armbilling.DocumentTypeInvoice), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://microsoft.com/invoice.pdf"), + // Name: to.Ptr("22345678"), + // Kind: to.Ptr(armbilling.InvoiceDocumentTypeTaxReceipt), // }}, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-16T17:32:28.000Z"); return t}()), - // FreeAzureCreditApplied: &armbilling.Amount{ + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-16T17:32:28.000Z"); return t}()), + // FreeAzureCreditApplied: &armbilling.InvoicePropertiesFreeAzureCreditApplied{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](0), // }, - // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T17:32:28.000Z"); return t}()), - // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-15T17:32:28.000Z"); return t}()), - // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T17:32:28.000Z"); return t}()), + // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T17:32:28.000Z"); return t}()), + // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-15T17:32:28.000Z"); return t}()), + // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T17:32:28.000Z"); return t}()), // IsMonthlyInvoice: to.Ptr(false), - // Payments: []*armbilling.PaymentProperties{ - // { - // Amount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](1), - // }, - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-14T17:32:28.000Z"); return t}()), - // PaymentMethodFamily: to.Ptr(armbilling.PaymentMethodFamilyCreditCard), - // PaymentMethodType: to.Ptr("visa"), - // PaymentType: to.Ptr("credited"), - // }}, // PurchaseOrderNumber: to.Ptr("123456"), - // RebillDetails: map[string]*armbilling.RebillDetails{ - // "creditNoteDocumentId": &armbilling.RebillDetails{ - // }, - // "invoiceDocumentId": &armbilling.RebillDetails{ - // }, - // "rebillDetails": &armbilling.RebillDetails{ + // RebillDetails: &armbilling.InvoicePropertiesRebillDetails{ + // CreditNoteDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/CreditNote2"), + // InvoiceDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/I000002"), + // RebillDetails: &armbilling.RebillDetails{ + // CreditNoteDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/CreditNote"), + // InvoiceDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/I000001"), // }, // }, // Status: to.Ptr(armbilling.InvoiceStatusDue), - // SubTotal: &armbilling.Amount{ + // SubTotal: &armbilling.InvoicePropertiesSubTotal{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](33.99), // }, - // TaxAmount: &armbilling.Amount{ + // TaxAmount: &armbilling.InvoicePropertiesTaxAmount{ // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](0), + // Value: to.Ptr[float32](1), // }, - // TotalAmount: &armbilling.Amount{ + // TotalAmount: &armbilling.InvoicePropertiesTotalAmount{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](7.53), // }, // }, // }, // { - // Name: to.Ptr("1383724"), + // Name: to.Ptr("G987654321"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/invoices"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/1383724"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/G987654321"), // Properties: &armbilling.InvoiceProperties{ - // AmountDue: &armbilling.Amount{ + // AmountDue: &armbilling.InvoicePropertiesAmountDue{ // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](16.53), + // Value: to.Ptr[float32](0), // }, - // AzurePrepaymentApplied: &armbilling.Amount{ + // AzurePrepaymentApplied: &armbilling.InvoicePropertiesAzurePrepaymentApplied{ // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](15.46), + // Value: to.Ptr[float32](25.46), // }, - // BilledAmount: &armbilling.Amount{ + // BilledAmount: &armbilling.InvoicePropertiesBilledAmount{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](33.99), // }, // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // CreditAmount: &armbilling.Amount{ + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // CreditAmount: &armbilling.InvoicePropertiesCreditAmount{ // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2), + // Value: to.Ptr[float32](0), // }, // DocumentType: to.Ptr(armbilling.InvoiceDocumentTypeInvoice), - // Documents: []*armbilling.Document{ + // Documents: []*armbilling.InvoiceDocument{ + // { + // Name: to.Ptr("12345678"), + // Kind: to.Ptr(armbilling.InvoiceDocumentTypeInvoice), + // }, // { - // Kind: to.Ptr(armbilling.DocumentTypeTaxReceipt), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://microsoft.com/taxreceipt.pdf"), + // Name: to.Ptr("22345678"), + // Kind: to.Ptr(armbilling.InvoiceDocumentTypeTaxReceipt), // }}, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-01T17:32:28.000Z"); return t}()), - // FreeAzureCreditApplied: &armbilling.Amount{ + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-16T17:32:28.000Z"); return t}()), + // FreeAzureCreditApplied: &armbilling.InvoicePropertiesFreeAzureCreditApplied{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](0), // }, - // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T17:32:28.000Z"); return t}()), - // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-28T17:32:28.000Z"); return t}()), - // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T17:32:28.000Z"); return t}()), - // IsMonthlyInvoice: to.Ptr(true), - // Payments: []*armbilling.PaymentProperties{ + // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-01T17:32:28.000Z"); return t}()), + // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-15T17:32:28.000Z"); return t}()), + // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-01T17:32:28.000Z"); return t}()), + // IsMonthlyInvoice: to.Ptr(false), + // Payments: []*armbilling.Payment{ // { - // Amount: &armbilling.Amount{ + // Amount: &armbilling.PaymentAmount{ // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2), + // Value: to.Ptr[float32](33.99), // }, - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-14T17:32:28.000Z"); return t}()), + // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-14T17:32:28.000Z"); return t}()), // PaymentMethodFamily: to.Ptr(armbilling.PaymentMethodFamilyCreditCard), // PaymentMethodType: to.Ptr("visa"), - // PaymentType: to.Ptr("credited"), + // PaymentType: to.Ptr("debited"), // }}, - // PurchaseOrderNumber: to.Ptr("123456"), - // Status: to.Ptr(armbilling.InvoiceStatus("PastDue")), - // SubTotal: &armbilling.Amount{ + // PurchaseOrderNumber: to.Ptr("123455"), + // RebillDetails: &armbilling.InvoicePropertiesRebillDetails{ + // CreditNoteDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/CreditNote2"), + // InvoiceDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/I000002"), + // RebillDetails: &armbilling.RebillDetails{ + // CreditNoteDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/CreditNote"), + // InvoiceDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/I000001"), + // }, + // }, + // Status: to.Ptr(armbilling.InvoiceStatusPaid), + // SubTotal: &armbilling.InvoicePropertiesSubTotal{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](33.99), // }, - // TaxAmount: &armbilling.Amount{ + // TaxAmount: &armbilling.InvoicePropertiesTaxAmount{ // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](0), + // Value: to.Ptr[float32](1), // }, - // TotalAmount: &armbilling.Amount{ + // TotalAmount: &armbilling.InvoicePropertiesTotalAmount{ // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](16.53), + // Value: to.Ptr[float32](7.53), // }, // }, // }}, @@ -346,8 +578,8 @@ func ExampleInvoicesClient_NewListByBillingAccountPager_billingAccountInvoicesLi } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/InvoicesListByBillingProfile.json -func ExampleInvoicesClient_NewListByBillingProfilePager_invoicesListByBillingProfile() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesDownloadDocumentsByBillingSubscription.json +func ExampleInvoicesClient_BeginDownloadDocumentsByBillingSubscription() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -357,528 +589,33 @@ func ExampleInvoicesClient_NewListByBillingProfilePager_invoicesListByBillingPro if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewInvoicesClient().NewListByBillingProfilePager("{billingAccountName}", "{billingProfileName}", "2018-01-01", "2018-06-30", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.InvoiceListResult = armbilling.InvoiceListResult{ - // Value: []*armbilling.Invoice{ - // { - // Name: to.Ptr("1383723"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/invoices"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/1383723"), - // Properties: &armbilling.InvoiceProperties{ - // AmountDue: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](8.53), - // }, - // AzurePrepaymentApplied: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](25.46), - // }, - // BilledAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](33.99), - // }, - // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"), - // CreditAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](1), - // }, - // DocumentType: to.Ptr(armbilling.InvoiceDocumentTypeInvoice), - // Documents: []*armbilling.Document{ - // { - // Kind: to.Ptr(armbilling.DocumentTypeInvoice), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://microsoft.com/invoice.pdf"), - // }, - // { - // Kind: to.Ptr(armbilling.DocumentTypeTaxReceipt), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://microsoft.com/taxDoc.pdf"), - // }}, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-16T17:32:28.000Z"); return t}()), - // FreeAzureCreditApplied: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](0), - // }, - // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T17:32:28.000Z"); return t}()), - // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-15T17:32:28.000Z"); return t}()), - // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T17:32:28.000Z"); return t}()), - // IsMonthlyInvoice: to.Ptr(false), - // Payments: []*armbilling.PaymentProperties{ - // { - // Amount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](1), - // }, - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-14T17:32:28.000Z"); return t}()), - // PaymentMethodFamily: to.Ptr(armbilling.PaymentMethodFamilyCreditCard), - // PaymentMethodType: to.Ptr("visa"), - // PaymentType: to.Ptr("credited"), - // }}, - // PurchaseOrderNumber: to.Ptr("123456"), - // Status: to.Ptr(armbilling.InvoiceStatusDue), - // SubTotal: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](33.99), - // }, - // TaxAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](0), - // }, - // TotalAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](7.53), - // }, - // }, - // }, - // { - // Name: to.Ptr("1383724"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/invoices"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/1383724"), - // Properties: &armbilling.InvoiceProperties{ - // AmountDue: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](16.53), - // }, - // AzurePrepaymentApplied: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](15.46), - // }, - // BilledAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](33.99), - // }, - // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"), - // CreditAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2), - // }, - // DocumentType: to.Ptr(armbilling.InvoiceDocumentTypeInvoice), - // Documents: []*armbilling.Document{ - // { - // Kind: to.Ptr(armbilling.DocumentTypeInvoice), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://microsoft.com/invoice.pdf"), - // }, - // { - // Kind: to.Ptr(armbilling.DocumentTypeTaxReceipt), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://microsoft.com/taxDoc.pdf"), - // }}, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-01T17:32:28.000Z"); return t}()), - // FreeAzureCreditApplied: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](0), - // }, - // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T17:32:28.000Z"); return t}()), - // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-28T17:32:28.000Z"); return t}()), - // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T17:32:28.000Z"); return t}()), - // IsMonthlyInvoice: to.Ptr(true), - // Payments: []*armbilling.PaymentProperties{ - // { - // Amount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2), - // }, - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-14T17:32:28.000Z"); return t}()), - // PaymentMethodFamily: to.Ptr(armbilling.PaymentMethodFamilyCreditCard), - // PaymentMethodType: to.Ptr("visa"), - // PaymentType: to.Ptr("credited"), - // }}, - // PurchaseOrderNumber: to.Ptr("123456"), - // Status: to.Ptr(armbilling.InvoiceStatusDue), - // SubTotal: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](33.99), - // }, - // TaxAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](0), - // }, - // TotalAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](16.53), - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/InvoicesListByBillingProfileWithRebillDetails.json -func ExampleInvoicesClient_NewListByBillingProfilePager_invoicesListByBillingProfileWithRebillDetails() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbilling.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewInvoicesClient().NewListByBillingProfilePager("{billingAccountName}", "{billingProfileName}", "2018-01-01", "2018-06-30", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.InvoiceListResult = armbilling.InvoiceListResult{ - // Value: []*armbilling.Invoice{ - // { - // Name: to.Ptr("I000003"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/invoices"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/I000003"), - // Properties: &armbilling.InvoiceProperties{ - // AmountDue: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](8.53), - // }, - // AzurePrepaymentApplied: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](25.46), - // }, - // BilledAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](33.99), - // }, - // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"), - // CreditAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](1), - // }, - // DocumentType: to.Ptr(armbilling.InvoiceDocumentTypeInvoice), - // Documents: []*armbilling.Document{ - // { - // Kind: to.Ptr(armbilling.DocumentTypeInvoice), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://microsoft.com/invoice.pdf"), - // }, - // { - // Kind: to.Ptr(armbilling.DocumentTypeTaxReceipt), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://microsoft.com/taxDoc.pdf"), - // }}, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-16T17:32:28.000Z"); return t}()), - // FreeAzureCreditApplied: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](0), - // }, - // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T17:32:28.000Z"); return t}()), - // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-15T17:32:28.000Z"); return t}()), - // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T17:32:28.000Z"); return t}()), - // IsMonthlyInvoice: to.Ptr(false), - // Payments: []*armbilling.PaymentProperties{ - // { - // Amount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](1), - // }, - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-14T17:32:28.000Z"); return t}()), - // PaymentMethodFamily: to.Ptr(armbilling.PaymentMethodFamilyCreditCard), - // PaymentMethodType: to.Ptr("visa"), - // PaymentType: to.Ptr("credited"), - // }}, - // PurchaseOrderNumber: to.Ptr("123456"), - // RebillDetails: map[string]*armbilling.RebillDetails{ - // "creditNoteDocumentId": &armbilling.RebillDetails{ - // }, - // "invoiceDocumentId": &armbilling.RebillDetails{ - // }, - // "rebillDetails": &armbilling.RebillDetails{ - // }, - // }, - // Status: to.Ptr(armbilling.InvoiceStatusDue), - // SubTotal: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](33.99), - // }, - // TaxAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](0), - // }, - // TotalAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](7.53), - // }, - // }, - // }, - // { - // Name: to.Ptr("1383724"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/invoices"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/1383724"), - // Properties: &armbilling.InvoiceProperties{ - // AmountDue: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](16.53), - // }, - // AzurePrepaymentApplied: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](15.46), - // }, - // BilledAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](33.99), - // }, - // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"), - // CreditAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2), - // }, - // DocumentType: to.Ptr(armbilling.InvoiceDocumentTypeInvoice), - // Documents: []*armbilling.Document{ - // { - // Kind: to.Ptr(armbilling.DocumentTypeInvoice), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://microsoft.com/invoice.pdf"), - // }, - // { - // Kind: to.Ptr(armbilling.DocumentTypeTaxReceipt), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://microsoft.com/taxDoc.pdf"), - // }}, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-01T17:32:28.000Z"); return t}()), - // FreeAzureCreditApplied: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](0), - // }, - // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T17:32:28.000Z"); return t}()), - // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-28T17:32:28.000Z"); return t}()), - // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T17:32:28.000Z"); return t}()), - // IsMonthlyInvoice: to.Ptr(true), - // Payments: []*armbilling.PaymentProperties{ - // { - // Amount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2), - // }, - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-14T17:32:28.000Z"); return t}()), - // PaymentMethodFamily: to.Ptr(armbilling.PaymentMethodFamilyCreditCard), - // PaymentMethodType: to.Ptr("visa"), - // PaymentType: to.Ptr("credited"), - // }}, - // PurchaseOrderNumber: to.Ptr("123456"), - // Status: to.Ptr(armbilling.InvoiceStatusDue), - // SubTotal: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](33.99), - // }, - // TaxAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](0), - // }, - // TotalAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](16.53), - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/CreditNote.json -func ExampleInvoicesClient_Get_creditNote() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbilling.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewInvoicesClient().Get(ctx, "{billingAccountName}", "{invoiceName}", nil) + poller, err := clientFactory.NewInvoicesClient().BeginDownloadDocumentsByBillingSubscription(ctx, []*armbilling.DocumentDownloadRequest{ + { + DocumentName: to.Ptr("12345678"), + InvoiceName: to.Ptr("E123456789"), + }, + { + DocumentName: to.Ptr("12345678"), + InvoiceName: to.Ptr("E987654321"), + }}, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Invoice = armbilling.Invoice{ - // Name: to.Ptr("{invoiceName}"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/invoices"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}"), - // Properties: &armbilling.InvoiceProperties{ - // AmountDue: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](16.53), - // }, - // AzurePrepaymentApplied: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](15.46), - // }, - // BilledAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](33.99), - // }, - // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"), - // CreditAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2), - // }, - // CreditForDocumentID: to.Ptr("providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/I000001"), - // DocumentType: to.Ptr(armbilling.InvoiceDocumentTypeCreditNote), - // Documents: []*armbilling.Document{ - // { - // Kind: to.Ptr(armbilling.DocumentTypeInvoice), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://microsoft.com/invoice.pdf"), - // }, - // { - // Kind: to.Ptr(armbilling.DocumentTypeTaxReceipt), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://microsoft.com/taxDoc.pdf"), - // }}, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-16T17:32:28.000Z"); return t}()), - // FreeAzureCreditApplied: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](0), - // }, - // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T17:32:28.000Z"); return t}()), - // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-15T17:32:28.000Z"); return t}()), - // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T17:32:28.000Z"); return t}()), - // IsMonthlyInvoice: to.Ptr(false), - // Payments: []*armbilling.PaymentProperties{ - // { - // Amount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2), - // }, - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-14T17:32:28.000Z"); return t}()), - // PaymentMethodFamily: to.Ptr(armbilling.PaymentMethodFamilyCreditCard), - // PaymentMethodType: to.Ptr("visa"), - // PaymentType: to.Ptr("credited"), - // }}, - // PurchaseOrderNumber: to.Ptr("123456"), - // Status: to.Ptr(armbilling.InvoiceStatusPaid), - // SubTotal: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](33.99), - // }, - // TaxAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](0), - // }, - // TotalAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](16.53), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/Invoice.json -func ExampleInvoicesClient_Get_invoice() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbilling.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewInvoicesClient().Get(ctx, "{billingAccountName}", "{invoiceName}", nil) + res, err := poller.PollUntilDone(ctx, nil) if err != nil { - log.Fatalf("failed to finish the request: %v", err) + log.Fatalf("failed to pull the result: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Invoice = armbilling.Invoice{ - // Name: to.Ptr("{invoiceName}"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/invoices"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}"), - // Properties: &armbilling.InvoiceProperties{ - // AmountDue: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](16.53), - // }, - // AzurePrepaymentApplied: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](15.46), - // }, - // BilledAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](33.99), - // }, - // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"), - // CreditAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2), - // }, - // DocumentType: to.Ptr(armbilling.InvoiceDocumentTypeInvoice), - // Documents: []*armbilling.Document{ - // { - // Kind: to.Ptr(armbilling.DocumentTypeInvoice), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://microsoft.com/invoice.pdf"), - // }, - // { - // Kind: to.Ptr(armbilling.DocumentTypeTaxReceipt), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://microsoft.com/taxDoc.pdf"), - // }}, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-16T17:32:28.000Z"); return t}()), - // FreeAzureCreditApplied: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](0), - // }, - // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T17:32:28.000Z"); return t}()), - // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-15T17:32:28.000Z"); return t}()), - // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T17:32:28.000Z"); return t}()), - // IsMonthlyInvoice: to.Ptr(false), - // Payments: []*armbilling.PaymentProperties{ - // { - // Amount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2), - // }, - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-14T17:32:28.000Z"); return t}()), - // PaymentMethodFamily: to.Ptr(armbilling.PaymentMethodFamilyCreditCard), - // PaymentMethodType: to.Ptr("visa"), - // PaymentType: to.Ptr("credited"), - // }}, - // PurchaseOrderNumber: to.Ptr("123456"), - // Status: to.Ptr(armbilling.InvoiceStatusDue), - // SubTotal: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](33.99), - // }, - // TaxAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](0), - // }, - // TotalAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](16.53), - // }, - // }, + // res.DocumentDownloadResult = armbilling.DocumentDownloadResult{ + // ExpiryTime: to.Ptr("2023-02-16T17:32:28Z"), + // URL: to.Ptr("https://myaccount.blob.core.windows.net/invoices/1383724.pdf?sv=2019-02-02&sr=b&sp=r"), // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/InvoiceWithRebillDetails.json -func ExampleInvoicesClient_Get_invoiceWithRebillDetails() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesDownloadByBillingSubscription.json +func ExampleInvoicesClient_BeginDownloadByBillingSubscription() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -888,188 +625,25 @@ func ExampleInvoicesClient_Get_invoiceWithRebillDetails() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewInvoicesClient().Get(ctx, "{billingAccountName}", "{invoiceName}", nil) + poller, err := clientFactory.NewInvoicesClient().BeginDownloadByBillingSubscription(ctx, "E123456789", &armbilling.InvoicesClientBeginDownloadByBillingSubscriptionOptions{DocumentName: to.Ptr("12345678")}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Invoice = armbilling.Invoice{ - // Name: to.Ptr("{invoiceName}"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/invoices"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}"), - // Properties: &armbilling.InvoiceProperties{ - // AmountDue: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](16.53), - // }, - // AzurePrepaymentApplied: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](15.46), - // }, - // BilledAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](33.99), - // }, - // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"), - // CreditAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2), - // }, - // DocumentType: to.Ptr(armbilling.InvoiceDocumentTypeInvoice), - // Documents: []*armbilling.Document{ - // { - // Kind: to.Ptr(armbilling.DocumentTypeInvoice), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://microsoft.com/invoice.pdf"), - // }, - // { - // Kind: to.Ptr(armbilling.DocumentTypeTaxReceipt), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://microsoft.com/taxDoc.pdf"), - // }}, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-16T17:32:28.000Z"); return t}()), - // FreeAzureCreditApplied: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](0), - // }, - // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T17:32:28.000Z"); return t}()), - // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-15T17:32:28.000Z"); return t}()), - // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T17:32:28.000Z"); return t}()), - // IsMonthlyInvoice: to.Ptr(false), - // Payments: []*armbilling.PaymentProperties{ - // { - // Amount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2), - // }, - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-14T17:32:28.000Z"); return t}()), - // PaymentMethodFamily: to.Ptr(armbilling.PaymentMethodFamilyCreditCard), - // PaymentMethodType: to.Ptr("visa"), - // PaymentType: to.Ptr("credited"), - // }}, - // PurchaseOrderNumber: to.Ptr("123456"), - // RebillDetails: map[string]*armbilling.RebillDetails{ - // "creditNoteDocumentId": &armbilling.RebillDetails{ - // }, - // "invoiceDocumentId": &armbilling.RebillDetails{ - // }, - // "rebillDetails": &armbilling.RebillDetails{ - // }, - // }, - // Status: to.Ptr(armbilling.InvoiceStatusDue), - // SubTotal: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](33.99), - // }, - // TaxAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](0), - // }, - // TotalAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](16.53), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/VoidInvoice.json -func ExampleInvoicesClient_Get_voidInvoice() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbilling.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewInvoicesClient().Get(ctx, "{billingAccountName}", "{invoiceName}", nil) + res, err := poller.PollUntilDone(ctx, nil) if err != nil { - log.Fatalf("failed to finish the request: %v", err) + log.Fatalf("failed to pull the result: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Invoice = armbilling.Invoice{ - // Name: to.Ptr("{invoiceName}"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/invoices"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}"), - // Properties: &armbilling.InvoiceProperties{ - // AmountDue: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](16.53), - // }, - // AzurePrepaymentApplied: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](15.46), - // }, - // BilledAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](33.99), - // }, - // BilledDocumentID: to.Ptr("providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/I000002"), - // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"), - // CreditAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2), - // }, - // DocumentType: to.Ptr(armbilling.InvoiceDocumentTypeInvoice), - // Documents: []*armbilling.Document{ - // { - // Kind: to.Ptr(armbilling.DocumentTypeInvoice), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://microsoft.com/invoice.pdf"), - // }, - // { - // Kind: to.Ptr(armbilling.DocumentTypeTaxReceipt), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://microsoft.com/taxDoc.pdf"), - // }}, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-16T17:32:28.000Z"); return t}()), - // FreeAzureCreditApplied: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](0), - // }, - // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T17:32:28.000Z"); return t}()), - // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-15T17:32:28.000Z"); return t}()), - // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T17:32:28.000Z"); return t}()), - // IsMonthlyInvoice: to.Ptr(false), - // Payments: []*armbilling.PaymentProperties{ - // { - // Amount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2), - // }, - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-14T17:32:28.000Z"); return t}()), - // PaymentMethodFamily: to.Ptr(armbilling.PaymentMethodFamilyCreditCard), - // PaymentMethodType: to.Ptr("visa"), - // PaymentType: to.Ptr("credited"), - // }}, - // PurchaseOrderNumber: to.Ptr("123456"), - // Status: to.Ptr(armbilling.InvoiceStatusVoid), - // SubTotal: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](33.99), - // }, - // TaxAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](0), - // }, - // TotalAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](16.53), - // }, - // }, + // res.DocumentDownloadResult = armbilling.DocumentDownloadResult{ + // ExpiryTime: to.Ptr("2023-02-16T17:32:28Z"), + // URL: to.Ptr("https://myaccount.blob.core.windows.net/invoices/1383724.pdf?sv=2019-02-02&sr=b&sp=r"), // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/InvoiceById.json -func ExampleInvoicesClient_GetByID() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesGetByBillingSubscription.json +func ExampleInvoicesClient_GetByBillingSubscription() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -1079,7 +653,7 @@ func ExampleInvoicesClient_GetByID() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewInvoicesClient().GetByID(ctx, "{invoiceName}", nil) + res, err := clientFactory.NewInvoicesClient().GetByBillingSubscription(ctx, "E123456789", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -1087,135 +661,32 @@ func ExampleInvoicesClient_GetByID() { _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Invoice = armbilling.Invoice{ - // Name: to.Ptr("{invoiceName}"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/invoices"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}"), + // Name: to.Ptr("E123456789"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions/invoices"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/11111111-1111-1111-1111-111111111111/invoices/E123456789"), // Properties: &armbilling.InvoiceProperties{ - // AmountDue: &armbilling.Amount{ + // AmountDue: &armbilling.InvoicePropertiesAmountDue{ // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](16.53), + // Value: to.Ptr[float32](8.53), // }, - // AzurePrepaymentApplied: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](15.46), - // }, - // BilledAmount: &armbilling.Amount{ + // BilledAmount: &armbilling.InvoicePropertiesBilledAmount{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](33.99), // }, - // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"), - // CreditAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2), - // }, - // Documents: []*armbilling.Document{ - // { - // Kind: to.Ptr(armbilling.DocumentTypeInvoice), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://microsoft.com/invoice.pdf"), - // }, - // { - // Kind: to.Ptr(armbilling.DocumentTypeTaxReceipt), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://microsoft.com/taxDoc.pdf"), - // }}, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-16T17:32:28.000Z"); return t}()), - // FreeAzureCreditApplied: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](0), - // }, - // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T17:32:28.000Z"); return t}()), - // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-15T17:32:28.000Z"); return t}()), - // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T17:32:28.000Z"); return t}()), - // IsMonthlyInvoice: to.Ptr(false), - // Payments: []*armbilling.PaymentProperties{ - // { - // Amount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2), - // }, - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-14T17:32:28.000Z"); return t}()), - // PaymentMethodFamily: to.Ptr(armbilling.PaymentMethodFamilyCreditCard), - // PaymentMethodType: to.Ptr("visa"), - // PaymentType: to.Ptr("credited"), - // }}, + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-16T17:32:28.000Z"); return t}()), + // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T17:32:28.000Z"); return t}()), + // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-15T17:32:28.000Z"); return t}()), + // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T17:32:28.000Z"); return t}()), + // InvoiceType: to.Ptr(armbilling.InvoiceTypeAzureServices), // PurchaseOrderNumber: to.Ptr("123456"), // Status: to.Ptr(armbilling.InvoiceStatusDue), - // SubTotal: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](33.99), - // }, - // TaxAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](0), - // }, - // TotalAmount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](16.53), - // }, + // SubscriptionDisplayName: to.Ptr("Contoso Operations Billing"), + // SubscriptionID: to.Ptr("11111111-1111-1111-1111-111111111111"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/ModernInvoiceDownload.json -func ExampleInvoicesClient_BeginDownloadInvoice() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbilling.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewInvoicesClient().BeginDownloadInvoice(ctx, "{billingAccountName}", "{invoiceName}", "DRS_12345", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.DownloadURL = armbilling.DownloadURL{ - // URL: to.Ptr("https://myaccount.blob.core.windows.net/invoices/1383724.pdf?sv=2019-02-02&sr=b&sp=r"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/MultipleModernInvoiceDownload.json -func ExampleInvoicesClient_BeginDownloadMultipleBillingProfileInvoices() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbilling.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewInvoicesClient().BeginDownloadMultipleBillingProfileInvoices(ctx, "{billingAccountName}", []*string{ - to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/download?downloadToken={downloadToken}&useCache=True&api-version=2020-05-01"), - to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/download?downloadToken={downloadToken}&useCache=True&api-version=2020-05-01"), - to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/download?downloadToken={downloadToken}&useCache=True&api-version=2020-05-01")}, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.DownloadURL = armbilling.DownloadURL{ - // URL: to.Ptr("https://myaccount.blob.core.windows.net/invoices/1383724.pdf?sv=2019-02-02&sr=b&sp=r"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingSubscriptionInvoicesList.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesListByBillingSubscription.json func ExampleInvoicesClient_NewListByBillingSubscriptionPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1226,7 +697,15 @@ func ExampleInvoicesClient_NewListByBillingSubscriptionPager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewInvoicesClient().NewListByBillingSubscriptionPager("2018-01-01", "2018-06-30", nil) + pager := clientFactory.NewInvoicesClient().NewListByBillingSubscriptionPager(&armbilling.InvoicesClientListByBillingSubscriptionOptions{PeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-01-01"); return t }()), + PeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-06-30"); return t }()), + Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -1240,72 +719,99 @@ func ExampleInvoicesClient_NewListByBillingSubscriptionPager() { // page.InvoiceListResult = armbilling.InvoiceListResult{ // Value: []*armbilling.Invoice{ // { - // Name: to.Ptr("1383723"), + // Name: to.Ptr("E123456789"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions/invoices"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/11000000-0000-0000-0000-000000000000/invoices/1383723"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/11111111-1111-1111-1111-111111111111/invoices/E123456789"), // Properties: &armbilling.InvoiceProperties{ - // AmountDue: &armbilling.Amount{ + // AmountDue: &armbilling.InvoicePropertiesAmountDue{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](8.53), + // }, + // BilledAmount: &armbilling.InvoicePropertiesBilledAmount{ // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2000), + // Value: to.Ptr[float32](33.99), // }, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-16T17:32:28.000Z"); return t}()), - // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T17:32:28.000Z"); return t}()), - // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-15T17:32:28.000Z"); return t}()), - // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T17:32:28.000Z"); return t}()), - // InvoiceType: to.Ptr(armbilling.InvoiceType("AzureServices")), + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-16T17:32:28.000Z"); return t}()), + // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T17:32:28.000Z"); return t}()), + // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-15T17:32:28.000Z"); return t}()), + // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T17:32:28.000Z"); return t}()), + // InvoiceType: to.Ptr(armbilling.InvoiceTypeAzureServices), // PurchaseOrderNumber: to.Ptr("123456"), // Status: to.Ptr(armbilling.InvoiceStatusDue), - // SubscriptionID: to.Ptr("55000000-0000-0000-0000-000000000011"), + // SubscriptionDisplayName: to.Ptr("Contoso Operations Billing"), + // SubscriptionID: to.Ptr("11111111-1111-1111-1111-111111111111"), // }, // }, // { - // Name: to.Ptr("1383724"), + // Name: to.Ptr("G123456789"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions/invoices"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/11000000-0000-0000-0000-000000000000/invoices/1383724"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/11111111-1111-1111-1111-111111111111/invoices/G123456789"), // Properties: &armbilling.InvoiceProperties{ - // AmountDue: &armbilling.Amount{ + // AmountDue: &armbilling.InvoicePropertiesAmountDue{ // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2000), + // Value: to.Ptr[float32](15.53), // }, - // BilledAmount: &armbilling.Amount{ + // BilledAmount: &armbilling.InvoicePropertiesBilledAmount{ // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2000), + // Value: to.Ptr[float32](55.99), // }, - // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // Documents: []*armbilling.Document{ + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-16T17:32:28.000Z"); return t}()), + // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T17:32:28.000Z"); return t}()), + // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-15T17:32:28.000Z"); return t}()), + // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T17:32:28.000Z"); return t}()), + // InvoiceType: to.Ptr(armbilling.InvoiceTypeAzureMarketplace), + // PurchaseOrderNumber: to.Ptr("123456"), + // Status: to.Ptr(armbilling.InvoiceStatusDue), + // SubscriptionDisplayName: to.Ptr("Contoso Operations Billing"), + // SubscriptionID: to.Ptr("11111111-1111-1111-1111-111111111111"), + // }, + // }, + // { + // Name: to.Ptr("E987654321"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions/invoices"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/11111111-1111-1111-1111-111111111111/invoices/E987654321"), + // Properties: &armbilling.InvoiceProperties{ + // AmountDue: &armbilling.InvoicePropertiesAmountDue{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](8.53), + // }, + // BilledAmount: &armbilling.InvoicePropertiesBilledAmount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](33.99), + // }, + // Documents: []*armbilling.InvoiceDocument{ // { - // Kind: to.Ptr(armbilling.DocumentTypeInvoice), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/11000000-0000-0000-0000-000000000000/invoices/1383724/download"), + // Name: to.Ptr("12345678"), + // Kind: to.Ptr(armbilling.InvoiceDocumentTypeInvoice), // }}, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-01T17:32:28.000Z"); return t}()), - // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T17:32:28.000Z"); return t}()), - // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-02T17:32:28.000Z"); return t}()), - // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T17:32:28.000Z"); return t}()), - // InvoiceType: to.Ptr(armbilling.InvoiceTypeAzureMarketplace), - // Payments: []*armbilling.PaymentProperties{ + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-16T17:32:28.000Z"); return t}()), + // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-01T17:32:28.000Z"); return t}()), + // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-15T17:32:28.000Z"); return t}()), + // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-01T17:32:28.000Z"); return t}()), + // InvoiceType: to.Ptr(armbilling.InvoiceTypeAzureSupport), + // Payments: []*armbilling.Payment{ // { - // Amount: &armbilling.Amount{ + // Amount: &armbilling.PaymentAmount{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](2000), // }, - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-14T17:32:28.000Z"); return t}()), + // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-14T17:32:28.000Z"); return t}()), // PaymentMethodFamily: to.Ptr(armbilling.PaymentMethodFamilyCreditCard), // PaymentMethodType: to.Ptr("visa"), // PaymentType: to.Ptr("credited"), // }}, // PurchaseOrderNumber: to.Ptr("123456"), - // Status: to.Ptr(armbilling.InvoiceStatusPaid), - // SubscriptionID: to.Ptr("55000000-0000-0000-0000-000000000011"), + // Status: to.Ptr(armbilling.InvoiceStatusDue), + // SubscriptionDisplayName: to.Ptr("Contoso Operations Billing"), + // SubscriptionID: to.Ptr("11111111-1111-1111-1111-111111111111"), // }, // }}, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingSubscriptionInvoice.json -func ExampleInvoicesClient_GetBySubscriptionAndInvoiceID() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesGet.json +func ExampleInvoicesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -1315,7 +821,7 @@ func ExampleInvoicesClient_GetBySubscriptionAndInvoiceID() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewInvoicesClient().GetBySubscriptionAndInvoiceID(ctx, "{invoiceName}", nil) + res, err := clientFactory.NewInvoicesClient().Get(ctx, "G123456789", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -1323,102 +829,70 @@ func ExampleInvoicesClient_GetBySubscriptionAndInvoiceID() { _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Invoice = armbilling.Invoice{ - // Name: to.Ptr("1383724"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions/invoices"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/11000000-0000-0000-0000-000000000000/invoices/1383724"), + // Name: to.Ptr("G123456789"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/invoices"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/G123456789"), // Properties: &armbilling.InvoiceProperties{ - // AmountDue: &armbilling.Amount{ + // AmountDue: &armbilling.InvoicePropertiesAmountDue{ // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2000), + // Value: to.Ptr[float32](8.53), // }, - // BilledAmount: &armbilling.Amount{ + // AzurePrepaymentApplied: &armbilling.InvoicePropertiesAzurePrepaymentApplied{ // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2000), + // Value: to.Ptr[float32](25.46), + // }, + // BilledAmount: &armbilling.InvoicePropertiesBilledAmount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](33.99), // }, // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // Documents: []*armbilling.Document{ + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // CreditAmount: &armbilling.InvoicePropertiesCreditAmount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](0), + // }, + // DocumentType: to.Ptr(armbilling.InvoiceDocumentTypeInvoice), + // Documents: []*armbilling.InvoiceDocument{ // { - // Kind: to.Ptr(armbilling.DocumentTypeInvoice), - // Source: to.Ptr(armbilling.DocumentSourceDRS), - // URL: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/11000000-0000-0000-0000-000000000000/invoices/1383724/download"), - // }}, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-01T17:32:28.000Z"); return t}()), - // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T17:32:28.000Z"); return t}()), - // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-02T17:32:28.000Z"); return t}()), - // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T17:32:28.000Z"); return t}()), - // InvoiceType: to.Ptr(armbilling.InvoiceTypeAzureMarketplace), - // Payments: []*armbilling.PaymentProperties{ + // Name: to.Ptr("12345678"), + // Kind: to.Ptr(armbilling.InvoiceDocumentTypeInvoice), + // }, // { - // Amount: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](2000), - // }, - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-14T17:32:28.000Z"); return t}()), - // PaymentMethodFamily: to.Ptr(armbilling.PaymentMethodFamilyCreditCard), - // PaymentMethodType: to.Ptr("visa"), - // PaymentType: to.Ptr("credited"), + // Name: to.Ptr("22345678"), + // Kind: to.Ptr(armbilling.InvoiceDocumentTypeTaxReceipt), // }}, + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-16T17:32:28.000Z"); return t}()), + // FreeAzureCreditApplied: &armbilling.InvoicePropertiesFreeAzureCreditApplied{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](0), + // }, + // InvoiceDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T17:32:28.000Z"); return t}()), + // InvoicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-15T17:32:28.000Z"); return t}()), + // InvoicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T17:32:28.000Z"); return t}()), + // IsMonthlyInvoice: to.Ptr(false), // PurchaseOrderNumber: to.Ptr("123456"), - // Status: to.Ptr(armbilling.InvoiceStatusPaid), - // SubscriptionID: to.Ptr("55000000-0000-0000-0000-000000000011"), + // RebillDetails: &armbilling.InvoicePropertiesRebillDetails{ + // CreditNoteDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/CreditNote2"), + // InvoiceDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/I000002"), + // RebillDetails: &armbilling.RebillDetails{ + // CreditNoteDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/CreditNote"), + // InvoiceDocumentID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/I000001"), + // }, + // }, + // SpecialTaxationType: to.Ptr(armbilling.SpecialTaxationTypeSubtotalLevel), + // Status: to.Ptr(armbilling.InvoiceStatusDue), + // SubTotal: &armbilling.InvoicePropertiesSubTotal{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](33.99), + // }, + // TaxAmount: &armbilling.InvoicePropertiesTaxAmount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](1), + // }, + // TotalAmount: &armbilling.InvoicePropertiesTotalAmount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](7.53), + // }, // }, // } } - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingSubscriptionInvoiceDownload.json -func ExampleInvoicesClient_BeginDownloadBillingSubscriptionInvoice() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbilling.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewInvoicesClient().BeginDownloadBillingSubscriptionInvoice(ctx, "{invoiceName}", "DRS_12345", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.DownloadURL = armbilling.DownloadURL{ - // URL: to.Ptr("https://myaccount.blob.core.windows.net/invoices/1383724.pdf?sv=2019-02-02&sr=b&sig=sp=r"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/MultipleBillingSubscriptionInvoiceDownload.json -func ExampleInvoicesClient_BeginDownloadMultipleBillingSubscriptionInvoices() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbilling.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewInvoicesClient().BeginDownloadMultipleBillingSubscriptionInvoices(ctx, []*string{ - to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}/download?downloadToken={downloadToken}&useCache=True&api-version=2020-05-01"), - to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}/download?downloadToken={downloadToken}&useCache=True&api-version=2020-05-01"), - to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}/download?downloadToken={downloadToken}&useCache=True&api-version=2020-05-01")}, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.DownloadURL = armbilling.DownloadURL{ - // URL: to.Ptr("https://myaccount.blob.core.windows.net/invoices/1383724.pdf?sv=2019-02-02&sr=b&sp=r"), - // } -} diff --git a/sdk/resourcemanager/billing/armbilling/invoicesections_client.go b/sdk/resourcemanager/billing/armbilling/invoicesections_client.go index 459638d060de..a53638dad098 100644 --- a/sdk/resourcemanager/billing/armbilling/invoicesections_client.go +++ b/sdk/resourcemanager/billing/armbilling/invoicesections_client.go @@ -11,13 +11,15 @@ package armbilling import ( "context" "errors" + "net/http" + "net/url" + "strconv" + "strings" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" ) // InvoiceSectionsClient contains the methods for the InvoiceSections group. @@ -44,11 +46,11 @@ func NewInvoiceSectionsClient(credential azcore.TokenCredential, options *arm.Cl // agreement type Microsoft Customer Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingProfileName - The ID that uniquely identifies a billing profile. // - invoiceSectionName - The ID that uniquely identifies an invoice section. -// - parameters - The new or updated invoice section. +// - parameters - An invoice section. // - options - InvoiceSectionsClientBeginCreateOrUpdateOptions contains the optional parameters for the InvoiceSectionsClient.BeginCreateOrUpdate // method. func (client *InvoiceSectionsClient) BeginCreateOrUpdate(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, parameters InvoiceSection, options *InvoiceSectionsClientBeginCreateOrUpdateOptions) (*runtime.Poller[InvoiceSectionsClientCreateOrUpdateResponse], error) { @@ -58,7 +60,8 @@ func (client *InvoiceSectionsClient) BeginCreateOrUpdate(ctx context.Context, bi return nil, err } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[InvoiceSectionsClientCreateOrUpdateResponse]{ - Tracer: client.internal.Tracer(), + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) return poller, err } else { @@ -72,7 +75,7 @@ func (client *InvoiceSectionsClient) BeginCreateOrUpdate(ctx context.Context, bi // type Microsoft Customer Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 func (client *InvoiceSectionsClient) createOrUpdate(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, parameters InvoiceSection, options *InvoiceSectionsClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "InvoiceSectionsClient.BeginCreateOrUpdate" @@ -87,7 +90,7 @@ func (client *InvoiceSectionsClient) createOrUpdate(ctx context.Context, billing if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -114,7 +117,7 @@ func (client *InvoiceSectionsClient) createOrUpdateCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -123,11 +126,91 @@ func (client *InvoiceSectionsClient) createOrUpdateCreateRequest(ctx context.Con return req, nil } +// BeginDelete - Deletes an invoice section. The operation is supported for billing accounts with agreement type Microsoft +// Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - invoiceSectionName - The ID that uniquely identifies an invoice section. +// - options - InvoiceSectionsClientBeginDeleteOptions contains the optional parameters for the InvoiceSectionsClient.BeginDelete +// method. +func (client *InvoiceSectionsClient) BeginDelete(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, options *InvoiceSectionsClientBeginDeleteOptions) (*runtime.Poller[InvoiceSectionsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, billingAccountName, billingProfileName, invoiceSectionName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[InvoiceSectionsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[InvoiceSectionsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Deletes an invoice section. The operation is supported for billing accounts with agreement type Microsoft Customer +// Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *InvoiceSectionsClient) deleteOperation(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, options *InvoiceSectionsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "InvoiceSectionsClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *InvoiceSectionsClient) deleteCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, options *InvoiceSectionsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if invoiceSectionName == "" { + return nil, errors.New("parameter invoiceSectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + // Get - Gets an invoice section by its ID. The operation is supported only for billing accounts with agreement type Microsoft // Customer Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingProfileName - The ID that uniquely identifies a billing profile. // - invoiceSectionName - The ID that uniquely identifies an invoice section. @@ -174,7 +257,7 @@ func (client *InvoiceSectionsClient) getCreateRequest(ctx context.Context, billi return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -192,7 +275,7 @@ func (client *InvoiceSectionsClient) getHandleResponse(resp *http.Response) (Inv // NewListByBillingProfilePager - Lists the invoice sections that a user has access to. The operation is supported only for // billing accounts with agreement type Microsoft Customer Agreement. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingProfileName - The ID that uniquely identifies a billing profile. // - options - InvoiceSectionsClientListByBillingProfileOptions contains the optional parameters for the InvoiceSectionsClient.NewListByBillingProfilePager @@ -236,7 +319,28 @@ func (client *InvoiceSectionsClient) listByBillingProfileCreateRequest(ctx conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.IncludeDeleted != nil { + reqQP.Set("includeDeleted", strconv.FormatBool(*options.IncludeDeleted)) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -250,3 +354,70 @@ func (client *InvoiceSectionsClient) listByBillingProfileHandleResponse(resp *ht } return result, nil } + +// ValidateDeleteEligibility - Validates if the invoice section can be deleted. The operation is supported for billing accounts +// with agreement type Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - invoiceSectionName - The ID that uniquely identifies an invoice section. +// - options - InvoiceSectionsClientValidateDeleteEligibilityOptions contains the optional parameters for the InvoiceSectionsClient.ValidateDeleteEligibility +// method. +func (client *InvoiceSectionsClient) ValidateDeleteEligibility(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, options *InvoiceSectionsClientValidateDeleteEligibilityOptions) (InvoiceSectionsClientValidateDeleteEligibilityResponse, error) { + var err error + const operationName = "InvoiceSectionsClient.ValidateDeleteEligibility" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.validateDeleteEligibilityCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, options) + if err != nil { + return InvoiceSectionsClientValidateDeleteEligibilityResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return InvoiceSectionsClientValidateDeleteEligibilityResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return InvoiceSectionsClientValidateDeleteEligibilityResponse{}, err + } + resp, err := client.validateDeleteEligibilityHandleResponse(httpResp) + return resp, err +} + +// validateDeleteEligibilityCreateRequest creates the ValidateDeleteEligibility request. +func (client *InvoiceSectionsClient) validateDeleteEligibilityCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, options *InvoiceSectionsClientValidateDeleteEligibilityOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/validateDeleteEligibility" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if invoiceSectionName == "" { + return nil, errors.New("parameter invoiceSectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// validateDeleteEligibilityHandleResponse handles the ValidateDeleteEligibility response. +func (client *InvoiceSectionsClient) validateDeleteEligibilityHandleResponse(resp *http.Response) (InvoiceSectionsClientValidateDeleteEligibilityResponse, error) { + result := InvoiceSectionsClientValidateDeleteEligibilityResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeleteInvoiceSectionEligibilityResult); err != nil { + return InvoiceSectionsClientValidateDeleteEligibilityResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/invoicesections_client_example_test.go b/sdk/resourcemanager/billing/armbilling/invoicesections_client_example_test.go index 50568d6f3273..81da20c235c9 100644 --- a/sdk/resourcemanager/billing/armbilling/invoicesections_client_example_test.go +++ b/sdk/resourcemanager/billing/armbilling/invoicesections_client_example_test.go @@ -18,8 +18,8 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/InvoiceSectionsListByBillingProfile.json -func ExampleInvoiceSectionsClient_NewListByBillingProfilePager() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsValidateDeleteEligibilityFailure.json +func ExampleInvoiceSectionsClient_ValidateDeleteEligibility_invoiceSectionsValidateDeleteEligibilityFailure() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -29,61 +29,79 @@ func ExampleInvoiceSectionsClient_NewListByBillingProfilePager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewInvoiceSectionsClient().NewListByBillingProfilePager("{billingAccountName}", "{billingProfileName}", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.InvoiceSectionListResult = armbilling.InvoiceSectionListResult{ - // Value: []*armbilling.InvoiceSection{ - // { - // Name: to.Ptr("22000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/22000000-0000-0000-0000-000000000000"), - // Properties: &armbilling.InvoiceSectionProperties{ - // DisplayName: to.Ptr("invoiceSection1"), - // Labels: map[string]*string{ - // "costCategory": to.Ptr("Support"), - // "pcCode": to.Ptr("A123456"), - // }, - // State: to.Ptr(armbilling.InvoiceSectionStateActive), - // SystemID: to.Ptr("XX1X-XXAA-XXX-ZZZ"), - // Tags: map[string]*string{ - // "costCategory": to.Ptr("Support"), - // "pcCode": to.Ptr("A123456"), - // }, - // }, - // }, - // { - // Name: to.Ptr("22000000-0000-0000-0000-000000000011"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/22000000-0000-0000-0000-000000000011"), - // Properties: &armbilling.InvoiceSectionProperties{ - // DisplayName: to.Ptr("invoiceSection2"), - // Labels: map[string]*string{ - // "costCategory": to.Ptr("Marketing"), - // "pcCode": to.Ptr("Z223456"), - // }, - // State: to.Ptr(armbilling.InvoiceSectionStateRestricted), - // SystemID: to.Ptr("YY1X-BBAA-XXX-ZZZ"), - // Tags: map[string]*string{ - // "costCategory": to.Ptr("Marketing"), - // "pcCode": to.Ptr("Z223456"), - // }, - // TargetCloud: to.Ptr(armbilling.TargetCloudUSSec), - // }, - // }}, - // } + res, err := clientFactory.NewInvoiceSectionsClient().ValidateDeleteEligibility(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "yyyy-yyyy-yyy-yyy", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DeleteInvoiceSectionEligibilityResult = armbilling.DeleteInvoiceSectionEligibilityResult{ + // EligibilityDetails: []*armbilling.DeleteInvoiceSectionEligibilityDetail{ + // { + // Code: to.Ptr(armbilling.DeleteInvoiceSectionEligibilityCodeActiveBillingSubscriptions), + // Message: to.Ptr("There are active or disabled subscriptions assigned to the invoice section. Either move the subscription to another invoice section or delete the subscriptions and then try deleting the invoice section."), + // }, + // { + // Code: to.Ptr(armbilling.DeleteInvoiceSectionEligibilityCodeLastInvoiceSection), + // Message: to.Ptr("This is the only invoice section in this billing profile so it can’t be deleted."), + // }, + // { + // Code: to.Ptr(armbilling.DeleteInvoiceSectionEligibilityCodeActiveAzurePlans), + // Message: to.Ptr("This is the invoice section that was created when its billing profile was created so it can’t be deleted."), + // }, + // { + // Code: to.Ptr(armbilling.DeleteInvoiceSectionEligibilityCodeReservedInstances), + // Message: to.Ptr("The invoice section has the RI asset with a billing plan."), + // }}, + // EligibilityStatus: to.Ptr(armbilling.DeleteInvoiceSectionEligibilityStatusNotAllowed), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsValidateDeleteEligibilitySuccess.json +func ExampleInvoiceSectionsClient_ValidateDeleteEligibility_invoiceSectionsValidateDeleteEligibilitySuccess() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewInvoiceSectionsClient().ValidateDeleteEligibility(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "yyyy-yyyy-yyy-yyy", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DeleteInvoiceSectionEligibilityResult = armbilling.DeleteInvoiceSectionEligibilityResult{ + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsDelete.json +func ExampleInvoiceSectionsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewInvoiceSectionsClient().BeginDelete(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "yyyy-yyyy-yyy-yyy", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/InvoiceSection.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsGet.json func ExampleInvoiceSectionsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -94,7 +112,7 @@ func ExampleInvoiceSectionsClient_Get() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewInvoiceSectionsClient().Get(ctx, "{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", nil) + res, err := clientFactory.NewInvoiceSectionsClient().Get(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "yyyy-yyyy-yyy-yyy", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -102,17 +120,12 @@ func ExampleInvoiceSectionsClient_Get() { _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.InvoiceSection = armbilling.InvoiceSection{ - // Name: to.Ptr("{invoiceSectionName}"), + // Name: to.Ptr("invoice-section-1"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/invoice-section-1"), // Properties: &armbilling.InvoiceSectionProperties{ - // DisplayName: to.Ptr("invoiceSection1"), - // Labels: map[string]*string{ - // "costCategory": to.Ptr("Support"), - // "pcCode": to.Ptr("A123456"), - // }, - // State: to.Ptr(armbilling.InvoiceSectionStateActive), - // SystemID: to.Ptr("XX1X-XXAA-XXX-ZZZ"), + // DisplayName: to.Ptr("Invoice Section 1"), + // SystemID: to.Ptr("yyyy-yyyy-yyy-yyy"), // Tags: map[string]*string{ // "costCategory": to.Ptr("Support"), // "pcCode": to.Ptr("A123456"), @@ -121,7 +134,7 @@ func ExampleInvoiceSectionsClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/PutInvoiceSection.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsCreateOrUpdate.json func ExampleInvoiceSectionsClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -132,10 +145,10 @@ func ExampleInvoiceSectionsClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := clientFactory.NewInvoiceSectionsClient().BeginCreateOrUpdate(ctx, "{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", armbilling.InvoiceSection{ + poller, err := clientFactory.NewInvoiceSectionsClient().BeginCreateOrUpdate(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "invoice-section-1", armbilling.InvoiceSection{ Properties: &armbilling.InvoiceSectionProperties{ - DisplayName: to.Ptr("invoiceSection1"), - Labels: map[string]*string{ + DisplayName: to.Ptr("Invoice Section 1"), + Tags: map[string]*string{ "costCategory": to.Ptr("Support"), "pcCode": to.Ptr("A123456"), }, @@ -152,16 +165,94 @@ func ExampleInvoiceSectionsClient_BeginCreateOrUpdate() { _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.InvoiceSection = armbilling.InvoiceSection{ - // Name: to.Ptr("{invoiceSectionName}"), + // Name: to.Ptr("invoice-section-1"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/invoice-section-1"), // Properties: &armbilling.InvoiceSectionProperties{ - // DisplayName: to.Ptr("invoiceSection1"), - // Labels: map[string]*string{ + // DisplayName: to.Ptr("Invoice Section 1"), + // SystemID: to.Ptr("yyyy-yyyy-yyy-yyy"), + // Tags: map[string]*string{ // "costCategory": to.Ptr("Support"), // "pcCode": to.Ptr("A123456"), // }, - // SystemID: to.Ptr("XX1X-XXAA-XXX-ZZZ"), // }, // } } + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsListByBillingProfile.json +func ExampleInvoiceSectionsClient_NewListByBillingProfilePager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewInvoiceSectionsClient().NewListByBillingProfilePager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", &armbilling.InvoiceSectionsClientListByBillingProfileOptions{IncludeDeleted: to.Ptr(true), + Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.InvoiceSectionListResult = armbilling.InvoiceSectionListResult{ + // Value: []*armbilling.InvoiceSection{ + // { + // Name: to.Ptr("invoice-section-1"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/invoice-section-1"), + // Properties: &armbilling.InvoiceSectionProperties{ + // DisplayName: to.Ptr("Invoice Section 1"), + // State: to.Ptr(armbilling.InvoiceSectionStateActive), + // SystemID: to.Ptr("yyyy-yyyy-yyy-yyy"), + // Tags: map[string]*string{ + // "costCategory": to.Ptr("Support"), + // "pcCode": to.Ptr("A123456"), + // }, + // }, + // }, + // { + // Name: to.Ptr("invoice-section-2"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/invoice-section-2"), + // Properties: &armbilling.InvoiceSectionProperties{ + // DisplayName: to.Ptr("Invoice Section 2"), + // ReasonCode: to.Ptr(armbilling.InvoiceSectionStateReasonCodePastDue), + // State: to.Ptr(armbilling.InvoiceSectionStateWarned), + // SystemID: to.Ptr("zzzz-zzzz-zzz-zzz"), + // Tags: map[string]*string{ + // "costCategory": to.Ptr("Marketing"), + // "pcCode": to.Ptr("Z345678"), + // }, + // }, + // }, + // { + // Name: to.Ptr("invoice-section-3"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/invoice-section-3"), + // Properties: &armbilling.InvoiceSectionProperties{ + // DisplayName: to.Ptr("Invoice Section 3"), + // State: to.Ptr(armbilling.InvoiceSectionStateDeleted), + // SystemID: to.Ptr("aaaa-aaaa-aaa-aaa"), + // Tags: map[string]*string{ + // "costCategory": to.Ptr("Support"), + // "pcCode": to.Ptr("A123456"), + // }, + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/billing/armbilling/models.go b/sdk/resourcemanager/billing/armbilling/models.go index d4990596fdf2..89c0d9b90384 100644 --- a/sdk/resourcemanager/billing/armbilling/models.go +++ b/sdk/resourcemanager/billing/armbilling/models.go @@ -10,71 +10,291 @@ package armbilling import "time" +// AcceptTransferProperties - Request parameters to accept transfer. +type AcceptTransferProperties struct { + // Request parameters to accept transfer. + ProductDetails []*ProductDetails +} + +// AcceptTransferRequest - Request parameters to accept transfer. +type AcceptTransferRequest struct { + // Request parameters to accept transfer. + Properties *AcceptTransferProperties +} + // Account - A billing account. type Account struct { - // The properties of the billing account. + // A billing account. Properties *AccountProperties - // READ-ONLY; Resource Id. + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // READ-ONLY; Resource name. + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Resource type. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// AccountListResult - The list of billing accounts. +// AccountListResult - A container for a list of resources type AccountListResult struct { // READ-ONLY; The link (url) to the next page of results. NextLink *string - // READ-ONLY; The list of billing accounts. + // READ-ONLY; The list of resources. Value []*Account } -// AccountProperties - The properties of the billing account. -type AccountProperties struct { - // The billing profiles associated with the billing account. By default this is not populated, unless it's specified in $expand. - BillingProfiles *ProfilesOnExpand +// AccountPatch - A billing account. +type AccountPatch struct { + // A billing account. + Properties *AccountProperties + + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// AccountPolicy - A policy at billing account scope. +type AccountPolicy struct { + // A policy at billing account scope. + Properties *AccountPolicyProperties + + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// AccountPolicyProperties - A policy at billing account scope. +type AccountPolicyProperties struct { + // The policies for Enterprise Agreement enrollments. + EnterpriseAgreementPolicies *AccountPolicyPropertiesEnterpriseAgreementPolicies + + // The policy that controls whether Azure marketplace purchases are allowed. + MarketplacePurchases *MarketplacePurchasesPolicy + + // List of all policies defined at the billing scope. + Policies []*PolicySummary + + // The policy that controls whether Azure reservation purchases are allowed. + ReservationPurchases *ReservationPurchasesPolicy + + // The policy that controls whether users with Azure savings plan purchase are allowed. + SavingsPlanPurchases *SavingsPlanPurchasesPolicy + + // READ-ONLY; The provisioning state of the resource during a long-running operation. + ProvisioningState *ProvisioningState +} + +// AccountPolicyPropertiesEnterpriseAgreementPolicies - The policies for Enterprise Agreement enrollments. +type AccountPolicyPropertiesEnterpriseAgreementPolicies struct { + // The policy that controls whether account owner can view charges. + AccountOwnerViewCharges *EnrollmentAccountOwnerViewCharges - // The departments associated to the enrollment. - Departments []*Department + // The state showing the enrollment auth level. + AuthenticationType *EnrollmentAuthLevelState + // The policy that controls whether department admin can view charges. + DepartmentAdminViewCharges *EnrollmentDepartmentAdminViewCharges +} + +// AccountProperties - A billing account. +type AccountProperties struct { // The billing account name. DisplayName *string - // The accounts associated to the enrollment. - EnrollmentAccounts []*EnrollmentAccount + // The properties of an enrollment. + EnrollmentDetails *AccountPropertiesEnrollmentDetails + + // Indicates whether or not the billing account has any billing profiles. + HasNoBillingProfiles *bool - // Notification email address, only for legacy accounts + // Indicates whether user has read access to the billing account. + HasReadAccess *bool + + // Notification email address for legacy account. Available for agreement type Microsoft Online Services Program. NotificationEmailAddress *string + // The tenant that was used to set up the billing account. By default, only users from this tenant can get role assignments + // on the billing account and all purchases are provisioned in this tenant. + PrimaryBillingTenantID *string + + // Describes the registration number of the organization linked with the billing account. + RegistrationNumber *AccountPropertiesRegistrationNumber + // The address of the individual or organization that is responsible for the billing account. - SoldTo *AddressDetails + SoldTo *AccountPropertiesSoldTo + + // A list of tax identifiers for the billing account. + TaxIDs []*TaxIdentifier // READ-ONLY; The current status of the billing account. AccountStatus *AccountStatus + // READ-ONLY; Reason for the specified billing account status. + AccountStatusReasonCode *BillingAccountStatusReasonCode + + // READ-ONLY; The tier of the account. + AccountSubType *AccountSubType + // READ-ONLY; The type of customer. AccountType *AccountType // READ-ONLY; The type of agreement. AgreementType *AgreementType - // READ-ONLY; The details about the associated legacy enrollment. By default this is not populated, unless it's specified - // in $expand. - EnrollmentDetails *Enrollment + // READ-ONLY; Identifies the billing relationships represented by a billing account. The billing relationship may be between + // Microsoft, the customer, and/or a third-party. + BillingRelationshipTypes []*BillingRelationshipType - // READ-ONLY; Indicates whether user has read access to the billing account. - HasReadAccess *bool + // READ-ONLY; The provisioning state of the resource during a long-running operation. + ProvisioningState *ProvisioningState + + // READ-ONLY; Qualifications for pricing on a billing account. Values may be Commercial, Education, Charity or Government. + Qualifications []*string } -// AccountUpdateRequest - The request properties of the billing account that can be updated. -type AccountUpdateRequest struct { - // A billing property. - Properties *AccountProperties +// AccountPropertiesEnrollmentDetails - The properties of an enrollment. +type AccountPropertiesEnrollmentDetails struct { + // The end date of the enrollment. + EndDate *time.Time + + // The properties of an enrollment which are applicable only for indirect enrollments. + IndirectRelationshipInfo *EnrollmentDetailsIndirectRelationshipInfo + + // The purchase order number of the enrollment. + PoNumber *string + + // The start date of the enrollment. + StartDate *time.Time + + // READ-ONLY; The billing cycle for the enrollment. + BillingCycle *string + + // READ-ONLY; The channel type of the enrollment. + Channel *string + + // READ-ONLY; The cloud of the enrollment. + Cloud *string + + // READ-ONLY; The country code of the enrollment. + CountryCode *string + + // READ-ONLY; The billing currency for the enrollment. + Currency *string + + // READ-ONLY; The billing account extension opted by the company. + ExtendedTermOption *ExtendedTermOption + + // READ-ONLY; The contact who receives invoices of the enrollment. + InvoiceRecipient *string + + // READ-ONLY; The language for the enrollment. + Language *string + + // READ-ONLY; Markup status of enrollment, applicable only for indirect enrollments. + MarkupStatus *MarkupStatus + + // READ-ONLY; The support coverage period for the enrollment. + SupportCoverage *string + + // READ-ONLY; The support level offer associated with an enrollment. + SupportLevel *SupportLevel +} + +// AccountPropertiesRegistrationNumber - Describes the registration number of the organization linked with the billing account. +type AccountPropertiesRegistrationNumber struct { + // The unique identification number of the organization linked with the billing account. + ID *string + + // READ-ONLY; Identifies if the registration number is required for the billing account. + Required *bool + + // READ-ONLY; The types of registration number allowed based on the country of the billing account. + Type []*string +} + +// AccountPropertiesSoldTo - The address of the individual or organization that is responsible for the billing account. +type AccountPropertiesSoldTo struct { + // REQUIRED; Address line 1. + AddressLine1 *string + + // REQUIRED; Country code uses ISO 3166-1 Alpha-2 format. + Country *string + + // Address line 2. + AddressLine2 *string + + // Address line 3. + AddressLine3 *string + + // Address city. + City *string + + // Company name. Optional for MCA Individual (Pay-as-you-go). + CompanyName *string + + // Address district. + District *string + + // Email address. + Email *string + + // First name. Optional for MCA Enterprise. + FirstName *string + + // Indicates if the address is incomplete. + IsValidAddress *bool + + // Last name. Optional for MCA Enterprise. + LastName *string + + // Middle name. + MiddleName *string + + // Phone number. + PhoneNumber *string + + // Postal code. + PostalCode *string + + // Address region. + Region *string } // AddressDetails - Address details. @@ -82,7 +302,7 @@ type AddressDetails struct { // REQUIRED; Address line 1. AddressLine1 *string - // REQUIRED; Country code uses ISO2, 2-digit format. + // REQUIRED; Country code uses ISO 3166-1 Alpha-2 format. Country *string // Address line 2. @@ -94,7 +314,7 @@ type AddressDetails struct { // Address city. City *string - // Company name. + // Company name. Optional for MCA Individual (Pay-as-you-go). CompanyName *string // Address district. @@ -103,10 +323,13 @@ type AddressDetails struct { // Email address. Email *string - // First name. + // First name. Optional for MCA Enterprise. FirstName *string - // Last name. + // Indicates if the address is incomplete. + IsValidAddress *bool + + // Last name. Optional for MCA Enterprise. LastName *string // Middle name. @@ -122,35 +345,52 @@ type AddressDetails struct { Region *string } +// AddressValidationResponse - Result of the address validation. +type AddressValidationResponse struct { + // READ-ONLY; Status of the address validation. + Status *AddressValidationStatus + + // READ-ONLY; The list of suggested addresses. + SuggestedAddresses []*AddressDetails + + // READ-ONLY; Validation error message. + ValidationMessage *string +} + // Agreement - An agreement. type Agreement struct { - // The properties of an agreement. + // An agreement. Properties *AgreementProperties - // READ-ONLY; Resource Id. + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // READ-ONLY; Resource name. + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Resource type. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// AgreementListResult - Result of listing agreements. +// AgreementListResult - A container for a list of resources type AgreementListResult struct { // READ-ONLY; The link (url) to the next page of results. NextLink *string - // READ-ONLY; The list of agreements. + // READ-ONLY; The list of resources. Value []*Agreement } -// AgreementProperties - The properties of an agreement. +// AgreementProperties - An agreement. type AgreementProperties struct { - // The list of participants that participates in acceptance of an agreement. - Participants []*Participants - // READ-ONLY; The mode of acceptance for an agreement. AcceptanceMode *AcceptanceMode @@ -158,343 +398,670 @@ type AgreementProperties struct { AgreementLink *string // READ-ONLY; The list of billing profiles associated with agreement and present only for specific agreements. - BillingProfileInfo *ProfileInfo + BillingProfileInfo []*ProfileInfo - // READ-ONLY; The category of the agreement signed by a customer. + // READ-ONLY; The category of the agreement. Category *Category + // READ-ONLY; The name of the agreement signed by a customer. + DisplayName *string + // READ-ONLY; The date from which the agreement is effective. EffectiveDate *time.Time // READ-ONLY; The date when the agreement expires. ExpirationDate *time.Time + // READ-ONLY; The ID of the lead billing account if this agreement is part of the Customer Affiliate Purchase Terms. + LeadBillingAccountName *string + + // READ-ONLY; The list of participants that participates in acceptance of an agreement. + Participants []*Participant + // READ-ONLY; The current status of the agreement. Status *string } // Amount - The amount. type Amount struct { - // Amount value. - Value *float32 - // READ-ONLY; The currency for the amount value. Currency *string + + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 +} + +// AppliedScopeProperties - Properties specific to applied scope type. Not required if not applicable. +type AppliedScopeProperties struct { + // Display name + DisplayName *string + + // Fully-qualified identifier of the management group where the benefit is applied. + ManagementGroupID *string + + // Fully-qualified identifier of the resource group where the benefit is applied. + ResourceGroupID *string + + // Fully-qualified identifier of the subscription where the benefit is applied. + SubscriptionID *string + + // Tenant ID where the savings plan where the benefit is applied. + TenantID *string +} + +// AssociatedTenant - An associated tenant. +type AssociatedTenant struct { + // An associated tenant. + Properties *AssociatedTenantProperties + + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// AssociatedTenantListResult - A container for a list of resources +type AssociatedTenantListResult struct { + // READ-ONLY; The link (url) to the next page of results. + NextLink *string + + // READ-ONLY; The list of resources. + Value []*AssociatedTenant +} + +// AssociatedTenantProperties - An associated tenant. +type AssociatedTenantProperties struct { + // The state determines whether users from the associated tenant can be assigned roles for commerce activities like viewing + // and downloading invoices, managing payments, and making purchases. + BillingManagementState *BillingManagementTenantState + + // The name of the associated tenant. + DisplayName *string + + // The state determines whether subscriptions and licenses can be provisioned in the associated tenant. It can be set to 'Pending' + // to initiate a billing request. + ProvisioningManagementState *ProvisioningTenantState + + // The ID that uniquely identifies a tenant. + TenantID *string + + // READ-ONLY; The unique identifier for the billing request that is created when enabling provisioning for an associated tenant. + ProvisioningBillingRequestID *string + + // READ-ONLY; The provisioning state of the resource during a long-running operation. + ProvisioningState *ProvisioningState } -// AvailableBalance - The latest Azure credit balance. This is the balance available for pay now. +// AvailableBalance - The Available Credit or Payment on Account Balance. The credit balance can be used to settle due or +// past due invoices. type AvailableBalance struct { - // The properties of available balance. + // The Available Credit or Payment on Account Balance. The credit balance can be used to settle due or past due invoices. Properties *AvailableBalanceProperties - // READ-ONLY; Resource Id. + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // READ-ONLY; Resource name. + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Resource type. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// AvailableBalanceProperties - The properties of available balance. +// AvailableBalanceProperties - The Available Credit or Payment on Account Balance. The credit balance can be used to settle +// due or past due invoices. type AvailableBalanceProperties struct { - // READ-ONLY; Balance amount. - Amount *Amount + // Credit amount for immediate payment. + Amount *AvailableBalancePropertiesAmount + + // Total amount of payments on accounts. + TotalPaymentsOnAccount *AvailableBalancePropertiesTotalPaymentsOnAccount + + // READ-ONLY; The list of payments on accounts. + PaymentsOnAccount []*PaymentOnAccount +} + +// AvailableBalancePropertiesAmount - Credit amount for immediate payment. +type AvailableBalancePropertiesAmount struct { + // READ-ONLY; The currency for the amount value. + Currency *string + + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 +} + +// AvailableBalancePropertiesTotalPaymentsOnAccount - Total amount of payments on accounts. +type AvailableBalancePropertiesTotalPaymentsOnAccount struct { + // READ-ONLY; The currency for the amount value. + Currency *string + + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 } // AzurePlan - Details of the Azure plan. type AzurePlan struct { - // The sku id. - SKUID *string + // The ID that uniquely identifies a product. + ProductID *string - // READ-ONLY; The sku description. + // The sku description. SKUDescription *string + + // The ID that uniquely identifies a sku. + SKUID *string +} + +// Beneficiary - Details of the beneficiary. +type Beneficiary struct { + // The ID that uniquely identifies a user in a tenant. + ObjectID *string + + // The ID that uniquely identifies a tenant. + TenantID *string +} + +// CancelSubscriptionRequest - Request parameters for cancel customer subscription. +type CancelSubscriptionRequest struct { + // REQUIRED; Cancellation reason. + CancellationReason *CancellationReason + + // The fully qualified ID that uniquely identifies a customer. + CustomerID *string +} + +// CheckAccessRequest - Request to check access. +type CheckAccessRequest struct { + // List of actions passed in the request body against which the permissions will be checked. + Actions []*string +} + +// CheckAccessResponse - The properties of a check access response. +type CheckAccessResponse struct { + // READ-ONLY; Access Decision, specifies access is allowed or not. + AccessDecision *AccessDecision + + // READ-ONLY; Gets or sets an action. + Action *string +} + +// Commitment towards the benefit. +type Commitment struct { + Amount *float64 + + // The ISO 4217 3-letter currency code for the currency used by this purchase record. + CurrencyCode *string + + // Commitment grain. + Grain *CommitmentGrain } // Customer - A partner's customer. type Customer struct { - // The customer. + // A partner's customer. Properties *CustomerProperties - // READ-ONLY; Resource Id. + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // READ-ONLY; Resource name. + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Resource type. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// CustomerListResult - The list of customers. +// CustomerListResult - A container for a list of resources type CustomerListResult struct { // READ-ONLY; The link (url) to the next page of results. NextLink *string - // READ-ONLY; Total number of records. - TotalCount *int32 - - // READ-ONLY; The list of customers. + // READ-ONLY; The list of resources. Value []*Customer } -// CustomerPolicy - The customer's Policy. +// CustomerPolicy - A policy at customer scope. type CustomerPolicy struct { - // The properties of a customer's policy. + // A policy at customer scope. Properties *CustomerPolicyProperties - // READ-ONLY; Resource Id. + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // READ-ONLY; Resource name. + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Resource type. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// CustomerPolicyProperties - The properties of a customer's policy. +// CustomerPolicyProperties - A policy at customer scope. type CustomerPolicyProperties struct { - // The policy that controls whether the users in customer's organization can view charges at pay-as-you-go prices. - ViewCharges *ViewCharges + // REQUIRED; The policy that controls whether the users in customer's organization can view charges at pay-as-you-go prices. + ViewCharges *ViewChargesPolicy + + // List of all policies defined at the billing scope. + Policies []*PolicySummary + + // READ-ONLY; The provisioning state of the resource during a long-running operation. + ProvisioningState *ProvisioningState } -// CustomerProperties - The properties of a customer. +// CustomerProperties - A partner's customer. type CustomerProperties struct { - // The name of the customer. - DisplayName *string - // Azure plans enabled for the customer. EnabledAzurePlans []*AzurePlan // The list of resellers for which an Azure plan is enabled for the customer. Resellers []*Reseller - // READ-ONLY; The name of the billing profile for the invoice section. + // Dictionary of metadata associated with the resource. Maximum key/value length supported of 256 characters. Keys/value should + // not empty value nor null. Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; The name of the billing profile. BillingProfileDisplayName *string - // READ-ONLY; The ID of the billing profile for the invoice section. + // READ-ONLY; The fully qualified ID that uniquely identifies a billing profile. BillingProfileID *string -} - -// Department - A department. -type Department struct { - // A department. - Properties *DepartmentProperties - // READ-ONLY; Resource Id. - ID *string + // READ-ONLY; The name of the customer. + DisplayName *string - // READ-ONLY; Resource name. - Name *string + // READ-ONLY; Identifies the status of an customer. This is an upcoming property that will be populated in the future. + Status *CustomerStatus - // READ-ONLY; Resource type. - Type *string + // READ-ONLY; The system generated unique identifier for a customer. + SystemID *string } -// DepartmentProperties - The properties of a department. -type DepartmentProperties struct { - // The cost center associated with the department. - CostCenter *string +// DeleteBillingProfileEligibilityDetail - Validation details of delete billing profile eligibility. +type DeleteBillingProfileEligibilityDetail struct { + // Code of the delete invoice section eligibility response. + Code *DeleteBillingProfileEligibilityCode - // The name of the department. - DepartmentName *string + // Validation message. + Message *string +} - // Associated enrollment accounts. By default this is not populated, unless it's specified in $expand. - EnrollmentAccounts []*EnrollmentAccount +// DeleteBillingProfileEligibilityResult - Eligibility to delete a billing profile result. +type DeleteBillingProfileEligibilityResult struct { + // Validation details of delete billing profile eligibility. + EligibilityDetails []*DeleteBillingProfileEligibilityDetail - // The status of the department. - Status *string + // Status describing if billing profile is eligible to be deleted. + EligibilityStatus *DeleteBillingProfileEligibilityStatus } -// Document - The properties of a document. -type Document struct { - // READ-ONLY; The type of the document. - Kind *DocumentType - - // READ-ONLY; The source of the document. ENF for Brazil and DRS for rest of the world. - Source *DocumentSource +// DeleteInvoiceSectionEligibilityDetail - The details of delete invoice section eligibility result. +type DeleteInvoiceSectionEligibilityDetail struct { + // Code for the delete invoice section validation. + Code *DeleteInvoiceSectionEligibilityCode - // READ-ONLY; Document URL. - URL *string + // Validation message. + Message *string } -// DownloadURL - A secure URL that can be used to download a an entity until the URL expires. -type DownloadURL struct { - // READ-ONLY; The time in UTC when the download URL will expire. - ExpiryTime *time.Time +// DeleteInvoiceSectionEligibilityResult - Eligibility to delete an invoice section result. +type DeleteInvoiceSectionEligibilityResult struct { + // A list of delete invoice section eligibility result details. + EligibilityDetails []*DeleteInvoiceSectionEligibilityDetail - // READ-ONLY; The URL to the PDF file. - URL *string + // Status describing if invoice section is eligible to be deleted. + EligibilityStatus *DeleteInvoiceSectionEligibilityStatus } -// Enrollment - The properties of an enrollment. -type Enrollment struct { - // The end date of the enrollment. - EndDate *time.Time +// Department - Optional grouping of enrollment accounts to segment costs into logical groupings and set budgets. +type Department struct { + // Optional grouping of enrollment accounts to segment costs into logical groupings and set budgets. + Properties *DepartmentProperties - // The start date of the enrollment. - StartDate *time.Time + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string - // READ-ONLY; The billing cycle for the enrollment. - BillingCycle *string + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string - // READ-ONLY; The channel type of the enrollment. - Channel *string + // READ-ONLY; The name of the resource + Name *string - // READ-ONLY; The country code of the enrollment. - CountryCode *string + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData - // READ-ONLY; The billing currency for the enrollment. - Currency *string + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} - // READ-ONLY; The language for the enrollment. - Language *string +// DepartmentListResult - A container for a list of resources +type DepartmentListResult struct { + // READ-ONLY; The link (url) to the next page of results. + NextLink *string - // READ-ONLY; The policies for Enterprise Agreement enrollments. - Policies *EnrollmentPolicies + // READ-ONLY; The list of resources. + Value []*Department +} + +// DepartmentProperties - Optional grouping of enrollment accounts to segment costs into logical groupings and set budgets. +type DepartmentProperties struct { + // The cost center associated with the department. + CostCenter *string + + // The name of the department. + DisplayName *string - // READ-ONLY; The current status of the enrollment. + // READ-ONLY; The ID that uniquely identifies the department. + ID *string + + // READ-ONLY; The status of the department. Status *string } -// EnrollmentAccount - An enrollment account. -type EnrollmentAccount struct { - // The properties of an enrollment account. - Properties *EnrollmentAccountProperties +// DetailedTransferStatus - Detailed transfer status. +type DetailedTransferStatus struct { + // Error details for transfer execution. + ErrorDetails *TransferError - // READ-ONLY; Resource Id. - ID *string + // READ-ONLY; The ID of the product that is transferred. + ProductID *string - // READ-ONLY; Resource name. - Name *string + // READ-ONLY; The name of the product that is transferred. + ProductName *string - // READ-ONLY; Resource type. - Type *string + // READ-ONLY; Type of product that is transferred. + ProductType *ProductType + + // READ-ONLY; The SKU of the product that is transferred. + SKUDescription *string + + // READ-ONLY; Transfer status. + TransferStatus *ProductTransferStatus } -// EnrollmentAccountContext - The enrollment account context -type EnrollmentAccountContext struct { - // The cost center associated with the enrollment account. - CostCenter *string +// DocumentDownloadRequest - A list of download details for individual documents. +type DocumentDownloadRequest struct { + // The ID that uniquely identifies an invoice document. This ID may be an identifier for an invoice PDF, a credit note, or + // a tax receipt. If omitted, the most recent invoice PDF for the invoice will be + // returned. + DocumentName *string - // The end date of the enrollment account. - EndDate *time.Time + // The ID that uniquely identifies an invoice. + InvoiceName *string +} - // The ID of the enrollment account. - EnrollmentAccountName *string +// DocumentDownloadResult - A secure URL that can be used to download a an entity until the URL expires. +type DocumentDownloadResult struct { + // READ-ONLY; The time in UTC when the download URL will expire. + ExpiryTime *string - // The start date of the enrollment account. - StartDate *time.Time + // READ-ONLY; The URL to the PDF or .zip file. + URL *string +} + +// EnrollmentAccount - It is an organizational hierarchy within a billing account to administer and manage azure costs. +type EnrollmentAccount struct { + // It is an organizational hierarchy within a billing account to administer and manage azure costs. + Properties *EnrollmentAccountProperties + + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string } -// EnrollmentAccountListResult - Result of listing enrollment accounts. +// EnrollmentAccountListResult - A container for a list of resources type EnrollmentAccountListResult struct { // READ-ONLY; The link (url) to the next page of results. NextLink *string - // READ-ONLY; The list of enrollment accounts. - Value []*EnrollmentAccountSummary + // READ-ONLY; The list of resources. + Value []*EnrollmentAccount } -// EnrollmentAccountProperties - The properties of an enrollment account. +// EnrollmentAccountProperties - It is an organizational hierarchy within a billing account to administer and manage azure +// costs. type EnrollmentAccountProperties struct { + // The cost center associated with the enrollment account. + CostCenter *string + // The name of the enrollment account. - AccountName *string + DisplayName *string - // The owner of the enrollment account. + // Boolean flag which enables subscribers to run development and testing workloads on Azure at special Dev/Test rates. + IsDevTestEnabled *bool + + // READ-ONLY; The owner of the enrollment account. AccountOwner *string - // The enrollment account owner email address. - AccountOwnerEmail *string + // READ-ONLY; The authorization type of the enrollment account. + AuthType *string - // The cost center associated with the enrollment account. - CostCenter *string + // READ-ONLY; The name of the department under which the enrollment account exists. + DepartmentDisplayName *string - // Associated department. By default this is not populated, unless it's specified in $expand. - Department *Department + // READ-ONLY; The ID that uniquely identifies the department. + DepartmentID *string - // The end date of the enrollment account. + // READ-ONLY; The date of expiration of the enrollment account. EndDate *time.Time - // The start date of the enrollment account. + // READ-ONLY; The date from which the enrollment account became valid and functional. StartDate *time.Time - // The status of the enrollment account. + // READ-ONLY; The status of the enrollment account. Status *string } -// EnrollmentAccountSummary - An enrollment account resource. -type EnrollmentAccountSummary struct { - // An enrollment account. - Properties *EnrollmentAccountSummaryProperties +// EnrollmentAccountSubscriptionDetails - The billing properties that can be modified. Available only for the Enterprise Agreement +// Type. +type EnrollmentAccountSubscriptionDetails struct { + // READ-ONLY; The enrollment Account and the subscription association start date. This field is available only for the Enterprise + // Agreement Type. + EnrollmentAccountStartDate *time.Time - // READ-ONLY; Resource Id. - ID *string + // READ-ONLY; The current enrollment account status of the subscription. This field is available only for the Enterprise Agreement + // Type. + SubscriptionEnrollmentAccountStatus *SubscriptionEnrollmentAccountStatus +} - // READ-ONLY; Resource name. - Name *string +// EnrollmentDetails - The properties of an enrollment. +type EnrollmentDetails struct { + // The end date of the enrollment. + EndDate *time.Time - // READ-ONLY; Resource type. - Type *string + // The properties of an enrollment which are applicable only for indirect enrollments. + IndirectRelationshipInfo *EnrollmentDetailsIndirectRelationshipInfo + + // The purchase order number of the enrollment. + PoNumber *string + + // The start date of the enrollment. + StartDate *time.Time + + // READ-ONLY; The billing cycle for the enrollment. + BillingCycle *string + + // READ-ONLY; The channel type of the enrollment. + Channel *string + + // READ-ONLY; The cloud of the enrollment. + Cloud *string + + // READ-ONLY; The country code of the enrollment. + CountryCode *string + + // READ-ONLY; The billing currency for the enrollment. + Currency *string + + // READ-ONLY; The billing account extension opted by the company. + ExtendedTermOption *ExtendedTermOption + + // READ-ONLY; The contact who receives invoices of the enrollment. + InvoiceRecipient *string + + // READ-ONLY; The language for the enrollment. + Language *string + + // READ-ONLY; Markup status of enrollment, applicable only for indirect enrollments. + MarkupStatus *MarkupStatus + + // READ-ONLY; The support coverage period for the enrollment. + SupportCoverage *string + + // READ-ONLY; The support level offer associated with an enrollment. + SupportLevel *SupportLevel } -// EnrollmentAccountSummaryProperties - The properties of the enrollment account. -type EnrollmentAccountSummaryProperties struct { - // READ-ONLY; The account owner's principal name. - PrincipalName *string +// EnrollmentDetailsIndirectRelationshipInfo - The properties of an enrollment which are applicable only for indirect enrollments. +type EnrollmentDetailsIndirectRelationshipInfo struct { + // The billing account name of the partner or the customer for an indirect motion. + BillingAccountName *string + + // The billing profile name of the partner or the customer for an indirect motion. + BillingProfileName *string + + // The display name of the partner or customer for an indirect motion. + DisplayName *string } -// EnrollmentPolicies - The policies for Enterprise Agreement enrollments. -type EnrollmentPolicies struct { - // READ-ONLY; The policy that controls whether Account Owners can view charges. - AccountOwnerViewCharges *bool +// EnterpriseAgreementPolicies - The policies for Enterprise Agreement enrollments. +type EnterpriseAgreementPolicies struct { + // The policy that controls whether account owner can view charges. + AccountOwnerViewCharges *EnrollmentAccountOwnerViewCharges - // READ-ONLY; The policy that controls whether Department Administrators can view charges. - DepartmentAdminViewCharges *bool + // The state showing the enrollment auth level. + AuthenticationType *EnrollmentAuthLevelState - // READ-ONLY; The policy that controls whether Azure marketplace purchases are allowed in the enrollment. - MarketplaceEnabled *bool + // The policy that controls whether department admin can view charges. + DepartmentAdminViewCharges *EnrollmentDepartmentAdminViewCharges +} + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info any - // READ-ONLY; The policy that controls whether Azure reservation purchases are allowed in the enrollment. - ReservedInstancesEnabled *bool + // READ-ONLY; The additional info type. + Type *string } -// ErrorDetails - The details of the error. -type ErrorDetails struct { - // READ-ONLY; Error code. +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo + + // READ-ONLY; The error code. Code *string - // READ-ONLY; The sub details of the error. - Details []*ErrorSubDetailsItem + // READ-ONLY; The error details. + Details []*ErrorDetail - // READ-ONLY; Error message indicating why the operation failed. + // READ-ONLY; The error message. Message *string - // READ-ONLY; The target of the particular error. + // READ-ONLY; The error target. Target *string } -// ErrorResponse - Error response indicates that the service is not able to process the incoming request. The reason is provided -// in the error message. +// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. +// (This also follows the OData error response format.). type ErrorResponse struct { - // The details of the error. - Error *ErrorDetails + // The error object. + Error *ErrorDetail } -type ErrorSubDetailsItem struct { - // READ-ONLY; Error code. - Code *string +// ExtendedStatusDefinitionProperties - Extended status definition properties +type ExtendedStatusDefinitionProperties struct { + // Subscription Id + SubscriptionID *string +} - // READ-ONLY; Error message indicating why the operation failed. +// ExtendedStatusInfo - Extended status information +type ExtendedStatusInfo struct { + // The message giving detailed information about the status code. Message *string - // READ-ONLY; The target of the particular error. - Target *string + // Properties specific to credit line check failure + Properties *ExtendedStatusInfoProperties + + // Status code providing additional information. + StatusCode *string +} + +// ExtendedStatusInfoProperties - Properties specific to credit line check failure +type ExtendedStatusInfoProperties struct { + // The subscription that has failed credit line check. + SubscriptionID *string +} + +// ExternalReference - An external reference. +type ExternalReference struct { + // READ-ONLY; The ID that uniquely identifies an external reference. + ID *string + + // READ-ONLY; The URL of the external reference. + URL *string +} + +// FailedPayment - A failed payment. +type FailedPayment struct { + // READ-ONLY; The date when the payment was attempted. + Date *time.Time + + // READ-ONLY; The reason that the payment failed. + FailedPaymentReason *FailedPaymentReason } -// IndirectRelationshipInfo - The billing profile details of the partner of the customer for an indirect motion. +// IndirectRelationshipInfo - Identifies the billing profile that is linked to another billing profile in indirect purchase +// motion. type IndirectRelationshipInfo struct { // The billing account name of the partner or the customer for an indirect motion. BillingAccountName *string @@ -506,43 +1073,16 @@ type IndirectRelationshipInfo struct { DisplayName *string } -// Instruction - An instruction. -type Instruction struct { - // A billing instruction used during invoice generation. - Properties *InstructionProperties - - // READ-ONLY; Resource Id. - ID *string - - // READ-ONLY; Resource name. - Name *string - - // READ-ONLY; Resource type. - Type *string -} - -// InstructionListResult - The list of billing instructions used during invoice generation. -type InstructionListResult struct { - // READ-ONLY; The link (url) to the next page of results. - NextLink *string - - // READ-ONLY; The list of billing instructions used during invoice generation. - Value []*Instruction +// InitiateTransferProperties - Request parameters to initiate transfer. +type InitiateTransferProperties struct { + // The email ID of the recipient to whom the transfer request is sent. + RecipientEmailID *string } -// InstructionProperties - A billing instruction used during invoice generation. -type InstructionProperties struct { - // REQUIRED; The amount budgeted for this billing instruction. - Amount *float32 - - // REQUIRED; The date this billing instruction is no longer in effect. - EndDate *time.Time - - // REQUIRED; The date this billing instruction goes into effect. - StartDate *time.Time - - // The date this billing instruction was created. - CreationDate *time.Time +// InitiateTransferRequest - Request parameters to initiate transfer. +type InitiateTransferRequest struct { + // Request parameters to initiate transfer. + Properties *InitiateTransferProperties } // Invoice - An invoice. @@ -550,39 +1090,91 @@ type Invoice struct { // An invoice. Properties *InvoiceProperties - // READ-ONLY; Resource Id. + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // READ-ONLY; Resource name. + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Resource type. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// InvoiceListResult - The list of invoices. +// InvoiceDocument - The properties of a document. +type InvoiceDocument struct { + // READ-ONLY; The document numbers for the invoice document. + DocumentNumbers []*string + + // READ-ONLY; The URL to download the invoice document if the source is external to Microsoft.Billing. + ExternalURL *string + + // READ-ONLY; The type of the document. + Kind *InvoiceDocumentType + + // READ-ONLY; The ID that uniquely identifies an invoice document. This ID may be an identifier for an invoice PDF, a credit + // note, or a tax receipt. + Name *string + + // READ-ONLY; The source of the document. ENF for Brazil and DRS for rest of the world. + Source *DocumentSource + + // READ-ONLY; The URL to download the invoice document if the source is internal to Microsoft.Billing. + URL *string +} + +// InvoiceListResult - A container for a list of resources type InvoiceListResult struct { // READ-ONLY; The link (url) to the next page of results. NextLink *string - // READ-ONLY; Total number of records. - TotalCount *int32 - - // READ-ONLY; The list of invoices. + // READ-ONLY; The list of resources. Value []*Invoice } -// InvoiceProperties - The properties of the invoice. +// InvoiceProperties - An invoice. type InvoiceProperties struct { - // READ-ONLY; The amount due as of now. - AmountDue *Amount + // The amount due as of now. + AmountDue *InvoicePropertiesAmountDue + + // The amount of Azure prepayment applied to the charges. This field is applicable to billing accounts with agreement type + // Microsoft Customer Agreement. + AzurePrepaymentApplied *InvoicePropertiesAzurePrepaymentApplied + + // The total charges for the invoice billing period. + BilledAmount *InvoicePropertiesBilledAmount + + // The total refund for returns and cancellations during the invoice billing period. This field is applicable to billing accounts + // with agreement type Microsoft Customer Agreement. + CreditAmount *InvoicePropertiesCreditAmount + + // The amount of free Azure credits applied to the charges. This field is applicable to billing accounts with agreement type + // Microsoft Customer Agreement. + FreeAzureCreditApplied *InvoicePropertiesFreeAzureCreditApplied + + // Rebill details for an invoice. + RebillDetails *InvoicePropertiesRebillDetails + + // The details of a refund request. + RefundDetails *InvoicePropertiesRefundDetails + + // The pre-tax amount due. This field is applicable to billing accounts with agreement type Microsoft Customer Agreement. + SubTotal *InvoicePropertiesSubTotal - // READ-ONLY; The amount of Azure prepayment applied to the charges. This field is applicable to billing accounts with agreement - // type Microsoft Customer Agreement. - AzurePrepaymentApplied *Amount + // The amount of tax charged for the billing period. This field is applicable to billing accounts with agreement type Microsoft + // Customer Agreement. + TaxAmount *InvoicePropertiesTaxAmount - // READ-ONLY; The total charges for the invoice billing period. - BilledAmount *Amount + // The amount due when the invoice was generated. This field is applicable to billing accounts with agreement type Microsoft + // Customer Agreement. + TotalAmount *InvoicePropertiesTotalAmount // READ-ONLY; The Id of the active invoice which is originally billed after this invoice was voided. This field is applicable // to the void invoices only. @@ -594,10 +1186,6 @@ type InvoiceProperties struct { // READ-ONLY; The ID of the billing profile for which the invoice is generated. BillingProfileID *string - // READ-ONLY; The total refund for returns and cancellations during the invoice billing period. This field is applicable to - // billing accounts with agreement type Microsoft Customer Agreement. - CreditAmount *Amount - // READ-ONLY; The Id of the invoice which got voided and this credit note was issued as a result. This field is applicable // to the credit notes only. CreditForDocumentID *string @@ -605,23 +1193,22 @@ type InvoiceProperties struct { // READ-ONLY; The type of the document. DocumentType *InvoiceDocumentType - // READ-ONLY; List of documents available to download such as invoice and tax receipt. - Documents []*Document + // READ-ONLY; List of documents available to download and view such as invoice, credit note, or tax receipt. + Documents []*InvoiceDocument // READ-ONLY; The due date for the invoice. DueDate *time.Time - // READ-ONLY; The amount of free Azure credits applied to the charges. This field is applicable to billing accounts with agreement - // type Microsoft Customer Agreement. - FreeAzureCreditApplied *Amount + // READ-ONLY; List of failed payments. + FailedPayments []*FailedPayment // READ-ONLY; The date when the invoice was generated. InvoiceDate *time.Time - // READ-ONLY; The end date of the billing period for which the invoice is generated. + // READ-ONLY; The end date of the billing period for which the invoice is generated. The date is in MM-DD-YYYY format. InvoicePeriodEndDate *time.Time - // READ-ONLY; The start date of the billing period for which the invoice is generated. + // READ-ONLY; The start date of the billing period for which the invoice is generated. The date is in MM-DD-YYYY format. InvoicePeriodStartDate *time.Time // READ-ONLY; Invoice type. @@ -632,201 +1219,367 @@ type InvoiceProperties struct { IsMonthlyInvoice *bool // READ-ONLY; List of payments. - Payments []*PaymentProperties + Payments []*Payment // READ-ONLY; An optional purchase order number for the invoice. PurchaseOrderNumber *string - // READ-ONLY; Rebill details for an invoice. - RebillDetails map[string]*RebillDetails + // READ-ONLY; Identifies the type of tax calculation used for the invoice. The field is applicable only to invoices with special + // tax calculation logic. + SpecialTaxationType *SpecialTaxationType // READ-ONLY; The current status of the invoice. Status *InvoiceStatus - // READ-ONLY; The pre-tax amount due. This field is applicable to billing accounts with agreement type Microsoft Customer - // Agreement. - SubTotal *Amount + // READ-ONLY; The name of the billing subscription for which the invoice is generated. + SubscriptionDisplayName *string // READ-ONLY; The ID of the subscription for which the invoice is generated. SubscriptionID *string +} - // READ-ONLY; The amount of tax charged for the billing period. This field is applicable to billing accounts with agreement - // type Microsoft Customer Agreement. - TaxAmount *Amount +// InvoicePropertiesAmountDue - The amount due as of now. +type InvoicePropertiesAmountDue struct { + // READ-ONLY; The currency for the amount value. + Currency *string - // READ-ONLY; The amount due when the invoice was generated. This field is applicable to billing accounts with agreement type - // Microsoft Customer Agreement. - TotalAmount *Amount + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 } -// InvoiceSection - An invoice section. -type InvoiceSection struct { - // The properties of an invoice section. - Properties *InvoiceSectionProperties +// InvoicePropertiesAzurePrepaymentApplied - The amount of Azure prepayment applied to the charges. This field is applicable +// to billing accounts with agreement type Microsoft Customer Agreement. +type InvoicePropertiesAzurePrepaymentApplied struct { + // READ-ONLY; The currency for the amount value. + Currency *string - // READ-ONLY; Resource Id. - ID *string + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 +} - // READ-ONLY; Resource name. - Name *string +// InvoicePropertiesBilledAmount - The total charges for the invoice billing period. +type InvoicePropertiesBilledAmount struct { + // READ-ONLY; The currency for the amount value. + Currency *string - // READ-ONLY; Resource type. - Type *string + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 } -// InvoiceSectionCreationRequest - The properties of the invoice section. -type InvoiceSectionCreationRequest struct { - // The name of the invoice section. - DisplayName *string -} +// InvoicePropertiesCreditAmount - The total refund for returns and cancellations during the invoice billing period. This +// field is applicable to billing accounts with agreement type Microsoft Customer Agreement. +type InvoicePropertiesCreditAmount struct { + // READ-ONLY; The currency for the amount value. + Currency *string -// InvoiceSectionListResult - The list of invoice sections. -type InvoiceSectionListResult struct { - // READ-ONLY; The link (url) to the next page of results. - NextLink *string + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 +} - // READ-ONLY; Total number of records. - TotalCount *int32 +// InvoicePropertiesFreeAzureCreditApplied - The amount of free Azure credits applied to the charges. This field is applicable +// to billing accounts with agreement type Microsoft Customer Agreement. +type InvoicePropertiesFreeAzureCreditApplied struct { + // READ-ONLY; The currency for the amount value. + Currency *string - // READ-ONLY; The list of invoice sections. - Value []*InvoiceSection + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 } -// InvoiceSectionListWithCreateSubPermissionResult - The list of invoice section properties with create subscription permission. -type InvoiceSectionListWithCreateSubPermissionResult struct { - // The list of invoice section properties with create subscription permission. - Value []*InvoiceSectionWithCreateSubPermission +// InvoicePropertiesRebillDetails - Rebill details for an invoice. +type InvoicePropertiesRebillDetails struct { + // READ-ONLY; The ID of credit note. + CreditNoteDocumentID *string - // READ-ONLY; The link (url) to the next page of results. - NextLink *string + // READ-ONLY; The ID of invoice. + InvoiceDocumentID *string + + // READ-ONLY; The rebill details of an invoice. + RebillDetails *RebillDetails } -// InvoiceSectionProperties - The properties of an invoice section. -type InvoiceSectionProperties struct { - // The name of the invoice section. - DisplayName *string +// InvoicePropertiesRefundDetails - The details of a refund request. +type InvoicePropertiesRefundDetails struct { + // The amount refunded. + AmountRefunded *RefundDetailsSummaryAmountRefunded - // Dictionary of metadata associated with the invoice section. - Labels map[string]*string + // The amount of refund requested. + AmountRequested *RefundDetailsSummaryAmountRequested - // Dictionary of metadata associated with the invoice section. Maximum key/value length supported of 256 characters. Keys/value - // should not empty value nor null. Keys can not contain < > % & \ ? / - Tags map[string]*string + // READ-ONLY; Date when the refund was approved. + ApprovedOn *time.Time - // READ-ONLY; Identifies the state of an invoice section. - State *InvoiceSectionState + // READ-ONLY; Date when the refund was completed. + CompletedOn *time.Time - // READ-ONLY; The system generated unique identifier for an invoice section. - SystemID *string + // READ-ONLY; The invoice ID of the rebill invoice for a refund. + RebillInvoiceID *string - // READ-ONLY; Identifies the cloud environments that are associated with an invoice section. This is a system managed optional - // field and gets updated as the invoice section gets associated with accounts in various - // clouds. - TargetCloud *TargetCloud -} + // READ-ONLY; The ID of refund operation. + RefundOperationID *string -// InvoiceSectionWithCreateSubPermission - Invoice section properties with create subscription permission. -type InvoiceSectionWithCreateSubPermission struct { - // Enabled azure plans for the associated billing profile. - EnabledAzurePlans []*AzurePlan + // READ-ONLY; The reason for refund. + RefundReason *RefundReasonCode - // READ-ONLY; The name of the billing profile for the invoice section. - BillingProfileDisplayName *string + // READ-ONLY; The status of refund request. + RefundStatus *RefundStatus - // READ-ONLY; The ID of the billing profile for the invoice section. - BillingProfileID *string + // READ-ONLY; Date when the refund was requested. + RequestedOn *time.Time - // READ-ONLY; The billing profile spending limit. - BillingProfileSpendingLimit *SpendingLimitForBillingProfile + // READ-ONLY; The number of transactions refunded. + TransactionCount *int32 +} - // READ-ONLY; The status of the billing profile. - BillingProfileStatus *BillingProfileStatus +// InvoicePropertiesSubTotal - The pre-tax amount due. This field is applicable to billing accounts with agreement type Microsoft +// Customer Agreement. +type InvoicePropertiesSubTotal struct { + // READ-ONLY; The currency for the amount value. + Currency *string - // READ-ONLY; Reason for the specified billing profile status. - BillingProfileStatusReasonCode *StatusReasonCodeForBillingProfile + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 +} + +// InvoicePropertiesTaxAmount - The amount of tax charged for the billing period. This field is applicable to billing accounts +// with agreement type Microsoft Customer Agreement. +type InvoicePropertiesTaxAmount struct { + // READ-ONLY; The currency for the amount value. + Currency *string + + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 +} + +// InvoicePropertiesTotalAmount - The amount due when the invoice was generated. This field is applicable to billing accounts +// with agreement type Microsoft Customer Agreement. +type InvoicePropertiesTotalAmount struct { + // READ-ONLY; The currency for the amount value. + Currency *string + + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 +} + +// InvoiceSection - An invoice section. +type InvoiceSection struct { + // An invoice section. + Properties *InvoiceSectionProperties + + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// InvoiceSectionListResult - A container for a list of resources +type InvoiceSectionListResult struct { + // READ-ONLY; The link (url) to the next page of results. + NextLink *string + + // READ-ONLY; The list of resources. + Value []*InvoiceSection +} + +// InvoiceSectionProperties - An invoice section. +type InvoiceSectionProperties struct { + // The name of the invoice section. + DisplayName *string + + // Reason for the specified invoice section status. + ReasonCode *InvoiceSectionStateReasonCode + + // Identifies the status of an invoice section. + State *InvoiceSectionState + + // Dictionary of metadata associated with the resource. Maximum key/value length supported of 256 characters. Keys/value should + // not empty value nor null. Keys can not contain < > % & \ ? / + Tags map[string]*string + + // Identifies the cloud environments that are associated with an invoice section. This is a system managed optional field + // and gets updated as the invoice section gets associated with accounts in various + // clouds. + TargetCloud *string + + // READ-ONLY; The provisioning state of the resource during a long-running operation. + ProvisioningState *ProvisioningState + + // READ-ONLY; The system generated unique identifier for an invoice section. + SystemID *string +} + +// InvoiceSectionWithCreateSubPermission - Invoice section properties with create subscription permission. +type InvoiceSectionWithCreateSubPermission struct { + // READ-ONLY; The name of the billing profile. + BillingProfileDisplayName *string + + // READ-ONLY; The fully qualified ID that uniquely identifies a billing profile. + BillingProfileID *string + + // READ-ONLY; The billing profile spending limit. + BillingProfileSpendingLimit *SpendingLimit + + // READ-ONLY; The status of the billing profile. + BillingProfileStatus *BillingProfileStatus + + // READ-ONLY; Reason for the specified billing profile status. + BillingProfileStatusReasonCode *BillingProfileStatusReasonCode // READ-ONLY; The system generated unique identifier for a billing profile. BillingProfileSystemID *string + // READ-ONLY; Enabled azure plans for the associated billing profile. + EnabledAzurePlans []*AzurePlan + // READ-ONLY; The name of the invoice section. InvoiceSectionDisplayName *string - // READ-ONLY; The ID of the invoice section. + // READ-ONLY; The fully qualified ID that uniquely identifies an invoice section. InvoiceSectionID *string // READ-ONLY; The system generated unique identifier for an invoice section. InvoiceSectionSystemID *string } -// InvoiceSectionsOnExpand - The invoice sections associated to the billing profile. By default this is not populated, unless -// it's specified in $expand. -type InvoiceSectionsOnExpand struct { - // The invoice sections associated to the billing profile. - Value []*InvoiceSection +// InvoiceSectionWithCreateSubPermissionListResult - A container for a list of resources +type InvoiceSectionWithCreateSubPermissionListResult struct { + // READ-ONLY; The link (url) to the next page of results. + NextLink *string + + // READ-ONLY; The list of resources. + Value []*InvoiceSectionWithCreateSubPermission +} + +// MoveBillingSubscriptionEligibilityResult - Result of the transfer eligibility validation. +type MoveBillingSubscriptionEligibilityResult struct { + // Error details of the transfer eligibility validation. + ErrorDetails *MoveBillingSubscriptionErrorDetails + + // READ-ONLY; Specifies whether the subscription is eligible to be transferred. + IsMoveEligible *bool +} + +// MoveBillingSubscriptionErrorDetails - Error details of the transfer eligibility validation. +type MoveBillingSubscriptionErrorDetails struct { + // Error code of the transfer validation response. + Code *SubscriptionTransferValidationErrorCode + + // Detailed error message explaining the error. + Details *string + + // The error message. + Message *string +} + +// MoveBillingSubscriptionRequest - Request parameters to transfer billing subscription. +type MoveBillingSubscriptionRequest struct { + // The destination enrollment account id. + DestinationEnrollmentAccountID *string + + // The destination invoice section id. + DestinationInvoiceSectionID *string +} + +// MoveProductEligibilityResult - Result of the transfer eligibility validation. +type MoveProductEligibilityResult struct { + // Error details of the transfer eligibility validation. + ErrorDetails *MoveProductEligibilityResultErrorDetails + + // Specifies whether the subscription is eligible to be transferred. + IsMoveEligible *bool +} + +// MoveProductEligibilityResultErrorDetails - Error details of the transfer eligibility validation. +type MoveProductEligibilityResultErrorDetails struct { + // READ-ONLY; Error code for the product transfer validation. + Code *MoveValidationErrorCode + + // READ-ONLY; Error details of the transfer eligibility validation. + Details *string + + // READ-ONLY; The error message. + Message *string +} + +// MoveProductErrorDetails - Error details of the transfer eligibility validation. +type MoveProductErrorDetails struct { + // READ-ONLY; Error code for the product transfer validation. + Code *MoveValidationErrorCode + + // READ-ONLY; Error details of the transfer eligibility validation. + Details *string + + // READ-ONLY; The error message. + Message *string +} + +// MoveProductRequest - The properties of the product to initiate a transfer. +type MoveProductRequest struct { + // REQUIRED; The destination invoice section id. + DestinationInvoiceSectionID *string +} - // READ-ONLY; Indicates whether there are more invoice sections than the ones listed in this collection. The collection lists - // a maximum of 50 invoice sections. To get all invoice sections, use the list invoice - // sections API. - HasMoreResults *bool +// NextBillingCycleDetails - Billing cycle details of the product. +type NextBillingCycleDetails struct { + // READ-ONLY; Billing frequency of the product under the subscription. + BillingFrequency *string } -// Operation - A Billing REST API operation. +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API. type Operation struct { - // The object that represents the operation. + // Localized display information for this particular operation. Display *OperationDisplay - // READ-ONLY; Identifies if the operation is a data operation. + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane + // operations. IsDataAction *bool - // READ-ONLY; Operation name: {provider}/{resource}/{operation}. + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + // "Microsoft.Compute/virtualMachines/capture/action". Name *string } -// OperationDisplay - The object that represents the operation. +// OperationDisplay - Localized display information for this particular operation. type OperationDisplay struct { - // READ-ONLY; Description of operation. + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. Description *string - // READ-ONLY; Operation type such as read, write and delete. + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + // Machine", "Restart Virtual Machine". Operation *string - // READ-ONLY; Service provider: Microsoft.Billing. + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". Provider *string - // READ-ONLY; Resource on which the operation is performed such as invoice and billing subscription. + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". Resource *string } -// OperationListResult - The list of billing operations and a URL link to get the next set of results. +// OperationListResult - A container for a list of resources type OperationListResult struct { - // READ-ONLY; URL to get the next set of operation list results if there are any. + // READ-ONLY; The link (url) to the next page of results. NextLink *string - // READ-ONLY; The list of billing operations supported by the Microsoft.Billing resource provider. + // READ-ONLY; The list of resources. Value []*Operation } -// OperationsErrorDetails - The details of the error. -type OperationsErrorDetails struct { - // READ-ONLY; Error code. - Code *string - - // READ-ONLY; Error message indicating why the operation failed. - Message *string - - // READ-ONLY; The target of the particular error. - Target *string -} - -// OperationsErrorResponse - Error response indicates that the service is not able to process the incoming request. The reason -// is provided in the error message. -type OperationsErrorResponse struct { - // The details of the error. - Error *OperationsErrorDetails -} - -// Participants - The details about a participant. -type Participants struct { +// Participant - Billing account name. Available for a specific type of agreement. +type Participant struct { // READ-ONLY; The email address of the participant. Email *string @@ -837,949 +1590,3538 @@ type Participants struct { StatusDate *time.Time } -// PaymentProperties - The properties of a payment. -type PaymentProperties struct { - // The family of payment method. - PaymentMethodFamily *PaymentMethodFamily - - // READ-ONLY; The paid amount. - Amount *Amount +// PartnerInitiateTransferProperties - Request parameters to initiate transfer. +type PartnerInitiateTransferProperties struct { + // The email ID of the recipient to whom the transfer request is sent. + RecipientEmailID *string - // READ-ONLY; The date when the payment was made. - Date *time.Time - - // READ-ONLY; The type of payment method. - PaymentMethodType *string + // Optional MPN ID of the reseller for transfer requests that are sent from a Microsoft Partner Agreement billing account. + ResellerID *string +} - // READ-ONLY; The type of payment. - PaymentType *string +// PartnerInitiateTransferRequest - Request parameters to initiate partner transfer. +type PartnerInitiateTransferRequest struct { + // Request parameters to initiate partner transfer. + Properties *PartnerInitiateTransferProperties } -// Period - A billing period resource. -type Period struct { - // A billing period. - Properties *PeriodProperties +// PartnerTransferDetails - Details of the transfer. +type PartnerTransferDetails struct { + // Details of the transfer. + Properties *PartnerTransferProperties + + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string - // READ-ONLY; Resource Id. + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // READ-ONLY; Resource name. + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Resource type. - Type *string -} - -// PeriodProperties - The properties of the billing period. -type PeriodProperties struct { - // READ-ONLY; The end of the date range covered by the billing period. - BillingPeriodEndDate *time.Time + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData - // READ-ONLY; The start of the date range covered by the billing period. - BillingPeriodStartDate *time.Time - - // READ-ONLY; Array of invoice ids that associated with. - InvoiceIDs []*string + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string } -// PeriodsListResult - Result of listing billing periods. It contains a list of available billing periods in reverse chronological -// order. -type PeriodsListResult struct { +// PartnerTransferDetailsListResult - The list of transfers initiated by partner. +type PartnerTransferDetailsListResult struct { // READ-ONLY; The link (url) to the next page of results. NextLink *string - // READ-ONLY; The list of billing periods. - Value []*Period + // READ-ONLY; The list of transfers initiated by partner. + Value []*PartnerTransferDetails } -// PermissionsListResult - Result of list billingPermissions a caller has on a billing account. -type PermissionsListResult struct { - // READ-ONLY; The link (url) to the next page of results. - NextLink *string +// PartnerTransferProperties - Transfer Details. +type PartnerTransferProperties struct { + // READ-ONLY; The email ID of the user who canceled the transfer request. + CanceledBy *string - // READ-ONLY; The list of billingPermissions a caller has on a billing account. - Value []*PermissionsProperties -} + // READ-ONLY; Detailed transfer status. + DetailedTransferStatus []*DetailedTransferStatus -// PermissionsProperties - The set of allowed action and not allowed actions a caller has on a billing account -type PermissionsProperties struct { - // READ-ONLY; The set of actions that the caller is allowed to perform. - Actions []*string + // READ-ONLY; The time at which the transfer request expires. + ExpirationTime *time.Time - // READ-ONLY; The set of actions that the caller is not allowed to perform. - NotActions []*string -} + // READ-ONLY; The type of customer who sent the transfer request. + InitiatorCustomerType *InitiatorCustomerType -// Policy - A policy. -type Policy struct { - // The properties of a policy. - Properties *PolicyProperties + // READ-ONLY; The email ID of the user who sent the transfer request. + InitiatorEmailID *string - // READ-ONLY; Resource Id. - ID *string + // READ-ONLY; The email ID of the user to whom the transfer request was sent. + RecipientEmailID *string - // READ-ONLY; Resource name. - Name *string + // READ-ONLY; Optional MPN ID of the reseller for transfer requests that are sent from a Microsoft Partner Agreement billing + // account. + ResellerID *string - // READ-ONLY; Resource type. - Type *string + // READ-ONLY; Optional name of the reseller for transfer requests that are sent from Microsoft Partner Agreement billing account. + ResellerName *string + + // READ-ONLY; Overall transfer status. + TransferStatus *TransferStatus } -// PolicyProperties - The properties of a policy. -type PolicyProperties struct { - // The policy that controls whether Azure marketplace purchases are allowed for a billing profile. - MarketplacePurchases *MarketplacePurchasesPolicy +// Patch - The request for reservation patch +type Patch struct { + // Properties for reservation patch + Properties *PatchProperties - // The policy that controls whether Azure reservation purchases are allowed for a billing profile. - ReservationPurchases *ReservationPurchasesPolicy + // The sku information associated to this reservation + SKU *ReservationSKUProperty - // The policy that controls whether users with Azure RBAC access to a subscription can view its charges. - ViewCharges *ViewChargesPolicy + // Tags for this reservation + Tags map[string]*string } -// Product - A product. -type Product struct { - // The properties of a product. - Properties *ProductProperties - - // READ-ONLY; Resource Id. - ID *string - - // READ-ONLY; Resource name. - Name *string +// PatchProperties - Properties for reservation patch +type PatchProperties struct { + // Properties specific to applied scope type. Not required if not applicable. Required and need to provide tenantId and managementGroupId + // if AppliedScopeType is ManagementGroup + AppliedScopeProperties *ReservationAppliedScopeProperties - // READ-ONLY; Resource type. - Type *string -} + // Type of the Applied Scope. + AppliedScopeType *AppliedScopeType -// ProductProperties - The properties of a product. -type ProductProperties struct { - // Indicates whether auto renewal is turned on or off for a product. - AutoRenew *AutoRenew + // Display name of the reservation + DisplayName *string - // The frequency at which the product will be billed. - BillingFrequency *BillingFrequency + // Turning this on will apply the reservation discount to other VMs in the same VM size group. Only specify for VirtualMachines + // reserved resource type. + InstanceFlexibility *InstanceFlexibility - // The current status of the product. - Status *ProductStatusType + // Setting this to true will automatically purchase a new benefit on the expiration date time. + Renew *bool + RenewProperties *PatchPropertiesRenewProperties - // READ-ONLY; The availability of the product. - AvailabilityID *string + // This is the date-time when the Azure hybrid benefit needs to be reviewed. + ReviewDateTime *time.Time +} - // READ-ONLY; The name of the billing profile to which the product is billed. - BillingProfileDisplayName *string +type PatchPropertiesRenewProperties struct { + // The request for reservation purchase + PurchaseProperties *ReservationPurchaseRequest +} - // READ-ONLY; The ID of the billing profile to which the product is billed. - BillingProfileID *string +// Payment - An invoice payment. +type Payment struct { + // The paid amount. + Amount *PaymentAmount - // READ-ONLY; The name of the customer for whom the product was purchased. The field is applicable only for Microsoft Partner - // Agreement billing account. - CustomerDisplayName *string + // READ-ONLY; The date when the payment was made. + Date *time.Time - // READ-ONLY; The ID of the customer for whom the product was purchased. The field is applicable only for Microsoft Partner - // Agreement billing account. - CustomerID *string + // READ-ONLY; The family of payment method. + PaymentMethodFamily *PaymentMethodFamily - // READ-ONLY; The display name of the product. - DisplayName *string + // READ-ONLY; The ID that uniquely identifies the payment method used for the invoice. + PaymentMethodID *string - // READ-ONLY; The date when the product will be renewed or canceled. - EndDate *time.Time + // READ-ONLY; The type of payment method. + PaymentMethodType *string - // READ-ONLY; The name of the invoice section to which the product is billed. - InvoiceSectionDisplayName *string + // READ-ONLY; The type of payment. + PaymentType *string +} - // READ-ONLY; The ID of the invoice section to which the product is billed. - InvoiceSectionID *string +// PaymentAmount - The paid amount. +type PaymentAmount struct { + // READ-ONLY; The currency for the amount value. + Currency *string - // READ-ONLY; The last month charges. - LastCharge *Amount + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 +} - // READ-ONLY; The date of the last charge. - LastChargeDate *time.Time +// PaymentDetail - Information about payment related to a savings plan order. +type PaymentDetail struct { + // Amount charged in Billing currency. Tax not included. Is null for future payments + BillingCurrencyTotal *Price - // READ-ONLY; The description of the type of product. - ProductType *string + // Date when the payment needs to be done. + DueDate *time.Time - // READ-ONLY; The ID of the type of product. - ProductTypeID *string + // Date when the transaction is completed. Null when it is scheduled. + PaymentDate *time.Time - // READ-ONLY; The date when the product was purchased. - PurchaseDate *time.Time + // Amount in pricing currency. Tax not included. + PricingCurrencyTotal *Price - // READ-ONLY; The quantity purchased for the product. - Quantity *float32 + // Describes whether the payment is completed, failed, pending, cancelled or scheduled in the future. + Status *PaymentStatus - // READ-ONLY; Reseller for this product. - Reseller *Reseller + // READ-ONLY; Extended status information + ExtendedStatusInfo *ExtendedStatusInfo +} - // READ-ONLY; The sku description of the product. - SKUDescription *string +// PaymentMethod - A payment method. +type PaymentMethod struct { + // Payment method properties + Properties *PaymentMethodProperties - // READ-ONLY; The sku ID of the product. - SKUID *string + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string - // READ-ONLY; The id of the tenant in which the product is used. - TenantID *string -} + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string -// ProductsListResult - The list of products. It contains a list of available product summaries in reverse chronological order -// by purchase date. -type ProductsListResult struct { - // READ-ONLY; The link (url) to the next page of results. - NextLink *string + // READ-ONLY; The name of the resource + Name *string - // READ-ONLY; Total number of records. - TotalCount *int32 + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData - // READ-ONLY; The list of products. - Value []*Product + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string } -// Profile - A billing profile. -type Profile struct { - // The properties of the billing profile. - Properties *ProfileProperties +// PaymentMethodLink - A payment method link. +type PaymentMethodLink struct { + // Payment method link properties + Properties *PaymentMethodLinkProperties + + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string - // READ-ONLY; Resource Id. + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // READ-ONLY; Resource name. + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Resource type. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// ProfileCreationRequest - The request parameters for creating a new billing profile. -type ProfileCreationRequest struct { - // The address of the individual or organization that is responsible for the billing profile. - BillTo *AddressDetails +// PaymentMethodLinkProperties - The properties of a payment method link. +type PaymentMethodLinkProperties struct { + // Projection of a payment method. Will not be returned in this or future versions. + PaymentMethod *PaymentMethodProperties - // The name of the billing profile. + // Id of payment method. Example: /providers/Microsoft.Billing/paymentMethods/ABCDABCDABC0 + PaymentMethodID *string + + // READ-ONLY; The account holder name for the payment method. This is only supported for payment methods with family CreditCard. + AccountHolderName *string + + // READ-ONLY; The display name of the payment method. DisplayName *string - // Enabled azure plans for the billing profile. - EnabledAzurePlans []*AzurePlan + // READ-ONLY; The expiration month and year of the payment method. This is only supported for payment methods with family + // CreditCard. + Expiration *string - // Flag controlling whether the invoices for the billing profile are sent through email. - InvoiceEmailOptIn *bool + // READ-ONLY; The family of payment method. + Family *PaymentMethodFamily - // The purchase order name that will appear on the invoices generated for the billing profile. - PoNumber *string -} + // READ-ONLY; Last four digits of payment method. + LastFourDigits *string -// ProfileInfo - Details about billing profile associated with agreement and available only for specific agreements. -type ProfileInfo struct { - // The name of the billing profile - BillingProfileDisplayName *string + // READ-ONLY; The list of logos for the payment method. + Logos []*PaymentMethodLogo - // The unique identifier for the billing profile. - BillingProfileID *string + // READ-ONLY; The type of payment method. + PaymentMethodType *string - // Billing account name. This property is available for a specific type of agreement. - IndirectRelationshipOrganizationName *string + // READ-ONLY; Status of the payment method. + Status *PaymentMethodStatus } -// ProfileListResult - The list of billing profiles. -type ProfileListResult struct { +// PaymentMethodLinksListResult - The list of payment method links. +type PaymentMethodLinksListResult struct { // READ-ONLY; The link (url) to the next page of results. NextLink *string - // READ-ONLY; Total number of records. - TotalCount *int32 + // READ-ONLY; The list of payment method links. + Value []*PaymentMethodLink +} + +// PaymentMethodLogo - Logo of payment method. +type PaymentMethodLogo struct { + // READ-ONLY; MIME type of the logo. + MimeType *string + + // READ-ONLY; Public URL of image of the logo. + URL *string +} + +// PaymentMethodProperties - The properties of a payment method. +type PaymentMethodProperties struct { + // The family of payment method. + Family *PaymentMethodFamily + + // The list of logos for the payment method. + Logos []*PaymentMethodLogo + + // Status of the payment method. + Status *PaymentMethodStatus + + // READ-ONLY; The account holder name for the payment method. This is only supported for payment methods with family CreditCard. + AccountHolderName *string + + // READ-ONLY; The display name of the payment method. + DisplayName *string + + // READ-ONLY; The expiration month and year of the payment method. This is only supported for payment methods with family + // CreditCard. + Expiration *string + + // READ-ONLY; Id of payment method. + ID *string + + // READ-ONLY; Last four digits of payment method. + LastFourDigits *string + + // READ-ONLY; The type of payment method. + PaymentMethodType *string +} + +// PaymentMethodsListResult - The list of payment methods. +type PaymentMethodsListResult struct { + // READ-ONLY; The link (url) to the next page of results. + NextLink *string + + // READ-ONLY; The list of payment methods. + Value []*PaymentMethod +} + +// PaymentOnAccount - A Payment on Account. +type PaymentOnAccount struct { + // Payment on Account amount. + Amount *PaymentOnAccountAmount + + // READ-ONLY; The name of the billing profile for the payments on account. + BillingProfileDisplayName *string + + // READ-ONLY; The ID of the billing profile for the payments on account. + BillingProfileID *string + + // READ-ONLY; The date of the payments on account. + Date *time.Time + + // READ-ONLY; The ID of the invoice for which the payments on account was generated. + InvoiceID *string + + // READ-ONLY; The name of the invoice for the payments on account. + InvoiceName *string + + // READ-ONLY; Payment on Account type. + PaymentMethodType *PaymentMethodFamily +} + +// PaymentOnAccountAmount - Payment on Account amount. +type PaymentOnAccountAmount struct { + // READ-ONLY; The currency for the amount value. + Currency *string + + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 +} + +// PaymentTerm - The properties of payment term. +type PaymentTerm struct { + // The date on when the defined 'Payment Term' will end and is always in UTC. + EndDate *time.Time + + // The date on when the defined 'Payment Term' will be effective from and is always in UTC. + StartDate *time.Time + + // Represents duration in netXX format. Always in days. + Term *string + + // READ-ONLY; Indicates payment term is the standard payment term. + IsDefault *bool +} + +// PaymentTermsEligibilityDetail - Details of the payment terms eligibility. +type PaymentTermsEligibilityDetail struct { + // Indicates the reason for the ineligibility of the payment terms. + Code *PaymentTermsEligibilityCode + + // Indicates the message for the ineligibility of the payment terms. + Message *string +} + +// PaymentTermsEligibilityResult - Result of the payment terms eligibility. +type PaymentTermsEligibilityResult struct { + // Details of the payment terms eligibility. + EligibilityDetails []*PaymentTermsEligibilityDetail + + // Indicates the eligibility status of the payment terms. + EligibilityStatus *PaymentTermsEligibilityStatus +} + +// Permission - The set of allowed action and not allowed actions a caller has on a resource. +type Permission struct { + // READ-ONLY; The set of actions that the caller is allowed to perform. + Actions []*string + + // READ-ONLY; The set of actions that the caller is not allowed to perform. + NotActions []*string +} + +// PermissionListResult - A container for a list of resources +type PermissionListResult struct { + // READ-ONLY; The link (url) to the next page of results. + NextLink *string + + // READ-ONLY; The list of resources. + Value []*Permission +} + +// PlanInformation - Information describing the type of billing plan for this savings plan. +type PlanInformation struct { + // For recurring billing plans, indicates the date when next payment will be processed. Null when total is paid off. + NextPaymentDueDate *time.Time + + // Amount of money to be paid for the Order. Tax is not included. + PricingCurrencyTotal *Price + + // Date when the billing plan has started. + StartDate *time.Time + Transactions []*PaymentDetail +} + +// PolicySummary - The summary of the policy. +type PolicySummary struct { + // The name of the policy. + Name *string + + // The type of the policy. + PolicyType *PolicyType + + // The scope at which the policy is defined. + Scope *string + + // The value of the policy. + Value *string +} + +// Price - The price. +type Price struct { + Amount *float64 + + // The ISO 4217 3-letter currency code for the currency used by this purchase record. + CurrencyCode *string +} + +// Principal - A principal who has interacted with a billing entity. +type Principal struct { + // The object id of the principal who has interacted with a billing entity. + ObjectID *string + + // The tenant id of the principal who has interacted with a billing entity. + TenantID *string + + // The user principal name of the principal who has interacted with a billing entity. + Upn *string +} + +// Product - A product. +type Product struct { + // A product. + Properties *ProductProperties + + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// ProductDetails - Details of the product that is transferred. +type ProductDetails struct { + // The ID of the product that is transferred. + ProductID *string + + // Type of the product that is transferred. + ProductType *ProductType +} + +// ProductListResult - A container for a list of resources +type ProductListResult struct { + // READ-ONLY; The link (url) to the next page of results. + NextLink *string + + // READ-ONLY; The list of resources. + Value []*Product +} + +// ProductPatch - A product. +type ProductPatch struct { + // A product. + Properties *ProductProperties + + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// ProductProperties - A product. +type ProductProperties struct { + // Indicates whether auto renewal is turned on or off for a product. + AutoRenew *AutoRenew + + // The last month charges. + LastCharge *ProductPropertiesLastCharge + + // Reseller for this product. The fields is not available for Microsoft Partner Agreement products. + Reseller *ProductPropertiesReseller + + // READ-ONLY; The availability of the product. + AvailabilityID *string + + // READ-ONLY; The frequency at which the product will be billed. + BillingFrequency *string + + // READ-ONLY; The name of the billing profile to which the product is billed. + BillingProfileDisplayName *string + + // READ-ONLY; The ID of the billing profile to which the product is billed. + BillingProfileID *string + + // READ-ONLY; The name of the customer for whom the product was purchased. The field is applicable only for Microsoft Partner + // Agreement billing account. + CustomerDisplayName *string + + // READ-ONLY; The ID of the customer for whom the product was purchased. The field is applicable only for Microsoft Partner + // Agreement billing account. + CustomerID *string + + // READ-ONLY; The display name of the product. + DisplayName *string + + // READ-ONLY; The date when the product will be renewed or canceled. + EndDate *string + + // READ-ONLY; The name of the invoice section to which the product is billed. + InvoiceSectionDisplayName *string + + // READ-ONLY; The ID of the invoice section to which the product is billed. + InvoiceSectionID *string + + // READ-ONLY; The date of the last charge. + LastChargeDate *string + + // READ-ONLY; The description of the type of product. + ProductType *string + + // READ-ONLY; The ID of the type of product. + ProductTypeID *string + + // READ-ONLY; The date when the product was purchased. + PurchaseDate *string + + // READ-ONLY; The quantity purchased for the product. + Quantity *int64 + + // READ-ONLY; The sku description of the product. + SKUDescription *string + + // READ-ONLY; The sku ID of the product. + SKUID *string + + // READ-ONLY; The status of the product. + Status *ProductStatus + + // READ-ONLY; The id of the tenant in which the product is used. + TenantID *string +} + +// ProductPropertiesLastCharge - The last month charges. +type ProductPropertiesLastCharge struct { + // READ-ONLY; The currency for the amount value. + Currency *string + + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 +} + +// ProductPropertiesReseller - Reseller for this product. The fields is not available for Microsoft Partner Agreement products. +type ProductPropertiesReseller struct { + // READ-ONLY; The name of the reseller. + Description *string + + // READ-ONLY; The MPN ID of the reseller. + ResellerID *string +} + +// Profile - A billing profile. +type Profile struct { + // A billing profile. + Properties *ProfileProperties + + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// ProfileInfo - Details about billing profile associated with agreement and available only for specific agreements. +type ProfileInfo struct { + // The fully qualified ID that uniquely identifies a billing account. + BillingAccountID *string + + // The name of the billing profile. + BillingProfileDisplayName *string + + // The friendly ID that uniquely identifies a billing profile. + BillingProfileID *string + + // The fully qualified ID that uniquely identifies a billing profile. + BillingProfileSystemID *string + + // Billing account name. Available for a specific type of agreement. + IndirectRelationshipOrganizationName *string +} + +// ProfileListResult - A container for a list of resources +type ProfileListResult struct { + // READ-ONLY; The link (url) to the next page of results. + NextLink *string + + // READ-ONLY; The list of resources. + Value []*Profile +} + +// ProfilePolicy - A policy at billing profile scope. +type ProfilePolicy struct { + // A policy at billing profile scope. + Properties *ProfilePolicyProperties + + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// ProfilePolicyProperties - A policy at billing profile scope. +type ProfilePolicyProperties struct { + // The policies for Enterprise Agreement enrollments. + EnterpriseAgreementPolicies *ProfilePolicyPropertiesEnterpriseAgreementPolicies + + // The policy that controls invoice section label management at invoice section scope. This is allowed by default. + InvoiceSectionLabelManagement *InvoiceSectionLabelManagementPolicy + + // The policy that controls whether Azure marketplace purchases are allowed. + MarketplacePurchases *MarketplacePurchasesPolicy + + // List of all policies defined at the billing scope. + Policies []*PolicySummary + + // The policy that controls whether Azure reservation purchases are allowed. + ReservationPurchases *ReservationPurchasesPolicy + + // The policy that controls whether users with Azure savings plan purchase are allowed. + SavingsPlanPurchases *SavingsPlanPurchasesPolicy + + // The policy that controls whether the users in customer's organization can view charges at pay-as-you-go prices. + ViewCharges *ViewChargesPolicy + + // READ-ONLY; The provisioning state of the resource during a long-running operation. + ProvisioningState *ProvisioningState +} + +// ProfilePolicyPropertiesEnterpriseAgreementPolicies - The policies for Enterprise Agreement enrollments. +type ProfilePolicyPropertiesEnterpriseAgreementPolicies struct { + // The policy that controls whether account owner can view charges. + AccountOwnerViewCharges *EnrollmentAccountOwnerViewCharges + + // The state showing the enrollment auth level. + AuthenticationType *EnrollmentAuthLevelState + + // The policy that controls whether department admin can view charges. + DepartmentAdminViewCharges *EnrollmentDepartmentAdminViewCharges +} + +// ProfileProperties - A billing profile. +type ProfileProperties struct { + // Billing address. + BillTo *ProfilePropertiesBillTo + + // The current payment term of the billing profile. + CurrentPaymentTerm *ProfilePropertiesCurrentPaymentTerm + + // The name of the billing profile. + DisplayName *string + + // Information about the enabled azure plans. + EnabledAzurePlans []*AzurePlan + + // Identifies the billing profile that is linked to another billing profile in indirect purchase motion. + IndirectRelationshipInfo *ProfilePropertiesIndirectRelationshipInfo + + // Flag controlling whether the invoices for the billing profile are sent through email. + InvoiceEmailOptIn *bool + + // The list of email addresses to receive invoices by email for the billing profile. + InvoiceRecipients []*string + + // The default purchase order number that will appear on the invoices generated for the billing profile. + PoNumber *string + + // The default address where the products are shipped, or the services are being used. If a ship to is not specified for a + // product or a subscription, then this address will be used. + ShipTo *ProfilePropertiesShipTo + + // The address of the individual or organization that is responsible for the billing account. + SoldTo *ProfilePropertiesSoldTo + + // Dictionary of metadata associated with the resource. Maximum key/value length supported of 256 characters. Keys/value should + // not empty value nor null. Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Identifies the billing relationship represented by the billing profile. The billing relationship may be between + // Microsoft, the customer, and/or a third-party. + BillingRelationshipType *BillingRelationshipType + + // READ-ONLY; The currency in which the charges for the billing profile are billed. + Currency *string + + // READ-ONLY; Indicates whether user has read access to the billing profile. + HasReadAccess *bool + + // READ-ONLY; The day of the month when the invoice for the billing profile is generated. + InvoiceDay *int32 + + // READ-ONLY; The other payment terms of the billing profile. + OtherPaymentTerms []*PaymentTerm + + // READ-ONLY; The provisioning state of the resource during a long-running operation. + ProvisioningState *ProvisioningState + + // READ-ONLY; The billing profile spending limit. + SpendingLimit *SpendingLimit + + // READ-ONLY; The details of billing profile spending limit. + SpendingLimitDetails []*SpendingLimitDetails + + // READ-ONLY; The status of the billing profile. + Status *BillingProfileStatus + + // READ-ONLY; Reason for the specified billing profile status. + StatusReasonCode *BillingProfileStatusReasonCode + + // READ-ONLY; The system generated unique identifier for a billing profile. + SystemID *string + + // READ-ONLY; Identifies the cloud environments that are associated with a billing profile. This is a system managed optional + // field and gets updated as the billing profile gets associated with accounts in various + // clouds. + TargetClouds []*string +} + +// ProfilePropertiesBillTo - Billing address. +type ProfilePropertiesBillTo struct { + // REQUIRED; Address line 1. + AddressLine1 *string + + // REQUIRED; Country code uses ISO 3166-1 Alpha-2 format. + Country *string + + // Address line 2. + AddressLine2 *string + + // Address line 3. + AddressLine3 *string + + // Address city. + City *string + + // Company name. Optional for MCA Individual (Pay-as-you-go). + CompanyName *string + + // Address district. + District *string + + // Email address. + Email *string + + // First name. Optional for MCA Enterprise. + FirstName *string + + // Indicates if the address is incomplete. + IsValidAddress *bool + + // Last name. Optional for MCA Enterprise. + LastName *string + + // Middle name. + MiddleName *string + + // Phone number. + PhoneNumber *string + + // Postal code. + PostalCode *string + + // Address region. + Region *string +} + +// ProfilePropertiesCurrentPaymentTerm - The current payment term of the billing profile. +type ProfilePropertiesCurrentPaymentTerm struct { + // The date on when the defined 'Payment Term' will end and is always in UTC. + EndDate *time.Time + + // The date on when the defined 'Payment Term' will be effective from and is always in UTC. + StartDate *time.Time + + // Represents duration in netXX format. Always in days. + Term *string + + // READ-ONLY; Indicates payment term is the standard payment term. + IsDefault *bool +} + +// ProfilePropertiesIndirectRelationshipInfo - Identifies the billing profile that is linked to another billing profile in +// indirect purchase motion. +type ProfilePropertiesIndirectRelationshipInfo struct { + // The billing account name of the partner or the customer for an indirect motion. + BillingAccountName *string + + // The billing profile name of the partner or the customer for an indirect motion. + BillingProfileName *string + + // The display name of the partner or customer for an indirect motion. + DisplayName *string +} + +// ProfilePropertiesShipTo - The default address where the products are shipped, or the services are being used. If a ship +// to is not specified for a product or a subscription, then this address will be used. +type ProfilePropertiesShipTo struct { + // REQUIRED; Address line 1. + AddressLine1 *string + + // REQUIRED; Country code uses ISO 3166-1 Alpha-2 format. + Country *string + + // Address line 2. + AddressLine2 *string + + // Address line 3. + AddressLine3 *string + + // Address city. + City *string + + // Company name. Optional for MCA Individual (Pay-as-you-go). + CompanyName *string + + // Address district. + District *string + + // Email address. + Email *string + + // First name. Optional for MCA Enterprise. + FirstName *string + + // Indicates if the address is incomplete. + IsValidAddress *bool + + // Last name. Optional for MCA Enterprise. + LastName *string + + // Middle name. + MiddleName *string + + // Phone number. + PhoneNumber *string + + // Postal code. + PostalCode *string + + // Address region. + Region *string +} + +// ProfilePropertiesSoldTo - The address of the individual or organization that is responsible for the billing account. +type ProfilePropertiesSoldTo struct { + // REQUIRED; Address line 1. + AddressLine1 *string + + // REQUIRED; Country code uses ISO 3166-1 Alpha-2 format. + Country *string + + // Address line 2. + AddressLine2 *string + + // Address line 3. + AddressLine3 *string + + // Address city. + City *string + + // Company name. Optional for MCA Individual (Pay-as-you-go). + CompanyName *string + + // Address district. + District *string + + // Email address. + Email *string + + // First name. Optional for MCA Enterprise. + FirstName *string + + // Indicates if the address is incomplete. + IsValidAddress *bool + + // Last name. Optional for MCA Enterprise. + LastName *string + + // Middle name. + MiddleName *string + + // Phone number. + PhoneNumber *string + + // Postal code. + PostalCode *string + + // Address region. + Region *string +} + +// Property - A billing property. +type Property struct { + // A billing property. + Properties *PropertyProperties + + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// PropertyProperties - A billing property. +type PropertyProperties struct { + // The cost center applied to the subscription. Available for agreement type Microsoft Customer Agreement and Microsoft Partner + // Agreement. This property can be updated via patch. + CostCenter *string + + // The enrollment details for the subscription. Available for billing accounts with agreement type Enterprise Agreement. + EnrollmentDetails *PropertyPropertiesEnrollmentDetails + + // The address of the individual or organization where service subscription is being used. Available for agreement type Microsoft + // Online Services Program. This property can be updated via patch. + SubscriptionServiceUsageAddress *PropertyPropertiesSubscriptionServiceUsageAddress + + // READ-ONLY; Notification email address for legacy account. Available for agreement type Microsoft Online Services Program. + AccountAdminNotificationEmailAddress *string + + // READ-ONLY; The type of agreement. + BillingAccountAgreementType *AgreementType + + // READ-ONLY; The name of the billing account. + BillingAccountDisplayName *string + + // READ-ONLY; The fully qualified ID that uniquely identifies a billing account. + BillingAccountID *string + + // READ-ONLY; The country of the individual or organization that is responsible for the billing account. + BillingAccountSoldToCountry *string + + // READ-ONLY; The current status of the billing account. + BillingAccountStatus *AccountStatus + + // READ-ONLY; Reason for the specified billing account status. + BillingAccountStatusReasonCode *BillingAccountStatusReasonCode + + // READ-ONLY; The tier of the account. + BillingAccountSubType *AccountSubType + + // READ-ONLY; The type of customer. + BillingAccountType *AccountType + + // READ-ONLY; The billing currency for the subscription. Available for billing accounts with agreement type Enterprise Agreement + BillingCurrency *string + + // READ-ONLY; The name of the billing profile. + BillingProfileDisplayName *string + + // READ-ONLY; The fully qualified ID that uniquely identifies a billing profile. + BillingProfileID *string + + // READ-ONLY; The payment method family of the primary payment method for the billing profile. + BillingProfilePaymentMethodFamily *PaymentMethodFamily + + // READ-ONLY; The payment method type of the primary payment method for the billing profile. + BillingProfilePaymentMethodType *string + + // READ-ONLY; The billing profile spending limit. + BillingProfileSpendingLimit *SpendingLimit + + // READ-ONLY; The details of billing profile spending limit. + BillingProfileSpendingLimitDetails []*SpendingLimitDetails + + // READ-ONLY; The status of the billing profile. + BillingProfileStatus *BillingProfileStatus + + // READ-ONLY; Reason for the specified billing profile status. + BillingProfileStatusReasonCode *BillingProfileStatusReasonCode + + // READ-ONLY; The Azure AD tenant ID of the billing account for the subscription. + BillingTenantID *string + + // READ-ONLY; The name of the customer. + CustomerDisplayName *string + + // READ-ONLY; The fully qualified ID that uniquely identifies a customer. + CustomerID *string + + // READ-ONLY; Identifies the status of an customer. This is an upcoming property that will be populated in the future. + CustomerStatus *CustomerStatus + + // READ-ONLY; The name of the invoice section. + InvoiceSectionDisplayName *string + + // READ-ONLY; The fully qualified ID that uniquely identifies an invoice section. + InvoiceSectionID *string + + // READ-ONLY; Identifies the status of an invoice section. + InvoiceSectionStatus *InvoiceSectionState + + // READ-ONLY; Reason for the specified invoice section status. + InvoiceSectionStatusReasonCode *InvoiceSectionStateReasonCode + + // READ-ONLY; Indicates whether user is the account admin. + IsAccountAdmin *bool + + // READ-ONLY; Specifies if the billing account for the subscription is transitioned from a Microsoft Online Service Program + // to a Microsoft Customer Agreement (MCA) account. Will be present and value will be true if + // its a transitioned billing account. + IsTransitionedBillingAccount *bool + + // READ-ONLY; The ID that uniquely identifies a product. + ProductID *string + + // READ-ONLY; The ID that uniquely identifies a product. + ProductName *string + + // READ-ONLY; The sku description. + SKUDescription *string + + // READ-ONLY; The ID that uniquely identifies a sku. + SKUID *string + + // READ-ONLY; The subscription status. + SubscriptionBillingStatus *BillingSubscriptionStatus + + // READ-ONLY; The reason codes for the subscription status. + SubscriptionBillingStatusDetails []*SubscriptionStatusDetails + + // READ-ONLY; The type of billing subscription. + SubscriptionBillingType *SubscriptionBillingType + + // READ-ONLY; The Azure workload type of the subscription. + SubscriptionWorkloadType *SubscriptionWorkloadType +} + +// PropertyPropertiesEnrollmentDetails - The enrollment details for the subscription. Available for billing accounts with +// agreement type Enterprise Agreement. +type PropertyPropertiesEnrollmentDetails struct { + // The name of the department + DepartmentDisplayName *string + + // The ID that uniquely identifies the department. + DepartmentID *string + + // The name of the enrollment account. + EnrollmentAccountDisplayName *string + + // The ID that uniquely identifies an enrollment account. + EnrollmentAccountID *string + + // The status of the enrollment account. + EnrollmentAccountStatus *string +} + +// PropertyPropertiesSubscriptionServiceUsageAddress - The address of the individual or organization where service subscription +// is being used. Available for agreement type Microsoft Online Services Program. This property can be updated via patch. +type PropertyPropertiesSubscriptionServiceUsageAddress struct { + // REQUIRED; Address line 1. + AddressLine1 *string + + // REQUIRED; Country code uses ISO 3166-1 Alpha-2 format. + Country *string + + // Address line 2. + AddressLine2 *string + + // Address line 3. + AddressLine3 *string + + // Address city. + City *string + + // Company name. Optional for MCA Individual (Pay-as-you-go). + CompanyName *string + + // Address district. + District *string + + // Email address. + Email *string + + // First name. Optional for MCA Enterprise. + FirstName *string + + // Indicates if the address is incomplete. + IsValidAddress *bool + + // Last name. Optional for MCA Enterprise. + LastName *string + + // Middle name. + MiddleName *string + + // Phone number. + PhoneNumber *string + + // Postal code. + PostalCode *string + + // Address region. + Region *string +} + +// ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a +// location +type ProxyResource struct { + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// ProxyResourceWithTags - Common fields that are returned in the response for all Azure Resource Manager resources. +type ProxyResourceWithTags struct { + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// PurchaseRequest - Purchase request. +type PurchaseRequest struct { + // Purchase request properties. + Properties *PurchaseRequestProperties + + // The SKU to be applied for this resource + SKU *SKU +} + +// PurchaseRequestProperties - Purchase request properties. +type PurchaseRequestProperties struct { + // Properties specific to applied scope type. Not required if not applicable. + AppliedScopeProperties *AppliedScopeProperties + + // Type of the Applied Scope. + AppliedScopeType *AppliedScopeType + + // Represents the billing plan in ISO 8601 format. Required only for monthly purchases. + BillingPlan *BillingPlan + + // Subscription that will be charged for purchasing SavingsPlan + BillingScopeID *string + + // Commitment towards the benefit. + Commitment *Commitment + + // Friendly name of the savings plan + DisplayName *string + + // Setting this to true will automatically purchase a new benefit on the expiration date time. + Renew *bool + + // Represents the Savings plan term in ISO 8601 format. + Term *SavingsPlanTerm +} + +// RebillDetails - The rebill details of an invoice. +type RebillDetails struct { + // READ-ONLY; The ID of credit note. + CreditNoteDocumentID *string + + // READ-ONLY; The ID of invoice. + InvoiceDocumentID *string + + // READ-ONLY; The rebill details of an invoice. + RebillDetails *RebillDetails +} + +// RecipientTransferDetails - Details of the transfer. +type RecipientTransferDetails struct { + // Details of the transfer. + Properties *RecipientTransferProperties + + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// RecipientTransferDetailsListResult - The list of transfers received by caller. +type RecipientTransferDetailsListResult struct { + // READ-ONLY; The link (url) to the next page of results. + NextLink *string + + // READ-ONLY; The list of transfers received by caller. + Value []*RecipientTransferDetails +} + +// RecipientTransferProperties - Transfer Details. +type RecipientTransferProperties struct { + // READ-ONLY; Type of subscriptions that can be transferred. + AllowedProductType []*EligibleProductType + + // READ-ONLY; The email ID of the user who canceled the transfer request. + CanceledBy *string + + // READ-ONLY; The customer tenant id. + CustomerTenantID *string + + // READ-ONLY; Detailed transfer status. + DetailedTransferStatus []*DetailedTransferStatus + + // READ-ONLY; The time at which the transfer request expires. + ExpirationTime *time.Time + + // READ-ONLY; The type of customer who sent the transfer request. + InitiatorCustomerType *InitiatorCustomerType + + // READ-ONLY; The email ID of the user who sent the transfer request. + InitiatorEmailID *string + + // READ-ONLY; The email ID of the user to whom the transfer request was sent. + RecipientEmailID *string + + // READ-ONLY; Optional MPN ID of the reseller for transfer requests that are sent from a Microsoft Partner Agreement billing + // account. + ResellerID *string + + // READ-ONLY; Optional name of the reseller for transfer requests that are sent from Microsoft Partner Agreement billing account. + ResellerName *string + + // READ-ONLY; List of supported account types. + SupportedAccounts []*SupportedAccountType + + // READ-ONLY; Overall transfer status. + TransferStatus *TransferStatus +} + +// RefundDetailsSummary - The details of refund request. +type RefundDetailsSummary struct { + // The amount refunded. + AmountRefunded *RefundDetailsSummaryAmountRefunded + + // The amount of refund requested. + AmountRequested *RefundDetailsSummaryAmountRequested + + // READ-ONLY; Date when the refund was approved. + ApprovedOn *time.Time + + // READ-ONLY; Date when the refund was completed. + CompletedOn *time.Time + + // READ-ONLY; The invoice ID of the rebill invoice for a refund. + RebillInvoiceID *string + + // READ-ONLY; The ID of refund operation. + RefundOperationID *string + + // READ-ONLY; The reason for refund. + RefundReason *RefundReasonCode + + // READ-ONLY; The status of refund request. + RefundStatus *RefundStatus + + // READ-ONLY; Date when the refund was requested. + RequestedOn *time.Time + + // READ-ONLY; The number of transactions refunded. + TransactionCount *int32 +} + +// RefundDetailsSummaryAmountRefunded - The amount refunded. +type RefundDetailsSummaryAmountRefunded struct { + // READ-ONLY; The currency for the amount value. + Currency *string + + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 +} + +// RefundDetailsSummaryAmountRequested - The amount of refund requested. +type RefundDetailsSummaryAmountRequested struct { + // READ-ONLY; The currency for the amount value. + Currency *string + + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 +} + +// RefundTransactionDetails - The refund details of a transaction. +type RefundTransactionDetails struct { + // The amount refunded. + AmountRefunded *RefundTransactionDetailsAmountRefunded + + // The amount of refund requested. + AmountRequested *RefundTransactionDetailsAmountRequested + + // The ID of refund operation. + RefundOperationID *string +} + +// RefundTransactionDetailsAmountRefunded - The amount refunded. +type RefundTransactionDetailsAmountRefunded struct { + // READ-ONLY; The currency for the amount value. + Currency *string + + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 +} + +// RefundTransactionDetailsAmountRequested - The amount of refund requested. +type RefundTransactionDetailsAmountRequested struct { + // READ-ONLY; The currency for the amount value. + Currency *string + + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 +} + +// RegistrationNumber - Describes the registration number of the organization linked with the billing account. +type RegistrationNumber struct { + // The unique identification number of the organization linked with the billing account. + ID *string + + // READ-ONLY; Identifies if the registration number is required for the billing account. + Required *bool + + // READ-ONLY; The types of registration number allowed based on the country of the billing account. + Type []*string +} + +// RenewProperties - Properties specific to renew. +type RenewProperties struct { + // Purchase request. + PurchaseProperties *PurchaseRequest +} + +// RenewPropertiesResponse - The renew properties for a reservation. +type RenewPropertiesResponse struct { + // Currency and amount that customer will be charged in customer's local currency for renewal purchase. Tax is not included. + BillingCurrencyTotal *Price + + // Amount that Microsoft uses for record. Used during refund for calculating refund limit. Tax is not included. This is locked + // price 30 days before expiry. + PricingCurrencyTotal *Price + + // The request for reservation purchase + PurchaseProperties *ReservationPurchaseRequest +} + +// RenewalTermDetails - Details for the next renewal term of a subscription. +type RenewalTermDetails struct { + // The quantity of licenses or fulfillment units for the subscription. + Quantity *int64 + + // READ-ONLY; The billing frequency in ISO8601 format of product in the subscription. Example: P1M, P3M, P1Y + BillingFrequency *string + + // READ-ONLY; Id of the product for which the subscription is purchased. + ProductID *string + + // READ-ONLY; Type Id of the product for which the subscription is purchased. + ProductTypeID *string + + // READ-ONLY; The SKU ID of the product for which the subscription is purchased. This field is is only available for Microsoft + // Customer Agreement billing accounts. + SKUID *string + + // READ-ONLY; The duration in ISO8601 format for which you can use the subscription. Example: P1M, P3M, P1Y + TermDuration *string + + // READ-ONLY; End date of the term in UTC time. + TermEndDate *time.Time +} + +// Request - A request submitted by a user to manage billing. Users with an owner role on the scope can approve or decline +// these requests. +type Request struct { + // A request submitted by a user to manage billing. Users with an owner role on the scope can approve or decline these requests. + Properties *RequestProperties + + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// RequestListResult - A container for a list of resources +type RequestListResult struct { + // READ-ONLY; The link (url) to the next page of results. + NextLink *string + + // READ-ONLY; The list of resources. + Value []*Request +} + +// RequestProperties - A request submitted by a user to manage billing. Users with an owner role on the scope can approve +// or decline these requests. +type RequestProperties struct { + // Additional information for the billing request. + AdditionalInformation map[string]*string + + // The principal of the entity who created the request. + CreatedBy *RequestPropertiesCreatedBy + + // The reason to approve or decline the request. + DecisionReason *string + + // Justification for submitting request. + Justification *string + + // The principal of the entity who last updated the request. + LastUpdatedBy *RequestPropertiesLastUpdatedBy + + // The recipients of the billing request. + Recipients []*Principal + + // The billing scope for which the request was submitted (ex. '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}'). + RequestScope *string + + // The principal of the request reviewer. Will only be set if request is approved. + ReviewedBy *RequestPropertiesReviewedBy + + // Status of billing request. + Status *BillingRequestStatus + + // Type of billing request. + Type *BillingRequestType + + // READ-ONLY; The name of the billing account. + BillingAccountDisplayName *string + + // READ-ONLY; The fully qualified ID that uniquely identifies a billing account. + BillingAccountID *string + + // READ-ONLY; The ID that uniquely identifies a billing account. + BillingAccountName *string + + // READ-ONLY; The primary tenant ID of the billing account for which the billing request was submitted. + BillingAccountPrimaryBillingTenantID *string + + // READ-ONLY; The name of the billing profile. + BillingProfileDisplayName *string + + // READ-ONLY; The fully qualified ID that uniquely identifies a billing profile. + BillingProfileID *string + + // READ-ONLY; The ID that uniquely identifies a billing profile. + BillingProfileName *string + + // READ-ONLY; The billing scope for which the request will be applied. This is a read only property derived by the service. + BillingScope *string + + // READ-ONLY; The date and time when the request was created. + CreationDate *time.Time + + // READ-ONLY; The name of the customer. + CustomerDisplayName *string + + // READ-ONLY; The fully qualified ID that uniquely identifies a customer. + CustomerID *string + + // READ-ONLY; The ID that uniquely identifies a customer. + CustomerName *string + + // READ-ONLY; The date and time when the request expires. + ExpirationDate *time.Time + + // READ-ONLY; The name of the invoice section. + InvoiceSectionDisplayName *string + + // READ-ONLY; The fully qualified ID that uniquely identifies an invoice section. + InvoiceSectionID *string + + // READ-ONLY; The ID that uniquely identifies an invoice section. + InvoiceSectionName *string + + // READ-ONLY; Date and time of last update. + LastUpdatedDate *time.Time + + // READ-ONLY; The provisioning state of the resource during a long-running operation. + ProvisioningState *ProvisioningState + + // READ-ONLY; The date and time when the request was reviewed. + ReviewalDate *time.Time + + // READ-ONLY; The name of the billing subscription. + SubscriptionDisplayName *string + + // READ-ONLY; The fully qualified ID that uniquely identifies a billing subscription. + SubscriptionID *string + + // READ-ONLY; The ID that uniquely identifies a billing subscription. + SubscriptionName *string +} + +// RequestPropertiesCreatedBy - The principal of the entity who created the request. +type RequestPropertiesCreatedBy struct { + // The object id of the principal who has interacted with a billing entity. + ObjectID *string + + // The tenant id of the principal who has interacted with a billing entity. + TenantID *string + + // The user principal name of the principal who has interacted with a billing entity. + Upn *string +} + +// RequestPropertiesLastUpdatedBy - The principal of the entity who last updated the request. +type RequestPropertiesLastUpdatedBy struct { + // The object id of the principal who has interacted with a billing entity. + ObjectID *string + + // The tenant id of the principal who has interacted with a billing entity. + TenantID *string + + // The user principal name of the principal who has interacted with a billing entity. + Upn *string +} + +// RequestPropertiesReviewedBy - The principal of the request reviewer. Will only be set if request is approved. +type RequestPropertiesReviewedBy struct { + // The object id of the principal who has interacted with a billing entity. + ObjectID *string + + // The tenant id of the principal who has interacted with a billing entity. + TenantID *string + + // The user principal name of the principal who has interacted with a billing entity. + Upn *string +} + +// Reseller - Details of the reseller. +type Reseller struct { + // READ-ONLY; The name of the reseller. + Description *string + + // READ-ONLY; The MPN ID of the reseller. + ResellerID *string +} + +// Reservation - The definition of the reservation. +type Reservation struct { + Etag *int32 + + // The location of the reservation. + Location *string + + // The properties associated to this reservation + Properties *ReservationProperty + + // The sku information associated to this reservation + SKU *ReservationSKUProperty + + // Tags for this reservation + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// ReservationAppliedScopeProperties - Properties specific to applied scope type. Not required if not applicable. Required +// and need to provide tenantId and managementGroupId if AppliedScopeType is ManagementGroup +type ReservationAppliedScopeProperties struct { + // Display name + DisplayName *string + + // Fully-qualified identifier of the management group where the benefit must be applied. + ManagementGroupID *string + + // Fully-qualified identifier of the resource group. + ResourceGroupID *string + + // Fully-qualified identifier of the subscription. + SubscriptionID *string + + // Tenant ID where the reservation should apply benefit. + TenantID *string +} + +// ReservationExtendedStatusInfo - Extended status information for the reservation. +type ReservationExtendedStatusInfo struct { + // The message giving detailed information about the status code. + Message *string + + // Properties for extended status information + Properties *ExtendedStatusDefinitionProperties + + // The status of the reservation. + StatusCode *ReservationStatusCode +} + +// ReservationList - List of `Reservations +type ReservationList struct { + // Url to get the next page of reservations. + NextLink *string + Value []*Reservation +} + +// ReservationMergeProperties - Properties of reservation merge +type ReservationMergeProperties struct { + // Reservation resource id Created due to the merge. Format of the resource id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + MergeDestination *string + + // Resource ids of the source reservation's merged to form this reservation. Format of the resource id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + MergeSources []*string +} + +// ReservationOrder - Details of a reservation order being returned. +type ReservationOrder struct { + Etag *int32 + + // The properties associated to this reservation order + Properties *ReservationOrderProperty + + // Tags for this reservation + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// ReservationOrderBillingPlanInformation - Information describing the type of billing plan for this reservation order. +type ReservationOrderBillingPlanInformation struct { + // For recurring billing plans, indicates the date when next payment will be processed. Null when total is paid off. + NextPaymentDueDate *time.Time + + // Amount of money to be paid for the Order. Tax is not included. + PricingCurrencyTotal *Price + + // Date when the billing plan has started. + StartDate *time.Time + Transactions []*ReservationPaymentDetail +} + +// ReservationOrderList - List of ReservationOrders +type ReservationOrderList struct { + // Url to get the next page of reservationOrders. + NextLink *string + Value []*ReservationOrder +} + +// ReservationOrderProperty - Properties of a reservation order. +type ReservationOrderProperty struct { + // This is the DateTime when the reservation benefit started. + BenefitStartTime *time.Time + + // Billing account Id associated to this reservation order. + BillingAccountID *string + + // Represent the billing plans. + BillingPlan *ReservationBillingPlan + + // Billing profile Id associated to this reservation order. + BillingProfileID *string + + // This is the DateTime when the reservation order was created. + CreatedDateTime *time.Time + + // Fully-qualified identifier of the customerId where the benefit is applied. Present only for Enterprise Agreement PartnerLed + // customers. + CustomerID *string + + // Friendly name for user to easily identified the reservation order. + DisplayName *string + + // Enrollment id of the reservation order. + EnrollmentID *string + + // This is the date when the reservation order will expire. + ExpiryDate *time.Time + + // This is the date-time when the reservation order will expire. + ExpiryDateTime *time.Time + + // Extended status information for the reservation. + ExtendedStatusInfo *ReservationExtendedStatusInfo + + // Total original quantity of the skus purchased in the reservation order. + OriginalQuantity *int32 + + // Information describing the type of billing plan for this reservation order. + PlanInformation *ReservationOrderBillingPlanInformation + + // Represents UPN + ProductCode *string + + // This is the DateTime when the reservation order was initially requested for purchase. + RequestDateTime *time.Time + Reservations []*Reservation + + // This is the date-time when the Azure Hybrid Benefit needs to be reviewed. + ReviewDateTime *time.Time + + // READ-ONLY; The provisioning state of the reservation, e.g. Succeeded + ProvisioningState *string + + // READ-ONLY; The term of the reservation, e.g. P1Y + Term *string +} + +// ReservationPaymentDetail - Information about payment related to a reservation order. +type ReservationPaymentDetail struct { + // Shows the Account that is charged for this payment. + BillingAccount *string + + // Amount charged in Billing currency. Tax not included. Is null for future payments + BillingCurrencyTotal *Price + + // Date when the payment needs to be done. + DueDate *time.Time + + // Extended status information for the reservation. + ExtendedStatusInfo *ReservationExtendedStatusInfo + + // Date when the transaction is completed. Is null when it is scheduled. + PaymentDate *time.Time + + // Amount in pricing currency. Tax not included. + PricingCurrencyTotal *Price + + // Describes whether the payment is completed, failed, pending, cancelled or scheduled in the future. + Status *PaymentStatus +} + +// ReservationProperty - The property of reservation object. +type ReservationProperty struct { + // Properties specific to applied scope type. Not required if not applicable. Required and need to provide tenantId and managementGroupId + // if AppliedScopeType is ManagementGroup + AppliedScopeProperties *ReservationAppliedScopeProperties + + // The array of applied scopes of a reservation. Will be null if the reservation is in Shared scope + AppliedScopes []*string + + // Indicates if the reservation is archived + Archived *bool + + // This is the DateTime when the reservation benefit started. + BenefitStartTime *time.Time + + // The billing plan options available for this sku. + BillingPlan *ReservationBillingPlan + + // Capabilities of the reservation + Capabilities *string + + // This is the date-time when the reservation will expire. + ExpiryDateTime *time.Time + + // The message giving detailed information about the status code. + ExtendedStatusInfo *ReservationExtendedStatusInfo + + // Allows reservation discount to be applied across skus within the same auto fit group. Not all skus support instance size + // flexibility. + InstanceFlexibility *InstanceFlexibility + + // Properties of reservation merge + MergeProperties *ReservationMergeProperties + + // Represents UPN + ProductCode *string + + // This is the date when the reservation was purchased. + PurchaseDate *time.Time + + // This is the date-time when the reservation was purchased. + PurchaseDateTime *time.Time + + // Reservation Id of the reservation which is purchased because of renew. Format of the resource Id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + RenewDestination *string + + // The renew properties for a reservation. + RenewProperties *RenewPropertiesResponse + + // This is the date-time when the Azure Hybrid Benefit needs to be reviewed. + ReviewDateTime *time.Time + + // Properties of reservation split + SplitProperties *ReservationSplitProperties + + // Properties of reservation swap + SwapProperties *ReservationSwapProperties + + // READ-ONLY; The applied scope type of the reservation. + AppliedScopeType *string + + // READ-ONLY; Subscription that will be charged for purchasing reservation or savings plan + BillingScopeID *string + + // READ-ONLY; The display name of the reservation + DisplayName *string + + // READ-ONLY; The provisioning state of the reservation for display, e.g. Succeeded + DisplayProvisioningState *string + + // READ-ONLY; The effective date time of the reservation + EffectiveDateTime *time.Time + + // READ-ONLY; The expiry date of the reservation + ExpiryDate *string + + // READ-ONLY; DateTime of the last time the reservation was updated. + LastUpdatedDateTime *time.Time + + // READ-ONLY; The provisioning state of the reservation, e.g. Succeeded + ProvisioningState *string + + // READ-ONLY; The provisioning state of the reservation, e.g. Succeeded + ProvisioningSubState *string + + // READ-ONLY; The number of the reservation. + Quantity *float32 + + // READ-ONLY; The renew state of the reservation + Renew *bool + + // READ-ONLY; The renew source of the reservation + RenewSource *string + + // READ-ONLY; The reserved source type of the reservation, e.g. virtual machine. + ReservedResourceType *string + + // READ-ONLY; The sku description of the reservation + SKUDescription *string + + // READ-ONLY; The term of the reservation, e.g. P1Y + Term *string + + // READ-ONLY; The applied scope type of the reservation for display, e.g. Shared + UserFriendlyAppliedScopeType *string + + // READ-ONLY; The renew state of the reservation for display, e.g. On + UserFriendlyRenewState *string + + // READ-ONLY; Reservation utilization + Utilization *ReservationPropertyUtilization +} + +// ReservationPropertyUtilization - Reservation utilization +type ReservationPropertyUtilization struct { + // The array of aggregates of a reservation's utilization + Aggregates []*ReservationUtilizationAggregates + + // READ-ONLY; last 7 day utilization trend for a reservation + Trend *string +} + +// ReservationPurchaseRequest - The request for reservation purchase +type ReservationPurchaseRequest struct { + // The Azure region where the reserved resource lives. + Location *string + + // Properties of reservation purchase request + Properties *ReservationPurchaseRequestProperties + + // The name of sku + SKU *SKUName +} + +// ReservationPurchaseRequestProperties - Properties of reservation purchase request +type ReservationPurchaseRequestProperties struct { + // Properties specific to applied scope type. Not required if not applicable. Required and need to provide tenantId and managementGroupId + // if AppliedScopeType is ManagementGroup + AppliedScopeProperties *ReservationAppliedScopeProperties + + // Type of the Applied Scope. + AppliedScopeType *AppliedScopeType + + // List of the subscriptions that the benefit will be applied. Do not specify if AppliedScopeType is Shared. + AppliedScopes []*string + + // Represent the billing plans. + BillingPlan *ReservationBillingPlan + + // Friendly name of the reservation + DisplayName *string + + // Allows reservation discount to be applied across skus within the same auto fit group. Not all skus support instance size + // flexibility. + InstanceFlexibility *InstanceFlexibility + + // Quantity of the skus that are part of the reservation. Must be greater than zero. + Quantity *int32 + + // Setting this to true will automatically purchase a new benefit on the expiration date time. + Renew *bool + + // Properties specific to each reserved resource type. Not required if not applicable. + ReservedResourceProperties *ReservationPurchaseRequestPropertiesReservedResourceProperties + + // This is the date-time when the Azure hybrid benefit needs to be reviewed. + ReviewDateTime *time.Time + + // READ-ONLY; Subscription that will be charged for purchasing reservation or savings plan + BillingScopeID *string + + // READ-ONLY; The reserved source type of the reservation, e.g. virtual machine. + ReservedResourceType *string + + // READ-ONLY; The term of the reservation, e.g. P1Y + Term *string +} + +// ReservationPurchaseRequestPropertiesReservedResourceProperties - Properties specific to each reserved resource type. Not +// required if not applicable. +type ReservationPurchaseRequestPropertiesReservedResourceProperties struct { + // Turning this on will apply the reservation discount to other VMs in the same VM size group. Only specify for VirtualMachines + // reserved resource type. + InstanceFlexibility *InstanceFlexibility +} + +// ReservationSKUProperty - The property of reservation sku object. +type ReservationSKUProperty struct { + // READ-ONLY; The name of the reservation sku. + Name *string +} + +// ReservationSplitProperties - Properties of reservation split +type ReservationSplitProperties struct { + // List of destination resource id that are created due to split. Format of the resource id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + SplitDestinations []*string + + // Resource id of the reservation from which this is split. Format of the resource id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + SplitSource *string +} + +// ReservationSummary - The roll up count summary of reservations in each state +type ReservationSummary struct { + // READ-ONLY; The number of reservation in Cancelled state + CancelledCount *float32 + + // READ-ONLY; The number of reservation in Expired state + ExpiredCount *float32 + + // READ-ONLY; The number of reservation in Expiring state + ExpiringCount *float32 + + // READ-ONLY; The number of reservation in Failed state + FailedCount *float32 + + // READ-ONLY; The number of reservation in 'No Benefit' state + NoBenefitCount *float32 + + // READ-ONLY; The number of reservation in Pending state + PendingCount *float32 + + // READ-ONLY; The number of reservation in Processing state + ProcessingCount *float32 + + // READ-ONLY; The number of reservation in Succeeded state + SucceededCount *float32 + + // READ-ONLY; The number of reservation in Warning state + WarningCount *float32 +} + +// ReservationSwapProperties - Properties of reservation swap +type ReservationSwapProperties struct { + // Reservation resource id that the original resource gets swapped to. Format of the resource id is /providers/microsoft.capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + SwapDestination *string + + // Resource id of the source reservation that gets swapped. Format of the resource id is /providers/microsoft.capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + SwapSource *string +} + +// ReservationUtilizationAggregates - The aggregate values of reservation utilization +type ReservationUtilizationAggregates struct { + // READ-ONLY; The grain of the aggregate + Grain *float32 + + // READ-ONLY; The grain unit of the aggregate + GrainUnit *string + + // READ-ONLY; The aggregate value + Value *float32 + + // READ-ONLY; The aggregate value unit + ValueUnit *string +} + +// ReservationsListResult - The list of reservations and summary of roll out count of reservations in each state. +type ReservationsListResult struct { + // The roll out count summary of the reservations + Summary *ReservationSummary + + // READ-ONLY; The link (url) to the next page of results. + NextLink *string + + // READ-ONLY; The list of reservations. + Value []*Reservation +} + +// Resource - Common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// RoleAssignment - The properties of the billing role assignment. +type RoleAssignment struct { + // The properties of the billing role assignment. + Properties *RoleAssignmentProperties + + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// RoleAssignmentListResult - A container for a list of resources +type RoleAssignmentListResult struct { + // READ-ONLY; The link (url) to the next page of results. + NextLink *string + + // READ-ONLY; The list of resources. + Value []*RoleAssignment +} + +// RoleAssignmentProperties - The properties of the billing role assignment. +type RoleAssignmentProperties struct { + // REQUIRED; The ID of the role definition. + RoleDefinitionID *string + + // The object id of the user to whom the role was assigned. + PrincipalID *string + + // The principal PUID of the user to whom the role was assigned. + PrincipalPuid *string + + // The principal tenant id of the user to whom the role was assigned. + PrincipalTenantID *string + + // The scope at which the role was assigned. + Scope *string + + // The authentication type of the user, whether Organization or MSA, of the user to whom the role was assigned. This is supported + // only for billing accounts with agreement type Enterprise Agreement. + UserAuthenticationType *string + + // The email address of the user to whom the role was assigned. This is supported only for billing accounts with agreement + // type Enterprise Agreement. + UserEmailAddress *string + + // READ-ONLY; The name of the billing account. + BillingAccountDisplayName *string + + // READ-ONLY; The fully qualified ID that uniquely identifies a billing account. + BillingAccountID *string + + // READ-ONLY; The name of the billing profile. + BillingProfileDisplayName *string + + // READ-ONLY; The fully qualified ID that uniquely identifies a billing profile. + BillingProfileID *string + + // READ-ONLY; The ID of the billing request that was created for the role assignment. This is only applicable to cross tenant + // role assignments or role assignments created through the billing request. + BillingRequestID *string + + // READ-ONLY; The object ID of the user who created the role assignment. + CreatedByPrincipalID *string + + // READ-ONLY; The principal PUID of the user who created the role assignment. + CreatedByPrincipalPuid *string + + // READ-ONLY; The tenant Id of the user who created the role assignment. + CreatedByPrincipalTenantID *string + + // READ-ONLY; The email address of the user who created the role assignment. This is supported only for billing accounts with + // agreement type Enterprise Agreement. + CreatedByUserEmailAddress *string + + // READ-ONLY; The date the role assignment was created. + CreatedOn *time.Time + + // READ-ONLY; The name of the customer. + CustomerDisplayName *string + + // READ-ONLY; The fully qualified ID that uniquely identifies a customer. + CustomerID *string + + // READ-ONLY; The name of the invoice section. + InvoiceSectionDisplayName *string + + // READ-ONLY; The fully qualified ID that uniquely identifies an invoice section. + InvoiceSectionID *string + + // READ-ONLY; The principal PUID of the user who modified the role assignment. + ModifiedByPrincipalID *string + + // READ-ONLY; The principal PUID of the user who modified the role assignment. + ModifiedByPrincipalPuid *string + + // READ-ONLY; The tenant Id of the user who modified the role assignment. + ModifiedByPrincipalTenantID *string + + // READ-ONLY; The email address of the user who modified the role assignment. This is supported only for billing accounts + // with agreement type Enterprise Agreement. + ModifiedByUserEmailAddress *string + + // READ-ONLY; The date the role assignment was modified. + ModifiedOn *time.Time + + // READ-ONLY; The display name of the principal to whom the role was assigned. + PrincipalDisplayName *string + + // READ-ONLY; The friendly name of the tenant of the user to whom the role was assigned. This will be 'Primary Tenant' for + // the primary tenant of the billing account. + PrincipalTenantName *string + + // READ-ONLY; The type of a role Assignment. + PrincipalType *PrincipalType + + // READ-ONLY; The provisioning state of the resource during a long-running operation. + ProvisioningState *ProvisioningState +} + +// RoleDefinition - The properties of a role definition. +type RoleDefinition struct { + // The properties of a role definition. + Properties *RoleDefinitionProperties + + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// RoleDefinitionListResult - A container for a list of resources +type RoleDefinitionListResult struct { + // READ-ONLY; The link (url) to the next page of results. + NextLink *string + + // READ-ONLY; The list of resources. + Value []*RoleDefinition +} + +// RoleDefinitionProperties - The properties of a role definition. +type RoleDefinitionProperties struct { + // REQUIRED; The name of the role. + RoleName *string + + // READ-ONLY; The role description. + Description *string + + // READ-ONLY; The billingPermissions the role has. + Permissions []*Permission +} + +// SKU - The SKU to be applied for this resource +type SKU struct { + // Name of the SKU to be applied + Name *string +} + +// SKUName - The name of sku +type SKUName struct { + Name *string +} + +// SavingsPlanModel - Savings plan +type SavingsPlanModel struct { + // REQUIRED; Savings plan SKU + SKU *SKU + + // Savings plan properties + Properties *SavingsPlanModelProperties + + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// SavingsPlanModelList - List of savings plans +type SavingsPlanModelList struct { + // Url to get the next page. + NextLink *string + Value []*SavingsPlanModel +} + +// SavingsPlanModelListResult - List of savings plans +type SavingsPlanModelListResult struct { + // Url to get the next page. + NextLink *string + + // The roll out count summary of the savings plans + Summary *SavingsPlanSummaryCount + Value []*SavingsPlanModel +} + +// SavingsPlanModelProperties - Savings plan properties +type SavingsPlanModelProperties struct { + // Properties specific to applied scope type. Not required if not applicable. + AppliedScopeProperties *AppliedScopeProperties + + // Type of the Applied Scope. + AppliedScopeType *AppliedScopeType + + // Represents the billing plan in ISO 8601 format. Required only for monthly purchases. + BillingPlan *BillingPlan + + // Subscription that will be charged for purchasing SavingsPlan + BillingScopeID *string + + // Commitment towards the benefit. + Commitment *Commitment + + // Display name + DisplayName *string + + // Represents UPN + ProductCode *string + + // The provisioning state of the resource during a long-running operation. + ProvisioningState *ProvisioningState + + // Setting this to true will automatically purchase a new benefit on the expiration date time. + Renew *bool + + // SavingsPlan Id of the SavingsPlan which is purchased because of renew. + RenewDestination *string + + // Properties specific to renew. + RenewProperties *RenewProperties + + // SavingsPlan Id of the SavingsPlan from which this SavingsPlan is renewed. + RenewSource *string + + // Represents the Savings plan term in ISO 8601 format. + Term *SavingsPlanTerm + + // READ-ONLY; This is the DateTime when the savings plan benefit starts. + BenefitStartTime *time.Time + + // READ-ONLY; Fully-qualified identifier of the billing account where the savings plan is applied. + BillingAccountID *string + + // READ-ONLY; Fully-qualified identifier of the billing profile where the savings plan is applied. Present only for Field-led + // or Customer-led customers. + BillingProfileID *string + + // READ-ONLY; Fully-qualified identifier of the customer where the savings plan is applied. Present only for Partner-led customers. + CustomerID *string + + // READ-ONLY; The provisioning state of the savings plan for display, e.g. Succeeded + DisplayProvisioningState *string + + // READ-ONLY; DateTime of the savings plan starting when this version is effective from. + EffectiveDateTime *time.Time + + // READ-ONLY; This is the date-time when the savings plan will expire. + ExpiryDateTime *time.Time + + // READ-ONLY; Extended status information + ExtendedStatusInfo *ExtendedStatusInfo + + // READ-ONLY; Date time when the savings plan was purchased. + PurchaseDateTime *time.Time + + // READ-ONLY; The applied scope type of the savings plan for display, e.g. Shared + UserFriendlyAppliedScopeType *string + + // READ-ONLY; Savings plan utilization + Utilization *Utilization +} + +// SavingsPlanOrderModel - Savings plan order +type SavingsPlanOrderModel struct { + // REQUIRED; Savings plan SKU + SKU *SKU + + // Savings plan order properties + Properties *SavingsPlanOrderModelProperties + + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} - // READ-ONLY; The list of billing profiles. - Value []*Profile +// SavingsPlanOrderModelList - List of savings plan orders +type SavingsPlanOrderModelList struct { + // Url to get the next page. + NextLink *string + Value []*SavingsPlanOrderModel } -// ProfileProperties - The properties of the billing profile. -type ProfileProperties struct { - // Billing address. - BillTo *AddressDetails +// SavingsPlanOrderModelProperties - Savings plan order properties +type SavingsPlanOrderModelProperties struct { + // Represents the billing plan in ISO 8601 format. Required only for monthly purchases. + BillingPlan *BillingPlan - // The name of the billing profile. + // Subscription that will be charged for purchasing SavingsPlan + BillingScopeID *string + + // Display name DisplayName *string - // Information about the enabled azure plans. - EnabledAzurePlans []*AzurePlan + // Information describing the type of billing plan for this savings plan. + PlanInformation *PlanInformation - // Flag controlling whether the invoices for the billing profile are sent through email. - InvoiceEmailOptIn *bool + // Represents UPN + ProductCode *string + SavingsPlans []*string - // The invoice sections associated to the billing profile. By default this is not populated, unless it's specified in $expand. - InvoiceSections *InvoiceSectionsOnExpand + // Represents the Savings plan term in ISO 8601 format. + Term *SavingsPlanTerm - // The purchase order name that will appear on the invoices generated for the billing profile. - PoNumber *string + // READ-ONLY; DateTime when the savings plan benefit started. + BenefitStartTime *time.Time - // Tags of billing profiles. - Tags map[string]*string + // READ-ONLY; Fully-qualified identifier of the billing account where the savings plan is applied. + BillingAccountID *string - // READ-ONLY; Identifies which services and purchases are paid by a billing profile. - BillingRelationshipType *BillingRelationshipType + // READ-ONLY; Fully-qualified identifier of the billing profile where the savings plan is applied. Present only for Field-led + // or Customer-led customers. + BillingProfileID *string - // READ-ONLY; The currency in which the charges for the billing profile are billed. - Currency *string + // READ-ONLY; Fully-qualified identifier of the customer where the savings plan is applied. Present only for Partner-led customers. + CustomerID *string - // READ-ONLY; Indicates whether user has read access to the billing profile. - HasReadAccess *bool + // READ-ONLY; DateTime when the savings plan will expire. + ExpiryDateTime *time.Time - // READ-ONLY; Identifies the billing profile that is linked to another billing profile in indirect purchase motion. - IndirectRelationshipInfo *IndirectRelationshipInfo + // READ-ONLY; Extended status information + ExtendedStatusInfo *ExtendedStatusInfo - // READ-ONLY; The day of the month when the invoice for the billing profile is generated. - InvoiceDay *int32 + // READ-ONLY; The provisioning state of the savings plan, e.g. Succeeded + ProvisioningState *string +} - // READ-ONLY; The billing profile spending limit. - SpendingLimit *SpendingLimit +// SavingsPlanSummaryCount - The roll up count summary of savings plans in each state +type SavingsPlanSummaryCount struct { + // READ-ONLY; The number of savings plans in Cancelled state + CancelledCount *float32 - // READ-ONLY; The status of the billing profile. - Status *BillingProfileStatus + // READ-ONLY; The number of savings plans in Expired state + ExpiredCount *float32 - // READ-ONLY; Reason for the specified billing profile status. - StatusReasonCode *StatusReasonCode + // READ-ONLY; The number of savings plans in Expiring state + ExpiringCount *float32 - // READ-ONLY; The system generated unique identifier for a billing profile. - SystemID *string + // READ-ONLY; The number of savings plans in Failed state + FailedCount *float32 - // READ-ONLY; Identifies the cloud environments that are associated with a billing profile. This is a system managed optional - // field and gets updated as the billing profile gets associated with accounts in various - // clouds. - TargetClouds []*TargetCloud -} + // READ-ONLY; The number of savings plans in No Benefit state + NoBenefitCount *float32 -// ProfilesOnExpand - The billing profiles associated with the billing account. By default this is not populated, unless it's -// specified in $expand. -type ProfilesOnExpand struct { - // The billing profiles associated with the billing account. - Value []*Profile + // READ-ONLY; The number of savings plans in Pending state + PendingCount *float32 - // READ-ONLY; Indicates whether there are more billing profiles than the ones listed in this collection. The collection lists - // a maximum of 50 billing profiles. To get all billing profiles, use the list billing - // profiles API. - HasMoreResults *bool -} + // READ-ONLY; The number of savings plans in Processing state + ProcessingCount *float32 -// Property - A billing property. -type Property struct { - // A billing property. - Properties *PropertyProperties + // READ-ONLY; The number of savings plans in Succeeded state + SucceededCount *float32 - // READ-ONLY; Resource Id. - ID *string + // READ-ONLY; The number of savings plans in Warning state + WarningCount *float32 +} - // READ-ONLY; Resource name. - Name *string +// SavingsPlanUpdateRequest - Savings plan patch request +type SavingsPlanUpdateRequest struct { + // Savings plan patch request + Properties *SavingsPlanUpdateRequestProperties - // READ-ONLY; Resource type. - Type *string + // The SKU to be applied for this resource + SKU *SKU + + // Tags for this reservation + Tags map[string]*string } -// PropertyProperties - The billing property. -type PropertyProperties struct { - // The cost center applied to the subscription. - CostCenter *string +// SavingsPlanUpdateRequestProperties - Savings plan patch request +type SavingsPlanUpdateRequestProperties struct { + // Properties specific to applied scope type. Not required if not applicable. + AppliedScopeProperties *AppliedScopeProperties - // READ-ONLY; The email address on which the account admin gets all Azure notifications. - AccountAdminNotificationEmailAddress *string + // Type of the Applied Scope. + AppliedScopeType *AppliedScopeType - // READ-ONLY; The name of the billing account to which the subscription is billed. - BillingAccountDisplayName *string + // Display name + DisplayName *string - // READ-ONLY; The ID of the billing account to which the subscription is billed. - BillingAccountID *string + // Setting this to true will automatically purchase a new benefit on the expiration date time. + Renew *bool - // READ-ONLY; The name of the billing profile to which the subscription is billed. - BillingProfileDisplayName *string + // Properties specific to renew. + RenewProperties *RenewProperties +} - // READ-ONLY; The ID of the billing profile to which the subscription is billed. - BillingProfileID *string +// SavingsPlanUpdateValidateRequest - Savings plan update validate request. +type SavingsPlanUpdateValidateRequest struct { + // The benefits of a savings plan. + Benefits []*SavingsPlanUpdateRequestProperties +} - // READ-ONLY; The billing profile spending limit. - BillingProfileSpendingLimit *BillingProfileSpendingLimit +// SavingsPlanValidResponseProperty - Benefit scope response property +type SavingsPlanValidResponseProperty struct { + // Failure reason if the provided input is invalid + Reason *string - // READ-ONLY; The status of the billing profile. - BillingProfileStatus *BillingProfileStatus + // Failure reason code if the provided input is invalid + ReasonCode *string - // READ-ONLY; Reason for the specified billing profile status. - BillingProfileStatusReasonCode *BillingProfileStatusReasonCode + // Indicates if the provided input is valid + Valid *bool +} - // READ-ONLY; The Azure AD tenant ID of the billing account for the subscription. - BillingTenantID *string +// SavingsPlanValidateResponse - Savings plan update validate response. +type SavingsPlanValidateResponse struct { + Benefits []*SavingsPlanValidResponseProperty - // READ-ONLY; The name of the invoice section to which the subscription is billed. - InvoiceSectionDisplayName *string + // Url to get the next page. + NextLink *string +} - // READ-ONLY; The ID of the invoice section to which the subscription is billed. - InvoiceSectionID *string +// SpendingLimitDetails - The billing profile spending limit. +type SpendingLimitDetails struct { + // The initial amount for the billing profile. + Amount *float32 - // READ-ONLY; Indicates whether user is the account admin. - IsAccountAdmin *bool + // The currency in which the charges for the billing profile are billed. + Currency *string - // READ-ONLY; The product ID of the Azure plan. - ProductID *string + // The date when this spending limit is no longer in effect. + EndDate *time.Time - // READ-ONLY; The product name of the Azure plan. - ProductName *string + // The date when this spending limit goes into effect. + StartDate *time.Time - // READ-ONLY; The sku description of the Azure plan for the subscription. - SKUDescription *string + // The status of current spending limit. + Status *SpendingLimitStatus - // READ-ONLY; The sku ID of the Azure plan for the subscription. - SKUID *string + // The type of spending limit. + Type *SpendingLimitType } -// RebillDetails - The rebill details of an invoice. -type RebillDetails struct { - // READ-ONLY; The ID of credit note. - CreditNoteDocumentID *string +// Subscription - The billing properties of a subscription. +type Subscription struct { + // The properties of a(n) BillingSubscription + Properties *SubscriptionProperties - // READ-ONLY; The ID of invoice. - InvoiceDocumentID *string + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string - // READ-ONLY; Rebill details for an invoice. - RebillDetails map[string]*RebillDetails -} + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string -// Reseller - Details of the reseller. -type Reseller struct { - // READ-ONLY; The name of the reseller. - Description *string + // READ-ONLY; The name of the resource + Name *string - // READ-ONLY; The MPN ID of the reseller. - ResellerID *string + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string } -// Reservation - The definition of the reservation. -type Reservation struct { - // The properties associated to this reservation - Properties *ReservationProperty +// SubscriptionAlias - A billing subscription alias. +type SubscriptionAlias struct { + // The properties of a(n) BillingSubscriptionAlias + Properties *SubscriptionAliasProperties - // The sku information associated to this reservation - SKU *ReservationSKUProperty + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string - // READ-ONLY; The id of the reservation. + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // READ-ONLY; The location of the reservation. - Location *string - - // READ-ONLY; The name of the reservation. + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; The type of the reservation. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// ReservationProperty - The property of reservation object. -type ReservationProperty struct { - // The array of applied scopes of a reservation. Will be null if the reservation is in Shared scope - AppliedScopes []*string +// SubscriptionAliasListResult - A container for a list of resources +type SubscriptionAliasListResult struct { + // READ-ONLY; The link (url) to the next page of results. + NextLink *string - // READ-ONLY; The applied scope type of the reservation. - AppliedScopeType *string + // READ-ONLY; The list of resources. + Value []*SubscriptionAlias +} - // READ-ONLY; The display name of the reservation +// SubscriptionAliasProperties - A billing subscription alias. +type SubscriptionAliasProperties struct { + // Indicates whether auto renewal is turned on or off for a product. + AutoRenew *AutoRenew + + // The beneficiary of the billing subscription. + Beneficiary *Beneficiary + + // The provisioning tenant of the subscription. + BeneficiaryTenantID *string + + // The billing frequency in ISO8601 format of product in the subscription. Example: P1M, P3M, P1Y + BillingFrequency *string + + // The fully qualified ID that uniquely identifies a billing profile. + BillingProfileID *string + + // The cost center applied to the subscription. This field is only available for consumption subscriptions of Microsoft Customer + // Agreement or Enterprise Agreement Type billing accounts. + ConsumptionCostCenter *string + + // The fully qualified ID that uniquely identifies a customer. + CustomerID *string + + // The name of the billing subscription. DisplayName *string - // READ-ONLY; The provisioning state of the reservation for display, e.g. Succeeded - DisplayProvisioningState *string + // The fully qualified ID that uniquely identifies an invoice section. + InvoiceSectionID *string - // READ-ONLY; The effective date time of the reservation - EffectiveDateTime *string + // Id of the product for which the subscription is purchased. + ProductTypeID *string - // READ-ONLY; The expiry date of the reservation - ExpiryDate *string + // The tenant in which the subscription is provisioned. + ProvisioningTenantID *string - // READ-ONLY; The provisioning state of the reservation, e.g. Succeeded - ProvisioningState *string + // The quantity of licenses or fulfillment units for the subscription. + Quantity *int64 - // READ-ONLY; The provisioning state of the reservation, e.g. Succeeded - ProvisioningSubState *string + // The SKU ID of the product for which the subscription is purchased. This field is is only available for Microsoft Customer + // Agreement billing accounts. + SKUID *string - // READ-ONLY; The number of the reservation. - Quantity *float32 + // System imposed policies that regulate behavior of the subscription. + SystemOverrides *SystemOverrides - // READ-ONLY; The renew state of the reservation - Renew *bool + // The duration in ISO8601 format for which you can use the subscription. Example: P1M, P3M, P1Y + TermDuration *string - // READ-ONLY; The renew source of the reservation - RenewSource *string + // READ-ONLY; Dictionary of billing policies associated with the subscription. + BillingPolicies map[string]*string - // READ-ONLY; The reserved source type of the reservation, e.g. virtual machine. - ReservedResourceType *string + // READ-ONLY; The name of the billing profile. + BillingProfileDisplayName *string - // READ-ONLY; The sku description of the reservation - SKUDescription *string + // READ-ONLY; The ID that uniquely identifies a billing profile. + BillingProfileName *string - // READ-ONLY; The term of the reservation, e.g. P1Y - Term *string + // READ-ONLY; The ID of the billing subscription with the subscription alias. + BillingSubscriptionID *string - // READ-ONLY; The applied scope type of the reservation for display, e.g. Shared - UserFriendlyAppliedScopeType *string + // READ-ONLY; The name of the customer. + CustomerDisplayName *string - // READ-ONLY; The renew state of the reservation for display, e.g. On - UserFriendlyRenewState *string + // READ-ONLY; The ID that uniquely identifies a customer. + CustomerName *string - // READ-ONLY; Reservation utilization - Utilization *ReservationPropertyUtilization -} + // READ-ONLY; The enrollment Account name associated with the subscription. This field is available only for the Enterprise + // Agreement Type billing accounts. + EnrollmentAccountDisplayName *string -// ReservationPropertyUtilization - Reservation utilization -type ReservationPropertyUtilization struct { - // The array of aggregates of a reservation's utilization - Aggregates []*ReservationUtilizationAggregates + // READ-ONLY; The enrollment Account ID associated with the subscription. This field is available only for the Enterprise + // Agreement Type billing accounts. + EnrollmentAccountID *string - // READ-ONLY; The number of days trend for a reservation - Trend *string -} + // READ-ONLY; Enrollment Account Subscription details. This field is available only for the Enterprise Agreement Type billing + // accounts. + EnrollmentAccountSubscriptionDetails *EnrollmentAccountSubscriptionDetails -// ReservationSKUProperty - The property of reservation sku object. -type ReservationSKUProperty struct { - // READ-ONLY; The name of the reservation sku. - Name *string -} + // READ-ONLY; The name of the invoice section. + InvoiceSectionDisplayName *string -// ReservationSummary - The roll up count summary of reservations in each state -type ReservationSummary struct { - // READ-ONLY; The number of reservation in Cancelled state - CancelledCount *float32 + // READ-ONLY; The ID that uniquely identifies an invoice section. + InvoiceSectionName *string - // READ-ONLY; The number of reservation in Expired state - ExpiredCount *float32 + // READ-ONLY; The last month's charges. This field is only available for usage based subscriptions of Microsoft Customer Agreement + // billing accounts. + LastMonthCharges *Amount - // READ-ONLY; The number of reservation in Expiring state - ExpiringCount *float32 + // READ-ONLY; The current month to date charges. This field is only available for usage based subscriptions of Microsoft Customer + // Agreement billing accounts. + MonthToDateCharges *Amount - // READ-ONLY; The number of reservation in Failed state - FailedCount *float32 + // READ-ONLY; Next billing cycle details of the subscription. + NextBillingCycleDetails *NextBillingCycleDetails - // READ-ONLY; The number of reservation in Pending state - PendingCount *float32 + // READ-ONLY; The offer ID for the subscription. This field is only available for the Microsoft Online Services Program billing + // accounts. + OfferID *string - // READ-ONLY; The number of reservation in Succeeded state - SucceededCount *float32 -} + // READ-ONLY; The status of an operation on the subscription. When None, there is no ongoing operation. When LockedForUpdate, + // write operations will be blocked on the Billing Subscription. Other is the default value + // and you may need to refer to the latest API version for more details. + OperationStatus *BillingSubscriptionOperationStatus -// ReservationUtilizationAggregates - The aggregate values of reservation utilization -type ReservationUtilizationAggregates struct { - // READ-ONLY; The grain of the aggregate - Grain *float32 + // READ-ONLY; The category of the product for which the subscription is purchased. Possible values include: AzureSupport, + // Hardware, ReservationOrder, SaaS, SavingsPlanOrder, Software, UsageBased, Other. + ProductCategory *string - // READ-ONLY; The grain unit of the aggregate - GrainUnit *string + // READ-ONLY; Type of the product for which the subscription is purchased. + ProductType *string - // READ-ONLY; The aggregate value - Value *float32 + // READ-ONLY; The provisioning state of the resource during a long-running operation. + ProvisioningState *ProvisioningState - // READ-ONLY; The aggregate value unit - ValueUnit *string -} + // READ-ONLY; Purchase date of the product in UTC time. + PurchaseDate *time.Time -// ReservationsListResult - The list of reservations and summary of roll out count of reservations in each state. -type ReservationsListResult struct { - // The roll out count summary of the reservations - Summary *ReservationSummary + // READ-ONLY; Details for the next renewal term of a subscription. + RenewalTermDetails *RenewalTermDetails - // READ-ONLY; The link (url) to the next page of results. - NextLink *string + // READ-ONLY; Reseller for this subscription. The fields is not available for Microsoft Partner Agreement billing accounts. + Reseller *Reseller - // READ-ONLY; The list of reservations. - Value []*Reservation -} + // READ-ONLY; Unique identifier of the linked resource. + ResourceURI *string -// Resource - The Resource model definition. -type Resource struct { - // READ-ONLY; Resource Id. - ID *string + // READ-ONLY; The SKU description of the product for which the subscription is purchased. This field is is only available + // for billing accounts with agreement type Microsoft Customer Agreement and Microsoft Partner + // Agreement. + SKUDescription *string - // READ-ONLY; Resource name. - Name *string + // READ-ONLY; The status of the subscription. This field is not available for Enterprise Agreement billing accounts + Status *BillingSubscriptionStatus - // READ-ONLY; Resource type. - Type *string + // READ-ONLY; The ID of the subscription. + SubscriptionID *string + + // READ-ONLY; The suspension details for a subscription. This field is not available for Enterprise Agreement billing accounts. + SuspensionReasonDetails []*SubscriptionStatusDetails + + // READ-ONLY; The suspension reason for a subscription. This field is not available for Enterprise Agreement billing accounts. + SuspensionReasons []*string + + // READ-ONLY; End date of the term in UTC time. + TermEndDate *time.Time + + // READ-ONLY; Start date of the term in UTC time. + TermStartDate *time.Time } -// RoleAssignment - The role assignment -type RoleAssignment struct { - // The properties of the role assignment. - Properties *RoleAssignmentProperties +// SubscriptionEnrollmentDetails - The enrollment details for the subscription. Available for billing accounts with agreement +// type Enterprise Agreement. +type SubscriptionEnrollmentDetails struct { + // The name of the department + DepartmentDisplayName *string - // READ-ONLY; Resource Id. - ID *string + // The ID that uniquely identifies the department. + DepartmentID *string - // READ-ONLY; Resource name. - Name *string + // The name of the enrollment account. + EnrollmentAccountDisplayName *string - // READ-ONLY; Resource type. - Type *string + // The ID that uniquely identifies an enrollment account. + EnrollmentAccountID *string + + // The status of the enrollment account. + EnrollmentAccountStatus *string } -// RoleAssignmentListResult - The list of role assignments. -type RoleAssignmentListResult struct { +// SubscriptionListResult - A container for a list of resources +type SubscriptionListResult struct { // READ-ONLY; The link (url) to the next page of results. NextLink *string - // READ-ONLY; The list of role assignments. - Value []*RoleAssignment -} - -// RoleAssignmentProperties - The properties of the role assignment. -type RoleAssignmentProperties struct { - // The principal id of the user to whom the role was assigned. - PrincipalID *string + // READ-ONLY; Total number of records. + TotalCount *int32 - // The principal tenant id of the user to whom the role was assigned. - PrincipalTenantID *string + // READ-ONLY; The list of resources. + Value []*Subscription +} - // The ID of the role definition. - RoleDefinitionID *string +// SubscriptionMergeRequest - Request parameters that are provided to merge the two billing subscriptions. +type SubscriptionMergeRequest struct { + // The quantity of the source billing subscription that will be merged with the target billing subscription. + Quantity *int32 - // The authentication type. - UserAuthenticationType *string + // The ID of the target billing subscription that will be merged with the source subscription provided in the request. + TargetBillingSubscriptionName *string +} - // The email address of the user. - UserEmailAddress *string +// SubscriptionPatch - The billing properties of a subscription. +type SubscriptionPatch struct { + // The properties of a(n) BillingSubscription + Properties *SubscriptionProperties - // READ-ONLY; The principal Id of the user who created the role assignment. - CreatedByPrincipalID *string + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string - // READ-ONLY; The tenant Id of the user who created the role assignment. - CreatedByPrincipalTenantID *string + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string - // READ-ONLY; The email address of the user who created the role assignment. - CreatedByUserEmailAddress *string + // READ-ONLY; The name of the resource + Name *string - // READ-ONLY; The date the role assignment was created. - CreatedOn *string + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData - // READ-ONLY; The scope at which the role was assigned. - Scope *string + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string } -// RoleDefinition - The properties of a role definition. -type RoleDefinition struct { - // The properties of the a role definition. - Properties *RoleDefinitionProperties +// SubscriptionPolicy - A policy at subscription scope. +type SubscriptionPolicy struct { + // A policy at subscription scope. + Properties *SubscriptionPolicyProperties + + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string - // READ-ONLY; Resource Id. + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // READ-ONLY; Resource name. + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Resource type. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// RoleDefinitionListResult - The list of role definitions. -type RoleDefinitionListResult struct { - // READ-ONLY; The link (url) to the next page of results. - NextLink *string +// SubscriptionPolicyProperties - A policy at subscription scope. +type SubscriptionPolicyProperties struct { + // List of all policies defined at the billing scope. + Policies []*PolicySummary - // READ-ONLY; The role definitions. - Value []*RoleDefinition + // READ-ONLY; The provisioning state of the resource during a long-running operation. + ProvisioningState *ProvisioningState } -// RoleDefinitionProperties - The properties of the a role definition. -type RoleDefinitionProperties struct { - // The billingPermissions the role has - Permissions []*PermissionsProperties +// SubscriptionProperties - The billing properties of a subscription. +type SubscriptionProperties struct { + // Indicates whether auto renewal is turned on or off for a product. + AutoRenew *AutoRenew - // READ-ONLY; The role description - Description *string + // The beneficiary of the billing subscription. + Beneficiary *Beneficiary - // READ-ONLY; The name of the role - RoleName *string -} + // The provisioning tenant of the subscription. + BeneficiaryTenantID *string -// Subscription - A billing subscription. -type Subscription struct { - // The billing properties of a subscription. - Properties *SubscriptionProperties + // The billing frequency in ISO8601 format of product in the subscription. Example: P1M, P3M, P1Y + BillingFrequency *string - // READ-ONLY; Resource Id. - ID *string + // The fully qualified ID that uniquely identifies a billing profile. + BillingProfileID *string - // READ-ONLY; Resource name. - Name *string + // The cost center applied to the subscription. This field is only available for consumption subscriptions of Microsoft Customer + // Agreement or Enterprise Agreement Type billing accounts. + ConsumptionCostCenter *string - // READ-ONLY; Resource type. - Type *string -} + // The fully qualified ID that uniquely identifies a customer. + CustomerID *string -// SubscriptionProperties - The billing properties of a subscription. -type SubscriptionProperties struct { - // The cost center applied to the subscription. - CostCenter *string + // The name of the billing subscription. + DisplayName *string + + // The fully qualified ID that uniquely identifies an invoice section. + InvoiceSectionID *string + + // Id of the product for which the subscription is purchased. + ProductTypeID *string + + // The tenant in which the subscription is provisioned. + ProvisioningTenantID *string + + // The quantity of licenses or fulfillment units for the subscription. + Quantity *int64 - // The sku ID of the Azure plan for the subscription. + // The SKU ID of the product for which the subscription is purchased. This field is is only available for Microsoft Customer + // Agreement billing accounts. SKUID *string - // The current billing status of the subscription. - SubscriptionBillingStatus *BillingSubscriptionStatusType + // System imposed policies that regulate behavior of the subscription. + SystemOverrides *SystemOverrides - // READ-ONLY; The name of the billing profile to which the subscription is billed. + // The duration in ISO8601 format for which you can use the subscription. Example: P1M, P3M, P1Y + TermDuration *string + + // READ-ONLY; Dictionary of billing policies associated with the subscription. + BillingPolicies map[string]*string + + // READ-ONLY; The name of the billing profile. BillingProfileDisplayName *string - // READ-ONLY; The ID of the billing profile to which the subscription is billed. - BillingProfileID *string + // READ-ONLY; The ID that uniquely identifies a billing profile. + BillingProfileName *string - // READ-ONLY; The name of the customer for whom the subscription was created. The field is applicable only for Microsoft Partner - // Agreement billing account. + // READ-ONLY; The name of the customer. CustomerDisplayName *string - // READ-ONLY; The ID of the customer for whom the subscription was created. The field is applicable only for Microsoft Partner - // Agreement billing account. - CustomerID *string + // READ-ONLY; The ID that uniquely identifies a customer. + CustomerName *string - // READ-ONLY; The name of the subscription. - DisplayName *string + // READ-ONLY; The enrollment Account name associated with the subscription. This field is available only for the Enterprise + // Agreement Type billing accounts. + EnrollmentAccountDisplayName *string - // READ-ONLY; The name of the invoice section to which the subscription is billed. + // READ-ONLY; The enrollment Account ID associated with the subscription. This field is available only for the Enterprise + // Agreement Type billing accounts. + EnrollmentAccountID *string + + // READ-ONLY; Enrollment Account Subscription details. This field is available only for the Enterprise Agreement Type billing + // accounts. + EnrollmentAccountSubscriptionDetails *EnrollmentAccountSubscriptionDetails + + // READ-ONLY; The name of the invoice section. InvoiceSectionDisplayName *string - // READ-ONLY; The ID of the invoice section to which the subscription is billed. - InvoiceSectionID *string + // READ-ONLY; The ID that uniquely identifies an invoice section. + InvoiceSectionName *string - // READ-ONLY; The last month charges. + // READ-ONLY; The last month's charges. This field is only available for usage based subscriptions of Microsoft Customer Agreement + // billing accounts. LastMonthCharges *Amount - // READ-ONLY; The current month to date charges. + // READ-ONLY; The current month to date charges. This field is only available for usage based subscriptions of Microsoft Customer + // Agreement billing accounts. MonthToDateCharges *Amount - // READ-ONLY; Reseller for this subscription. + // READ-ONLY; Next billing cycle details of the subscription. + NextBillingCycleDetails *NextBillingCycleDetails + + // READ-ONLY; The offer ID for the subscription. This field is only available for the Microsoft Online Services Program billing + // accounts. + OfferID *string + + // READ-ONLY; The status of an operation on the subscription. When None, there is no ongoing operation. When LockedForUpdate, + // write operations will be blocked on the Billing Subscription. Other is the default value + // and you may need to refer to the latest API version for more details. + OperationStatus *BillingSubscriptionOperationStatus + + // READ-ONLY; The category of the product for which the subscription is purchased. Possible values include: AzureSupport, + // Hardware, ReservationOrder, SaaS, SavingsPlanOrder, Software, UsageBased, Other. + ProductCategory *string + + // READ-ONLY; Type of the product for which the subscription is purchased. + ProductType *string + + // READ-ONLY; The provisioning state of the resource during a long-running operation. + ProvisioningState *ProvisioningState + + // READ-ONLY; Purchase date of the product in UTC time. + PurchaseDate *time.Time + + // READ-ONLY; Details for the next renewal term of a subscription. + RenewalTermDetails *RenewalTermDetails + + // READ-ONLY; Reseller for this subscription. The fields is not available for Microsoft Partner Agreement billing accounts. Reseller *Reseller - // READ-ONLY; The sku description of the Azure plan for the subscription. + // READ-ONLY; Unique identifier of the linked resource. + ResourceURI *string + + // READ-ONLY; The SKU description of the product for which the subscription is purchased. This field is is only available + // for billing accounts with agreement type Microsoft Customer Agreement and Microsoft Partner + // Agreement. SKUDescription *string + // READ-ONLY; The status of the subscription. This field is not available for Enterprise Agreement billing accounts + Status *BillingSubscriptionStatus + // READ-ONLY; The ID of the subscription. SubscriptionID *string - // READ-ONLY; The suspension reason for a subscription. Applies only to subscriptions in Microsoft Online Services Program - // billing accounts. + // READ-ONLY; The suspension details for a subscription. This field is not available for Enterprise Agreement billing accounts. + SuspensionReasonDetails []*SubscriptionStatusDetails + + // READ-ONLY; The suspension reason for a subscription. This field is not available for Enterprise Agreement billing accounts. SuspensionReasons []*string + + // READ-ONLY; End date of the term in UTC time. + TermEndDate *time.Time + + // READ-ONLY; Start date of the term in UTC time. + TermStartDate *time.Time } -// SubscriptionsListResult - The list of billing subscriptions. -type SubscriptionsListResult struct { - // READ-ONLY; The link (url) to the next page of results. - NextLink *string +// SubscriptionSplitRequest - Request parameters that are provided to split the billing subscription. +type SubscriptionSplitRequest struct { + // The billing frequency of the target subscription in the ISO8601 format. Example: P1M, P3M, P1Y" + BillingFrequency *string - // READ-ONLY; Total number of records. - TotalCount *int32 + // The quantity of the target product to which the subscription needs to be split into. + Quantity *int32 - // READ-ONLY; The list of billing subscriptions. - Value []*Subscription + // The ID of the target product to which the subscription needs to be split into. This value is not same as the value returned + // in Get API call and can be retrieved from Catalog API to know the product id + // to split into. + TargetProductTypeID *string + + // The ID of the target product to which the subscription needs to be split into. This value is not same as the value returned + // in Get API call and can be retrieved from Catalog API to know the sku id to + // split into. + TargetSKUID *string + + // The term duration of the target in ISO8601 format product to which the subscription needs to be split into. Example: P1M, + // P1Y + TermDuration *string +} + +// SubscriptionStatusDetails - The suspension details for a subscription. This field is not available for Enterprise Agreement +// billing accounts. +type SubscriptionStatusDetails struct { + // READ-ONLY; The suspension effective date for a subscription. This field is not available for Enterprise Agreement billing + // accounts. + EffectiveDate *time.Time + + // READ-ONLY; The suspension reason for a subscription. This field is not available for Enterprise Agreement billing accounts. + Reason *SubscriptionStatusReason +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // The identity that created the resource. + CreatedBy *string + + // The type of identity that created the resource. + CreatedByType *CreatedByType + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time + + // The identity that last modified the resource. + LastModifiedBy *string + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType +} + +// SystemOverrides - System imposed policies that regulate behavior of the subscription. +type SystemOverrides struct { + // READ-ONLY; The policy override for the subscription indicates whether the self-serve cancellation or seat reduction is + // allowed. + Cancellation *Cancellation + + // READ-ONLY; The end date in UTC time by when the self-serve cancellation ends. + CancellationAllowedEndDate *time.Time +} + +// TaxIdentifier - A tax identifier for the billing account. +type TaxIdentifier struct { + // The country of the tax identifier. + Country *string + + // The id of the tax identifier. + ID *string + + // The scope of the tax identifier. + Scope *string + + // The status of the tax identifier. + Status *TaxIdentifierStatus + + // The type of the tax identifier. + Type *TaxIdentifierType } // Transaction - A transaction. type Transaction struct { - // The properties of a transaction. + // A transaction. Properties *TransactionProperties - // READ-ONLY; Resource Id. + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // READ-ONLY; Resource name. + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Resource type. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// TransactionListResult - The list of transactions. +// TransactionListResult - A container for a list of resources type TransactionListResult struct { // READ-ONLY; The link (url) to the next page of results. NextLink *string - // READ-ONLY; Total number of records. - TotalCount *int32 - - // READ-ONLY; The list of transactions. + // READ-ONLY; The list of resources. Value []*Transaction } -// TransactionProperties - The properties of a transaction. +// TransactionProperties - A transaction. type TransactionProperties struct { - // The kind of transaction. Options are all or reservation. - Kind *TransactionTypeKind - - // The type of transaction. - TransactionType *ReservationType - - // READ-ONLY; The amount of any Azure credits automatically applied to this transaction. - AzureCreditApplied *Amount + // The amount of any Azure credits automatically applied to this transaction. + AzureCreditApplied *TransactionPropertiesAzureCreditApplied - // READ-ONLY; The type of azure plan of the subscription that was used for the transaction. + // Details of the Azure plan. AzurePlan *string - // READ-ONLY; The ISO 4217 code for the currency in which this transaction is billed. + // The ISO 4217 code for the currency in which this transaction is billed. BillingCurrency *string - // READ-ONLY; The name of the billing profile which will be billed for the transaction. - BillingProfileDisplayName *string + // The name of the billing profile. + BillingProfileDisplayName any - // READ-ONLY; The ID of the billing profile which will be billed for the transaction. + // The fully qualified ID that uniquely identifies a billing profile. BillingProfileID *string - // READ-ONLY; The name of the customer for which the transaction took place. The field is applicable only for Microsoft Partner - // Agreement billing account. + // The amount of Microsoft Azure Consumption Commitment(MACC) decrement through the transaction. + ConsumptionCommitmentDecremented *TransactionPropertiesConsumptionCommitmentDecremented + + // The credit type of the transaction. Applies only to credited transactions. + CreditType *CreditType + + // The name of the customer. CustomerDisplayName *string - // READ-ONLY; The ID of the customer for which the transaction took place. The field is applicable only for Microsoft Partner - // Agreement billing account. + // The fully qualified ID that uniquely identifies a customer. CustomerID *string - // READ-ONLY; The date of transaction. + // The date of transaction. Date *time.Time - // READ-ONLY; The percentage discount, if any, applied to this transaction. + // The percentage discount, if any, applied to this transaction. Discount *float32 - // READ-ONLY; The price of the product after applying any discounts. - EffectivePrice *Amount + // The price of the product after applying any discounts. + EffectivePrice *TransactionPropertiesEffectivePrice - // READ-ONLY; The exchange rate used to convert charged amount to billing currency, if applicable. + // The exchange rate used to convert charged amount to billing currency, if applicable. ExchangeRate *float32 - // READ-ONLY; Invoice on which the transaction was billed or 'pending' if the transaction is not billed. + // Invoice name on which the transaction was billed or 'Pending' if the transaction is not billed. Invoice *string - // READ-ONLY; The ID of the invoice on which the transaction was billed. This field is only applicable for transactions which - // are billed. + // The fully qualified ID of the invoice on which the transaction was billed. This field is only applicable for transactions + // which are billed. InvoiceID *string - // READ-ONLY; The name of the invoice section which will be billed for the transaction. + // The name of the invoice section. InvoiceSectionDisplayName *string - // READ-ONLY; The ID of the invoice section which will be billed for the transaction. + // The fully qualified ID that uniquely identifies an invoice section. InvoiceSectionID *string - // READ-ONLY; The retail price of the product. - MarketPrice *Amount + // Whether or not the transaction is third party. + IsThirdParty *bool - // READ-ONLY; The order ID of the reservation. The field is only applicable for transaction of kind reservation. - OrderID *string + // Type of the transaction, billed or unbilled. + Kind *TransactionKind - // READ-ONLY; The name of the reservation order. The field is only applicable for transactions of kind reservation. - OrderName *string + // The retail price of the product. + MarketPrice *TransactionPropertiesMarketPrice - // READ-ONLY; The ISO 4217 code for the currency in which the product is priced. + // The part number of the product for which the transaction took place. The field is only applicable for Enterprise Agreement + // invoices. + PartNumber *string + + // The ISO 4217 code for the currency in which the product is priced. PricingCurrency *string - // READ-ONLY; The description of the product for which the transaction took place. + // The description of the product for which the transaction took place. ProductDescription *string - // READ-ONLY; The family of the product for which the transaction took place. + // The family of the product for which the transaction took place. ProductFamily *string - // READ-ONLY; The type of the product for which the transaction took place. + // The type of the product for which the transaction took place. ProductType *string - // READ-ONLY; The ID of the product type for which the transaction took place. + // The ID of the product type for which the transaction took place. ProductTypeID *string - // READ-ONLY; The quantity purchased in the transaction. + // The quantity purchased in the transaction. Quantity *int32 - // READ-ONLY; The end date of the product term, or the end date of the month in which usage ended. + // There reason code for the transaction. + ReasonCode *string + + // The refund details of a transaction. + RefundTransactionDetails *TransactionPropertiesRefundTransactionDetails + + // The end date of the product term, or the end date of the month in which usage ended. ServicePeriodEndDate *time.Time - // READ-ONLY; The date of the purchase of the product, or the start date of the month in which usage started. + // The date of the purchase of the product, or the start date of the month in which usage started. ServicePeriodStartDate *time.Time - // READ-ONLY; The pre-tax charged amount for the transaction. - SubTotal *Amount + // Identifies the type of tax calculation used for the invoice. The field is applicable only to invoices with special tax + // calculation logic. + SpecialTaxationType *SpecialTaxationType - // READ-ONLY; The ID of the subscription that was used for the transaction. The field is only applicable for transaction of - // kind reservation. - SubscriptionID *string + // The pre-tax charged amount for the transaction. + SubTotal *TransactionPropertiesSubTotal - // READ-ONLY; The name of the subscription that was used for the transaction. The field is only applicable for transaction - // of kind reservation. - SubscriptionName *string + // The tax amount applied to the transaction. + Tax *TransactionPropertiesTax - // READ-ONLY; The tax amount applied to the transaction. - Tax *Amount + // The charge associated with the transaction. + TransactionAmount *TransactionPropertiesTransactionAmount - // READ-ONLY; The charge associated with the transaction. - TransactionAmount *Amount + // The type of transaction. + TransactionType *string - // READ-ONLY; The unit of measure used to bill for the product. For example, compute services are billed per hour. + // The unit of measure used to bill for the product. For example, compute services are billed per hour. UnitOfMeasure *string - // READ-ONLY; The description for the unit of measure for a given product. + // The description for the unit of measure for a given product. UnitType *string - // READ-ONLY; The number of units used for a given product. + // The number of units used for a given product. Units *float32 } -// TransferBillingSubscriptionRequestProperties - Request parameters to transfer billing subscription. -type TransferBillingSubscriptionRequestProperties struct { - // REQUIRED; The destination invoice section id. - DestinationInvoiceSectionID *string +// TransactionPropertiesAzureCreditApplied - The amount of any Azure credits automatically applied to this transaction. +type TransactionPropertiesAzureCreditApplied struct { + // READ-ONLY; The currency for the amount value. + Currency *string + + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 } -// TransferProductRequestProperties - The properties of the product to initiate a transfer. -type TransferProductRequestProperties struct { - // The destination invoice section id. - DestinationInvoiceSectionID *string +// TransactionPropertiesConsumptionCommitmentDecremented - The amount of Microsoft Azure Consumption Commitment(MACC) decrement +// through the transaction. +type TransactionPropertiesConsumptionCommitmentDecremented struct { + // READ-ONLY; The currency for the amount value. + Currency *string + + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 } -// ValidateAddressResponse - Result of the address validation -type ValidateAddressResponse struct { - // status of the address validation. - Status *AddressValidationStatus +// TransactionPropertiesEffectivePrice - The price of the product after applying any discounts. +type TransactionPropertiesEffectivePrice struct { + // READ-ONLY; The currency for the amount value. + Currency *string - // The list of suggested addresses. - SuggestedAddresses []*AddressDetails + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 +} - // Validation error message. - ValidationMessage *string +// TransactionPropertiesMarketPrice - The retail price of the product. +type TransactionPropertiesMarketPrice struct { + // READ-ONLY; The currency for the amount value. + Currency *string + + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 } -// ValidateProductTransferEligibilityError - Error details of the product transfer eligibility validation. -type ValidateProductTransferEligibilityError struct { - // Error code for the product transfer validation. - Code *ProductTransferValidationErrorCode +// TransactionPropertiesRefundTransactionDetails - The refund details of a transaction. +type TransactionPropertiesRefundTransactionDetails struct { + // The amount refunded. + AmountRefunded *RefundTransactionDetailsAmountRefunded - // Detailed error message explaining the error. - Details *string + // The amount of refund requested. + AmountRequested *RefundTransactionDetailsAmountRequested - // The error message. - Message *string + // The ID of refund operation. + RefundOperationID *string } -// ValidateProductTransferEligibilityResult - Result of the product transfer eligibility validation. -type ValidateProductTransferEligibilityResult struct { - // Validation error details. - ErrorDetails *ValidateProductTransferEligibilityError +// TransactionPropertiesSubTotal - The pre-tax charged amount for the transaction. +type TransactionPropertiesSubTotal struct { + // READ-ONLY; The currency for the amount value. + Currency *string - // READ-ONLY; Specifies whether the transfer is eligible or not. - IsMoveEligible *bool + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 } -// ValidateSubscriptionTransferEligibilityError - Error details of the transfer eligibility validation -type ValidateSubscriptionTransferEligibilityError struct { - // Error code for the product transfer validation. - Code *SubscriptionTransferValidationErrorCode +// TransactionPropertiesTax - The tax amount applied to the transaction. +type TransactionPropertiesTax struct { + // READ-ONLY; The currency for the amount value. + Currency *string - // Detailed error message explaining the error. - Details *string + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 +} - // The error message. +// TransactionPropertiesTransactionAmount - The charge associated with the transaction. +type TransactionPropertiesTransactionAmount struct { + // READ-ONLY; The currency for the amount value. + Currency *string + + // READ-ONLY; The amount value. For example, if the currency is USD, then a value of 600 would be $600.00. + Value *float32 +} + +// TransactionSummary - A transaction summary. +type TransactionSummary struct { + // READ-ONLY; The total amount of any Azure credits applied. + AzureCreditApplied *float32 + + // READ-ONLY; The ISO 4217 code for the currency in which the transactions are billed. + BillingCurrency *string + + // READ-ONLY; The total Microsoft Azure Consumption Commitment (MACC) decrement through the invoice. + ConsumptionCommitmentDecremented *float32 + + // READ-ONLY; The total pre-tax charged amount. + SubTotal *float32 + + // READ-ONLY; The total tax amount applied. + Tax *float32 + + // READ-ONLY; The total charges. + Total *float32 +} + +// TransferDetails - Details of the transfer. +type TransferDetails struct { + // Details of the transfer. + Properties *TransferProperties + + // Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value + // length supported of 256 characters. Keys/value should not empty value nor null. + // Keys can not contain < > % & \ ? / + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// TransferDetailsListResult - The list of transfers initiated by caller. +type TransferDetailsListResult struct { + // READ-ONLY; The link (url) to the next page of results. + NextLink *string + + // READ-ONLY; The list of transfers initiated by caller. + Value []*TransferDetails +} + +// TransferError - Error details for transfer execution. +type TransferError struct { + // READ-ONLY; Error code. + Code *string + + // READ-ONLY; Error message. Message *string } -// ValidateSubscriptionTransferEligibilityResult - Result of the transfer eligibility validation. -type ValidateSubscriptionTransferEligibilityResult struct { - // Validation error details. - ErrorDetails *ValidateSubscriptionTransferEligibilityError +// TransferItemQueryParameter - Query parameter to enumerate transfer requests. +type TransferItemQueryParameter struct { + // State of the transfer request query filter. + State *string +} - // READ-ONLY; Specifies whether the subscription is eligible to be transferred. - IsMoveEligible *bool +// TransferProperties - Transfer details +type TransferProperties struct { + // READ-ONLY; The email ID of the user who canceled the transfer request. + CanceledBy *string + + // READ-ONLY; Detailed transfer status. + DetailedTransferStatus []*DetailedTransferStatus + + // READ-ONLY; The time at which the transfer request expires. + ExpirationTime *time.Time + + // READ-ONLY; The email ID of the user who sent the transfer request. + InitiatorEmailID *string + + // READ-ONLY; The email ID of the user to whom the transfer request was sent. + RecipientEmailID *string + + // READ-ONLY; Overall transfer status. + TransferStatus *TransferStatus +} + +// TransitionDetails - The details for a billing account transitioned from agreement type Microsoft Online Services Program +// to agreement type Microsoft Customer Agreement. +type TransitionDetails struct { + // READ-ONLY; The anniversary day of the pre-transitioned account of type Microsoft Online Services Program. + AnniversaryDay *int32 + + // READ-ONLY; The transition completion date. + TransitionDate *time.Time +} + +// Utilization - Savings plan utilization +type Utilization struct { + // The array of aggregates of a savings plan's utilization + Aggregates []*UtilizationAggregates + + // READ-ONLY; The trend for a savings plan's utilization + Trend *string +} + +// UtilizationAggregates - The aggregate values of savings plan utilization +type UtilizationAggregates struct { + // READ-ONLY; The grain of the aggregate + Grain *float32 + + // READ-ONLY; The grain unit of the aggregate + GrainUnit *string + + // READ-ONLY; The aggregate value + Value *float32 + + // READ-ONLY; The aggregate value unit + ValueUnit *string +} + +// ValidateTransferListResponse - Result of transfer validation. +type ValidateTransferListResponse struct { + // READ-ONLY; The list of transfer validation results. + Value []*ValidateTransferResponse +} + +// ValidateTransferResponse - Transfer validation response. +type ValidateTransferResponse struct { + // The properties of transfer validation response. + Properties *ValidateTransferResponseProperties +} + +// ValidateTransferResponseProperties - The properties of transfer validation response. +type ValidateTransferResponseProperties struct { + // The array of validation results. + Results []*ValidationResultProperties + + // READ-ONLY; The product id for which this result applies. + ProductID *string + + // READ-ONLY; The status of validation + Status *string +} + +// ValidationResultProperties - The properties of the validation result. +type ValidationResultProperties struct { + // READ-ONLY; Result Code. + Code *string + + // READ-ONLY; Result Level. + Level *string + + // READ-ONLY; The validation message. + Message *string } diff --git a/sdk/resourcemanager/billing/armbilling/models_serde.go b/sdk/resourcemanager/billing/armbilling/models_serde.go index 10e34fba9ac7..dab5acdc9953 100644 --- a/sdk/resourcemanager/billing/armbilling/models_serde.go +++ b/sdk/resourcemanager/billing/armbilling/models_serde.go @@ -11,16 +11,73 @@ package armbilling import ( "encoding/json" "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" "reflect" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" ) +// MarshalJSON implements the json.Marshaller interface for type AcceptTransferProperties. +func (a AcceptTransferProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "productDetails", a.ProductDetails) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcceptTransferProperties. +func (a *AcceptTransferProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "productDetails": + err = unpopulate(val, "ProductDetails", &a.ProductDetails) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcceptTransferRequest. +func (a AcceptTransferRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcceptTransferRequest. +func (a *AcceptTransferRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Account. func (a Account) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "tags", a.Tags) populate(objectMap, "type", a.Type) return json.Marshal(objectMap) } @@ -43,6 +100,12 @@ func (a *Account) UnmarshalJSON(data []byte) error { case "properties": err = unpopulate(val, "Properties", &a.Properties) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &a.Type) delete(rawMsg, key) @@ -85,20 +148,202 @@ func (a *AccountListResult) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type AccountPatch. +func (a AccountPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountPatch. +func (a *AccountPatch) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccountPolicy. +func (a AccountPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountPolicy. +func (a *AccountPolicy) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccountPolicyProperties. +func (a AccountPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "enterpriseAgreementPolicies", a.EnterpriseAgreementPolicies) + populate(objectMap, "marketplacePurchases", a.MarketplacePurchases) + populate(objectMap, "policies", a.Policies) + populate(objectMap, "provisioningState", a.ProvisioningState) + populate(objectMap, "reservationPurchases", a.ReservationPurchases) + populate(objectMap, "savingsPlanPurchases", a.SavingsPlanPurchases) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountPolicyProperties. +func (a *AccountPolicyProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "enterpriseAgreementPolicies": + err = unpopulate(val, "EnterpriseAgreementPolicies", &a.EnterpriseAgreementPolicies) + delete(rawMsg, key) + case "marketplacePurchases": + err = unpopulate(val, "MarketplacePurchases", &a.MarketplacePurchases) + delete(rawMsg, key) + case "policies": + err = unpopulate(val, "Policies", &a.Policies) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) + delete(rawMsg, key) + case "reservationPurchases": + err = unpopulate(val, "ReservationPurchases", &a.ReservationPurchases) + delete(rawMsg, key) + case "savingsPlanPurchases": + err = unpopulate(val, "SavingsPlanPurchases", &a.SavingsPlanPurchases) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccountPolicyPropertiesEnterpriseAgreementPolicies. +func (a AccountPolicyPropertiesEnterpriseAgreementPolicies) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountOwnerViewCharges", a.AccountOwnerViewCharges) + populate(objectMap, "authenticationType", a.AuthenticationType) + populate(objectMap, "departmentAdminViewCharges", a.DepartmentAdminViewCharges) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountPolicyPropertiesEnterpriseAgreementPolicies. +func (a *AccountPolicyPropertiesEnterpriseAgreementPolicies) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accountOwnerViewCharges": + err = unpopulate(val, "AccountOwnerViewCharges", &a.AccountOwnerViewCharges) + delete(rawMsg, key) + case "authenticationType": + err = unpopulate(val, "AuthenticationType", &a.AuthenticationType) + delete(rawMsg, key) + case "departmentAdminViewCharges": + err = unpopulate(val, "DepartmentAdminViewCharges", &a.DepartmentAdminViewCharges) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type AccountProperties. func (a AccountProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "accountStatus", a.AccountStatus) + populate(objectMap, "accountStatusReasonCode", a.AccountStatusReasonCode) + populate(objectMap, "accountSubType", a.AccountSubType) populate(objectMap, "accountType", a.AccountType) populate(objectMap, "agreementType", a.AgreementType) - populate(objectMap, "billingProfiles", a.BillingProfiles) - populate(objectMap, "departments", a.Departments) + populate(objectMap, "billingRelationshipTypes", a.BillingRelationshipTypes) populate(objectMap, "displayName", a.DisplayName) - populate(objectMap, "enrollmentAccounts", a.EnrollmentAccounts) populate(objectMap, "enrollmentDetails", a.EnrollmentDetails) + populate(objectMap, "hasNoBillingProfiles", a.HasNoBillingProfiles) populate(objectMap, "hasReadAccess", a.HasReadAccess) populate(objectMap, "notificationEmailAddress", a.NotificationEmailAddress) + populate(objectMap, "primaryBillingTenantId", a.PrimaryBillingTenantID) + populate(objectMap, "provisioningState", a.ProvisioningState) + populate(objectMap, "qualifications", a.Qualifications) + populate(objectMap, "registrationNumber", a.RegistrationNumber) populate(objectMap, "soldTo", a.SoldTo) + populate(objectMap, "taxIds", a.TaxIDs) return json.Marshal(objectMap) } @@ -114,36 +359,54 @@ func (a *AccountProperties) UnmarshalJSON(data []byte) error { case "accountStatus": err = unpopulate(val, "AccountStatus", &a.AccountStatus) delete(rawMsg, key) + case "accountStatusReasonCode": + err = unpopulate(val, "AccountStatusReasonCode", &a.AccountStatusReasonCode) + delete(rawMsg, key) + case "accountSubType": + err = unpopulate(val, "AccountSubType", &a.AccountSubType) + delete(rawMsg, key) case "accountType": err = unpopulate(val, "AccountType", &a.AccountType) delete(rawMsg, key) case "agreementType": err = unpopulate(val, "AgreementType", &a.AgreementType) delete(rawMsg, key) - case "billingProfiles": - err = unpopulate(val, "BillingProfiles", &a.BillingProfiles) - delete(rawMsg, key) - case "departments": - err = unpopulate(val, "Departments", &a.Departments) + case "billingRelationshipTypes": + err = unpopulate(val, "BillingRelationshipTypes", &a.BillingRelationshipTypes) delete(rawMsg, key) case "displayName": err = unpopulate(val, "DisplayName", &a.DisplayName) delete(rawMsg, key) - case "enrollmentAccounts": - err = unpopulate(val, "EnrollmentAccounts", &a.EnrollmentAccounts) - delete(rawMsg, key) case "enrollmentDetails": err = unpopulate(val, "EnrollmentDetails", &a.EnrollmentDetails) delete(rawMsg, key) + case "hasNoBillingProfiles": + err = unpopulate(val, "HasNoBillingProfiles", &a.HasNoBillingProfiles) + delete(rawMsg, key) case "hasReadAccess": err = unpopulate(val, "HasReadAccess", &a.HasReadAccess) delete(rawMsg, key) case "notificationEmailAddress": err = unpopulate(val, "NotificationEmailAddress", &a.NotificationEmailAddress) delete(rawMsg, key) + case "primaryBillingTenantId": + err = unpopulate(val, "PrimaryBillingTenantID", &a.PrimaryBillingTenantID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) + delete(rawMsg, key) + case "qualifications": + err = unpopulate(val, "Qualifications", &a.Qualifications) + delete(rawMsg, key) + case "registrationNumber": + err = unpopulate(val, "RegistrationNumber", &a.RegistrationNumber) + delete(rawMsg, key) case "soldTo": err = unpopulate(val, "SoldTo", &a.SoldTo) delete(rawMsg, key) + case "taxIds": + err = unpopulate(val, "TaxIDs", &a.TaxIDs) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -152,15 +415,29 @@ func (a *AccountProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AccountUpdateRequest. -func (a AccountUpdateRequest) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AccountPropertiesEnrollmentDetails. +func (a AccountPropertiesEnrollmentDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "properties", a.Properties) + populate(objectMap, "billingCycle", a.BillingCycle) + populate(objectMap, "channel", a.Channel) + populate(objectMap, "cloud", a.Cloud) + populate(objectMap, "countryCode", a.CountryCode) + populate(objectMap, "currency", a.Currency) + populateDateTimeRFC3339(objectMap, "endDate", a.EndDate) + populate(objectMap, "extendedTermOption", a.ExtendedTermOption) + populate(objectMap, "indirectRelationshipInfo", a.IndirectRelationshipInfo) + populate(objectMap, "invoiceRecipient", a.InvoiceRecipient) + populate(objectMap, "language", a.Language) + populate(objectMap, "markupStatus", a.MarkupStatus) + populate(objectMap, "poNumber", a.PoNumber) + populateDateTimeRFC3339(objectMap, "startDate", a.StartDate) + populate(objectMap, "supportCoverage", a.SupportCoverage) + populate(objectMap, "supportLevel", a.SupportLevel) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AccountUpdateRequest. -func (a *AccountUpdateRequest) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountPropertiesEnrollmentDetails. +func (a *AccountPropertiesEnrollmentDetails) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -168,8 +445,50 @@ func (a *AccountUpdateRequest) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "properties": - err = unpopulate(val, "Properties", &a.Properties) + case "billingCycle": + err = unpopulate(val, "BillingCycle", &a.BillingCycle) + delete(rawMsg, key) + case "channel": + err = unpopulate(val, "Channel", &a.Channel) + delete(rawMsg, key) + case "cloud": + err = unpopulate(val, "Cloud", &a.Cloud) + delete(rawMsg, key) + case "countryCode": + err = unpopulate(val, "CountryCode", &a.CountryCode) + delete(rawMsg, key) + case "currency": + err = unpopulate(val, "Currency", &a.Currency) + delete(rawMsg, key) + case "endDate": + err = unpopulateDateTimeRFC3339(val, "EndDate", &a.EndDate) + delete(rawMsg, key) + case "extendedTermOption": + err = unpopulate(val, "ExtendedTermOption", &a.ExtendedTermOption) + delete(rawMsg, key) + case "indirectRelationshipInfo": + err = unpopulate(val, "IndirectRelationshipInfo", &a.IndirectRelationshipInfo) + delete(rawMsg, key) + case "invoiceRecipient": + err = unpopulate(val, "InvoiceRecipient", &a.InvoiceRecipient) + delete(rawMsg, key) + case "language": + err = unpopulate(val, "Language", &a.Language) + delete(rawMsg, key) + case "markupStatus": + err = unpopulate(val, "MarkupStatus", &a.MarkupStatus) + delete(rawMsg, key) + case "poNumber": + err = unpopulate(val, "PoNumber", &a.PoNumber) + delete(rawMsg, key) + case "startDate": + err = unpopulateDateTimeRFC3339(val, "StartDate", &a.StartDate) + delete(rawMsg, key) + case "supportCoverage": + err = unpopulate(val, "SupportCoverage", &a.SupportCoverage) + delete(rawMsg, key) + case "supportLevel": + err = unpopulate(val, "SupportLevel", &a.SupportLevel) delete(rawMsg, key) } if err != nil { @@ -179,8 +498,43 @@ func (a *AccountUpdateRequest) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AddressDetails. -func (a AddressDetails) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AccountPropertiesRegistrationNumber. +func (a AccountPropertiesRegistrationNumber) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "required", a.Required) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountPropertiesRegistrationNumber. +func (a *AccountPropertiesRegistrationNumber) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "required": + err = unpopulate(val, "Required", &a.Required) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccountPropertiesSoldTo. +func (a AccountPropertiesSoldTo) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "addressLine1", a.AddressLine1) populate(objectMap, "addressLine2", a.AddressLine2) @@ -191,6 +545,7 @@ func (a AddressDetails) MarshalJSON() ([]byte, error) { populate(objectMap, "district", a.District) populate(objectMap, "email", a.Email) populate(objectMap, "firstName", a.FirstName) + populate(objectMap, "isValidAddress", a.IsValidAddress) populate(objectMap, "lastName", a.LastName) populate(objectMap, "middleName", a.MiddleName) populate(objectMap, "phoneNumber", a.PhoneNumber) @@ -199,8 +554,8 @@ func (a AddressDetails) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AddressDetails. -func (a *AddressDetails) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountPropertiesSoldTo. +func (a *AccountPropertiesSoldTo) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -235,6 +590,9 @@ func (a *AddressDetails) UnmarshalJSON(data []byte) error { case "firstName": err = unpopulate(val, "FirstName", &a.FirstName) delete(rawMsg, key) + case "isValidAddress": + err = unpopulate(val, "IsValidAddress", &a.IsValidAddress) + delete(rawMsg, key) case "lastName": err = unpopulate(val, "LastName", &a.LastName) delete(rawMsg, key) @@ -258,12 +616,132 @@ func (a *AddressDetails) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type Agreement. -func (a Agreement) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AddressDetails. +func (a AddressDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", a.ID) - populate(objectMap, "name", a.Name) + populate(objectMap, "addressLine1", a.AddressLine1) + populate(objectMap, "addressLine2", a.AddressLine2) + populate(objectMap, "addressLine3", a.AddressLine3) + populate(objectMap, "city", a.City) + populate(objectMap, "companyName", a.CompanyName) + populate(objectMap, "country", a.Country) + populate(objectMap, "district", a.District) + populate(objectMap, "email", a.Email) + populate(objectMap, "firstName", a.FirstName) + populate(objectMap, "isValidAddress", a.IsValidAddress) + populate(objectMap, "lastName", a.LastName) + populate(objectMap, "middleName", a.MiddleName) + populate(objectMap, "phoneNumber", a.PhoneNumber) + populate(objectMap, "postalCode", a.PostalCode) + populate(objectMap, "region", a.Region) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AddressDetails. +func (a *AddressDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "addressLine1": + err = unpopulate(val, "AddressLine1", &a.AddressLine1) + delete(rawMsg, key) + case "addressLine2": + err = unpopulate(val, "AddressLine2", &a.AddressLine2) + delete(rawMsg, key) + case "addressLine3": + err = unpopulate(val, "AddressLine3", &a.AddressLine3) + delete(rawMsg, key) + case "city": + err = unpopulate(val, "City", &a.City) + delete(rawMsg, key) + case "companyName": + err = unpopulate(val, "CompanyName", &a.CompanyName) + delete(rawMsg, key) + case "country": + err = unpopulate(val, "Country", &a.Country) + delete(rawMsg, key) + case "district": + err = unpopulate(val, "District", &a.District) + delete(rawMsg, key) + case "email": + err = unpopulate(val, "Email", &a.Email) + delete(rawMsg, key) + case "firstName": + err = unpopulate(val, "FirstName", &a.FirstName) + delete(rawMsg, key) + case "isValidAddress": + err = unpopulate(val, "IsValidAddress", &a.IsValidAddress) + delete(rawMsg, key) + case "lastName": + err = unpopulate(val, "LastName", &a.LastName) + delete(rawMsg, key) + case "middleName": + err = unpopulate(val, "MiddleName", &a.MiddleName) + delete(rawMsg, key) + case "phoneNumber": + err = unpopulate(val, "PhoneNumber", &a.PhoneNumber) + delete(rawMsg, key) + case "postalCode": + err = unpopulate(val, "PostalCode", &a.PostalCode) + delete(rawMsg, key) + case "region": + err = unpopulate(val, "Region", &a.Region) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AddressValidationResponse. +func (a AddressValidationResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "status", a.Status) + populate(objectMap, "suggestedAddresses", a.SuggestedAddresses) + populate(objectMap, "validationMessage", a.ValidationMessage) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AddressValidationResponse. +func (a *AddressValidationResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "status": + err = unpopulate(val, "Status", &a.Status) + delete(rawMsg, key) + case "suggestedAddresses": + err = unpopulate(val, "SuggestedAddresses", &a.SuggestedAddresses) + delete(rawMsg, key) + case "validationMessage": + err = unpopulate(val, "ValidationMessage", &a.ValidationMessage) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Agreement. +func (a Agreement) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "tags", a.Tags) populate(objectMap, "type", a.Type) return json.Marshal(objectMap) } @@ -286,6 +764,12 @@ func (a *Agreement) UnmarshalJSON(data []byte) error { case "properties": err = unpopulate(val, "Properties", &a.Properties) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &a.Type) delete(rawMsg, key) @@ -335,8 +819,10 @@ func (a AgreementProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "agreementLink", a.AgreementLink) populate(objectMap, "billingProfileInfo", a.BillingProfileInfo) populate(objectMap, "category", a.Category) + populate(objectMap, "displayName", a.DisplayName) populateDateTimeRFC3339(objectMap, "effectiveDate", a.EffectiveDate) populateDateTimeRFC3339(objectMap, "expirationDate", a.ExpirationDate) + populate(objectMap, "leadBillingAccountName", a.LeadBillingAccountName) populate(objectMap, "participants", a.Participants) populate(objectMap, "status", a.Status) return json.Marshal(objectMap) @@ -363,12 +849,18 @@ func (a *AgreementProperties) UnmarshalJSON(data []byte) error { case "category": err = unpopulate(val, "Category", &a.Category) delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &a.DisplayName) + delete(rawMsg, key) case "effectiveDate": err = unpopulateDateTimeRFC3339(val, "EffectiveDate", &a.EffectiveDate) delete(rawMsg, key) case "expirationDate": err = unpopulateDateTimeRFC3339(val, "ExpirationDate", &a.ExpirationDate) delete(rawMsg, key) + case "leadBillingAccountName": + err = unpopulate(val, "LeadBillingAccountName", &a.LeadBillingAccountName) + delete(rawMsg, key) case "participants": err = unpopulate(val, "Participants", &a.Participants) delete(rawMsg, key) @@ -414,18 +906,63 @@ func (a *Amount) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AvailableBalance. -func (a AvailableBalance) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AppliedScopeProperties. +func (a AppliedScopeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", a.DisplayName) + populate(objectMap, "managementGroupId", a.ManagementGroupID) + populate(objectMap, "resourceGroupId", a.ResourceGroupID) + populate(objectMap, "subscriptionId", a.SubscriptionID) + populate(objectMap, "tenantId", a.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AppliedScopeProperties. +func (a *AppliedScopeProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "displayName": + err = unpopulate(val, "DisplayName", &a.DisplayName) + delete(rawMsg, key) + case "managementGroupId": + err = unpopulate(val, "ManagementGroupID", &a.ManagementGroupID) + delete(rawMsg, key) + case "resourceGroupId": + err = unpopulate(val, "ResourceGroupID", &a.ResourceGroupID) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &a.SubscriptionID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &a.TenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AssociatedTenant. +func (a AssociatedTenant) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "tags", a.Tags) populate(objectMap, "type", a.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AvailableBalance. -func (a *AvailableBalance) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AssociatedTenant. +func (a *AssociatedTenant) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -442,6 +979,12 @@ func (a *AvailableBalance) UnmarshalJSON(data []byte) error { case "properties": err = unpopulate(val, "Properties", &a.Properties) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &a.Type) delete(rawMsg, key) @@ -453,15 +996,16 @@ func (a *AvailableBalance) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AvailableBalanceProperties. -func (a AvailableBalanceProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AssociatedTenantListResult. +func (a AssociatedTenantListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "amount", a.Amount) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AvailableBalanceProperties. -func (a *AvailableBalanceProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AssociatedTenantListResult. +func (a *AssociatedTenantListResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -469,8 +1013,11 @@ func (a *AvailableBalanceProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "amount": - err = unpopulate(val, "Amount", &a.Amount) + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) delete(rawMsg, key) } if err != nil { @@ -480,16 +1027,20 @@ func (a *AvailableBalanceProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AzurePlan. -func (a AzurePlan) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AssociatedTenantProperties. +func (a AssociatedTenantProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "skuDescription", a.SKUDescription) - populate(objectMap, "skuId", a.SKUID) + populate(objectMap, "billingManagementState", a.BillingManagementState) + populate(objectMap, "displayName", a.DisplayName) + populate(objectMap, "provisioningBillingRequestId", a.ProvisioningBillingRequestID) + populate(objectMap, "provisioningManagementState", a.ProvisioningManagementState) + populate(objectMap, "provisioningState", a.ProvisioningState) + populate(objectMap, "tenantId", a.TenantID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AzurePlan. -func (a *AzurePlan) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AssociatedTenantProperties. +func (a *AssociatedTenantProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -497,11 +1048,23 @@ func (a *AzurePlan) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "skuDescription": - err = unpopulate(val, "SKUDescription", &a.SKUDescription) + case "billingManagementState": + err = unpopulate(val, "BillingManagementState", &a.BillingManagementState) delete(rawMsg, key) - case "skuId": - err = unpopulate(val, "SKUID", &a.SKUID) + case "displayName": + err = unpopulate(val, "DisplayName", &a.DisplayName) + delete(rawMsg, key) + case "provisioningBillingRequestId": + err = unpopulate(val, "ProvisioningBillingRequestID", &a.ProvisioningBillingRequestID) + delete(rawMsg, key) + case "provisioningManagementState": + err = unpopulate(val, "ProvisioningManagementState", &a.ProvisioningManagementState) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &a.TenantID) delete(rawMsg, key) } if err != nil { @@ -511,3280 +1074,10045 @@ func (a *AzurePlan) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type Customer. -func (c Customer) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AvailableBalance. +func (a AvailableBalance) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", c.ID) - populate(objectMap, "name", c.Name) - populate(objectMap, "properties", c.Properties) - populate(objectMap, "type", c.Type) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Customer. -func (c *Customer) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AvailableBalance. +func (a *AvailableBalance) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) + return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { case "id": - err = unpopulate(val, "ID", &c.ID) + err = unpopulate(val, "ID", &a.ID) delete(rawMsg, key) case "name": - err = unpopulate(val, "Name", &c.Name) + err = unpopulate(val, "Name", &a.Name) delete(rawMsg, key) case "properties": - err = unpopulate(val, "Properties", &c.Properties) + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) delete(rawMsg, key) case "type": - err = unpopulate(val, "Type", &c.Type) + err = unpopulate(val, "Type", &a.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) + return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type CustomerListResult. -func (c CustomerListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AvailableBalanceProperties. +func (a AvailableBalanceProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", c.NextLink) - populate(objectMap, "totalCount", c.TotalCount) - populate(objectMap, "value", c.Value) + populate(objectMap, "amount", a.Amount) + populate(objectMap, "paymentsOnAccount", a.PaymentsOnAccount) + populate(objectMap, "totalPaymentsOnAccount", a.TotalPaymentsOnAccount) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type CustomerListResult. -func (c *CustomerListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AvailableBalanceProperties. +func (a *AvailableBalanceProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) + return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &c.NextLink) + case "amount": + err = unpopulate(val, "Amount", &a.Amount) delete(rawMsg, key) - case "totalCount": - err = unpopulate(val, "TotalCount", &c.TotalCount) + case "paymentsOnAccount": + err = unpopulate(val, "PaymentsOnAccount", &a.PaymentsOnAccount) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &c.Value) + case "totalPaymentsOnAccount": + err = unpopulate(val, "TotalPaymentsOnAccount", &a.TotalPaymentsOnAccount) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) + return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type CustomerPolicy. -func (c CustomerPolicy) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AvailableBalancePropertiesAmount. +func (a AvailableBalancePropertiesAmount) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", c.ID) - populate(objectMap, "name", c.Name) - populate(objectMap, "properties", c.Properties) - populate(objectMap, "type", c.Type) + populate(objectMap, "currency", a.Currency) + populate(objectMap, "value", a.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type CustomerPolicy. -func (c *CustomerPolicy) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AvailableBalancePropertiesAmount. +func (a *AvailableBalancePropertiesAmount) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) + return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &c.ID) + case "currency": + err = unpopulate(val, "Currency", &a.Currency) delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &c.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &c.Properties) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &c.Type) + case "value": + err = unpopulate(val, "Value", &a.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) + return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type CustomerPolicyProperties. -func (c CustomerPolicyProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AvailableBalancePropertiesTotalPaymentsOnAccount. +func (a AvailableBalancePropertiesTotalPaymentsOnAccount) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "viewCharges", c.ViewCharges) + populate(objectMap, "currency", a.Currency) + populate(objectMap, "value", a.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type CustomerPolicyProperties. -func (c *CustomerPolicyProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AvailableBalancePropertiesTotalPaymentsOnAccount. +func (a *AvailableBalancePropertiesTotalPaymentsOnAccount) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) + return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { - case "viewCharges": - err = unpopulate(val, "ViewCharges", &c.ViewCharges) + case "currency": + err = unpopulate(val, "Currency", &a.Currency) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) + return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type CustomerProperties. -func (c CustomerProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AzurePlan. +func (a AzurePlan) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "billingProfileDisplayName", c.BillingProfileDisplayName) - populate(objectMap, "billingProfileId", c.BillingProfileID) - populate(objectMap, "displayName", c.DisplayName) - populate(objectMap, "enabledAzurePlans", c.EnabledAzurePlans) - populate(objectMap, "resellers", c.Resellers) + populate(objectMap, "productId", a.ProductID) + populate(objectMap, "skuDescription", a.SKUDescription) + populate(objectMap, "skuId", a.SKUID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type CustomerProperties. -func (c *CustomerProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AzurePlan. +func (a *AzurePlan) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) + return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { - case "billingProfileDisplayName": - err = unpopulate(val, "BillingProfileDisplayName", &c.BillingProfileDisplayName) - delete(rawMsg, key) - case "billingProfileId": - err = unpopulate(val, "BillingProfileID", &c.BillingProfileID) - delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &c.DisplayName) + case "productId": + err = unpopulate(val, "ProductID", &a.ProductID) delete(rawMsg, key) - case "enabledAzurePlans": - err = unpopulate(val, "EnabledAzurePlans", &c.EnabledAzurePlans) + case "skuDescription": + err = unpopulate(val, "SKUDescription", &a.SKUDescription) delete(rawMsg, key) - case "resellers": - err = unpopulate(val, "Resellers", &c.Resellers) + case "skuId": + err = unpopulate(val, "SKUID", &a.SKUID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) + return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Department. -func (d Department) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Beneficiary. +func (b Beneficiary) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", d.ID) - populate(objectMap, "name", d.Name) - populate(objectMap, "properties", d.Properties) - populate(objectMap, "type", d.Type) + populate(objectMap, "objectId", b.ObjectID) + populate(objectMap, "tenantId", b.TenantID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Department. -func (d *Department) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Beneficiary. +func (b *Beneficiary) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) + return fmt.Errorf("unmarshalling type %T: %v", b, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &d.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &d.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &d.Properties) + case "objectId": + err = unpopulate(val, "ObjectID", &b.ObjectID) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &d.Type) + case "tenantId": + err = unpopulate(val, "TenantID", &b.TenantID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) + return fmt.Errorf("unmarshalling type %T: %v", b, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type DepartmentProperties. -func (d DepartmentProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type CancelSubscriptionRequest. +func (c CancelSubscriptionRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "costCenter", d.CostCenter) - populate(objectMap, "departmentName", d.DepartmentName) - populate(objectMap, "enrollmentAccounts", d.EnrollmentAccounts) - populate(objectMap, "status", d.Status) + populate(objectMap, "cancellationReason", c.CancellationReason) + populate(objectMap, "customerId", c.CustomerID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type DepartmentProperties. -func (d *DepartmentProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type CancelSubscriptionRequest. +func (c *CancelSubscriptionRequest) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } for key, val := range rawMsg { var err error switch key { - case "costCenter": - err = unpopulate(val, "CostCenter", &d.CostCenter) + case "cancellationReason": + err = unpopulate(val, "CancellationReason", &c.CancellationReason) delete(rawMsg, key) - case "departmentName": - err = unpopulate(val, "DepartmentName", &d.DepartmentName) - delete(rawMsg, key) - case "enrollmentAccounts": - err = unpopulate(val, "EnrollmentAccounts", &d.EnrollmentAccounts) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &d.Status) + case "customerId": + err = unpopulate(val, "CustomerID", &c.CustomerID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Document. -func (d Document) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type CheckAccessRequest. +func (c CheckAccessRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "kind", d.Kind) - populate(objectMap, "source", d.Source) - populate(objectMap, "url", d.URL) + populate(objectMap, "actions", c.Actions) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Document. -func (d *Document) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckAccessRequest. +func (c *CheckAccessRequest) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } for key, val := range rawMsg { var err error switch key { - case "kind": - err = unpopulate(val, "Kind", &d.Kind) - delete(rawMsg, key) - case "source": - err = unpopulate(val, "Source", &d.Source) - delete(rawMsg, key) - case "url": - err = unpopulate(val, "URL", &d.URL) + case "actions": + err = unpopulate(val, "Actions", &c.Actions) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type DownloadURL. -func (d DownloadURL) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type CheckAccessResponse. +func (c CheckAccessResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateDateTimeRFC3339(objectMap, "expiryTime", d.ExpiryTime) - populate(objectMap, "url", d.URL) + populate(objectMap, "accessDecision", c.AccessDecision) + populate(objectMap, "action", c.Action) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type DownloadURL. -func (d *DownloadURL) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckAccessResponse. +func (c *CheckAccessResponse) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } for key, val := range rawMsg { var err error switch key { - case "expiryTime": - err = unpopulateDateTimeRFC3339(val, "ExpiryTime", &d.ExpiryTime) + case "accessDecision": + err = unpopulate(val, "AccessDecision", &c.AccessDecision) delete(rawMsg, key) - case "url": - err = unpopulate(val, "URL", &d.URL) + case "action": + err = unpopulate(val, "Action", &c.Action) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Enrollment. -func (e Enrollment) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Commitment. +func (c Commitment) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "billingCycle", e.BillingCycle) - populate(objectMap, "channel", e.Channel) - populate(objectMap, "countryCode", e.CountryCode) - populate(objectMap, "currency", e.Currency) - populateDateTimeRFC3339(objectMap, "endDate", e.EndDate) - populate(objectMap, "language", e.Language) - populate(objectMap, "policies", e.Policies) - populateDateTimeRFC3339(objectMap, "startDate", e.StartDate) - populate(objectMap, "status", e.Status) + populate(objectMap, "amount", c.Amount) + populate(objectMap, "currencyCode", c.CurrencyCode) + populate(objectMap, "grain", c.Grain) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Enrollment. -func (e *Enrollment) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Commitment. +func (c *Commitment) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } for key, val := range rawMsg { var err error switch key { - case "billingCycle": - err = unpopulate(val, "BillingCycle", &e.BillingCycle) - delete(rawMsg, key) - case "channel": - err = unpopulate(val, "Channel", &e.Channel) - delete(rawMsg, key) - case "countryCode": - err = unpopulate(val, "CountryCode", &e.CountryCode) - delete(rawMsg, key) - case "currency": - err = unpopulate(val, "Currency", &e.Currency) - delete(rawMsg, key) - case "endDate": - err = unpopulateDateTimeRFC3339(val, "EndDate", &e.EndDate) - delete(rawMsg, key) - case "language": - err = unpopulate(val, "Language", &e.Language) - delete(rawMsg, key) - case "policies": - err = unpopulate(val, "Policies", &e.Policies) + case "amount": + err = unpopulate(val, "Amount", &c.Amount) delete(rawMsg, key) - case "startDate": - err = unpopulateDateTimeRFC3339(val, "StartDate", &e.StartDate) + case "currencyCode": + err = unpopulate(val, "CurrencyCode", &c.CurrencyCode) delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &e.Status) + case "grain": + err = unpopulate(val, "Grain", &c.Grain) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type EnrollmentAccount. -func (e EnrollmentAccount) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Customer. +func (c Customer) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", e.ID) - populate(objectMap, "name", e.Name) - populate(objectMap, "properties", e.Properties) - populate(objectMap, "type", e.Type) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "tags", c.Tags) + populate(objectMap, "type", c.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type EnrollmentAccount. -func (e *EnrollmentAccount) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Customer. +func (c *Customer) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } for key, val := range rawMsg { var err error switch key { case "id": - err = unpopulate(val, "ID", &e.ID) + err = unpopulate(val, "ID", &c.ID) delete(rawMsg, key) case "name": - err = unpopulate(val, "Name", &e.Name) + err = unpopulate(val, "Name", &c.Name) delete(rawMsg, key) case "properties": - err = unpopulate(val, "Properties", &e.Properties) + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &c.Tags) delete(rawMsg, key) case "type": - err = unpopulate(val, "Type", &e.Type) + err = unpopulate(val, "Type", &c.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type EnrollmentAccountContext. -func (e EnrollmentAccountContext) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type CustomerListResult. +func (c CustomerListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "costCenter", e.CostCenter) - populateDateTimeRFC3339(objectMap, "endDate", e.EndDate) - populate(objectMap, "enrollmentAccountName", e.EnrollmentAccountName) - populateDateTimeRFC3339(objectMap, "startDate", e.StartDate) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type EnrollmentAccountContext. -func (e *EnrollmentAccountContext) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomerListResult. +func (c *CustomerListResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } for key, val := range rawMsg { var err error switch key { - case "costCenter": - err = unpopulate(val, "CostCenter", &e.CostCenter) - delete(rawMsg, key) - case "endDate": - err = unpopulateDateTimeRFC3339(val, "EndDate", &e.EndDate) - delete(rawMsg, key) - case "enrollmentAccountName": - err = unpopulate(val, "EnrollmentAccountName", &e.EnrollmentAccountName) + case "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) delete(rawMsg, key) - case "startDate": - err = unpopulateDateTimeRFC3339(val, "StartDate", &e.StartDate) + case "value": + err = unpopulate(val, "Value", &c.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type EnrollmentAccountListResult. -func (e EnrollmentAccountListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type CustomerPolicy. +func (c CustomerPolicy) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", e.NextLink) - populate(objectMap, "value", e.Value) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "tags", c.Tags) + populate(objectMap, "type", c.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type EnrollmentAccountListResult. -func (e *EnrollmentAccountListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomerPolicy. +func (c *CustomerPolicy) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &e.NextLink) + case "id": + err = unpopulate(val, "ID", &c.ID) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &e.Value) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &c.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type EnrollmentAccountProperties. -func (e EnrollmentAccountProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type CustomerPolicyProperties. +func (c CustomerPolicyProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "accountName", e.AccountName) - populate(objectMap, "accountOwner", e.AccountOwner) - populate(objectMap, "accountOwnerEmail", e.AccountOwnerEmail) - populate(objectMap, "costCenter", e.CostCenter) - populate(objectMap, "department", e.Department) - populateDateTimeRFC3339(objectMap, "endDate", e.EndDate) - populateDateTimeRFC3339(objectMap, "startDate", e.StartDate) - populate(objectMap, "status", e.Status) + populate(objectMap, "policies", c.Policies) + populate(objectMap, "provisioningState", c.ProvisioningState) + populate(objectMap, "viewCharges", c.ViewCharges) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type EnrollmentAccountProperties. -func (e *EnrollmentAccountProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomerPolicyProperties. +func (c *CustomerPolicyProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } for key, val := range rawMsg { var err error switch key { - case "accountName": - err = unpopulate(val, "AccountName", &e.AccountName) - delete(rawMsg, key) - case "accountOwner": - err = unpopulate(val, "AccountOwner", &e.AccountOwner) - delete(rawMsg, key) - case "accountOwnerEmail": - err = unpopulate(val, "AccountOwnerEmail", &e.AccountOwnerEmail) - delete(rawMsg, key) - case "costCenter": - err = unpopulate(val, "CostCenter", &e.CostCenter) - delete(rawMsg, key) - case "department": - err = unpopulate(val, "Department", &e.Department) - delete(rawMsg, key) - case "endDate": - err = unpopulateDateTimeRFC3339(val, "EndDate", &e.EndDate) + case "policies": + err = unpopulate(val, "Policies", &c.Policies) delete(rawMsg, key) - case "startDate": - err = unpopulateDateTimeRFC3339(val, "StartDate", &e.StartDate) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &c.ProvisioningState) delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &e.Status) + case "viewCharges": + err = unpopulate(val, "ViewCharges", &c.ViewCharges) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type EnrollmentAccountSummary. -func (e EnrollmentAccountSummary) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type CustomerProperties. +func (c CustomerProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", e.ID) - populate(objectMap, "name", e.Name) - populate(objectMap, "properties", e.Properties) - populate(objectMap, "type", e.Type) + populate(objectMap, "billingProfileDisplayName", c.BillingProfileDisplayName) + populate(objectMap, "billingProfileId", c.BillingProfileID) + populate(objectMap, "displayName", c.DisplayName) + populate(objectMap, "enabledAzurePlans", c.EnabledAzurePlans) + populate(objectMap, "resellers", c.Resellers) + populate(objectMap, "status", c.Status) + populate(objectMap, "systemId", c.SystemID) + populate(objectMap, "tags", c.Tags) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type EnrollmentAccountSummary. -func (e *EnrollmentAccountSummary) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomerProperties. +func (c *CustomerProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &e.ID) + case "billingProfileDisplayName": + err = unpopulate(val, "BillingProfileDisplayName", &c.BillingProfileDisplayName) delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &e.Name) + case "billingProfileId": + err = unpopulate(val, "BillingProfileID", &c.BillingProfileID) delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &e.Properties) + case "displayName": + err = unpopulate(val, "DisplayName", &c.DisplayName) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &e.Type) + case "enabledAzurePlans": + err = unpopulate(val, "EnabledAzurePlans", &c.EnabledAzurePlans) + delete(rawMsg, key) + case "resellers": + err = unpopulate(val, "Resellers", &c.Resellers) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &c.Status) + delete(rawMsg, key) + case "systemId": + err = unpopulate(val, "SystemID", &c.SystemID) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &c.Tags) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type EnrollmentAccountSummaryProperties. -func (e EnrollmentAccountSummaryProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type DeleteBillingProfileEligibilityDetail. +func (d DeleteBillingProfileEligibilityDetail) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "principalName", e.PrincipalName) + populate(objectMap, "code", d.Code) + populate(objectMap, "message", d.Message) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type EnrollmentAccountSummaryProperties. -func (e *EnrollmentAccountSummaryProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type DeleteBillingProfileEligibilityDetail. +func (d *DeleteBillingProfileEligibilityDetail) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { - case "principalName": - err = unpopulate(val, "PrincipalName", &e.PrincipalName) + case "code": + err = unpopulate(val, "Code", &d.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &d.Message) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type EnrollmentPolicies. -func (e EnrollmentPolicies) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type DeleteBillingProfileEligibilityResult. +func (d DeleteBillingProfileEligibilityResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "accountOwnerViewCharges", e.AccountOwnerViewCharges) - populate(objectMap, "departmentAdminViewCharges", e.DepartmentAdminViewCharges) - populate(objectMap, "marketplaceEnabled", e.MarketplaceEnabled) - populate(objectMap, "reservedInstancesEnabled", e.ReservedInstancesEnabled) + populate(objectMap, "eligibilityDetails", d.EligibilityDetails) + populate(objectMap, "eligibilityStatus", d.EligibilityStatus) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type EnrollmentPolicies. -func (e *EnrollmentPolicies) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type DeleteBillingProfileEligibilityResult. +func (d *DeleteBillingProfileEligibilityResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { - case "accountOwnerViewCharges": - err = unpopulate(val, "AccountOwnerViewCharges", &e.AccountOwnerViewCharges) - delete(rawMsg, key) - case "departmentAdminViewCharges": - err = unpopulate(val, "DepartmentAdminViewCharges", &e.DepartmentAdminViewCharges) + case "eligibilityDetails": + err = unpopulate(val, "EligibilityDetails", &d.EligibilityDetails) delete(rawMsg, key) - case "marketplaceEnabled": - err = unpopulate(val, "MarketplaceEnabled", &e.MarketplaceEnabled) - delete(rawMsg, key) - case "reservedInstancesEnabled": - err = unpopulate(val, "ReservedInstancesEnabled", &e.ReservedInstancesEnabled) + case "eligibilityStatus": + err = unpopulate(val, "EligibilityStatus", &d.EligibilityStatus) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ErrorDetails. -func (e ErrorDetails) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type DeleteInvoiceSectionEligibilityDetail. +func (d DeleteInvoiceSectionEligibilityDetail) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "code", e.Code) - populate(objectMap, "details", e.Details) - populate(objectMap, "message", e.Message) - populate(objectMap, "target", e.Target) + populate(objectMap, "code", d.Code) + populate(objectMap, "message", d.Message) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetails. -func (e *ErrorDetails) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type DeleteInvoiceSectionEligibilityDetail. +func (d *DeleteInvoiceSectionEligibilityDetail) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { case "code": - err = unpopulate(val, "Code", &e.Code) - delete(rawMsg, key) - case "details": - err = unpopulate(val, "Details", &e.Details) + err = unpopulate(val, "Code", &d.Code) delete(rawMsg, key) case "message": - err = unpopulate(val, "Message", &e.Message) - delete(rawMsg, key) - case "target": - err = unpopulate(val, "Target", &e.Target) + err = unpopulate(val, "Message", &d.Message) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. -func (e ErrorResponse) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type DeleteInvoiceSectionEligibilityResult. +func (d DeleteInvoiceSectionEligibilityResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "error", e.Error) + populate(objectMap, "eligibilityDetails", d.EligibilityDetails) + populate(objectMap, "eligibilityStatus", d.EligibilityStatus) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. -func (e *ErrorResponse) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type DeleteInvoiceSectionEligibilityResult. +func (d *DeleteInvoiceSectionEligibilityResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { - case "error": - err = unpopulate(val, "Error", &e.Error) + case "eligibilityDetails": + err = unpopulate(val, "EligibilityDetails", &d.EligibilityDetails) + delete(rawMsg, key) + case "eligibilityStatus": + err = unpopulate(val, "EligibilityStatus", &d.EligibilityStatus) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ErrorSubDetailsItem. -func (e ErrorSubDetailsItem) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Department. +func (d Department) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "code", e.Code) - populate(objectMap, "message", e.Message) - populate(objectMap, "target", e.Target) + populate(objectMap, "id", d.ID) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "tags", d.Tags) + populate(objectMap, "type", d.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorSubDetailsItem. -func (e *ErrorSubDetailsItem) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Department. +func (d *Department) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { - case "code": - err = unpopulate(val, "Code", &e.Code) + case "id": + err = unpopulate(val, "ID", &d.ID) delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &e.Message) + case "name": + err = unpopulate(val, "Name", &d.Name) delete(rawMsg, key) - case "target": - err = unpopulate(val, "Target", &e.Target) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &d.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type IndirectRelationshipInfo. -func (i IndirectRelationshipInfo) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type DepartmentListResult. +func (d DepartmentListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "billingAccountName", i.BillingAccountName) - populate(objectMap, "billingProfileName", i.BillingProfileName) - populate(objectMap, "displayName", i.DisplayName) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type IndirectRelationshipInfo. -func (i *IndirectRelationshipInfo) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type DepartmentListResult. +func (d *DepartmentListResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { - case "billingAccountName": - err = unpopulate(val, "BillingAccountName", &i.BillingAccountName) - delete(rawMsg, key) - case "billingProfileName": - err = unpopulate(val, "BillingProfileName", &i.BillingProfileName) + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &i.DisplayName) + case "value": + err = unpopulate(val, "Value", &d.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Instruction. -func (i Instruction) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type DepartmentProperties. +func (d DepartmentProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", i.ID) - populate(objectMap, "name", i.Name) - populate(objectMap, "properties", i.Properties) - populate(objectMap, "type", i.Type) + populate(objectMap, "costCenter", d.CostCenter) + populate(objectMap, "displayName", d.DisplayName) + populate(objectMap, "id", d.ID) + populate(objectMap, "status", d.Status) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Instruction. -func (i *Instruction) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type DepartmentProperties. +func (d *DepartmentProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &i.ID) + case "costCenter": + err = unpopulate(val, "CostCenter", &d.CostCenter) delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &i.Name) + case "displayName": + err = unpopulate(val, "DisplayName", &d.DisplayName) delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &i.Properties) + case "id": + err = unpopulate(val, "ID", &d.ID) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &i.Type) + case "status": + err = unpopulate(val, "Status", &d.Status) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type InstructionListResult. -func (i InstructionListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type DetailedTransferStatus. +func (d DetailedTransferStatus) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", i.NextLink) - populate(objectMap, "value", i.Value) + populate(objectMap, "errorDetails", d.ErrorDetails) + populate(objectMap, "productId", d.ProductID) + populate(objectMap, "productName", d.ProductName) + populate(objectMap, "productType", d.ProductType) + populate(objectMap, "skuDescription", d.SKUDescription) + populate(objectMap, "transferStatus", d.TransferStatus) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type InstructionListResult. -func (i *InstructionListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type DetailedTransferStatus. +func (d *DetailedTransferStatus) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &i.NextLink) + case "errorDetails": + err = unpopulate(val, "ErrorDetails", &d.ErrorDetails) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &i.Value) + case "productId": + err = unpopulate(val, "ProductID", &d.ProductID) + delete(rawMsg, key) + case "productName": + err = unpopulate(val, "ProductName", &d.ProductName) + delete(rawMsg, key) + case "productType": + err = unpopulate(val, "ProductType", &d.ProductType) + delete(rawMsg, key) + case "skuDescription": + err = unpopulate(val, "SKUDescription", &d.SKUDescription) + delete(rawMsg, key) + case "transferStatus": + err = unpopulate(val, "TransferStatus", &d.TransferStatus) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type InstructionProperties. -func (i InstructionProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type DocumentDownloadRequest. +func (d DocumentDownloadRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "amount", i.Amount) - populateDateTimeRFC3339(objectMap, "creationDate", i.CreationDate) - populateDateTimeRFC3339(objectMap, "endDate", i.EndDate) - populateDateTimeRFC3339(objectMap, "startDate", i.StartDate) + populate(objectMap, "documentName", d.DocumentName) + populate(objectMap, "invoiceName", d.InvoiceName) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type InstructionProperties. -func (i *InstructionProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type DocumentDownloadRequest. +func (d *DocumentDownloadRequest) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { - case "amount": - err = unpopulate(val, "Amount", &i.Amount) - delete(rawMsg, key) - case "creationDate": - err = unpopulateDateTimeRFC3339(val, "CreationDate", &i.CreationDate) + case "documentName": + err = unpopulate(val, "DocumentName", &d.DocumentName) delete(rawMsg, key) - case "endDate": - err = unpopulateDateTimeRFC3339(val, "EndDate", &i.EndDate) - delete(rawMsg, key) - case "startDate": - err = unpopulateDateTimeRFC3339(val, "StartDate", &i.StartDate) + case "invoiceName": + err = unpopulate(val, "InvoiceName", &d.InvoiceName) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Invoice. -func (i Invoice) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type DocumentDownloadResult. +func (d DocumentDownloadResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", i.ID) - populate(objectMap, "name", i.Name) - populate(objectMap, "properties", i.Properties) - populate(objectMap, "type", i.Type) + populate(objectMap, "expiryTime", d.ExpiryTime) + populate(objectMap, "url", d.URL) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Invoice. -func (i *Invoice) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type DocumentDownloadResult. +func (d *DocumentDownloadResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &i.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &i.Name) + case "expiryTime": + err = unpopulate(val, "ExpiryTime", &d.ExpiryTime) delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &i.Properties) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &i.Type) + case "url": + err = unpopulate(val, "URL", &d.URL) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type InvoiceListResult. -func (i InvoiceListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type EnrollmentAccount. +func (e EnrollmentAccount) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", i.NextLink) - populate(objectMap, "totalCount", i.TotalCount) - populate(objectMap, "value", i.Value) + populate(objectMap, "id", e.ID) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "systemData", e.SystemData) + populate(objectMap, "tags", e.Tags) + populate(objectMap, "type", e.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type InvoiceListResult. -func (i *InvoiceListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type EnrollmentAccount. +func (e *EnrollmentAccount) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &i.NextLink) + case "id": + err = unpopulate(val, "ID", &e.ID) delete(rawMsg, key) - case "totalCount": - err = unpopulate(val, "TotalCount", &i.TotalCount) + case "name": + err = unpopulate(val, "Name", &e.Name) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &i.Value) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &e.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type InvoiceProperties. -func (i InvoiceProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type EnrollmentAccountListResult. +func (e EnrollmentAccountListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "amountDue", i.AmountDue) - populate(objectMap, "azurePrepaymentApplied", i.AzurePrepaymentApplied) - populate(objectMap, "billedAmount", i.BilledAmount) - populate(objectMap, "billedDocumentId", i.BilledDocumentID) - populate(objectMap, "billingProfileDisplayName", i.BillingProfileDisplayName) - populate(objectMap, "billingProfileId", i.BillingProfileID) - populate(objectMap, "creditAmount", i.CreditAmount) - populate(objectMap, "creditForDocumentId", i.CreditForDocumentID) - populate(objectMap, "documentType", i.DocumentType) - populate(objectMap, "documents", i.Documents) - populateDateTimeRFC3339(objectMap, "dueDate", i.DueDate) - populate(objectMap, "freeAzureCreditApplied", i.FreeAzureCreditApplied) - populateDateTimeRFC3339(objectMap, "invoiceDate", i.InvoiceDate) - populateDateTimeRFC3339(objectMap, "invoicePeriodEndDate", i.InvoicePeriodEndDate) - populateDateTimeRFC3339(objectMap, "invoicePeriodStartDate", i.InvoicePeriodStartDate) - populate(objectMap, "invoiceType", i.InvoiceType) - populate(objectMap, "isMonthlyInvoice", i.IsMonthlyInvoice) - populate(objectMap, "payments", i.Payments) - populate(objectMap, "purchaseOrderNumber", i.PurchaseOrderNumber) - populate(objectMap, "rebillDetails", i.RebillDetails) - populate(objectMap, "status", i.Status) - populate(objectMap, "subTotal", i.SubTotal) - populate(objectMap, "subscriptionId", i.SubscriptionID) - populate(objectMap, "taxAmount", i.TaxAmount) - populate(objectMap, "totalAmount", i.TotalAmount) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type InvoiceProperties. -func (i *InvoiceProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type EnrollmentAccountListResult. +func (e *EnrollmentAccountListResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "amountDue": - err = unpopulate(val, "AmountDue", &i.AmountDue) - delete(rawMsg, key) - case "azurePrepaymentApplied": - err = unpopulate(val, "AzurePrepaymentApplied", &i.AzurePrepaymentApplied) - delete(rawMsg, key) - case "billedAmount": - err = unpopulate(val, "BilledAmount", &i.BilledAmount) - delete(rawMsg, key) - case "billedDocumentId": - err = unpopulate(val, "BilledDocumentID", &i.BilledDocumentID) - delete(rawMsg, key) - case "billingProfileDisplayName": - err = unpopulate(val, "BillingProfileDisplayName", &i.BillingProfileDisplayName) - delete(rawMsg, key) - case "billingProfileId": - err = unpopulate(val, "BillingProfileID", &i.BillingProfileID) - delete(rawMsg, key) - case "creditAmount": - err = unpopulate(val, "CreditAmount", &i.CreditAmount) - delete(rawMsg, key) - case "creditForDocumentId": - err = unpopulate(val, "CreditForDocumentID", &i.CreditForDocumentID) - delete(rawMsg, key) - case "documentType": - err = unpopulate(val, "DocumentType", &i.DocumentType) - delete(rawMsg, key) - case "documents": - err = unpopulate(val, "Documents", &i.Documents) + case "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) delete(rawMsg, key) - case "dueDate": - err = unpopulateDateTimeRFC3339(val, "DueDate", &i.DueDate) + case "value": + err = unpopulate(val, "Value", &e.Value) delete(rawMsg, key) - case "freeAzureCreditApplied": - err = unpopulate(val, "FreeAzureCreditApplied", &i.FreeAzureCreditApplied) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EnrollmentAccountProperties. +func (e EnrollmentAccountProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountOwner", e.AccountOwner) + populate(objectMap, "authType", e.AuthType) + populate(objectMap, "costCenter", e.CostCenter) + populate(objectMap, "departmentDisplayName", e.DepartmentDisplayName) + populate(objectMap, "departmentId", e.DepartmentID) + populate(objectMap, "displayName", e.DisplayName) + populateDateTimeRFC3339(objectMap, "endDate", e.EndDate) + populate(objectMap, "isDevTestEnabled", e.IsDevTestEnabled) + populateDateTimeRFC3339(objectMap, "startDate", e.StartDate) + populate(objectMap, "status", e.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnrollmentAccountProperties. +func (e *EnrollmentAccountProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accountOwner": + err = unpopulate(val, "AccountOwner", &e.AccountOwner) delete(rawMsg, key) - case "invoiceDate": - err = unpopulateDateTimeRFC3339(val, "InvoiceDate", &i.InvoiceDate) + case "authType": + err = unpopulate(val, "AuthType", &e.AuthType) delete(rawMsg, key) - case "invoicePeriodEndDate": - err = unpopulateDateTimeRFC3339(val, "InvoicePeriodEndDate", &i.InvoicePeriodEndDate) + case "costCenter": + err = unpopulate(val, "CostCenter", &e.CostCenter) delete(rawMsg, key) - case "invoicePeriodStartDate": - err = unpopulateDateTimeRFC3339(val, "InvoicePeriodStartDate", &i.InvoicePeriodStartDate) + case "departmentDisplayName": + err = unpopulate(val, "DepartmentDisplayName", &e.DepartmentDisplayName) delete(rawMsg, key) - case "invoiceType": - err = unpopulate(val, "InvoiceType", &i.InvoiceType) + case "departmentId": + err = unpopulate(val, "DepartmentID", &e.DepartmentID) delete(rawMsg, key) - case "isMonthlyInvoice": - err = unpopulate(val, "IsMonthlyInvoice", &i.IsMonthlyInvoice) + case "displayName": + err = unpopulate(val, "DisplayName", &e.DisplayName) delete(rawMsg, key) - case "payments": - err = unpopulate(val, "Payments", &i.Payments) + case "endDate": + err = unpopulateDateTimeRFC3339(val, "EndDate", &e.EndDate) delete(rawMsg, key) - case "purchaseOrderNumber": - err = unpopulate(val, "PurchaseOrderNumber", &i.PurchaseOrderNumber) + case "isDevTestEnabled": + err = unpopulate(val, "IsDevTestEnabled", &e.IsDevTestEnabled) delete(rawMsg, key) - case "rebillDetails": - err = unpopulate(val, "RebillDetails", &i.RebillDetails) + case "startDate": + err = unpopulateDateTimeRFC3339(val, "StartDate", &e.StartDate) delete(rawMsg, key) case "status": - err = unpopulate(val, "Status", &i.Status) - delete(rawMsg, key) - case "subTotal": - err = unpopulate(val, "SubTotal", &i.SubTotal) - delete(rawMsg, key) - case "subscriptionId": - err = unpopulate(val, "SubscriptionID", &i.SubscriptionID) - delete(rawMsg, key) - case "taxAmount": - err = unpopulate(val, "TaxAmount", &i.TaxAmount) - delete(rawMsg, key) - case "totalAmount": - err = unpopulate(val, "TotalAmount", &i.TotalAmount) + err = unpopulate(val, "Status", &e.Status) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type InvoiceSection. -func (i InvoiceSection) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type EnrollmentAccountSubscriptionDetails. +func (e EnrollmentAccountSubscriptionDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", i.ID) - populate(objectMap, "name", i.Name) - populate(objectMap, "properties", i.Properties) - populate(objectMap, "type", i.Type) + populateDateTimeRFC3339(objectMap, "enrollmentAccountStartDate", e.EnrollmentAccountStartDate) + populate(objectMap, "subscriptionEnrollmentAccountStatus", e.SubscriptionEnrollmentAccountStatus) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type InvoiceSection. -func (i *InvoiceSection) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type EnrollmentAccountSubscriptionDetails. +func (e *EnrollmentAccountSubscriptionDetails) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &i.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &i.Name) + case "enrollmentAccountStartDate": + err = unpopulateDateTimeRFC3339(val, "EnrollmentAccountStartDate", &e.EnrollmentAccountStartDate) delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &i.Properties) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &i.Type) + case "subscriptionEnrollmentAccountStatus": + err = unpopulate(val, "SubscriptionEnrollmentAccountStatus", &e.SubscriptionEnrollmentAccountStatus) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type InvoiceSectionCreationRequest. -func (i InvoiceSectionCreationRequest) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type EnrollmentDetails. +func (e EnrollmentDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "displayName", i.DisplayName) + populate(objectMap, "billingCycle", e.BillingCycle) + populate(objectMap, "channel", e.Channel) + populate(objectMap, "cloud", e.Cloud) + populate(objectMap, "countryCode", e.CountryCode) + populate(objectMap, "currency", e.Currency) + populateDateTimeRFC3339(objectMap, "endDate", e.EndDate) + populate(objectMap, "extendedTermOption", e.ExtendedTermOption) + populate(objectMap, "indirectRelationshipInfo", e.IndirectRelationshipInfo) + populate(objectMap, "invoiceRecipient", e.InvoiceRecipient) + populate(objectMap, "language", e.Language) + populate(objectMap, "markupStatus", e.MarkupStatus) + populate(objectMap, "poNumber", e.PoNumber) + populateDateTimeRFC3339(objectMap, "startDate", e.StartDate) + populate(objectMap, "supportCoverage", e.SupportCoverage) + populate(objectMap, "supportLevel", e.SupportLevel) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type InvoiceSectionCreationRequest. -func (i *InvoiceSectionCreationRequest) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type EnrollmentDetails. +func (e *EnrollmentDetails) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "displayName": - err = unpopulate(val, "DisplayName", &i.DisplayName) + case "billingCycle": + err = unpopulate(val, "BillingCycle", &e.BillingCycle) + delete(rawMsg, key) + case "channel": + err = unpopulate(val, "Channel", &e.Channel) + delete(rawMsg, key) + case "cloud": + err = unpopulate(val, "Cloud", &e.Cloud) + delete(rawMsg, key) + case "countryCode": + err = unpopulate(val, "CountryCode", &e.CountryCode) + delete(rawMsg, key) + case "currency": + err = unpopulate(val, "Currency", &e.Currency) + delete(rawMsg, key) + case "endDate": + err = unpopulateDateTimeRFC3339(val, "EndDate", &e.EndDate) + delete(rawMsg, key) + case "extendedTermOption": + err = unpopulate(val, "ExtendedTermOption", &e.ExtendedTermOption) + delete(rawMsg, key) + case "indirectRelationshipInfo": + err = unpopulate(val, "IndirectRelationshipInfo", &e.IndirectRelationshipInfo) + delete(rawMsg, key) + case "invoiceRecipient": + err = unpopulate(val, "InvoiceRecipient", &e.InvoiceRecipient) + delete(rawMsg, key) + case "language": + err = unpopulate(val, "Language", &e.Language) + delete(rawMsg, key) + case "markupStatus": + err = unpopulate(val, "MarkupStatus", &e.MarkupStatus) + delete(rawMsg, key) + case "poNumber": + err = unpopulate(val, "PoNumber", &e.PoNumber) + delete(rawMsg, key) + case "startDate": + err = unpopulateDateTimeRFC3339(val, "StartDate", &e.StartDate) + delete(rawMsg, key) + case "supportCoverage": + err = unpopulate(val, "SupportCoverage", &e.SupportCoverage) + delete(rawMsg, key) + case "supportLevel": + err = unpopulate(val, "SupportLevel", &e.SupportLevel) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type InvoiceSectionListResult. -func (i InvoiceSectionListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type EnrollmentDetailsIndirectRelationshipInfo. +func (e EnrollmentDetailsIndirectRelationshipInfo) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", i.NextLink) - populate(objectMap, "totalCount", i.TotalCount) - populate(objectMap, "value", i.Value) + populate(objectMap, "billingAccountName", e.BillingAccountName) + populate(objectMap, "billingProfileName", e.BillingProfileName) + populate(objectMap, "displayName", e.DisplayName) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type InvoiceSectionListResult. -func (i *InvoiceSectionListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type EnrollmentDetailsIndirectRelationshipInfo. +func (e *EnrollmentDetailsIndirectRelationshipInfo) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &i.NextLink) + case "billingAccountName": + err = unpopulate(val, "BillingAccountName", &e.BillingAccountName) delete(rawMsg, key) - case "totalCount": - err = unpopulate(val, "TotalCount", &i.TotalCount) + case "billingProfileName": + err = unpopulate(val, "BillingProfileName", &e.BillingProfileName) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &i.Value) + case "displayName": + err = unpopulate(val, "DisplayName", &e.DisplayName) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type InvoiceSectionListWithCreateSubPermissionResult. -func (i InvoiceSectionListWithCreateSubPermissionResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type EnterpriseAgreementPolicies. +func (e EnterpriseAgreementPolicies) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", i.NextLink) - populate(objectMap, "value", i.Value) + populate(objectMap, "accountOwnerViewCharges", e.AccountOwnerViewCharges) + populate(objectMap, "authenticationType", e.AuthenticationType) + populate(objectMap, "departmentAdminViewCharges", e.DepartmentAdminViewCharges) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type InvoiceSectionListWithCreateSubPermissionResult. -func (i *InvoiceSectionListWithCreateSubPermissionResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type EnterpriseAgreementPolicies. +func (e *EnterpriseAgreementPolicies) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &i.NextLink) + case "accountOwnerViewCharges": + err = unpopulate(val, "AccountOwnerViewCharges", &e.AccountOwnerViewCharges) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &i.Value) + case "authenticationType": + err = unpopulate(val, "AuthenticationType", &e.AuthenticationType) + delete(rawMsg, key) + case "departmentAdminViewCharges": + err = unpopulate(val, "DepartmentAdminViewCharges", &e.DepartmentAdminViewCharges) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type InvoiceSectionProperties. -func (i InvoiceSectionProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "displayName", i.DisplayName) - populate(objectMap, "labels", i.Labels) - populate(objectMap, "state", i.State) - populate(objectMap, "systemId", i.SystemID) - populate(objectMap, "tags", i.Tags) - populate(objectMap, "targetCloud", i.TargetCloud) + populateAny(objectMap, "info", e.Info) + populate(objectMap, "type", e.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type InvoiceSectionProperties. -func (i *InvoiceSectionProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. +func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "displayName": - err = unpopulate(val, "DisplayName", &i.DisplayName) - delete(rawMsg, key) - case "labels": - err = unpopulate(val, "Labels", &i.Labels) - delete(rawMsg, key) - case "state": - err = unpopulate(val, "State", &i.State) - delete(rawMsg, key) - case "systemId": - err = unpopulate(val, "SystemID", &i.SystemID) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &i.Tags) + case "info": + err = unpopulate(val, "Info", &e.Info) delete(rawMsg, key) - case "targetCloud": - err = unpopulate(val, "TargetCloud", &i.TargetCloud) + case "type": + err = unpopulate(val, "Type", &e.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type InvoiceSectionWithCreateSubPermission. -func (i InvoiceSectionWithCreateSubPermission) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "billingProfileDisplayName", i.BillingProfileDisplayName) - populate(objectMap, "billingProfileId", i.BillingProfileID) - populate(objectMap, "billingProfileSpendingLimit", i.BillingProfileSpendingLimit) - populate(objectMap, "billingProfileStatus", i.BillingProfileStatus) - populate(objectMap, "billingProfileStatusReasonCode", i.BillingProfileStatusReasonCode) - populate(objectMap, "billingProfileSystemId", i.BillingProfileSystemID) - populate(objectMap, "enabledAzurePlans", i.EnabledAzurePlans) - populate(objectMap, "invoiceSectionDisplayName", i.InvoiceSectionDisplayName) - populate(objectMap, "invoiceSectionId", i.InvoiceSectionID) - populate(objectMap, "invoiceSectionSystemId", i.InvoiceSectionSystemID) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type InvoiceSectionWithCreateSubPermission. -func (i *InvoiceSectionWithCreateSubPermission) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. +func (e *ErrorDetail) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "billingProfileDisplayName": - err = unpopulate(val, "BillingProfileDisplayName", &i.BillingProfileDisplayName) - delete(rawMsg, key) - case "billingProfileId": - err = unpopulate(val, "BillingProfileID", &i.BillingProfileID) - delete(rawMsg, key) - case "billingProfileSpendingLimit": - err = unpopulate(val, "BillingProfileSpendingLimit", &i.BillingProfileSpendingLimit) - delete(rawMsg, key) - case "billingProfileStatus": - err = unpopulate(val, "BillingProfileStatus", &i.BillingProfileStatus) - delete(rawMsg, key) - case "billingProfileStatusReasonCode": - err = unpopulate(val, "BillingProfileStatusReasonCode", &i.BillingProfileStatusReasonCode) - delete(rawMsg, key) - case "billingProfileSystemId": - err = unpopulate(val, "BillingProfileSystemID", &i.BillingProfileSystemID) + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) delete(rawMsg, key) - case "enabledAzurePlans": - err = unpopulate(val, "EnabledAzurePlans", &i.EnabledAzurePlans) + case "code": + err = unpopulate(val, "Code", &e.Code) delete(rawMsg, key) - case "invoiceSectionDisplayName": - err = unpopulate(val, "InvoiceSectionDisplayName", &i.InvoiceSectionDisplayName) + case "details": + err = unpopulate(val, "Details", &e.Details) delete(rawMsg, key) - case "invoiceSectionId": - err = unpopulate(val, "InvoiceSectionID", &i.InvoiceSectionID) + case "message": + err = unpopulate(val, "Message", &e.Message) delete(rawMsg, key) - case "invoiceSectionSystemId": - err = unpopulate(val, "InvoiceSectionSystemID", &i.InvoiceSectionSystemID) + case "target": + err = unpopulate(val, "Target", &e.Target) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type InvoiceSectionsOnExpand. -func (i InvoiceSectionsOnExpand) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "hasMoreResults", i.HasMoreResults) - populate(objectMap, "value", i.Value) + populate(objectMap, "error", e.Error) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type InvoiceSectionsOnExpand. -func (i *InvoiceSectionsOnExpand) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. +func (e *ErrorResponse) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "hasMoreResults": - err = unpopulate(val, "HasMoreResults", &i.HasMoreResults) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &i.Value) + case "error": + err = unpopulate(val, "Error", &e.Error) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Operation. -func (o Operation) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ExtendedStatusDefinitionProperties. +func (e ExtendedStatusDefinitionProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "display", o.Display) - populate(objectMap, "isDataAction", o.IsDataAction) - populate(objectMap, "name", o.Name) + populate(objectMap, "subscriptionId", e.SubscriptionID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. -func (o *Operation) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtendedStatusDefinitionProperties. +func (e *ExtendedStatusDefinitionProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "display": - err = unpopulate(val, "Display", &o.Display) - delete(rawMsg, key) - case "isDataAction": - err = unpopulate(val, "IsDataAction", &o.IsDataAction) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &o.Name) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &e.SubscriptionID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. -func (o OperationDisplay) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ExtendedStatusInfo. +func (e ExtendedStatusInfo) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "description", o.Description) - populate(objectMap, "operation", o.Operation) - populate(objectMap, "provider", o.Provider) - populate(objectMap, "resource", o.Resource) + populate(objectMap, "message", e.Message) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "statusCode", e.StatusCode) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. -func (o *OperationDisplay) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtendedStatusInfo. +func (e *ExtendedStatusInfo) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "description": - err = unpopulate(val, "Description", &o.Description) - delete(rawMsg, key) - case "operation": - err = unpopulate(val, "Operation", &o.Operation) + case "message": + err = unpopulate(val, "Message", &e.Message) delete(rawMsg, key) - case "provider": - err = unpopulate(val, "Provider", &o.Provider) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) delete(rawMsg, key) - case "resource": - err = unpopulate(val, "Resource", &o.Resource) + case "statusCode": + err = unpopulate(val, "StatusCode", &e.StatusCode) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type OperationListResult. -func (o OperationListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ExtendedStatusInfoProperties. +func (e ExtendedStatusInfoProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", o.NextLink) - populate(objectMap, "value", o.Value) + populate(objectMap, "subscriptionId", e.SubscriptionID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. -func (o *OperationListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtendedStatusInfoProperties. +func (e *ExtendedStatusInfoProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &o.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &o.Value) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &e.SubscriptionID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type OperationsErrorDetails. -func (o OperationsErrorDetails) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ExternalReference. +func (e ExternalReference) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "code", o.Code) - populate(objectMap, "message", o.Message) - populate(objectMap, "target", o.Target) + populate(objectMap, "id", e.ID) + populate(objectMap, "url", e.URL) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationsErrorDetails. -func (o *OperationsErrorDetails) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ExternalReference. +func (e *ExternalReference) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "code": - err = unpopulate(val, "Code", &o.Code) - delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &o.Message) + case "id": + err = unpopulate(val, "ID", &e.ID) delete(rawMsg, key) - case "target": - err = unpopulate(val, "Target", &o.Target) + case "url": + err = unpopulate(val, "URL", &e.URL) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type OperationsErrorResponse. -func (o OperationsErrorResponse) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type FailedPayment. +func (f FailedPayment) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "error", o.Error) + populateDateTimeRFC3339(objectMap, "date", f.Date) + populate(objectMap, "failedPaymentReason", f.FailedPaymentReason) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationsErrorResponse. -func (o *OperationsErrorResponse) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type FailedPayment. +func (f *FailedPayment) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", f, err) } for key, val := range rawMsg { var err error switch key { - case "error": - err = unpopulate(val, "Error", &o.Error) + case "date": + err = unpopulateDateTimeRFC3339(val, "Date", &f.Date) + delete(rawMsg, key) + case "failedPaymentReason": + err = unpopulate(val, "FailedPaymentReason", &f.FailedPaymentReason) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", f, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Participants. -func (p Participants) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type IndirectRelationshipInfo. +func (i IndirectRelationshipInfo) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "email", p.Email) - populate(objectMap, "status", p.Status) - populateDateTimeRFC3339(objectMap, "statusDate", p.StatusDate) + populate(objectMap, "billingAccountName", i.BillingAccountName) + populate(objectMap, "billingProfileName", i.BillingProfileName) + populate(objectMap, "displayName", i.DisplayName) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Participants. -func (p *Participants) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type IndirectRelationshipInfo. +func (i *IndirectRelationshipInfo) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "email": - err = unpopulate(val, "Email", &p.Email) + case "billingAccountName": + err = unpopulate(val, "BillingAccountName", &i.BillingAccountName) delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &p.Status) + case "billingProfileName": + err = unpopulate(val, "BillingProfileName", &i.BillingProfileName) delete(rawMsg, key) - case "statusDate": - err = unpopulateDateTimeRFC3339(val, "StatusDate", &p.StatusDate) + case "displayName": + err = unpopulate(val, "DisplayName", &i.DisplayName) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type PaymentProperties. -func (p PaymentProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type InitiateTransferProperties. +func (i InitiateTransferProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "amount", p.Amount) - populateDateTimeRFC3339(objectMap, "date", p.Date) - populate(objectMap, "paymentMethodFamily", p.PaymentMethodFamily) - populate(objectMap, "paymentMethodType", p.PaymentMethodType) - populate(objectMap, "paymentType", p.PaymentType) + populate(objectMap, "recipientEmailId", i.RecipientEmailID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PaymentProperties. -func (p *PaymentProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type InitiateTransferProperties. +func (i *InitiateTransferProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "amount": - err = unpopulate(val, "Amount", &p.Amount) - delete(rawMsg, key) - case "date": - err = unpopulateDateTimeRFC3339(val, "Date", &p.Date) - delete(rawMsg, key) - case "paymentMethodFamily": - err = unpopulate(val, "PaymentMethodFamily", &p.PaymentMethodFamily) - delete(rawMsg, key) - case "paymentMethodType": - err = unpopulate(val, "PaymentMethodType", &p.PaymentMethodType) - delete(rawMsg, key) - case "paymentType": - err = unpopulate(val, "PaymentType", &p.PaymentType) + case "recipientEmailId": + err = unpopulate(val, "RecipientEmailID", &i.RecipientEmailID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Period. -func (p Period) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type InitiateTransferRequest. +func (i InitiateTransferRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", p.ID) - populate(objectMap, "name", p.Name) - populate(objectMap, "properties", p.Properties) - populate(objectMap, "type", p.Type) + populate(objectMap, "properties", i.Properties) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Period. -func (p *Period) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type InitiateTransferRequest. +func (i *InitiateTransferRequest) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &p.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &p.Name) - delete(rawMsg, key) case "properties": - err = unpopulate(val, "Properties", &p.Properties) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &p.Type) + err = unpopulate(val, "Properties", &i.Properties) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type PeriodProperties. -func (p PeriodProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Invoice. +func (i Invoice) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateDateType(objectMap, "billingPeriodEndDate", p.BillingPeriodEndDate) - populateDateType(objectMap, "billingPeriodStartDate", p.BillingPeriodStartDate) - populate(objectMap, "invoiceIds", p.InvoiceIDs) + populate(objectMap, "id", i.ID) + populate(objectMap, "name", i.Name) + populate(objectMap, "properties", i.Properties) + populate(objectMap, "systemData", i.SystemData) + populate(objectMap, "tags", i.Tags) + populate(objectMap, "type", i.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PeriodProperties. -func (p *PeriodProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Invoice. +func (i *Invoice) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "billingPeriodEndDate": - err = unpopulateDateType(val, "BillingPeriodEndDate", &p.BillingPeriodEndDate) + case "id": + err = unpopulate(val, "ID", &i.ID) delete(rawMsg, key) - case "billingPeriodStartDate": - err = unpopulateDateType(val, "BillingPeriodStartDate", &p.BillingPeriodStartDate) + case "name": + err = unpopulate(val, "Name", &i.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &i.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &i.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &i.Tags) delete(rawMsg, key) - case "invoiceIds": - err = unpopulate(val, "InvoiceIDs", &p.InvoiceIDs) + case "type": + err = unpopulate(val, "Type", &i.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type PeriodsListResult. -func (p PeriodsListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type InvoiceDocument. +func (i InvoiceDocument) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", p.NextLink) - populate(objectMap, "value", p.Value) + populate(objectMap, "documentNumbers", i.DocumentNumbers) + populate(objectMap, "externalUrl", i.ExternalURL) + populate(objectMap, "kind", i.Kind) + populate(objectMap, "name", i.Name) + populate(objectMap, "source", i.Source) + populate(objectMap, "url", i.URL) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PeriodsListResult. -func (p *PeriodsListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type InvoiceDocument. +func (i *InvoiceDocument) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &p.NextLink) + case "documentNumbers": + err = unpopulate(val, "DocumentNumbers", &i.DocumentNumbers) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &p.Value) + case "externalUrl": + err = unpopulate(val, "ExternalURL", &i.ExternalURL) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &i.Kind) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &i.Name) + delete(rawMsg, key) + case "source": + err = unpopulate(val, "Source", &i.Source) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &i.URL) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type PermissionsListResult. -func (p PermissionsListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type InvoiceListResult. +func (i InvoiceListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", p.NextLink) - populate(objectMap, "value", p.Value) + populate(objectMap, "nextLink", i.NextLink) + populate(objectMap, "value", i.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PermissionsListResult. -func (p *PermissionsListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type InvoiceListResult. +func (i *InvoiceListResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { case "nextLink": - err = unpopulate(val, "NextLink", &p.NextLink) + err = unpopulate(val, "NextLink", &i.NextLink) delete(rawMsg, key) case "value": - err = unpopulate(val, "Value", &p.Value) + err = unpopulate(val, "Value", &i.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type PermissionsProperties. -func (p PermissionsProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type InvoiceProperties. +func (i InvoiceProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "actions", p.Actions) - populate(objectMap, "notActions", p.NotActions) + populate(objectMap, "amountDue", i.AmountDue) + populate(objectMap, "azurePrepaymentApplied", i.AzurePrepaymentApplied) + populate(objectMap, "billedAmount", i.BilledAmount) + populate(objectMap, "billedDocumentId", i.BilledDocumentID) + populate(objectMap, "billingProfileDisplayName", i.BillingProfileDisplayName) + populate(objectMap, "billingProfileId", i.BillingProfileID) + populate(objectMap, "creditAmount", i.CreditAmount) + populate(objectMap, "creditForDocumentId", i.CreditForDocumentID) + populate(objectMap, "documentType", i.DocumentType) + populate(objectMap, "documents", i.Documents) + populateDateTimeRFC3339(objectMap, "dueDate", i.DueDate) + populate(objectMap, "failedPayments", i.FailedPayments) + populate(objectMap, "freeAzureCreditApplied", i.FreeAzureCreditApplied) + populateDateTimeRFC3339(objectMap, "invoiceDate", i.InvoiceDate) + populateDateTimeRFC3339(objectMap, "invoicePeriodEndDate", i.InvoicePeriodEndDate) + populateDateTimeRFC3339(objectMap, "invoicePeriodStartDate", i.InvoicePeriodStartDate) + populate(objectMap, "invoiceType", i.InvoiceType) + populate(objectMap, "isMonthlyInvoice", i.IsMonthlyInvoice) + populate(objectMap, "payments", i.Payments) + populate(objectMap, "purchaseOrderNumber", i.PurchaseOrderNumber) + populate(objectMap, "rebillDetails", i.RebillDetails) + populate(objectMap, "refundDetails", i.RefundDetails) + populate(objectMap, "specialTaxationType", i.SpecialTaxationType) + populate(objectMap, "status", i.Status) + populate(objectMap, "subTotal", i.SubTotal) + populate(objectMap, "subscriptionDisplayName", i.SubscriptionDisplayName) + populate(objectMap, "subscriptionId", i.SubscriptionID) + populate(objectMap, "taxAmount", i.TaxAmount) + populate(objectMap, "totalAmount", i.TotalAmount) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PermissionsProperties. -func (p *PermissionsProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type InvoiceProperties. +func (i *InvoiceProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "actions": - err = unpopulate(val, "Actions", &p.Actions) + case "amountDue": + err = unpopulate(val, "AmountDue", &i.AmountDue) delete(rawMsg, key) - case "notActions": - err = unpopulate(val, "NotActions", &p.NotActions) + case "azurePrepaymentApplied": + err = unpopulate(val, "AzurePrepaymentApplied", &i.AzurePrepaymentApplied) + delete(rawMsg, key) + case "billedAmount": + err = unpopulate(val, "BilledAmount", &i.BilledAmount) + delete(rawMsg, key) + case "billedDocumentId": + err = unpopulate(val, "BilledDocumentID", &i.BilledDocumentID) + delete(rawMsg, key) + case "billingProfileDisplayName": + err = unpopulate(val, "BillingProfileDisplayName", &i.BillingProfileDisplayName) + delete(rawMsg, key) + case "billingProfileId": + err = unpopulate(val, "BillingProfileID", &i.BillingProfileID) + delete(rawMsg, key) + case "creditAmount": + err = unpopulate(val, "CreditAmount", &i.CreditAmount) + delete(rawMsg, key) + case "creditForDocumentId": + err = unpopulate(val, "CreditForDocumentID", &i.CreditForDocumentID) + delete(rawMsg, key) + case "documentType": + err = unpopulate(val, "DocumentType", &i.DocumentType) + delete(rawMsg, key) + case "documents": + err = unpopulate(val, "Documents", &i.Documents) + delete(rawMsg, key) + case "dueDate": + err = unpopulateDateTimeRFC3339(val, "DueDate", &i.DueDate) + delete(rawMsg, key) + case "failedPayments": + err = unpopulate(val, "FailedPayments", &i.FailedPayments) + delete(rawMsg, key) + case "freeAzureCreditApplied": + err = unpopulate(val, "FreeAzureCreditApplied", &i.FreeAzureCreditApplied) + delete(rawMsg, key) + case "invoiceDate": + err = unpopulateDateTimeRFC3339(val, "InvoiceDate", &i.InvoiceDate) + delete(rawMsg, key) + case "invoicePeriodEndDate": + err = unpopulateDateTimeRFC3339(val, "InvoicePeriodEndDate", &i.InvoicePeriodEndDate) + delete(rawMsg, key) + case "invoicePeriodStartDate": + err = unpopulateDateTimeRFC3339(val, "InvoicePeriodStartDate", &i.InvoicePeriodStartDate) + delete(rawMsg, key) + case "invoiceType": + err = unpopulate(val, "InvoiceType", &i.InvoiceType) + delete(rawMsg, key) + case "isMonthlyInvoice": + err = unpopulate(val, "IsMonthlyInvoice", &i.IsMonthlyInvoice) + delete(rawMsg, key) + case "payments": + err = unpopulate(val, "Payments", &i.Payments) + delete(rawMsg, key) + case "purchaseOrderNumber": + err = unpopulate(val, "PurchaseOrderNumber", &i.PurchaseOrderNumber) + delete(rawMsg, key) + case "rebillDetails": + err = unpopulate(val, "RebillDetails", &i.RebillDetails) + delete(rawMsg, key) + case "refundDetails": + err = unpopulate(val, "RefundDetails", &i.RefundDetails) + delete(rawMsg, key) + case "specialTaxationType": + err = unpopulate(val, "SpecialTaxationType", &i.SpecialTaxationType) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &i.Status) + delete(rawMsg, key) + case "subTotal": + err = unpopulate(val, "SubTotal", &i.SubTotal) + delete(rawMsg, key) + case "subscriptionDisplayName": + err = unpopulate(val, "SubscriptionDisplayName", &i.SubscriptionDisplayName) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &i.SubscriptionID) + delete(rawMsg, key) + case "taxAmount": + err = unpopulate(val, "TaxAmount", &i.TaxAmount) + delete(rawMsg, key) + case "totalAmount": + err = unpopulate(val, "TotalAmount", &i.TotalAmount) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Policy. -func (p Policy) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type InvoicePropertiesAmountDue. +func (i InvoicePropertiesAmountDue) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", p.ID) - populate(objectMap, "name", p.Name) - populate(objectMap, "properties", p.Properties) - populate(objectMap, "type", p.Type) + populate(objectMap, "currency", i.Currency) + populate(objectMap, "value", i.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Policy. -func (p *Policy) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type InvoicePropertiesAmountDue. +func (i *InvoicePropertiesAmountDue) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &p.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &p.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &p.Properties) + case "currency": + err = unpopulate(val, "Currency", &i.Currency) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &p.Type) + case "value": + err = unpopulate(val, "Value", &i.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type PolicyProperties. -func (p PolicyProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type InvoicePropertiesAzurePrepaymentApplied. +func (i InvoicePropertiesAzurePrepaymentApplied) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "marketplacePurchases", p.MarketplacePurchases) - populate(objectMap, "reservationPurchases", p.ReservationPurchases) - populate(objectMap, "viewCharges", p.ViewCharges) + populate(objectMap, "currency", i.Currency) + populate(objectMap, "value", i.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyProperties. -func (p *PolicyProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type InvoicePropertiesAzurePrepaymentApplied. +func (i *InvoicePropertiesAzurePrepaymentApplied) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "marketplacePurchases": - err = unpopulate(val, "MarketplacePurchases", &p.MarketplacePurchases) - delete(rawMsg, key) - case "reservationPurchases": - err = unpopulate(val, "ReservationPurchases", &p.ReservationPurchases) + case "currency": + err = unpopulate(val, "Currency", &i.Currency) delete(rawMsg, key) - case "viewCharges": - err = unpopulate(val, "ViewCharges", &p.ViewCharges) + case "value": + err = unpopulate(val, "Value", &i.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Product. -func (p Product) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type InvoicePropertiesBilledAmount. +func (i InvoicePropertiesBilledAmount) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", p.ID) - populate(objectMap, "name", p.Name) - populate(objectMap, "properties", p.Properties) - populate(objectMap, "type", p.Type) + populate(objectMap, "currency", i.Currency) + populate(objectMap, "value", i.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Product. -func (p *Product) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type InvoicePropertiesBilledAmount. +func (i *InvoicePropertiesBilledAmount) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &p.ID) + case "currency": + err = unpopulate(val, "Currency", &i.Currency) delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &p.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &p.Properties) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &p.Type) + case "value": + err = unpopulate(val, "Value", &i.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ProductProperties. -func (p ProductProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type InvoicePropertiesCreditAmount. +func (i InvoicePropertiesCreditAmount) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "autoRenew", p.AutoRenew) - populate(objectMap, "availabilityId", p.AvailabilityID) - populate(objectMap, "billingFrequency", p.BillingFrequency) - populate(objectMap, "billingProfileDisplayName", p.BillingProfileDisplayName) - populate(objectMap, "billingProfileId", p.BillingProfileID) - populate(objectMap, "customerDisplayName", p.CustomerDisplayName) - populate(objectMap, "customerId", p.CustomerID) - populate(objectMap, "displayName", p.DisplayName) - populateDateTimeRFC3339(objectMap, "endDate", p.EndDate) - populate(objectMap, "invoiceSectionDisplayName", p.InvoiceSectionDisplayName) - populate(objectMap, "invoiceSectionId", p.InvoiceSectionID) - populate(objectMap, "lastCharge", p.LastCharge) - populateDateTimeRFC3339(objectMap, "lastChargeDate", p.LastChargeDate) - populate(objectMap, "productType", p.ProductType) - populate(objectMap, "productTypeId", p.ProductTypeID) - populateDateTimeRFC3339(objectMap, "purchaseDate", p.PurchaseDate) - populate(objectMap, "quantity", p.Quantity) - populate(objectMap, "reseller", p.Reseller) - populate(objectMap, "skuDescription", p.SKUDescription) - populate(objectMap, "skuId", p.SKUID) - populate(objectMap, "status", p.Status) - populate(objectMap, "tenantId", p.TenantID) + populate(objectMap, "currency", i.Currency) + populate(objectMap, "value", i.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ProductProperties. -func (p *ProductProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type InvoicePropertiesCreditAmount. +func (i *InvoicePropertiesCreditAmount) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "autoRenew": - err = unpopulate(val, "AutoRenew", &p.AutoRenew) - delete(rawMsg, key) - case "availabilityId": - err = unpopulate(val, "AvailabilityID", &p.AvailabilityID) - delete(rawMsg, key) - case "billingFrequency": - err = unpopulate(val, "BillingFrequency", &p.BillingFrequency) - delete(rawMsg, key) - case "billingProfileDisplayName": - err = unpopulate(val, "BillingProfileDisplayName", &p.BillingProfileDisplayName) - delete(rawMsg, key) - case "billingProfileId": - err = unpopulate(val, "BillingProfileID", &p.BillingProfileID) - delete(rawMsg, key) - case "customerDisplayName": - err = unpopulate(val, "CustomerDisplayName", &p.CustomerDisplayName) - delete(rawMsg, key) - case "customerId": - err = unpopulate(val, "CustomerID", &p.CustomerID) - delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &p.DisplayName) - delete(rawMsg, key) - case "endDate": - err = unpopulateDateTimeRFC3339(val, "EndDate", &p.EndDate) - delete(rawMsg, key) - case "invoiceSectionDisplayName": - err = unpopulate(val, "InvoiceSectionDisplayName", &p.InvoiceSectionDisplayName) - delete(rawMsg, key) - case "invoiceSectionId": - err = unpopulate(val, "InvoiceSectionID", &p.InvoiceSectionID) - delete(rawMsg, key) - case "lastCharge": - err = unpopulate(val, "LastCharge", &p.LastCharge) - delete(rawMsg, key) - case "lastChargeDate": - err = unpopulateDateTimeRFC3339(val, "LastChargeDate", &p.LastChargeDate) - delete(rawMsg, key) - case "productType": - err = unpopulate(val, "ProductType", &p.ProductType) - delete(rawMsg, key) - case "productTypeId": - err = unpopulate(val, "ProductTypeID", &p.ProductTypeID) - delete(rawMsg, key) - case "purchaseDate": - err = unpopulateDateTimeRFC3339(val, "PurchaseDate", &p.PurchaseDate) - delete(rawMsg, key) - case "quantity": - err = unpopulate(val, "Quantity", &p.Quantity) - delete(rawMsg, key) - case "reseller": - err = unpopulate(val, "Reseller", &p.Reseller) - delete(rawMsg, key) - case "skuDescription": - err = unpopulate(val, "SKUDescription", &p.SKUDescription) - delete(rawMsg, key) - case "skuId": - err = unpopulate(val, "SKUID", &p.SKUID) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &p.Status) + case "currency": + err = unpopulate(val, "Currency", &i.Currency) delete(rawMsg, key) - case "tenantId": - err = unpopulate(val, "TenantID", &p.TenantID) + case "value": + err = unpopulate(val, "Value", &i.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ProductsListResult. -func (p ProductsListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type InvoicePropertiesFreeAzureCreditApplied. +func (i InvoicePropertiesFreeAzureCreditApplied) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", p.NextLink) - populate(objectMap, "totalCount", p.TotalCount) - populate(objectMap, "value", p.Value) + populate(objectMap, "currency", i.Currency) + populate(objectMap, "value", i.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ProductsListResult. -func (p *ProductsListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type InvoicePropertiesFreeAzureCreditApplied. +func (i *InvoicePropertiesFreeAzureCreditApplied) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &p.NextLink) - delete(rawMsg, key) - case "totalCount": - err = unpopulate(val, "TotalCount", &p.TotalCount) + case "currency": + err = unpopulate(val, "Currency", &i.Currency) delete(rawMsg, key) case "value": - err = unpopulate(val, "Value", &p.Value) + err = unpopulate(val, "Value", &i.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Profile. -func (p Profile) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type InvoicePropertiesRebillDetails. +func (i InvoicePropertiesRebillDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", p.ID) - populate(objectMap, "name", p.Name) - populate(objectMap, "properties", p.Properties) - populate(objectMap, "type", p.Type) + populate(objectMap, "creditNoteDocumentId", i.CreditNoteDocumentID) + populate(objectMap, "invoiceDocumentId", i.InvoiceDocumentID) + populate(objectMap, "rebillDetails", i.RebillDetails) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Profile. -func (p *Profile) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type InvoicePropertiesRebillDetails. +func (i *InvoicePropertiesRebillDetails) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &p.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &p.Name) + case "creditNoteDocumentId": + err = unpopulate(val, "CreditNoteDocumentID", &i.CreditNoteDocumentID) delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &p.Properties) + case "invoiceDocumentId": + err = unpopulate(val, "InvoiceDocumentID", &i.InvoiceDocumentID) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &p.Type) + case "rebillDetails": + err = unpopulate(val, "RebillDetails", &i.RebillDetails) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ProfileCreationRequest. -func (p ProfileCreationRequest) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type InvoicePropertiesRefundDetails. +func (i InvoicePropertiesRefundDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "billTo", p.BillTo) - populate(objectMap, "displayName", p.DisplayName) - populate(objectMap, "enabledAzurePlans", p.EnabledAzurePlans) - populate(objectMap, "invoiceEmailOptIn", p.InvoiceEmailOptIn) - populate(objectMap, "poNumber", p.PoNumber) + populate(objectMap, "amountRefunded", i.AmountRefunded) + populate(objectMap, "amountRequested", i.AmountRequested) + populateDateTimeRFC3339(objectMap, "approvedOn", i.ApprovedOn) + populateDateTimeRFC3339(objectMap, "completedOn", i.CompletedOn) + populate(objectMap, "rebillInvoiceId", i.RebillInvoiceID) + populate(objectMap, "refundOperationId", i.RefundOperationID) + populate(objectMap, "refundReason", i.RefundReason) + populate(objectMap, "refundStatus", i.RefundStatus) + populateDateTimeRFC3339(objectMap, "requestedOn", i.RequestedOn) + populate(objectMap, "transactionCount", i.TransactionCount) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ProfileCreationRequest. -func (p *ProfileCreationRequest) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type InvoicePropertiesRefundDetails. +func (i *InvoicePropertiesRefundDetails) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "billTo": - err = unpopulate(val, "BillTo", &p.BillTo) + case "amountRefunded": + err = unpopulate(val, "AmountRefunded", &i.AmountRefunded) delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &p.DisplayName) + case "amountRequested": + err = unpopulate(val, "AmountRequested", &i.AmountRequested) delete(rawMsg, key) - case "enabledAzurePlans": - err = unpopulate(val, "EnabledAzurePlans", &p.EnabledAzurePlans) + case "approvedOn": + err = unpopulateDateTimeRFC3339(val, "ApprovedOn", &i.ApprovedOn) delete(rawMsg, key) - case "invoiceEmailOptIn": - err = unpopulate(val, "InvoiceEmailOptIn", &p.InvoiceEmailOptIn) + case "completedOn": + err = unpopulateDateTimeRFC3339(val, "CompletedOn", &i.CompletedOn) delete(rawMsg, key) - case "poNumber": - err = unpopulate(val, "PoNumber", &p.PoNumber) + case "rebillInvoiceId": + err = unpopulate(val, "RebillInvoiceID", &i.RebillInvoiceID) + delete(rawMsg, key) + case "refundOperationId": + err = unpopulate(val, "RefundOperationID", &i.RefundOperationID) + delete(rawMsg, key) + case "refundReason": + err = unpopulate(val, "RefundReason", &i.RefundReason) + delete(rawMsg, key) + case "refundStatus": + err = unpopulate(val, "RefundStatus", &i.RefundStatus) + delete(rawMsg, key) + case "requestedOn": + err = unpopulateDateTimeRFC3339(val, "RequestedOn", &i.RequestedOn) + delete(rawMsg, key) + case "transactionCount": + err = unpopulate(val, "TransactionCount", &i.TransactionCount) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ProfileInfo. -func (p ProfileInfo) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type InvoicePropertiesSubTotal. +func (i InvoicePropertiesSubTotal) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "billingProfileDisplayName", p.BillingProfileDisplayName) - populate(objectMap, "billingProfileId", p.BillingProfileID) - populate(objectMap, "indirectRelationshipOrganizationName", p.IndirectRelationshipOrganizationName) + populate(objectMap, "currency", i.Currency) + populate(objectMap, "value", i.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ProfileInfo. -func (p *ProfileInfo) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type InvoicePropertiesSubTotal. +func (i *InvoicePropertiesSubTotal) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "billingProfileDisplayName": - err = unpopulate(val, "BillingProfileDisplayName", &p.BillingProfileDisplayName) - delete(rawMsg, key) - case "billingProfileId": - err = unpopulate(val, "BillingProfileID", &p.BillingProfileID) + case "currency": + err = unpopulate(val, "Currency", &i.Currency) delete(rawMsg, key) - case "indirectRelationshipOrganizationName": - err = unpopulate(val, "IndirectRelationshipOrganizationName", &p.IndirectRelationshipOrganizationName) + case "value": + err = unpopulate(val, "Value", &i.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ProfileListResult. -func (p ProfileListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type InvoicePropertiesTaxAmount. +func (i InvoicePropertiesTaxAmount) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", p.NextLink) - populate(objectMap, "totalCount", p.TotalCount) - populate(objectMap, "value", p.Value) + populate(objectMap, "currency", i.Currency) + populate(objectMap, "value", i.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ProfileListResult. -func (p *ProfileListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type InvoicePropertiesTaxAmount. +func (i *InvoicePropertiesTaxAmount) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &p.NextLink) - delete(rawMsg, key) - case "totalCount": - err = unpopulate(val, "TotalCount", &p.TotalCount) + case "currency": + err = unpopulate(val, "Currency", &i.Currency) delete(rawMsg, key) case "value": - err = unpopulate(val, "Value", &p.Value) + err = unpopulate(val, "Value", &i.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ProfileProperties. -func (p ProfileProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type InvoicePropertiesTotalAmount. +func (i InvoicePropertiesTotalAmount) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "billTo", p.BillTo) - populate(objectMap, "billingRelationshipType", p.BillingRelationshipType) - populate(objectMap, "currency", p.Currency) - populate(objectMap, "displayName", p.DisplayName) - populate(objectMap, "enabledAzurePlans", p.EnabledAzurePlans) - populate(objectMap, "hasReadAccess", p.HasReadAccess) - populate(objectMap, "indirectRelationshipInfo", p.IndirectRelationshipInfo) - populate(objectMap, "invoiceDay", p.InvoiceDay) - populate(objectMap, "invoiceEmailOptIn", p.InvoiceEmailOptIn) - populate(objectMap, "invoiceSections", p.InvoiceSections) - populate(objectMap, "poNumber", p.PoNumber) - populate(objectMap, "spendingLimit", p.SpendingLimit) - populate(objectMap, "status", p.Status) - populate(objectMap, "statusReasonCode", p.StatusReasonCode) - populate(objectMap, "systemId", p.SystemID) - populate(objectMap, "tags", p.Tags) - populate(objectMap, "targetClouds", p.TargetClouds) + populate(objectMap, "currency", i.Currency) + populate(objectMap, "value", i.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ProfileProperties. -func (p *ProfileProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type InvoicePropertiesTotalAmount. +func (i *InvoicePropertiesTotalAmount) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "billTo": - err = unpopulate(val, "BillTo", &p.BillTo) - delete(rawMsg, key) - case "billingRelationshipType": - err = unpopulate(val, "BillingRelationshipType", &p.BillingRelationshipType) - delete(rawMsg, key) case "currency": - err = unpopulate(val, "Currency", &p.Currency) - delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &p.DisplayName) - delete(rawMsg, key) - case "enabledAzurePlans": - err = unpopulate(val, "EnabledAzurePlans", &p.EnabledAzurePlans) - delete(rawMsg, key) - case "hasReadAccess": - err = unpopulate(val, "HasReadAccess", &p.HasReadAccess) - delete(rawMsg, key) - case "indirectRelationshipInfo": - err = unpopulate(val, "IndirectRelationshipInfo", &p.IndirectRelationshipInfo) - delete(rawMsg, key) - case "invoiceDay": - err = unpopulate(val, "InvoiceDay", &p.InvoiceDay) - delete(rawMsg, key) - case "invoiceEmailOptIn": - err = unpopulate(val, "InvoiceEmailOptIn", &p.InvoiceEmailOptIn) + err = unpopulate(val, "Currency", &i.Currency) delete(rawMsg, key) - case "invoiceSections": - err = unpopulate(val, "InvoiceSections", &p.InvoiceSections) + case "value": + err = unpopulate(val, "Value", &i.Value) delete(rawMsg, key) - case "poNumber": - err = unpopulate(val, "PoNumber", &p.PoNumber) - delete(rawMsg, key) - case "spendingLimit": - err = unpopulate(val, "SpendingLimit", &p.SpendingLimit) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type InvoiceSection. +func (i InvoiceSection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", i.ID) + populate(objectMap, "name", i.Name) + populate(objectMap, "properties", i.Properties) + populate(objectMap, "systemData", i.SystemData) + populate(objectMap, "tags", i.Tags) + populate(objectMap, "type", i.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type InvoiceSection. +func (i *InvoiceSection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &i.ID) delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &p.Status) + case "name": + err = unpopulate(val, "Name", &i.Name) delete(rawMsg, key) - case "statusReasonCode": - err = unpopulate(val, "StatusReasonCode", &p.StatusReasonCode) + case "properties": + err = unpopulate(val, "Properties", &i.Properties) delete(rawMsg, key) - case "systemId": - err = unpopulate(val, "SystemID", &p.SystemID) + case "systemData": + err = unpopulate(val, "SystemData", &i.SystemData) delete(rawMsg, key) case "tags": - err = unpopulate(val, "Tags", &p.Tags) + err = unpopulate(val, "Tags", &i.Tags) delete(rawMsg, key) - case "targetClouds": - err = unpopulate(val, "TargetClouds", &p.TargetClouds) + case "type": + err = unpopulate(val, "Type", &i.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ProfilesOnExpand. -func (p ProfilesOnExpand) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type InvoiceSectionListResult. +func (i InvoiceSectionListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "hasMoreResults", p.HasMoreResults) - populate(objectMap, "value", p.Value) + populate(objectMap, "nextLink", i.NextLink) + populate(objectMap, "value", i.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ProfilesOnExpand. -func (p *ProfilesOnExpand) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type InvoiceSectionListResult. +func (i *InvoiceSectionListResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "hasMoreResults": - err = unpopulate(val, "HasMoreResults", &p.HasMoreResults) + case "nextLink": + err = unpopulate(val, "NextLink", &i.NextLink) delete(rawMsg, key) case "value": - err = unpopulate(val, "Value", &p.Value) + err = unpopulate(val, "Value", &i.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Property. -func (p Property) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type InvoiceSectionProperties. +func (i InvoiceSectionProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", p.ID) - populate(objectMap, "name", p.Name) - populate(objectMap, "properties", p.Properties) - populate(objectMap, "type", p.Type) + populate(objectMap, "displayName", i.DisplayName) + populate(objectMap, "provisioningState", i.ProvisioningState) + populate(objectMap, "reasonCode", i.ReasonCode) + populate(objectMap, "state", i.State) + populate(objectMap, "systemId", i.SystemID) + populate(objectMap, "tags", i.Tags) + populate(objectMap, "targetCloud", i.TargetCloud) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Property. -func (p *Property) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type InvoiceSectionProperties. +func (i *InvoiceSectionProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &p.ID) + case "displayName": + err = unpopulate(val, "DisplayName", &i.DisplayName) delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &p.Name) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &i.ProvisioningState) delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &p.Properties) + case "reasonCode": + err = unpopulate(val, "ReasonCode", &i.ReasonCode) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &p.Type) + case "state": + err = unpopulate(val, "State", &i.State) + delete(rawMsg, key) + case "systemId": + err = unpopulate(val, "SystemID", &i.SystemID) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &i.Tags) + delete(rawMsg, key) + case "targetCloud": + err = unpopulate(val, "TargetCloud", &i.TargetCloud) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type PropertyProperties. -func (p PropertyProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type InvoiceSectionWithCreateSubPermission. +func (i InvoiceSectionWithCreateSubPermission) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "accountAdminNotificationEmailAddress", p.AccountAdminNotificationEmailAddress) - populate(objectMap, "billingAccountDisplayName", p.BillingAccountDisplayName) - populate(objectMap, "billingAccountId", p.BillingAccountID) - populate(objectMap, "billingProfileDisplayName", p.BillingProfileDisplayName) - populate(objectMap, "billingProfileId", p.BillingProfileID) - populate(objectMap, "billingProfileSpendingLimit", p.BillingProfileSpendingLimit) - populate(objectMap, "billingProfileStatus", p.BillingProfileStatus) - populate(objectMap, "billingProfileStatusReasonCode", p.BillingProfileStatusReasonCode) - populate(objectMap, "billingTenantId", p.BillingTenantID) - populate(objectMap, "costCenter", p.CostCenter) - populate(objectMap, "invoiceSectionDisplayName", p.InvoiceSectionDisplayName) - populate(objectMap, "invoiceSectionId", p.InvoiceSectionID) - populate(objectMap, "isAccountAdmin", p.IsAccountAdmin) - populate(objectMap, "productId", p.ProductID) - populate(objectMap, "productName", p.ProductName) - populate(objectMap, "skuDescription", p.SKUDescription) - populate(objectMap, "skuId", p.SKUID) + populate(objectMap, "billingProfileDisplayName", i.BillingProfileDisplayName) + populate(objectMap, "billingProfileId", i.BillingProfileID) + populate(objectMap, "billingProfileSpendingLimit", i.BillingProfileSpendingLimit) + populate(objectMap, "billingProfileStatus", i.BillingProfileStatus) + populate(objectMap, "billingProfileStatusReasonCode", i.BillingProfileStatusReasonCode) + populate(objectMap, "billingProfileSystemId", i.BillingProfileSystemID) + populate(objectMap, "enabledAzurePlans", i.EnabledAzurePlans) + populate(objectMap, "invoiceSectionDisplayName", i.InvoiceSectionDisplayName) + populate(objectMap, "invoiceSectionId", i.InvoiceSectionID) + populate(objectMap, "invoiceSectionSystemId", i.InvoiceSectionSystemID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PropertyProperties. -func (p *PropertyProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type InvoiceSectionWithCreateSubPermission. +func (i *InvoiceSectionWithCreateSubPermission) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "accountAdminNotificationEmailAddress": - err = unpopulate(val, "AccountAdminNotificationEmailAddress", &p.AccountAdminNotificationEmailAddress) - delete(rawMsg, key) - case "billingAccountDisplayName": - err = unpopulate(val, "BillingAccountDisplayName", &p.BillingAccountDisplayName) - delete(rawMsg, key) - case "billingAccountId": - err = unpopulate(val, "BillingAccountID", &p.BillingAccountID) - delete(rawMsg, key) case "billingProfileDisplayName": - err = unpopulate(val, "BillingProfileDisplayName", &p.BillingProfileDisplayName) + err = unpopulate(val, "BillingProfileDisplayName", &i.BillingProfileDisplayName) delete(rawMsg, key) case "billingProfileId": - err = unpopulate(val, "BillingProfileID", &p.BillingProfileID) + err = unpopulate(val, "BillingProfileID", &i.BillingProfileID) delete(rawMsg, key) case "billingProfileSpendingLimit": - err = unpopulate(val, "BillingProfileSpendingLimit", &p.BillingProfileSpendingLimit) + err = unpopulate(val, "BillingProfileSpendingLimit", &i.BillingProfileSpendingLimit) delete(rawMsg, key) case "billingProfileStatus": - err = unpopulate(val, "BillingProfileStatus", &p.BillingProfileStatus) + err = unpopulate(val, "BillingProfileStatus", &i.BillingProfileStatus) delete(rawMsg, key) case "billingProfileStatusReasonCode": - err = unpopulate(val, "BillingProfileStatusReasonCode", &p.BillingProfileStatusReasonCode) + err = unpopulate(val, "BillingProfileStatusReasonCode", &i.BillingProfileStatusReasonCode) delete(rawMsg, key) - case "billingTenantId": - err = unpopulate(val, "BillingTenantID", &p.BillingTenantID) + case "billingProfileSystemId": + err = unpopulate(val, "BillingProfileSystemID", &i.BillingProfileSystemID) delete(rawMsg, key) - case "costCenter": - err = unpopulate(val, "CostCenter", &p.CostCenter) + case "enabledAzurePlans": + err = unpopulate(val, "EnabledAzurePlans", &i.EnabledAzurePlans) delete(rawMsg, key) case "invoiceSectionDisplayName": - err = unpopulate(val, "InvoiceSectionDisplayName", &p.InvoiceSectionDisplayName) + err = unpopulate(val, "InvoiceSectionDisplayName", &i.InvoiceSectionDisplayName) delete(rawMsg, key) case "invoiceSectionId": - err = unpopulate(val, "InvoiceSectionID", &p.InvoiceSectionID) - delete(rawMsg, key) - case "isAccountAdmin": - err = unpopulate(val, "IsAccountAdmin", &p.IsAccountAdmin) - delete(rawMsg, key) - case "productId": - err = unpopulate(val, "ProductID", &p.ProductID) - delete(rawMsg, key) - case "productName": - err = unpopulate(val, "ProductName", &p.ProductName) - delete(rawMsg, key) - case "skuDescription": - err = unpopulate(val, "SKUDescription", &p.SKUDescription) + err = unpopulate(val, "InvoiceSectionID", &i.InvoiceSectionID) delete(rawMsg, key) - case "skuId": - err = unpopulate(val, "SKUID", &p.SKUID) + case "invoiceSectionSystemId": + err = unpopulate(val, "InvoiceSectionSystemID", &i.InvoiceSectionSystemID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type RebillDetails. -func (r RebillDetails) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type InvoiceSectionWithCreateSubPermissionListResult. +func (i InvoiceSectionWithCreateSubPermissionListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "creditNoteDocumentId", r.CreditNoteDocumentID) - populate(objectMap, "invoiceDocumentId", r.InvoiceDocumentID) - populate(objectMap, "rebillDetails", r.RebillDetails) + populate(objectMap, "nextLink", i.NextLink) + populate(objectMap, "value", i.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type RebillDetails. -func (r *RebillDetails) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type InvoiceSectionWithCreateSubPermissionListResult. +func (i *InvoiceSectionWithCreateSubPermissionListResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "creditNoteDocumentId": - err = unpopulate(val, "CreditNoteDocumentID", &r.CreditNoteDocumentID) - delete(rawMsg, key) - case "invoiceDocumentId": - err = unpopulate(val, "InvoiceDocumentID", &r.InvoiceDocumentID) + case "nextLink": + err = unpopulate(val, "NextLink", &i.NextLink) delete(rawMsg, key) - case "rebillDetails": - err = unpopulate(val, "RebillDetails", &r.RebillDetails) + case "value": + err = unpopulate(val, "Value", &i.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Reseller. -func (r Reseller) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type MoveBillingSubscriptionEligibilityResult. +func (m MoveBillingSubscriptionEligibilityResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "description", r.Description) - populate(objectMap, "resellerId", r.ResellerID) + populate(objectMap, "errorDetails", m.ErrorDetails) + populate(objectMap, "isMoveEligible", m.IsMoveEligible) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Reseller. -func (r *Reseller) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type MoveBillingSubscriptionEligibilityResult. +func (m *MoveBillingSubscriptionEligibilityResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { - case "description": - err = unpopulate(val, "Description", &r.Description) + case "errorDetails": + err = unpopulate(val, "ErrorDetails", &m.ErrorDetails) delete(rawMsg, key) - case "resellerId": - err = unpopulate(val, "ResellerID", &r.ResellerID) + case "isMoveEligible": + err = unpopulate(val, "IsMoveEligible", &m.IsMoveEligible) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Reservation. -func (r Reservation) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type MoveBillingSubscriptionErrorDetails. +func (m MoveBillingSubscriptionErrorDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", r.ID) - populate(objectMap, "location", r.Location) - populate(objectMap, "name", r.Name) - populate(objectMap, "properties", r.Properties) - populate(objectMap, "sku", r.SKU) - populate(objectMap, "type", r.Type) + populate(objectMap, "code", m.Code) + populate(objectMap, "details", m.Details) + populate(objectMap, "message", m.Message) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Reservation. -func (r *Reservation) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type MoveBillingSubscriptionErrorDetails. +func (m *MoveBillingSubscriptionErrorDetails) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &r.ID) + case "code": + err = unpopulate(val, "Code", &m.Code) delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &r.Location) + case "details": + err = unpopulate(val, "Details", &m.Details) delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &r.Properties) - delete(rawMsg, key) - case "sku": - err = unpopulate(val, "SKU", &r.SKU) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &r.Type) + case "message": + err = unpopulate(val, "Message", &m.Message) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ReservationProperty. -func (r ReservationProperty) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type MoveBillingSubscriptionRequest. +func (m MoveBillingSubscriptionRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "appliedScopeType", r.AppliedScopeType) - populate(objectMap, "appliedScopes", r.AppliedScopes) - populate(objectMap, "displayName", r.DisplayName) - populate(objectMap, "displayProvisioningState", r.DisplayProvisioningState) - populate(objectMap, "effectiveDateTime", r.EffectiveDateTime) - populate(objectMap, "expiryDate", r.ExpiryDate) - populate(objectMap, "provisioningState", r.ProvisioningState) - populate(objectMap, "provisioningSubState", r.ProvisioningSubState) - populate(objectMap, "quantity", r.Quantity) - populate(objectMap, "renew", r.Renew) - populate(objectMap, "renewSource", r.RenewSource) - populate(objectMap, "reservedResourceType", r.ReservedResourceType) - populate(objectMap, "skuDescription", r.SKUDescription) - populate(objectMap, "term", r.Term) - populate(objectMap, "userFriendlyAppliedScopeType", r.UserFriendlyAppliedScopeType) - populate(objectMap, "userFriendlyRenewState", r.UserFriendlyRenewState) - populate(objectMap, "utilization", r.Utilization) + populate(objectMap, "destinationEnrollmentAccountId", m.DestinationEnrollmentAccountID) + populate(objectMap, "destinationInvoiceSectionId", m.DestinationInvoiceSectionID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationProperty. -func (r *ReservationProperty) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type MoveBillingSubscriptionRequest. +func (m *MoveBillingSubscriptionRequest) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { - case "appliedScopeType": - err = unpopulate(val, "AppliedScopeType", &r.AppliedScopeType) - delete(rawMsg, key) - case "appliedScopes": - err = unpopulate(val, "AppliedScopes", &r.AppliedScopes) - delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &r.DisplayName) - delete(rawMsg, key) - case "displayProvisioningState": - err = unpopulate(val, "DisplayProvisioningState", &r.DisplayProvisioningState) - delete(rawMsg, key) - case "effectiveDateTime": - err = unpopulate(val, "EffectiveDateTime", &r.EffectiveDateTime) - delete(rawMsg, key) - case "expiryDate": - err = unpopulate(val, "ExpiryDate", &r.ExpiryDate) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) - delete(rawMsg, key) - case "provisioningSubState": - err = unpopulate(val, "ProvisioningSubState", &r.ProvisioningSubState) - delete(rawMsg, key) - case "quantity": - err = unpopulate(val, "Quantity", &r.Quantity) - delete(rawMsg, key) - case "renew": - err = unpopulate(val, "Renew", &r.Renew) - delete(rawMsg, key) - case "renewSource": - err = unpopulate(val, "RenewSource", &r.RenewSource) - delete(rawMsg, key) - case "reservedResourceType": - err = unpopulate(val, "ReservedResourceType", &r.ReservedResourceType) - delete(rawMsg, key) - case "skuDescription": - err = unpopulate(val, "SKUDescription", &r.SKUDescription) - delete(rawMsg, key) - case "term": - err = unpopulate(val, "Term", &r.Term) - delete(rawMsg, key) - case "userFriendlyAppliedScopeType": - err = unpopulate(val, "UserFriendlyAppliedScopeType", &r.UserFriendlyAppliedScopeType) + case "destinationEnrollmentAccountId": + err = unpopulate(val, "DestinationEnrollmentAccountID", &m.DestinationEnrollmentAccountID) delete(rawMsg, key) - case "userFriendlyRenewState": - err = unpopulate(val, "UserFriendlyRenewState", &r.UserFriendlyRenewState) - delete(rawMsg, key) - case "utilization": - err = unpopulate(val, "Utilization", &r.Utilization) + case "destinationInvoiceSectionId": + err = unpopulate(val, "DestinationInvoiceSectionID", &m.DestinationInvoiceSectionID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ReservationPropertyUtilization. -func (r ReservationPropertyUtilization) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type MoveProductEligibilityResult. +func (m MoveProductEligibilityResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "aggregates", r.Aggregates) - populate(objectMap, "trend", r.Trend) + populate(objectMap, "errorDetails", m.ErrorDetails) + populate(objectMap, "isMoveEligible", m.IsMoveEligible) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationPropertyUtilization. -func (r *ReservationPropertyUtilization) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type MoveProductEligibilityResult. +func (m *MoveProductEligibilityResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { - case "aggregates": - err = unpopulate(val, "Aggregates", &r.Aggregates) + case "errorDetails": + err = unpopulate(val, "ErrorDetails", &m.ErrorDetails) delete(rawMsg, key) - case "trend": - err = unpopulate(val, "Trend", &r.Trend) + case "isMoveEligible": + err = unpopulate(val, "IsMoveEligible", &m.IsMoveEligible) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ReservationSKUProperty. -func (r ReservationSKUProperty) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type MoveProductEligibilityResultErrorDetails. +func (m MoveProductEligibilityResultErrorDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "name", r.Name) + populate(objectMap, "code", m.Code) + populate(objectMap, "details", m.Details) + populate(objectMap, "message", m.Message) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationSKUProperty. -func (r *ReservationSKUProperty) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type MoveProductEligibilityResultErrorDetails. +func (m *MoveProductEligibilityResultErrorDetails) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { - case "name": - err = unpopulate(val, "Name", &r.Name) + case "code": + err = unpopulate(val, "Code", &m.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &m.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &m.Message) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ReservationSummary. -func (r ReservationSummary) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type MoveProductErrorDetails. +func (m MoveProductErrorDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "cancelledCount", r.CancelledCount) - populate(objectMap, "expiredCount", r.ExpiredCount) - populate(objectMap, "expiringCount", r.ExpiringCount) - populate(objectMap, "failedCount", r.FailedCount) - populate(objectMap, "pendingCount", r.PendingCount) - populate(objectMap, "succeededCount", r.SucceededCount) + populate(objectMap, "code", m.Code) + populate(objectMap, "details", m.Details) + populate(objectMap, "message", m.Message) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationSummary. -func (r *ReservationSummary) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type MoveProductErrorDetails. +func (m *MoveProductErrorDetails) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { - case "cancelledCount": - err = unpopulate(val, "CancelledCount", &r.CancelledCount) - delete(rawMsg, key) - case "expiredCount": - err = unpopulate(val, "ExpiredCount", &r.ExpiredCount) - delete(rawMsg, key) - case "expiringCount": - err = unpopulate(val, "ExpiringCount", &r.ExpiringCount) - delete(rawMsg, key) - case "failedCount": - err = unpopulate(val, "FailedCount", &r.FailedCount) + case "code": + err = unpopulate(val, "Code", &m.Code) delete(rawMsg, key) - case "pendingCount": - err = unpopulate(val, "PendingCount", &r.PendingCount) + case "details": + err = unpopulate(val, "Details", &m.Details) delete(rawMsg, key) - case "succeededCount": - err = unpopulate(val, "SucceededCount", &r.SucceededCount) + case "message": + err = unpopulate(val, "Message", &m.Message) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ReservationUtilizationAggregates. -func (r ReservationUtilizationAggregates) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type MoveProductRequest. +func (m MoveProductRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "grain", r.Grain) - populate(objectMap, "grainUnit", r.GrainUnit) - populate(objectMap, "value", r.Value) - populate(objectMap, "valueUnit", r.ValueUnit) + populate(objectMap, "destinationInvoiceSectionId", m.DestinationInvoiceSectionID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationUtilizationAggregates. -func (r *ReservationUtilizationAggregates) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type MoveProductRequest. +func (m *MoveProductRequest) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { - case "grain": - err = unpopulate(val, "Grain", &r.Grain) - delete(rawMsg, key) - case "grainUnit": - err = unpopulate(val, "GrainUnit", &r.GrainUnit) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &r.Value) + case "destinationInvoiceSectionId": + err = unpopulate(val, "DestinationInvoiceSectionID", &m.DestinationInvoiceSectionID) delete(rawMsg, key) - case "valueUnit": - err = unpopulate(val, "ValueUnit", &r.ValueUnit) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NextBillingCycleDetails. +func (n NextBillingCycleDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "billingFrequency", n.BillingFrequency) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NextBillingCycleDetails. +func (n *NextBillingCycleDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "billingFrequency": + err = unpopulate(val, "BillingFrequency", &n.BillingFrequency) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", n, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ReservationsListResult. -func (r ReservationsListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", r.NextLink) - populate(objectMap, "summary", r.Summary) - populate(objectMap, "value", r.Value) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationsListResult. -func (r *ReservationsListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", o, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &r.NextLink) + case "display": + err = unpopulate(val, "Display", &o.Display) delete(rawMsg, key) - case "summary": - err = unpopulate(val, "Summary", &r.Summary) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &r.Value) + case "name": + err = unpopulate(val, "Name", &o.Name) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", o, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Resource. -func (r Resource) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", r.ID) - populate(objectMap, "name", r.Name) - populate(objectMap, "type", r.Type) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. -func (r *Resource) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", o, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &r.ID) + case "description": + err = unpopulate(val, "Description", &o.Description) delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &r.Name) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &r.Type) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", o, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type RoleAssignment. -func (r RoleAssignment) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", r.ID) - populate(objectMap, "name", r.Name) - populate(objectMap, "properties", r.Properties) - populate(objectMap, "type", r.Type) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type RoleAssignment. -func (r *RoleAssignment) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Participant. +func (p Participant) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "email", p.Email) + populate(objectMap, "status", p.Status) + populateDateTimeRFC3339(objectMap, "statusDate", p.StatusDate) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Participant. +func (p *Participant) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "email": + err = unpopulate(val, "Email", &p.Email) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + case "statusDate": + err = unpopulateDateTimeRFC3339(val, "StatusDate", &p.StatusDate) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PartnerInitiateTransferProperties. +func (p PartnerInitiateTransferProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "recipientEmailId", p.RecipientEmailID) + populate(objectMap, "resellerId", p.ResellerID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PartnerInitiateTransferProperties. +func (p *PartnerInitiateTransferProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "recipientEmailId": + err = unpopulate(val, "RecipientEmailID", &p.RecipientEmailID) + delete(rawMsg, key) + case "resellerId": + err = unpopulate(val, "ResellerID", &p.ResellerID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PartnerInitiateTransferRequest. +func (p PartnerInitiateTransferRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PartnerInitiateTransferRequest. +func (p *PartnerInitiateTransferRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PartnerTransferDetails. +func (p PartnerTransferDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PartnerTransferDetails. +func (p *PartnerTransferDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PartnerTransferDetailsListResult. +func (p PartnerTransferDetailsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PartnerTransferDetailsListResult. +func (p *PartnerTransferDetailsListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PartnerTransferProperties. +func (p PartnerTransferProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "canceledBy", p.CanceledBy) + populate(objectMap, "detailedTransferStatus", p.DetailedTransferStatus) + populateDateTimeRFC3339(objectMap, "expirationTime", p.ExpirationTime) + populate(objectMap, "initiatorCustomerType", p.InitiatorCustomerType) + populate(objectMap, "initiatorEmailId", p.InitiatorEmailID) + populate(objectMap, "recipientEmailId", p.RecipientEmailID) + populate(objectMap, "resellerId", p.ResellerID) + populate(objectMap, "resellerName", p.ResellerName) + populate(objectMap, "transferStatus", p.TransferStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PartnerTransferProperties. +func (p *PartnerTransferProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "canceledBy": + err = unpopulate(val, "CanceledBy", &p.CanceledBy) + delete(rawMsg, key) + case "detailedTransferStatus": + err = unpopulate(val, "DetailedTransferStatus", &p.DetailedTransferStatus) + delete(rawMsg, key) + case "expirationTime": + err = unpopulateDateTimeRFC3339(val, "ExpirationTime", &p.ExpirationTime) + delete(rawMsg, key) + case "initiatorCustomerType": + err = unpopulate(val, "InitiatorCustomerType", &p.InitiatorCustomerType) + delete(rawMsg, key) + case "initiatorEmailId": + err = unpopulate(val, "InitiatorEmailID", &p.InitiatorEmailID) + delete(rawMsg, key) + case "recipientEmailId": + err = unpopulate(val, "RecipientEmailID", &p.RecipientEmailID) + delete(rawMsg, key) + case "resellerId": + err = unpopulate(val, "ResellerID", &p.ResellerID) + delete(rawMsg, key) + case "resellerName": + err = unpopulate(val, "ResellerName", &p.ResellerName) + delete(rawMsg, key) + case "transferStatus": + err = unpopulate(val, "TransferStatus", &p.TransferStatus) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Patch. +func (p Patch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "sku", p.SKU) + populate(objectMap, "tags", p.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Patch. +func (p *Patch) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &p.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PatchProperties. +func (p PatchProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "appliedScopeProperties", p.AppliedScopeProperties) + populate(objectMap, "appliedScopeType", p.AppliedScopeType) + populate(objectMap, "displayName", p.DisplayName) + populate(objectMap, "instanceFlexibility", p.InstanceFlexibility) + populate(objectMap, "renew", p.Renew) + populate(objectMap, "renewProperties", p.RenewProperties) + populateDateTimeRFC3339(objectMap, "reviewDateTime", p.ReviewDateTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PatchProperties. +func (p *PatchProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "appliedScopeProperties": + err = unpopulate(val, "AppliedScopeProperties", &p.AppliedScopeProperties) + delete(rawMsg, key) + case "appliedScopeType": + err = unpopulate(val, "AppliedScopeType", &p.AppliedScopeType) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &p.DisplayName) + delete(rawMsg, key) + case "instanceFlexibility": + err = unpopulate(val, "InstanceFlexibility", &p.InstanceFlexibility) + delete(rawMsg, key) + case "renew": + err = unpopulate(val, "Renew", &p.Renew) + delete(rawMsg, key) + case "renewProperties": + err = unpopulate(val, "RenewProperties", &p.RenewProperties) + delete(rawMsg, key) + case "reviewDateTime": + err = unpopulateDateTimeRFC3339(val, "ReviewDateTime", &p.ReviewDateTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PatchPropertiesRenewProperties. +func (p PatchPropertiesRenewProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "purchaseProperties", p.PurchaseProperties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PatchPropertiesRenewProperties. +func (p *PatchPropertiesRenewProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "purchaseProperties": + err = unpopulate(val, "PurchaseProperties", &p.PurchaseProperties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Payment. +func (p Payment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "amount", p.Amount) + populateDateTimeRFC3339(objectMap, "date", p.Date) + populate(objectMap, "paymentMethodFamily", p.PaymentMethodFamily) + populate(objectMap, "paymentMethodId", p.PaymentMethodID) + populate(objectMap, "paymentMethodType", p.PaymentMethodType) + populate(objectMap, "paymentType", p.PaymentType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Payment. +func (p *Payment) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "amount": + err = unpopulate(val, "Amount", &p.Amount) + delete(rawMsg, key) + case "date": + err = unpopulateDateTimeRFC3339(val, "Date", &p.Date) + delete(rawMsg, key) + case "paymentMethodFamily": + err = unpopulate(val, "PaymentMethodFamily", &p.PaymentMethodFamily) + delete(rawMsg, key) + case "paymentMethodId": + err = unpopulate(val, "PaymentMethodID", &p.PaymentMethodID) + delete(rawMsg, key) + case "paymentMethodType": + err = unpopulate(val, "PaymentMethodType", &p.PaymentMethodType) + delete(rawMsg, key) + case "paymentType": + err = unpopulate(val, "PaymentType", &p.PaymentType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PaymentAmount. +func (p PaymentAmount) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "currency", p.Currency) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PaymentAmount. +func (p *PaymentAmount) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "currency": + err = unpopulate(val, "Currency", &p.Currency) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PaymentDetail. +func (p PaymentDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "billingCurrencyTotal", p.BillingCurrencyTotal) + populateDateType(objectMap, "dueDate", p.DueDate) + populate(objectMap, "extendedStatusInfo", p.ExtendedStatusInfo) + populateDateType(objectMap, "paymentDate", p.PaymentDate) + populate(objectMap, "pricingCurrencyTotal", p.PricingCurrencyTotal) + populate(objectMap, "status", p.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PaymentDetail. +func (p *PaymentDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "billingCurrencyTotal": + err = unpopulate(val, "BillingCurrencyTotal", &p.BillingCurrencyTotal) + delete(rawMsg, key) + case "dueDate": + err = unpopulateDateType(val, "DueDate", &p.DueDate) + delete(rawMsg, key) + case "extendedStatusInfo": + err = unpopulate(val, "ExtendedStatusInfo", &p.ExtendedStatusInfo) + delete(rawMsg, key) + case "paymentDate": + err = unpopulateDateType(val, "PaymentDate", &p.PaymentDate) + delete(rawMsg, key) + case "pricingCurrencyTotal": + err = unpopulate(val, "PricingCurrencyTotal", &p.PricingCurrencyTotal) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PaymentMethod. +func (p PaymentMethod) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PaymentMethod. +func (p *PaymentMethod) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PaymentMethodLink. +func (p PaymentMethodLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PaymentMethodLink. +func (p *PaymentMethodLink) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PaymentMethodLinkProperties. +func (p PaymentMethodLinkProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountHolderName", p.AccountHolderName) + populate(objectMap, "displayName", p.DisplayName) + populate(objectMap, "expiration", p.Expiration) + populate(objectMap, "family", p.Family) + populate(objectMap, "lastFourDigits", p.LastFourDigits) + populate(objectMap, "logos", p.Logos) + populate(objectMap, "paymentMethod", p.PaymentMethod) + populate(objectMap, "paymentMethodId", p.PaymentMethodID) + populate(objectMap, "paymentMethodType", p.PaymentMethodType) + populate(objectMap, "status", p.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PaymentMethodLinkProperties. +func (p *PaymentMethodLinkProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accountHolderName": + err = unpopulate(val, "AccountHolderName", &p.AccountHolderName) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &p.DisplayName) + delete(rawMsg, key) + case "expiration": + err = unpopulate(val, "Expiration", &p.Expiration) + delete(rawMsg, key) + case "family": + err = unpopulate(val, "Family", &p.Family) + delete(rawMsg, key) + case "lastFourDigits": + err = unpopulate(val, "LastFourDigits", &p.LastFourDigits) + delete(rawMsg, key) + case "logos": + err = unpopulate(val, "Logos", &p.Logos) + delete(rawMsg, key) + case "paymentMethod": + err = unpopulate(val, "PaymentMethod", &p.PaymentMethod) + delete(rawMsg, key) + case "paymentMethodId": + err = unpopulate(val, "PaymentMethodID", &p.PaymentMethodID) + delete(rawMsg, key) + case "paymentMethodType": + err = unpopulate(val, "PaymentMethodType", &p.PaymentMethodType) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PaymentMethodLinksListResult. +func (p PaymentMethodLinksListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PaymentMethodLinksListResult. +func (p *PaymentMethodLinksListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PaymentMethodLogo. +func (p PaymentMethodLogo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "mimeType", p.MimeType) + populate(objectMap, "url", p.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PaymentMethodLogo. +func (p *PaymentMethodLogo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "mimeType": + err = unpopulate(val, "MimeType", &p.MimeType) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &p.URL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PaymentMethodProperties. +func (p PaymentMethodProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountHolderName", p.AccountHolderName) + populate(objectMap, "displayName", p.DisplayName) + populate(objectMap, "expiration", p.Expiration) + populate(objectMap, "family", p.Family) + populate(objectMap, "id", p.ID) + populate(objectMap, "lastFourDigits", p.LastFourDigits) + populate(objectMap, "logos", p.Logos) + populate(objectMap, "paymentMethodType", p.PaymentMethodType) + populate(objectMap, "status", p.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PaymentMethodProperties. +func (p *PaymentMethodProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accountHolderName": + err = unpopulate(val, "AccountHolderName", &p.AccountHolderName) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &p.DisplayName) + delete(rawMsg, key) + case "expiration": + err = unpopulate(val, "Expiration", &p.Expiration) + delete(rawMsg, key) + case "family": + err = unpopulate(val, "Family", &p.Family) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "lastFourDigits": + err = unpopulate(val, "LastFourDigits", &p.LastFourDigits) + delete(rawMsg, key) + case "logos": + err = unpopulate(val, "Logos", &p.Logos) + delete(rawMsg, key) + case "paymentMethodType": + err = unpopulate(val, "PaymentMethodType", &p.PaymentMethodType) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PaymentMethodsListResult. +func (p PaymentMethodsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PaymentMethodsListResult. +func (p *PaymentMethodsListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PaymentOnAccount. +func (p PaymentOnAccount) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "amount", p.Amount) + populate(objectMap, "billingProfileDisplayName", p.BillingProfileDisplayName) + populate(objectMap, "billingProfileId", p.BillingProfileID) + populateDateTimeRFC3339(objectMap, "date", p.Date) + populate(objectMap, "invoiceId", p.InvoiceID) + populate(objectMap, "invoiceName", p.InvoiceName) + populate(objectMap, "paymentMethodType", p.PaymentMethodType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PaymentOnAccount. +func (p *PaymentOnAccount) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "amount": + err = unpopulate(val, "Amount", &p.Amount) + delete(rawMsg, key) + case "billingProfileDisplayName": + err = unpopulate(val, "BillingProfileDisplayName", &p.BillingProfileDisplayName) + delete(rawMsg, key) + case "billingProfileId": + err = unpopulate(val, "BillingProfileID", &p.BillingProfileID) + delete(rawMsg, key) + case "date": + err = unpopulateDateTimeRFC3339(val, "Date", &p.Date) + delete(rawMsg, key) + case "invoiceId": + err = unpopulate(val, "InvoiceID", &p.InvoiceID) + delete(rawMsg, key) + case "invoiceName": + err = unpopulate(val, "InvoiceName", &p.InvoiceName) + delete(rawMsg, key) + case "paymentMethodType": + err = unpopulate(val, "PaymentMethodType", &p.PaymentMethodType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PaymentOnAccountAmount. +func (p PaymentOnAccountAmount) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "currency", p.Currency) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PaymentOnAccountAmount. +func (p *PaymentOnAccountAmount) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "currency": + err = unpopulate(val, "Currency", &p.Currency) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PaymentTerm. +func (p PaymentTerm) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "endDate", p.EndDate) + populate(objectMap, "isDefault", p.IsDefault) + populateDateTimeRFC3339(objectMap, "startDate", p.StartDate) + populate(objectMap, "term", p.Term) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PaymentTerm. +func (p *PaymentTerm) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "endDate": + err = unpopulateDateTimeRFC3339(val, "EndDate", &p.EndDate) + delete(rawMsg, key) + case "isDefault": + err = unpopulate(val, "IsDefault", &p.IsDefault) + delete(rawMsg, key) + case "startDate": + err = unpopulateDateTimeRFC3339(val, "StartDate", &p.StartDate) + delete(rawMsg, key) + case "term": + err = unpopulate(val, "Term", &p.Term) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PaymentTermsEligibilityDetail. +func (p PaymentTermsEligibilityDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", p.Code) + populate(objectMap, "message", p.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PaymentTermsEligibilityDetail. +func (p *PaymentTermsEligibilityDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &p.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &p.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PaymentTermsEligibilityResult. +func (p PaymentTermsEligibilityResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eligibilityDetails", p.EligibilityDetails) + populate(objectMap, "eligibilityStatus", p.EligibilityStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PaymentTermsEligibilityResult. +func (p *PaymentTermsEligibilityResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "eligibilityDetails": + err = unpopulate(val, "EligibilityDetails", &p.EligibilityDetails) + delete(rawMsg, key) + case "eligibilityStatus": + err = unpopulate(val, "EligibilityStatus", &p.EligibilityStatus) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Permission. +func (p Permission) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actions", p.Actions) + populate(objectMap, "notActions", p.NotActions) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Permission. +func (p *Permission) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actions": + err = unpopulate(val, "Actions", &p.Actions) + delete(rawMsg, key) + case "notActions": + err = unpopulate(val, "NotActions", &p.NotActions) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PermissionListResult. +func (p PermissionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PermissionListResult. +func (p *PermissionListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PlanInformation. +func (p PlanInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateType(objectMap, "nextPaymentDueDate", p.NextPaymentDueDate) + populate(objectMap, "pricingCurrencyTotal", p.PricingCurrencyTotal) + populateDateType(objectMap, "startDate", p.StartDate) + populate(objectMap, "transactions", p.Transactions) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PlanInformation. +func (p *PlanInformation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextPaymentDueDate": + err = unpopulateDateType(val, "NextPaymentDueDate", &p.NextPaymentDueDate) + delete(rawMsg, key) + case "pricingCurrencyTotal": + err = unpopulate(val, "PricingCurrencyTotal", &p.PricingCurrencyTotal) + delete(rawMsg, key) + case "startDate": + err = unpopulateDateType(val, "StartDate", &p.StartDate) + delete(rawMsg, key) + case "transactions": + err = unpopulate(val, "Transactions", &p.Transactions) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PolicySummary. +func (p PolicySummary) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", p.Name) + populate(objectMap, "policyType", p.PolicyType) + populate(objectMap, "scope", p.Scope) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicySummary. +func (p *PolicySummary) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "policyType": + err = unpopulate(val, "PolicyType", &p.PolicyType) + delete(rawMsg, key) + case "scope": + err = unpopulate(val, "Scope", &p.Scope) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Price. +func (p Price) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "amount", p.Amount) + populate(objectMap, "currencyCode", p.CurrencyCode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Price. +func (p *Price) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "amount": + err = unpopulate(val, "Amount", &p.Amount) + delete(rawMsg, key) + case "currencyCode": + err = unpopulate(val, "CurrencyCode", &p.CurrencyCode) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Principal. +func (p Principal) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "objectId", p.ObjectID) + populate(objectMap, "tenantId", p.TenantID) + populate(objectMap, "upn", p.Upn) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Principal. +func (p *Principal) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "objectId": + err = unpopulate(val, "ObjectID", &p.ObjectID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &p.TenantID) + delete(rawMsg, key) + case "upn": + err = unpopulate(val, "Upn", &p.Upn) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Product. +func (p Product) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Product. +func (p *Product) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProductDetails. +func (p ProductDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "productId", p.ProductID) + populate(objectMap, "productType", p.ProductType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductDetails. +func (p *ProductDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "productId": + err = unpopulate(val, "ProductID", &p.ProductID) + delete(rawMsg, key) + case "productType": + err = unpopulate(val, "ProductType", &p.ProductType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProductListResult. +func (p ProductListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductListResult. +func (p *ProductListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProductPatch. +func (p ProductPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductPatch. +func (p *ProductPatch) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProductProperties. +func (p ProductProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "autoRenew", p.AutoRenew) + populate(objectMap, "availabilityId", p.AvailabilityID) + populate(objectMap, "billingFrequency", p.BillingFrequency) + populate(objectMap, "billingProfileDisplayName", p.BillingProfileDisplayName) + populate(objectMap, "billingProfileId", p.BillingProfileID) + populate(objectMap, "customerDisplayName", p.CustomerDisplayName) + populate(objectMap, "customerId", p.CustomerID) + populate(objectMap, "displayName", p.DisplayName) + populate(objectMap, "endDate", p.EndDate) + populate(objectMap, "invoiceSectionDisplayName", p.InvoiceSectionDisplayName) + populate(objectMap, "invoiceSectionId", p.InvoiceSectionID) + populate(objectMap, "lastCharge", p.LastCharge) + populate(objectMap, "lastChargeDate", p.LastChargeDate) + populate(objectMap, "productType", p.ProductType) + populate(objectMap, "productTypeId", p.ProductTypeID) + populate(objectMap, "purchaseDate", p.PurchaseDate) + populate(objectMap, "quantity", p.Quantity) + populate(objectMap, "reseller", p.Reseller) + populate(objectMap, "skuDescription", p.SKUDescription) + populate(objectMap, "skuId", p.SKUID) + populate(objectMap, "status", p.Status) + populate(objectMap, "tenantId", p.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductProperties. +func (p *ProductProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "autoRenew": + err = unpopulate(val, "AutoRenew", &p.AutoRenew) + delete(rawMsg, key) + case "availabilityId": + err = unpopulate(val, "AvailabilityID", &p.AvailabilityID) + delete(rawMsg, key) + case "billingFrequency": + err = unpopulate(val, "BillingFrequency", &p.BillingFrequency) + delete(rawMsg, key) + case "billingProfileDisplayName": + err = unpopulate(val, "BillingProfileDisplayName", &p.BillingProfileDisplayName) + delete(rawMsg, key) + case "billingProfileId": + err = unpopulate(val, "BillingProfileID", &p.BillingProfileID) + delete(rawMsg, key) + case "customerDisplayName": + err = unpopulate(val, "CustomerDisplayName", &p.CustomerDisplayName) + delete(rawMsg, key) + case "customerId": + err = unpopulate(val, "CustomerID", &p.CustomerID) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &p.DisplayName) + delete(rawMsg, key) + case "endDate": + err = unpopulate(val, "EndDate", &p.EndDate) + delete(rawMsg, key) + case "invoiceSectionDisplayName": + err = unpopulate(val, "InvoiceSectionDisplayName", &p.InvoiceSectionDisplayName) + delete(rawMsg, key) + case "invoiceSectionId": + err = unpopulate(val, "InvoiceSectionID", &p.InvoiceSectionID) + delete(rawMsg, key) + case "lastCharge": + err = unpopulate(val, "LastCharge", &p.LastCharge) + delete(rawMsg, key) + case "lastChargeDate": + err = unpopulate(val, "LastChargeDate", &p.LastChargeDate) + delete(rawMsg, key) + case "productType": + err = unpopulate(val, "ProductType", &p.ProductType) + delete(rawMsg, key) + case "productTypeId": + err = unpopulate(val, "ProductTypeID", &p.ProductTypeID) + delete(rawMsg, key) + case "purchaseDate": + err = unpopulate(val, "PurchaseDate", &p.PurchaseDate) + delete(rawMsg, key) + case "quantity": + err = unpopulate(val, "Quantity", &p.Quantity) + delete(rawMsg, key) + case "reseller": + err = unpopulate(val, "Reseller", &p.Reseller) + delete(rawMsg, key) + case "skuDescription": + err = unpopulate(val, "SKUDescription", &p.SKUDescription) + delete(rawMsg, key) + case "skuId": + err = unpopulate(val, "SKUID", &p.SKUID) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &p.TenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProductPropertiesLastCharge. +func (p ProductPropertiesLastCharge) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "currency", p.Currency) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductPropertiesLastCharge. +func (p *ProductPropertiesLastCharge) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "currency": + err = unpopulate(val, "Currency", &p.Currency) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProductPropertiesReseller. +func (p ProductPropertiesReseller) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", p.Description) + populate(objectMap, "resellerId", p.ResellerID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductPropertiesReseller. +func (p *ProductPropertiesReseller) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "resellerId": + err = unpopulate(val, "ResellerID", &p.ResellerID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Profile. +func (p Profile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Profile. +func (p *Profile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProfileInfo. +func (p ProfileInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "billingAccountId", p.BillingAccountID) + populate(objectMap, "billingProfileDisplayName", p.BillingProfileDisplayName) + populate(objectMap, "billingProfileId", p.BillingProfileID) + populate(objectMap, "billingProfileSystemId", p.BillingProfileSystemID) + populate(objectMap, "indirectRelationshipOrganizationName", p.IndirectRelationshipOrganizationName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProfileInfo. +func (p *ProfileInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "billingAccountId": + err = unpopulate(val, "BillingAccountID", &p.BillingAccountID) + delete(rawMsg, key) + case "billingProfileDisplayName": + err = unpopulate(val, "BillingProfileDisplayName", &p.BillingProfileDisplayName) + delete(rawMsg, key) + case "billingProfileId": + err = unpopulate(val, "BillingProfileID", &p.BillingProfileID) + delete(rawMsg, key) + case "billingProfileSystemId": + err = unpopulate(val, "BillingProfileSystemID", &p.BillingProfileSystemID) + delete(rawMsg, key) + case "indirectRelationshipOrganizationName": + err = unpopulate(val, "IndirectRelationshipOrganizationName", &p.IndirectRelationshipOrganizationName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProfileListResult. +func (p ProfileListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProfileListResult. +func (p *ProfileListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProfilePolicy. +func (p ProfilePolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProfilePolicy. +func (p *ProfilePolicy) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProfilePolicyProperties. +func (p ProfilePolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "enterpriseAgreementPolicies", p.EnterpriseAgreementPolicies) + populate(objectMap, "invoiceSectionLabelManagement", p.InvoiceSectionLabelManagement) + populate(objectMap, "marketplacePurchases", p.MarketplacePurchases) + populate(objectMap, "policies", p.Policies) + populate(objectMap, "provisioningState", p.ProvisioningState) + populate(objectMap, "reservationPurchases", p.ReservationPurchases) + populate(objectMap, "savingsPlanPurchases", p.SavingsPlanPurchases) + populate(objectMap, "viewCharges", p.ViewCharges) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProfilePolicyProperties. +func (p *ProfilePolicyProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "enterpriseAgreementPolicies": + err = unpopulate(val, "EnterpriseAgreementPolicies", &p.EnterpriseAgreementPolicies) + delete(rawMsg, key) + case "invoiceSectionLabelManagement": + err = unpopulate(val, "InvoiceSectionLabelManagement", &p.InvoiceSectionLabelManagement) + delete(rawMsg, key) + case "marketplacePurchases": + err = unpopulate(val, "MarketplacePurchases", &p.MarketplacePurchases) + delete(rawMsg, key) + case "policies": + err = unpopulate(val, "Policies", &p.Policies) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) + case "reservationPurchases": + err = unpopulate(val, "ReservationPurchases", &p.ReservationPurchases) + delete(rawMsg, key) + case "savingsPlanPurchases": + err = unpopulate(val, "SavingsPlanPurchases", &p.SavingsPlanPurchases) + delete(rawMsg, key) + case "viewCharges": + err = unpopulate(val, "ViewCharges", &p.ViewCharges) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProfilePolicyPropertiesEnterpriseAgreementPolicies. +func (p ProfilePolicyPropertiesEnterpriseAgreementPolicies) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountOwnerViewCharges", p.AccountOwnerViewCharges) + populate(objectMap, "authenticationType", p.AuthenticationType) + populate(objectMap, "departmentAdminViewCharges", p.DepartmentAdminViewCharges) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProfilePolicyPropertiesEnterpriseAgreementPolicies. +func (p *ProfilePolicyPropertiesEnterpriseAgreementPolicies) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accountOwnerViewCharges": + err = unpopulate(val, "AccountOwnerViewCharges", &p.AccountOwnerViewCharges) + delete(rawMsg, key) + case "authenticationType": + err = unpopulate(val, "AuthenticationType", &p.AuthenticationType) + delete(rawMsg, key) + case "departmentAdminViewCharges": + err = unpopulate(val, "DepartmentAdminViewCharges", &p.DepartmentAdminViewCharges) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProfileProperties. +func (p ProfileProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "billTo", p.BillTo) + populate(objectMap, "billingRelationshipType", p.BillingRelationshipType) + populate(objectMap, "currency", p.Currency) + populate(objectMap, "currentPaymentTerm", p.CurrentPaymentTerm) + populate(objectMap, "displayName", p.DisplayName) + populate(objectMap, "enabledAzurePlans", p.EnabledAzurePlans) + populate(objectMap, "hasReadAccess", p.HasReadAccess) + populate(objectMap, "indirectRelationshipInfo", p.IndirectRelationshipInfo) + populate(objectMap, "invoiceDay", p.InvoiceDay) + populate(objectMap, "invoiceEmailOptIn", p.InvoiceEmailOptIn) + populate(objectMap, "invoiceRecipients", p.InvoiceRecipients) + populate(objectMap, "otherPaymentTerms", p.OtherPaymentTerms) + populate(objectMap, "poNumber", p.PoNumber) + populate(objectMap, "provisioningState", p.ProvisioningState) + populate(objectMap, "shipTo", p.ShipTo) + populate(objectMap, "soldTo", p.SoldTo) + populate(objectMap, "spendingLimit", p.SpendingLimit) + populate(objectMap, "spendingLimitDetails", p.SpendingLimitDetails) + populate(objectMap, "status", p.Status) + populate(objectMap, "statusReasonCode", p.StatusReasonCode) + populate(objectMap, "systemId", p.SystemID) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "targetClouds", p.TargetClouds) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProfileProperties. +func (p *ProfileProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "billTo": + err = unpopulate(val, "BillTo", &p.BillTo) + delete(rawMsg, key) + case "billingRelationshipType": + err = unpopulate(val, "BillingRelationshipType", &p.BillingRelationshipType) + delete(rawMsg, key) + case "currency": + err = unpopulate(val, "Currency", &p.Currency) + delete(rawMsg, key) + case "currentPaymentTerm": + err = unpopulate(val, "CurrentPaymentTerm", &p.CurrentPaymentTerm) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &p.DisplayName) + delete(rawMsg, key) + case "enabledAzurePlans": + err = unpopulate(val, "EnabledAzurePlans", &p.EnabledAzurePlans) + delete(rawMsg, key) + case "hasReadAccess": + err = unpopulate(val, "HasReadAccess", &p.HasReadAccess) + delete(rawMsg, key) + case "indirectRelationshipInfo": + err = unpopulate(val, "IndirectRelationshipInfo", &p.IndirectRelationshipInfo) + delete(rawMsg, key) + case "invoiceDay": + err = unpopulate(val, "InvoiceDay", &p.InvoiceDay) + delete(rawMsg, key) + case "invoiceEmailOptIn": + err = unpopulate(val, "InvoiceEmailOptIn", &p.InvoiceEmailOptIn) + delete(rawMsg, key) + case "invoiceRecipients": + err = unpopulate(val, "InvoiceRecipients", &p.InvoiceRecipients) + delete(rawMsg, key) + case "otherPaymentTerms": + err = unpopulate(val, "OtherPaymentTerms", &p.OtherPaymentTerms) + delete(rawMsg, key) + case "poNumber": + err = unpopulate(val, "PoNumber", &p.PoNumber) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) + case "shipTo": + err = unpopulate(val, "ShipTo", &p.ShipTo) + delete(rawMsg, key) + case "soldTo": + err = unpopulate(val, "SoldTo", &p.SoldTo) + delete(rawMsg, key) + case "spendingLimit": + err = unpopulate(val, "SpendingLimit", &p.SpendingLimit) + delete(rawMsg, key) + case "spendingLimitDetails": + err = unpopulate(val, "SpendingLimitDetails", &p.SpendingLimitDetails) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + case "statusReasonCode": + err = unpopulate(val, "StatusReasonCode", &p.StatusReasonCode) + delete(rawMsg, key) + case "systemId": + err = unpopulate(val, "SystemID", &p.SystemID) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + case "targetClouds": + err = unpopulate(val, "TargetClouds", &p.TargetClouds) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProfilePropertiesBillTo. +func (p ProfilePropertiesBillTo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "addressLine1", p.AddressLine1) + populate(objectMap, "addressLine2", p.AddressLine2) + populate(objectMap, "addressLine3", p.AddressLine3) + populate(objectMap, "city", p.City) + populate(objectMap, "companyName", p.CompanyName) + populate(objectMap, "country", p.Country) + populate(objectMap, "district", p.District) + populate(objectMap, "email", p.Email) + populate(objectMap, "firstName", p.FirstName) + populate(objectMap, "isValidAddress", p.IsValidAddress) + populate(objectMap, "lastName", p.LastName) + populate(objectMap, "middleName", p.MiddleName) + populate(objectMap, "phoneNumber", p.PhoneNumber) + populate(objectMap, "postalCode", p.PostalCode) + populate(objectMap, "region", p.Region) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProfilePropertiesBillTo. +func (p *ProfilePropertiesBillTo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "addressLine1": + err = unpopulate(val, "AddressLine1", &p.AddressLine1) + delete(rawMsg, key) + case "addressLine2": + err = unpopulate(val, "AddressLine2", &p.AddressLine2) + delete(rawMsg, key) + case "addressLine3": + err = unpopulate(val, "AddressLine3", &p.AddressLine3) + delete(rawMsg, key) + case "city": + err = unpopulate(val, "City", &p.City) + delete(rawMsg, key) + case "companyName": + err = unpopulate(val, "CompanyName", &p.CompanyName) + delete(rawMsg, key) + case "country": + err = unpopulate(val, "Country", &p.Country) + delete(rawMsg, key) + case "district": + err = unpopulate(val, "District", &p.District) + delete(rawMsg, key) + case "email": + err = unpopulate(val, "Email", &p.Email) + delete(rawMsg, key) + case "firstName": + err = unpopulate(val, "FirstName", &p.FirstName) + delete(rawMsg, key) + case "isValidAddress": + err = unpopulate(val, "IsValidAddress", &p.IsValidAddress) + delete(rawMsg, key) + case "lastName": + err = unpopulate(val, "LastName", &p.LastName) + delete(rawMsg, key) + case "middleName": + err = unpopulate(val, "MiddleName", &p.MiddleName) + delete(rawMsg, key) + case "phoneNumber": + err = unpopulate(val, "PhoneNumber", &p.PhoneNumber) + delete(rawMsg, key) + case "postalCode": + err = unpopulate(val, "PostalCode", &p.PostalCode) + delete(rawMsg, key) + case "region": + err = unpopulate(val, "Region", &p.Region) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProfilePropertiesCurrentPaymentTerm. +func (p ProfilePropertiesCurrentPaymentTerm) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "endDate", p.EndDate) + populate(objectMap, "isDefault", p.IsDefault) + populateDateTimeRFC3339(objectMap, "startDate", p.StartDate) + populate(objectMap, "term", p.Term) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProfilePropertiesCurrentPaymentTerm. +func (p *ProfilePropertiesCurrentPaymentTerm) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "endDate": + err = unpopulateDateTimeRFC3339(val, "EndDate", &p.EndDate) + delete(rawMsg, key) + case "isDefault": + err = unpopulate(val, "IsDefault", &p.IsDefault) + delete(rawMsg, key) + case "startDate": + err = unpopulateDateTimeRFC3339(val, "StartDate", &p.StartDate) + delete(rawMsg, key) + case "term": + err = unpopulate(val, "Term", &p.Term) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProfilePropertiesIndirectRelationshipInfo. +func (p ProfilePropertiesIndirectRelationshipInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "billingAccountName", p.BillingAccountName) + populate(objectMap, "billingProfileName", p.BillingProfileName) + populate(objectMap, "displayName", p.DisplayName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProfilePropertiesIndirectRelationshipInfo. +func (p *ProfilePropertiesIndirectRelationshipInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "billingAccountName": + err = unpopulate(val, "BillingAccountName", &p.BillingAccountName) + delete(rawMsg, key) + case "billingProfileName": + err = unpopulate(val, "BillingProfileName", &p.BillingProfileName) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &p.DisplayName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProfilePropertiesShipTo. +func (p ProfilePropertiesShipTo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "addressLine1", p.AddressLine1) + populate(objectMap, "addressLine2", p.AddressLine2) + populate(objectMap, "addressLine3", p.AddressLine3) + populate(objectMap, "city", p.City) + populate(objectMap, "companyName", p.CompanyName) + populate(objectMap, "country", p.Country) + populate(objectMap, "district", p.District) + populate(objectMap, "email", p.Email) + populate(objectMap, "firstName", p.FirstName) + populate(objectMap, "isValidAddress", p.IsValidAddress) + populate(objectMap, "lastName", p.LastName) + populate(objectMap, "middleName", p.MiddleName) + populate(objectMap, "phoneNumber", p.PhoneNumber) + populate(objectMap, "postalCode", p.PostalCode) + populate(objectMap, "region", p.Region) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProfilePropertiesShipTo. +func (p *ProfilePropertiesShipTo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "addressLine1": + err = unpopulate(val, "AddressLine1", &p.AddressLine1) + delete(rawMsg, key) + case "addressLine2": + err = unpopulate(val, "AddressLine2", &p.AddressLine2) + delete(rawMsg, key) + case "addressLine3": + err = unpopulate(val, "AddressLine3", &p.AddressLine3) + delete(rawMsg, key) + case "city": + err = unpopulate(val, "City", &p.City) + delete(rawMsg, key) + case "companyName": + err = unpopulate(val, "CompanyName", &p.CompanyName) + delete(rawMsg, key) + case "country": + err = unpopulate(val, "Country", &p.Country) + delete(rawMsg, key) + case "district": + err = unpopulate(val, "District", &p.District) + delete(rawMsg, key) + case "email": + err = unpopulate(val, "Email", &p.Email) + delete(rawMsg, key) + case "firstName": + err = unpopulate(val, "FirstName", &p.FirstName) + delete(rawMsg, key) + case "isValidAddress": + err = unpopulate(val, "IsValidAddress", &p.IsValidAddress) + delete(rawMsg, key) + case "lastName": + err = unpopulate(val, "LastName", &p.LastName) + delete(rawMsg, key) + case "middleName": + err = unpopulate(val, "MiddleName", &p.MiddleName) + delete(rawMsg, key) + case "phoneNumber": + err = unpopulate(val, "PhoneNumber", &p.PhoneNumber) + delete(rawMsg, key) + case "postalCode": + err = unpopulate(val, "PostalCode", &p.PostalCode) + delete(rawMsg, key) + case "region": + err = unpopulate(val, "Region", &p.Region) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProfilePropertiesSoldTo. +func (p ProfilePropertiesSoldTo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "addressLine1", p.AddressLine1) + populate(objectMap, "addressLine2", p.AddressLine2) + populate(objectMap, "addressLine3", p.AddressLine3) + populate(objectMap, "city", p.City) + populate(objectMap, "companyName", p.CompanyName) + populate(objectMap, "country", p.Country) + populate(objectMap, "district", p.District) + populate(objectMap, "email", p.Email) + populate(objectMap, "firstName", p.FirstName) + populate(objectMap, "isValidAddress", p.IsValidAddress) + populate(objectMap, "lastName", p.LastName) + populate(objectMap, "middleName", p.MiddleName) + populate(objectMap, "phoneNumber", p.PhoneNumber) + populate(objectMap, "postalCode", p.PostalCode) + populate(objectMap, "region", p.Region) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProfilePropertiesSoldTo. +func (p *ProfilePropertiesSoldTo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "addressLine1": + err = unpopulate(val, "AddressLine1", &p.AddressLine1) + delete(rawMsg, key) + case "addressLine2": + err = unpopulate(val, "AddressLine2", &p.AddressLine2) + delete(rawMsg, key) + case "addressLine3": + err = unpopulate(val, "AddressLine3", &p.AddressLine3) + delete(rawMsg, key) + case "city": + err = unpopulate(val, "City", &p.City) + delete(rawMsg, key) + case "companyName": + err = unpopulate(val, "CompanyName", &p.CompanyName) + delete(rawMsg, key) + case "country": + err = unpopulate(val, "Country", &p.Country) + delete(rawMsg, key) + case "district": + err = unpopulate(val, "District", &p.District) + delete(rawMsg, key) + case "email": + err = unpopulate(val, "Email", &p.Email) + delete(rawMsg, key) + case "firstName": + err = unpopulate(val, "FirstName", &p.FirstName) + delete(rawMsg, key) + case "isValidAddress": + err = unpopulate(val, "IsValidAddress", &p.IsValidAddress) + delete(rawMsg, key) + case "lastName": + err = unpopulate(val, "LastName", &p.LastName) + delete(rawMsg, key) + case "middleName": + err = unpopulate(val, "MiddleName", &p.MiddleName) + delete(rawMsg, key) + case "phoneNumber": + err = unpopulate(val, "PhoneNumber", &p.PhoneNumber) + delete(rawMsg, key) + case "postalCode": + err = unpopulate(val, "PostalCode", &p.PostalCode) + delete(rawMsg, key) + case "region": + err = unpopulate(val, "Region", &p.Region) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Property. +func (p Property) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Property. +func (p *Property) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PropertyProperties. +func (p PropertyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountAdminNotificationEmailAddress", p.AccountAdminNotificationEmailAddress) + populate(objectMap, "billingAccountAgreementType", p.BillingAccountAgreementType) + populate(objectMap, "billingAccountDisplayName", p.BillingAccountDisplayName) + populate(objectMap, "billingAccountId", p.BillingAccountID) + populate(objectMap, "billingAccountSoldToCountry", p.BillingAccountSoldToCountry) + populate(objectMap, "billingAccountStatus", p.BillingAccountStatus) + populate(objectMap, "billingAccountStatusReasonCode", p.BillingAccountStatusReasonCode) + populate(objectMap, "billingAccountSubType", p.BillingAccountSubType) + populate(objectMap, "billingAccountType", p.BillingAccountType) + populate(objectMap, "billingCurrency", p.BillingCurrency) + populate(objectMap, "billingProfileDisplayName", p.BillingProfileDisplayName) + populate(objectMap, "billingProfileId", p.BillingProfileID) + populate(objectMap, "billingProfilePaymentMethodFamily", p.BillingProfilePaymentMethodFamily) + populate(objectMap, "billingProfilePaymentMethodType", p.BillingProfilePaymentMethodType) + populate(objectMap, "billingProfileSpendingLimit", p.BillingProfileSpendingLimit) + populate(objectMap, "billingProfileSpendingLimitDetails", p.BillingProfileSpendingLimitDetails) + populate(objectMap, "billingProfileStatus", p.BillingProfileStatus) + populate(objectMap, "billingProfileStatusReasonCode", p.BillingProfileStatusReasonCode) + populate(objectMap, "billingTenantId", p.BillingTenantID) + populate(objectMap, "costCenter", p.CostCenter) + populate(objectMap, "customerDisplayName", p.CustomerDisplayName) + populate(objectMap, "customerId", p.CustomerID) + populate(objectMap, "customerStatus", p.CustomerStatus) + populate(objectMap, "enrollmentDetails", p.EnrollmentDetails) + populate(objectMap, "invoiceSectionDisplayName", p.InvoiceSectionDisplayName) + populate(objectMap, "invoiceSectionId", p.InvoiceSectionID) + populate(objectMap, "invoiceSectionStatus", p.InvoiceSectionStatus) + populate(objectMap, "invoiceSectionStatusReasonCode", p.InvoiceSectionStatusReasonCode) + populate(objectMap, "isAccountAdmin", p.IsAccountAdmin) + populate(objectMap, "isTransitionedBillingAccount", p.IsTransitionedBillingAccount) + populate(objectMap, "productId", p.ProductID) + populate(objectMap, "productName", p.ProductName) + populate(objectMap, "skuDescription", p.SKUDescription) + populate(objectMap, "skuId", p.SKUID) + populate(objectMap, "subscriptionBillingStatus", p.SubscriptionBillingStatus) + populate(objectMap, "subscriptionBillingStatusDetails", p.SubscriptionBillingStatusDetails) + populate(objectMap, "subscriptionBillingType", p.SubscriptionBillingType) + populate(objectMap, "subscriptionServiceUsageAddress", p.SubscriptionServiceUsageAddress) + populate(objectMap, "subscriptionWorkloadType", p.SubscriptionWorkloadType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PropertyProperties. +func (p *PropertyProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accountAdminNotificationEmailAddress": + err = unpopulate(val, "AccountAdminNotificationEmailAddress", &p.AccountAdminNotificationEmailAddress) + delete(rawMsg, key) + case "billingAccountAgreementType": + err = unpopulate(val, "BillingAccountAgreementType", &p.BillingAccountAgreementType) + delete(rawMsg, key) + case "billingAccountDisplayName": + err = unpopulate(val, "BillingAccountDisplayName", &p.BillingAccountDisplayName) + delete(rawMsg, key) + case "billingAccountId": + err = unpopulate(val, "BillingAccountID", &p.BillingAccountID) + delete(rawMsg, key) + case "billingAccountSoldToCountry": + err = unpopulate(val, "BillingAccountSoldToCountry", &p.BillingAccountSoldToCountry) + delete(rawMsg, key) + case "billingAccountStatus": + err = unpopulate(val, "BillingAccountStatus", &p.BillingAccountStatus) + delete(rawMsg, key) + case "billingAccountStatusReasonCode": + err = unpopulate(val, "BillingAccountStatusReasonCode", &p.BillingAccountStatusReasonCode) + delete(rawMsg, key) + case "billingAccountSubType": + err = unpopulate(val, "BillingAccountSubType", &p.BillingAccountSubType) + delete(rawMsg, key) + case "billingAccountType": + err = unpopulate(val, "BillingAccountType", &p.BillingAccountType) + delete(rawMsg, key) + case "billingCurrency": + err = unpopulate(val, "BillingCurrency", &p.BillingCurrency) + delete(rawMsg, key) + case "billingProfileDisplayName": + err = unpopulate(val, "BillingProfileDisplayName", &p.BillingProfileDisplayName) + delete(rawMsg, key) + case "billingProfileId": + err = unpopulate(val, "BillingProfileID", &p.BillingProfileID) + delete(rawMsg, key) + case "billingProfilePaymentMethodFamily": + err = unpopulate(val, "BillingProfilePaymentMethodFamily", &p.BillingProfilePaymentMethodFamily) + delete(rawMsg, key) + case "billingProfilePaymentMethodType": + err = unpopulate(val, "BillingProfilePaymentMethodType", &p.BillingProfilePaymentMethodType) + delete(rawMsg, key) + case "billingProfileSpendingLimit": + err = unpopulate(val, "BillingProfileSpendingLimit", &p.BillingProfileSpendingLimit) + delete(rawMsg, key) + case "billingProfileSpendingLimitDetails": + err = unpopulate(val, "BillingProfileSpendingLimitDetails", &p.BillingProfileSpendingLimitDetails) + delete(rawMsg, key) + case "billingProfileStatus": + err = unpopulate(val, "BillingProfileStatus", &p.BillingProfileStatus) + delete(rawMsg, key) + case "billingProfileStatusReasonCode": + err = unpopulate(val, "BillingProfileStatusReasonCode", &p.BillingProfileStatusReasonCode) + delete(rawMsg, key) + case "billingTenantId": + err = unpopulate(val, "BillingTenantID", &p.BillingTenantID) + delete(rawMsg, key) + case "costCenter": + err = unpopulate(val, "CostCenter", &p.CostCenter) + delete(rawMsg, key) + case "customerDisplayName": + err = unpopulate(val, "CustomerDisplayName", &p.CustomerDisplayName) + delete(rawMsg, key) + case "customerId": + err = unpopulate(val, "CustomerID", &p.CustomerID) + delete(rawMsg, key) + case "customerStatus": + err = unpopulate(val, "CustomerStatus", &p.CustomerStatus) + delete(rawMsg, key) + case "enrollmentDetails": + err = unpopulate(val, "EnrollmentDetails", &p.EnrollmentDetails) + delete(rawMsg, key) + case "invoiceSectionDisplayName": + err = unpopulate(val, "InvoiceSectionDisplayName", &p.InvoiceSectionDisplayName) + delete(rawMsg, key) + case "invoiceSectionId": + err = unpopulate(val, "InvoiceSectionID", &p.InvoiceSectionID) + delete(rawMsg, key) + case "invoiceSectionStatus": + err = unpopulate(val, "InvoiceSectionStatus", &p.InvoiceSectionStatus) + delete(rawMsg, key) + case "invoiceSectionStatusReasonCode": + err = unpopulate(val, "InvoiceSectionStatusReasonCode", &p.InvoiceSectionStatusReasonCode) + delete(rawMsg, key) + case "isAccountAdmin": + err = unpopulate(val, "IsAccountAdmin", &p.IsAccountAdmin) + delete(rawMsg, key) + case "isTransitionedBillingAccount": + err = unpopulate(val, "IsTransitionedBillingAccount", &p.IsTransitionedBillingAccount) + delete(rawMsg, key) + case "productId": + err = unpopulate(val, "ProductID", &p.ProductID) + delete(rawMsg, key) + case "productName": + err = unpopulate(val, "ProductName", &p.ProductName) + delete(rawMsg, key) + case "skuDescription": + err = unpopulate(val, "SKUDescription", &p.SKUDescription) + delete(rawMsg, key) + case "skuId": + err = unpopulate(val, "SKUID", &p.SKUID) + delete(rawMsg, key) + case "subscriptionBillingStatus": + err = unpopulate(val, "SubscriptionBillingStatus", &p.SubscriptionBillingStatus) + delete(rawMsg, key) + case "subscriptionBillingStatusDetails": + err = unpopulate(val, "SubscriptionBillingStatusDetails", &p.SubscriptionBillingStatusDetails) + delete(rawMsg, key) + case "subscriptionBillingType": + err = unpopulate(val, "SubscriptionBillingType", &p.SubscriptionBillingType) + delete(rawMsg, key) + case "subscriptionServiceUsageAddress": + err = unpopulate(val, "SubscriptionServiceUsageAddress", &p.SubscriptionServiceUsageAddress) + delete(rawMsg, key) + case "subscriptionWorkloadType": + err = unpopulate(val, "SubscriptionWorkloadType", &p.SubscriptionWorkloadType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PropertyPropertiesEnrollmentDetails. +func (p PropertyPropertiesEnrollmentDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "departmentDisplayName", p.DepartmentDisplayName) + populate(objectMap, "departmentId", p.DepartmentID) + populate(objectMap, "enrollmentAccountDisplayName", p.EnrollmentAccountDisplayName) + populate(objectMap, "enrollmentAccountId", p.EnrollmentAccountID) + populate(objectMap, "enrollmentAccountStatus", p.EnrollmentAccountStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PropertyPropertiesEnrollmentDetails. +func (p *PropertyPropertiesEnrollmentDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "departmentDisplayName": + err = unpopulate(val, "DepartmentDisplayName", &p.DepartmentDisplayName) + delete(rawMsg, key) + case "departmentId": + err = unpopulate(val, "DepartmentID", &p.DepartmentID) + delete(rawMsg, key) + case "enrollmentAccountDisplayName": + err = unpopulate(val, "EnrollmentAccountDisplayName", &p.EnrollmentAccountDisplayName) + delete(rawMsg, key) + case "enrollmentAccountId": + err = unpopulate(val, "EnrollmentAccountID", &p.EnrollmentAccountID) + delete(rawMsg, key) + case "enrollmentAccountStatus": + err = unpopulate(val, "EnrollmentAccountStatus", &p.EnrollmentAccountStatus) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PropertyPropertiesSubscriptionServiceUsageAddress. +func (p PropertyPropertiesSubscriptionServiceUsageAddress) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "addressLine1", p.AddressLine1) + populate(objectMap, "addressLine2", p.AddressLine2) + populate(objectMap, "addressLine3", p.AddressLine3) + populate(objectMap, "city", p.City) + populate(objectMap, "companyName", p.CompanyName) + populate(objectMap, "country", p.Country) + populate(objectMap, "district", p.District) + populate(objectMap, "email", p.Email) + populate(objectMap, "firstName", p.FirstName) + populate(objectMap, "isValidAddress", p.IsValidAddress) + populate(objectMap, "lastName", p.LastName) + populate(objectMap, "middleName", p.MiddleName) + populate(objectMap, "phoneNumber", p.PhoneNumber) + populate(objectMap, "postalCode", p.PostalCode) + populate(objectMap, "region", p.Region) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PropertyPropertiesSubscriptionServiceUsageAddress. +func (p *PropertyPropertiesSubscriptionServiceUsageAddress) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "addressLine1": + err = unpopulate(val, "AddressLine1", &p.AddressLine1) + delete(rawMsg, key) + case "addressLine2": + err = unpopulate(val, "AddressLine2", &p.AddressLine2) + delete(rawMsg, key) + case "addressLine3": + err = unpopulate(val, "AddressLine3", &p.AddressLine3) + delete(rawMsg, key) + case "city": + err = unpopulate(val, "City", &p.City) + delete(rawMsg, key) + case "companyName": + err = unpopulate(val, "CompanyName", &p.CompanyName) + delete(rawMsg, key) + case "country": + err = unpopulate(val, "Country", &p.Country) + delete(rawMsg, key) + case "district": + err = unpopulate(val, "District", &p.District) + delete(rawMsg, key) + case "email": + err = unpopulate(val, "Email", &p.Email) + delete(rawMsg, key) + case "firstName": + err = unpopulate(val, "FirstName", &p.FirstName) + delete(rawMsg, key) + case "isValidAddress": + err = unpopulate(val, "IsValidAddress", &p.IsValidAddress) + delete(rawMsg, key) + case "lastName": + err = unpopulate(val, "LastName", &p.LastName) + delete(rawMsg, key) + case "middleName": + err = unpopulate(val, "MiddleName", &p.MiddleName) + delete(rawMsg, key) + case "phoneNumber": + err = unpopulate(val, "PhoneNumber", &p.PhoneNumber) + delete(rawMsg, key) + case "postalCode": + err = unpopulate(val, "PostalCode", &p.PostalCode) + delete(rawMsg, key) + case "region": + err = unpopulate(val, "Region", &p.Region) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProxyResource. +func (p ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProxyResource. +func (p *ProxyResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProxyResourceWithTags. +func (p ProxyResourceWithTags) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProxyResourceWithTags. +func (p *ProxyResourceWithTags) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PurchaseRequest. +func (p PurchaseRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "sku", p.SKU) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PurchaseRequest. +func (p *PurchaseRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &p.SKU) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PurchaseRequestProperties. +func (p PurchaseRequestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "appliedScopeProperties", p.AppliedScopeProperties) + populate(objectMap, "appliedScopeType", p.AppliedScopeType) + populate(objectMap, "billingPlan", p.BillingPlan) + populate(objectMap, "billingScopeId", p.BillingScopeID) + populate(objectMap, "commitment", p.Commitment) + populate(objectMap, "displayName", p.DisplayName) + populate(objectMap, "renew", p.Renew) + populate(objectMap, "term", p.Term) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PurchaseRequestProperties. +func (p *PurchaseRequestProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "appliedScopeProperties": + err = unpopulate(val, "AppliedScopeProperties", &p.AppliedScopeProperties) + delete(rawMsg, key) + case "appliedScopeType": + err = unpopulate(val, "AppliedScopeType", &p.AppliedScopeType) + delete(rawMsg, key) + case "billingPlan": + err = unpopulate(val, "BillingPlan", &p.BillingPlan) + delete(rawMsg, key) + case "billingScopeId": + err = unpopulate(val, "BillingScopeID", &p.BillingScopeID) + delete(rawMsg, key) + case "commitment": + err = unpopulate(val, "Commitment", &p.Commitment) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &p.DisplayName) + delete(rawMsg, key) + case "renew": + err = unpopulate(val, "Renew", &p.Renew) + delete(rawMsg, key) + case "term": + err = unpopulate(val, "Term", &p.Term) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RebillDetails. +func (r RebillDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "creditNoteDocumentId", r.CreditNoteDocumentID) + populate(objectMap, "invoiceDocumentId", r.InvoiceDocumentID) + populate(objectMap, "rebillDetails", r.RebillDetails) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RebillDetails. +func (r *RebillDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "creditNoteDocumentId": + err = unpopulate(val, "CreditNoteDocumentID", &r.CreditNoteDocumentID) + delete(rawMsg, key) + case "invoiceDocumentId": + err = unpopulate(val, "InvoiceDocumentID", &r.InvoiceDocumentID) + delete(rawMsg, key) + case "rebillDetails": + err = unpopulate(val, "RebillDetails", &r.RebillDetails) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RecipientTransferDetails. +func (r RecipientTransferDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecipientTransferDetails. +func (r *RecipientTransferDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RecipientTransferDetailsListResult. +func (r RecipientTransferDetailsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecipientTransferDetailsListResult. +func (r *RecipientTransferDetailsListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RecipientTransferProperties. +func (r RecipientTransferProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "allowedProductType", r.AllowedProductType) + populate(objectMap, "canceledBy", r.CanceledBy) + populate(objectMap, "customerTenantId", r.CustomerTenantID) + populate(objectMap, "detailedTransferStatus", r.DetailedTransferStatus) + populateDateTimeRFC3339(objectMap, "expirationTime", r.ExpirationTime) + populate(objectMap, "initiatorCustomerType", r.InitiatorCustomerType) + populate(objectMap, "initiatorEmailId", r.InitiatorEmailID) + populate(objectMap, "recipientEmailId", r.RecipientEmailID) + populate(objectMap, "resellerId", r.ResellerID) + populate(objectMap, "resellerName", r.ResellerName) + populate(objectMap, "supportedAccounts", r.SupportedAccounts) + populate(objectMap, "transferStatus", r.TransferStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecipientTransferProperties. +func (r *RecipientTransferProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "allowedProductType": + err = unpopulate(val, "AllowedProductType", &r.AllowedProductType) + delete(rawMsg, key) + case "canceledBy": + err = unpopulate(val, "CanceledBy", &r.CanceledBy) + delete(rawMsg, key) + case "customerTenantId": + err = unpopulate(val, "CustomerTenantID", &r.CustomerTenantID) + delete(rawMsg, key) + case "detailedTransferStatus": + err = unpopulate(val, "DetailedTransferStatus", &r.DetailedTransferStatus) + delete(rawMsg, key) + case "expirationTime": + err = unpopulateDateTimeRFC3339(val, "ExpirationTime", &r.ExpirationTime) + delete(rawMsg, key) + case "initiatorCustomerType": + err = unpopulate(val, "InitiatorCustomerType", &r.InitiatorCustomerType) + delete(rawMsg, key) + case "initiatorEmailId": + err = unpopulate(val, "InitiatorEmailID", &r.InitiatorEmailID) + delete(rawMsg, key) + case "recipientEmailId": + err = unpopulate(val, "RecipientEmailID", &r.RecipientEmailID) + delete(rawMsg, key) + case "resellerId": + err = unpopulate(val, "ResellerID", &r.ResellerID) + delete(rawMsg, key) + case "resellerName": + err = unpopulate(val, "ResellerName", &r.ResellerName) + delete(rawMsg, key) + case "supportedAccounts": + err = unpopulate(val, "SupportedAccounts", &r.SupportedAccounts) + delete(rawMsg, key) + case "transferStatus": + err = unpopulate(val, "TransferStatus", &r.TransferStatus) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RefundDetailsSummary. +func (r RefundDetailsSummary) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "amountRefunded", r.AmountRefunded) + populate(objectMap, "amountRequested", r.AmountRequested) + populateDateTimeRFC3339(objectMap, "approvedOn", r.ApprovedOn) + populateDateTimeRFC3339(objectMap, "completedOn", r.CompletedOn) + populate(objectMap, "rebillInvoiceId", r.RebillInvoiceID) + populate(objectMap, "refundOperationId", r.RefundOperationID) + populate(objectMap, "refundReason", r.RefundReason) + populate(objectMap, "refundStatus", r.RefundStatus) + populateDateTimeRFC3339(objectMap, "requestedOn", r.RequestedOn) + populate(objectMap, "transactionCount", r.TransactionCount) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RefundDetailsSummary. +func (r *RefundDetailsSummary) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "amountRefunded": + err = unpopulate(val, "AmountRefunded", &r.AmountRefunded) + delete(rawMsg, key) + case "amountRequested": + err = unpopulate(val, "AmountRequested", &r.AmountRequested) + delete(rawMsg, key) + case "approvedOn": + err = unpopulateDateTimeRFC3339(val, "ApprovedOn", &r.ApprovedOn) + delete(rawMsg, key) + case "completedOn": + err = unpopulateDateTimeRFC3339(val, "CompletedOn", &r.CompletedOn) + delete(rawMsg, key) + case "rebillInvoiceId": + err = unpopulate(val, "RebillInvoiceID", &r.RebillInvoiceID) + delete(rawMsg, key) + case "refundOperationId": + err = unpopulate(val, "RefundOperationID", &r.RefundOperationID) + delete(rawMsg, key) + case "refundReason": + err = unpopulate(val, "RefundReason", &r.RefundReason) + delete(rawMsg, key) + case "refundStatus": + err = unpopulate(val, "RefundStatus", &r.RefundStatus) + delete(rawMsg, key) + case "requestedOn": + err = unpopulateDateTimeRFC3339(val, "RequestedOn", &r.RequestedOn) + delete(rawMsg, key) + case "transactionCount": + err = unpopulate(val, "TransactionCount", &r.TransactionCount) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RefundDetailsSummaryAmountRefunded. +func (r RefundDetailsSummaryAmountRefunded) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "currency", r.Currency) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RefundDetailsSummaryAmountRefunded. +func (r *RefundDetailsSummaryAmountRefunded) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "currency": + err = unpopulate(val, "Currency", &r.Currency) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RefundDetailsSummaryAmountRequested. +func (r RefundDetailsSummaryAmountRequested) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "currency", r.Currency) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RefundDetailsSummaryAmountRequested. +func (r *RefundDetailsSummaryAmountRequested) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "currency": + err = unpopulate(val, "Currency", &r.Currency) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RefundTransactionDetails. +func (r RefundTransactionDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "amountRefunded", r.AmountRefunded) + populate(objectMap, "amountRequested", r.AmountRequested) + populate(objectMap, "refundOperationId", r.RefundOperationID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RefundTransactionDetails. +func (r *RefundTransactionDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "amountRefunded": + err = unpopulate(val, "AmountRefunded", &r.AmountRefunded) + delete(rawMsg, key) + case "amountRequested": + err = unpopulate(val, "AmountRequested", &r.AmountRequested) + delete(rawMsg, key) + case "refundOperationId": + err = unpopulate(val, "RefundOperationID", &r.RefundOperationID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RefundTransactionDetailsAmountRefunded. +func (r RefundTransactionDetailsAmountRefunded) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "currency", r.Currency) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RefundTransactionDetailsAmountRefunded. +func (r *RefundTransactionDetailsAmountRefunded) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "currency": + err = unpopulate(val, "Currency", &r.Currency) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RefundTransactionDetailsAmountRequested. +func (r RefundTransactionDetailsAmountRequested) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "currency", r.Currency) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RefundTransactionDetailsAmountRequested. +func (r *RefundTransactionDetailsAmountRequested) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "currency": + err = unpopulate(val, "Currency", &r.Currency) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RegistrationNumber. +func (r RegistrationNumber) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "required", r.Required) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RegistrationNumber. +func (r *RegistrationNumber) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "required": + err = unpopulate(val, "Required", &r.Required) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RenewProperties. +func (r RenewProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "purchaseProperties", r.PurchaseProperties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RenewProperties. +func (r *RenewProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "purchaseProperties": + err = unpopulate(val, "PurchaseProperties", &r.PurchaseProperties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RenewPropertiesResponse. +func (r RenewPropertiesResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "billingCurrencyTotal", r.BillingCurrencyTotal) + populate(objectMap, "pricingCurrencyTotal", r.PricingCurrencyTotal) + populate(objectMap, "purchaseProperties", r.PurchaseProperties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RenewPropertiesResponse. +func (r *RenewPropertiesResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "billingCurrencyTotal": + err = unpopulate(val, "BillingCurrencyTotal", &r.BillingCurrencyTotal) + delete(rawMsg, key) + case "pricingCurrencyTotal": + err = unpopulate(val, "PricingCurrencyTotal", &r.PricingCurrencyTotal) + delete(rawMsg, key) + case "purchaseProperties": + err = unpopulate(val, "PurchaseProperties", &r.PurchaseProperties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RenewalTermDetails. +func (r RenewalTermDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "billingFrequency", r.BillingFrequency) + populate(objectMap, "productId", r.ProductID) + populate(objectMap, "productTypeId", r.ProductTypeID) + populate(objectMap, "quantity", r.Quantity) + populate(objectMap, "skuId", r.SKUID) + populate(objectMap, "termDuration", r.TermDuration) + populateDateTimeRFC3339(objectMap, "termEndDate", r.TermEndDate) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RenewalTermDetails. +func (r *RenewalTermDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "billingFrequency": + err = unpopulate(val, "BillingFrequency", &r.BillingFrequency) + delete(rawMsg, key) + case "productId": + err = unpopulate(val, "ProductID", &r.ProductID) + delete(rawMsg, key) + case "productTypeId": + err = unpopulate(val, "ProductTypeID", &r.ProductTypeID) + delete(rawMsg, key) + case "quantity": + err = unpopulate(val, "Quantity", &r.Quantity) + delete(rawMsg, key) + case "skuId": + err = unpopulate(val, "SKUID", &r.SKUID) + delete(rawMsg, key) + case "termDuration": + err = unpopulate(val, "TermDuration", &r.TermDuration) + delete(rawMsg, key) + case "termEndDate": + err = unpopulateDateTimeRFC3339(val, "TermEndDate", &r.TermEndDate) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Request. +func (r Request) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Request. +func (r *Request) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RequestListResult. +func (r RequestListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RequestListResult. +func (r *RequestListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RequestProperties. +func (r RequestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInformation", r.AdditionalInformation) + populate(objectMap, "billingAccountDisplayName", r.BillingAccountDisplayName) + populate(objectMap, "billingAccountId", r.BillingAccountID) + populate(objectMap, "billingAccountName", r.BillingAccountName) + populate(objectMap, "billingAccountPrimaryBillingTenantId", r.BillingAccountPrimaryBillingTenantID) + populate(objectMap, "billingProfileDisplayName", r.BillingProfileDisplayName) + populate(objectMap, "billingProfileId", r.BillingProfileID) + populate(objectMap, "billingProfileName", r.BillingProfileName) + populate(objectMap, "billingScope", r.BillingScope) + populate(objectMap, "createdBy", r.CreatedBy) + populateDateTimeRFC3339(objectMap, "creationDate", r.CreationDate) + populate(objectMap, "customerDisplayName", r.CustomerDisplayName) + populate(objectMap, "customerId", r.CustomerID) + populate(objectMap, "customerName", r.CustomerName) + populate(objectMap, "decisionReason", r.DecisionReason) + populateDateTimeRFC3339(objectMap, "expirationDate", r.ExpirationDate) + populate(objectMap, "invoiceSectionDisplayName", r.InvoiceSectionDisplayName) + populate(objectMap, "invoiceSectionId", r.InvoiceSectionID) + populate(objectMap, "invoiceSectionName", r.InvoiceSectionName) + populate(objectMap, "justification", r.Justification) + populate(objectMap, "lastUpdatedBy", r.LastUpdatedBy) + populateDateTimeRFC3339(objectMap, "lastUpdatedDate", r.LastUpdatedDate) + populate(objectMap, "provisioningState", r.ProvisioningState) + populate(objectMap, "recipients", r.Recipients) + populate(objectMap, "requestScope", r.RequestScope) + populateDateTimeRFC3339(objectMap, "reviewalDate", r.ReviewalDate) + populate(objectMap, "reviewedBy", r.ReviewedBy) + populate(objectMap, "status", r.Status) + populate(objectMap, "subscriptionDisplayName", r.SubscriptionDisplayName) + populate(objectMap, "subscriptionId", r.SubscriptionID) + populate(objectMap, "subscriptionName", r.SubscriptionName) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RequestProperties. +func (r *RequestProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInformation": + err = unpopulate(val, "AdditionalInformation", &r.AdditionalInformation) + delete(rawMsg, key) + case "billingAccountDisplayName": + err = unpopulate(val, "BillingAccountDisplayName", &r.BillingAccountDisplayName) + delete(rawMsg, key) + case "billingAccountId": + err = unpopulate(val, "BillingAccountID", &r.BillingAccountID) + delete(rawMsg, key) + case "billingAccountName": + err = unpopulate(val, "BillingAccountName", &r.BillingAccountName) + delete(rawMsg, key) + case "billingAccountPrimaryBillingTenantId": + err = unpopulate(val, "BillingAccountPrimaryBillingTenantID", &r.BillingAccountPrimaryBillingTenantID) + delete(rawMsg, key) + case "billingProfileDisplayName": + err = unpopulate(val, "BillingProfileDisplayName", &r.BillingProfileDisplayName) + delete(rawMsg, key) + case "billingProfileId": + err = unpopulate(val, "BillingProfileID", &r.BillingProfileID) + delete(rawMsg, key) + case "billingProfileName": + err = unpopulate(val, "BillingProfileName", &r.BillingProfileName) + delete(rawMsg, key) + case "billingScope": + err = unpopulate(val, "BillingScope", &r.BillingScope) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &r.CreatedBy) + delete(rawMsg, key) + case "creationDate": + err = unpopulateDateTimeRFC3339(val, "CreationDate", &r.CreationDate) + delete(rawMsg, key) + case "customerDisplayName": + err = unpopulate(val, "CustomerDisplayName", &r.CustomerDisplayName) + delete(rawMsg, key) + case "customerId": + err = unpopulate(val, "CustomerID", &r.CustomerID) + delete(rawMsg, key) + case "customerName": + err = unpopulate(val, "CustomerName", &r.CustomerName) + delete(rawMsg, key) + case "decisionReason": + err = unpopulate(val, "DecisionReason", &r.DecisionReason) + delete(rawMsg, key) + case "expirationDate": + err = unpopulateDateTimeRFC3339(val, "ExpirationDate", &r.ExpirationDate) + delete(rawMsg, key) + case "invoiceSectionDisplayName": + err = unpopulate(val, "InvoiceSectionDisplayName", &r.InvoiceSectionDisplayName) + delete(rawMsg, key) + case "invoiceSectionId": + err = unpopulate(val, "InvoiceSectionID", &r.InvoiceSectionID) + delete(rawMsg, key) + case "invoiceSectionName": + err = unpopulate(val, "InvoiceSectionName", &r.InvoiceSectionName) + delete(rawMsg, key) + case "justification": + err = unpopulate(val, "Justification", &r.Justification) + delete(rawMsg, key) + case "lastUpdatedBy": + err = unpopulate(val, "LastUpdatedBy", &r.LastUpdatedBy) + delete(rawMsg, key) + case "lastUpdatedDate": + err = unpopulateDateTimeRFC3339(val, "LastUpdatedDate", &r.LastUpdatedDate) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) + delete(rawMsg, key) + case "recipients": + err = unpopulate(val, "Recipients", &r.Recipients) + delete(rawMsg, key) + case "requestScope": + err = unpopulate(val, "RequestScope", &r.RequestScope) + delete(rawMsg, key) + case "reviewalDate": + err = unpopulateDateTimeRFC3339(val, "ReviewalDate", &r.ReviewalDate) + delete(rawMsg, key) + case "reviewedBy": + err = unpopulate(val, "ReviewedBy", &r.ReviewedBy) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &r.Status) + delete(rawMsg, key) + case "subscriptionDisplayName": + err = unpopulate(val, "SubscriptionDisplayName", &r.SubscriptionDisplayName) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &r.SubscriptionID) + delete(rawMsg, key) + case "subscriptionName": + err = unpopulate(val, "SubscriptionName", &r.SubscriptionName) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RequestPropertiesCreatedBy. +func (r RequestPropertiesCreatedBy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "objectId", r.ObjectID) + populate(objectMap, "tenantId", r.TenantID) + populate(objectMap, "upn", r.Upn) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RequestPropertiesCreatedBy. +func (r *RequestPropertiesCreatedBy) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "objectId": + err = unpopulate(val, "ObjectID", &r.ObjectID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &r.TenantID) + delete(rawMsg, key) + case "upn": + err = unpopulate(val, "Upn", &r.Upn) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RequestPropertiesLastUpdatedBy. +func (r RequestPropertiesLastUpdatedBy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "objectId", r.ObjectID) + populate(objectMap, "tenantId", r.TenantID) + populate(objectMap, "upn", r.Upn) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RequestPropertiesLastUpdatedBy. +func (r *RequestPropertiesLastUpdatedBy) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "objectId": + err = unpopulate(val, "ObjectID", &r.ObjectID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &r.TenantID) + delete(rawMsg, key) + case "upn": + err = unpopulate(val, "Upn", &r.Upn) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RequestPropertiesReviewedBy. +func (r RequestPropertiesReviewedBy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "objectId", r.ObjectID) + populate(objectMap, "tenantId", r.TenantID) + populate(objectMap, "upn", r.Upn) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RequestPropertiesReviewedBy. +func (r *RequestPropertiesReviewedBy) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "objectId": + err = unpopulate(val, "ObjectID", &r.ObjectID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &r.TenantID) + delete(rawMsg, key) + case "upn": + err = unpopulate(val, "Upn", &r.Upn) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Reseller. +func (r Reseller) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", r.Description) + populate(objectMap, "resellerId", r.ResellerID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Reseller. +func (r *Reseller) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &r.Description) + delete(rawMsg, key) + case "resellerId": + err = unpopulate(val, "ResellerID", &r.ResellerID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Reservation. +func (r Reservation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", r.Etag) + populate(objectMap, "id", r.ID) + populate(objectMap, "location", r.Location) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "sku", r.SKU) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Reservation. +func (r *Reservation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "etag": + err = unpopulate(val, "Etag", &r.Etag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &r.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &r.SKU) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationAppliedScopeProperties. +func (r ReservationAppliedScopeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", r.DisplayName) + populate(objectMap, "managementGroupId", r.ManagementGroupID) + populate(objectMap, "resourceGroupId", r.ResourceGroupID) + populate(objectMap, "subscriptionId", r.SubscriptionID) + populate(objectMap, "tenantId", r.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationAppliedScopeProperties. +func (r *ReservationAppliedScopeProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "displayName": + err = unpopulate(val, "DisplayName", &r.DisplayName) + delete(rawMsg, key) + case "managementGroupId": + err = unpopulate(val, "ManagementGroupID", &r.ManagementGroupID) + delete(rawMsg, key) + case "resourceGroupId": + err = unpopulate(val, "ResourceGroupID", &r.ResourceGroupID) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &r.SubscriptionID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &r.TenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationExtendedStatusInfo. +func (r ReservationExtendedStatusInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", r.Message) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "statusCode", r.StatusCode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationExtendedStatusInfo. +func (r *ReservationExtendedStatusInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, "Message", &r.Message) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "statusCode": + err = unpopulate(val, "StatusCode", &r.StatusCode) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationList. +func (r ReservationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationList. +func (r *ReservationList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationMergeProperties. +func (r ReservationMergeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "mergeDestination", r.MergeDestination) + populate(objectMap, "mergeSources", r.MergeSources) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationMergeProperties. +func (r *ReservationMergeProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "mergeDestination": + err = unpopulate(val, "MergeDestination", &r.MergeDestination) + delete(rawMsg, key) + case "mergeSources": + err = unpopulate(val, "MergeSources", &r.MergeSources) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationOrder. +func (r ReservationOrder) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", r.Etag) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationOrder. +func (r *ReservationOrder) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "etag": + err = unpopulate(val, "Etag", &r.Etag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationOrderBillingPlanInformation. +func (r ReservationOrderBillingPlanInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateType(objectMap, "nextPaymentDueDate", r.NextPaymentDueDate) + populate(objectMap, "pricingCurrencyTotal", r.PricingCurrencyTotal) + populateDateType(objectMap, "startDate", r.StartDate) + populate(objectMap, "transactions", r.Transactions) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationOrderBillingPlanInformation. +func (r *ReservationOrderBillingPlanInformation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextPaymentDueDate": + err = unpopulateDateType(val, "NextPaymentDueDate", &r.NextPaymentDueDate) + delete(rawMsg, key) + case "pricingCurrencyTotal": + err = unpopulate(val, "PricingCurrencyTotal", &r.PricingCurrencyTotal) + delete(rawMsg, key) + case "startDate": + err = unpopulateDateType(val, "StartDate", &r.StartDate) + delete(rawMsg, key) + case "transactions": + err = unpopulate(val, "Transactions", &r.Transactions) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationOrderList. +func (r ReservationOrderList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationOrderList. +func (r *ReservationOrderList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationOrderProperty. +func (r ReservationOrderProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "benefitStartTime", r.BenefitStartTime) + populate(objectMap, "billingAccountId", r.BillingAccountID) + populate(objectMap, "billingPlan", r.BillingPlan) + populate(objectMap, "billingProfileId", r.BillingProfileID) + populateDateTimeRFC3339(objectMap, "createdDateTime", r.CreatedDateTime) + populate(objectMap, "customerId", r.CustomerID) + populate(objectMap, "displayName", r.DisplayName) + populate(objectMap, "enrollmentId", r.EnrollmentID) + populateDateType(objectMap, "expiryDate", r.ExpiryDate) + populateDateTimeRFC3339(objectMap, "expiryDateTime", r.ExpiryDateTime) + populate(objectMap, "extendedStatusInfo", r.ExtendedStatusInfo) + populate(objectMap, "originalQuantity", r.OriginalQuantity) + populate(objectMap, "planInformation", r.PlanInformation) + populate(objectMap, "productCode", r.ProductCode) + populate(objectMap, "provisioningState", r.ProvisioningState) + populateDateTimeRFC3339(objectMap, "requestDateTime", r.RequestDateTime) + populate(objectMap, "reservations", r.Reservations) + populateDateTimeRFC3339(objectMap, "reviewDateTime", r.ReviewDateTime) + populate(objectMap, "term", r.Term) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationOrderProperty. +func (r *ReservationOrderProperty) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "benefitStartTime": + err = unpopulateDateTimeRFC3339(val, "BenefitStartTime", &r.BenefitStartTime) + delete(rawMsg, key) + case "billingAccountId": + err = unpopulate(val, "BillingAccountID", &r.BillingAccountID) + delete(rawMsg, key) + case "billingPlan": + err = unpopulate(val, "BillingPlan", &r.BillingPlan) + delete(rawMsg, key) + case "billingProfileId": + err = unpopulate(val, "BillingProfileID", &r.BillingProfileID) + delete(rawMsg, key) + case "createdDateTime": + err = unpopulateDateTimeRFC3339(val, "CreatedDateTime", &r.CreatedDateTime) + delete(rawMsg, key) + case "customerId": + err = unpopulate(val, "CustomerID", &r.CustomerID) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &r.DisplayName) + delete(rawMsg, key) + case "enrollmentId": + err = unpopulate(val, "EnrollmentID", &r.EnrollmentID) + delete(rawMsg, key) + case "expiryDate": + err = unpopulateDateType(val, "ExpiryDate", &r.ExpiryDate) + delete(rawMsg, key) + case "expiryDateTime": + err = unpopulateDateTimeRFC3339(val, "ExpiryDateTime", &r.ExpiryDateTime) + delete(rawMsg, key) + case "extendedStatusInfo": + err = unpopulate(val, "ExtendedStatusInfo", &r.ExtendedStatusInfo) + delete(rawMsg, key) + case "originalQuantity": + err = unpopulate(val, "OriginalQuantity", &r.OriginalQuantity) + delete(rawMsg, key) + case "planInformation": + err = unpopulate(val, "PlanInformation", &r.PlanInformation) + delete(rawMsg, key) + case "productCode": + err = unpopulate(val, "ProductCode", &r.ProductCode) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) + delete(rawMsg, key) + case "requestDateTime": + err = unpopulateDateTimeRFC3339(val, "RequestDateTime", &r.RequestDateTime) + delete(rawMsg, key) + case "reservations": + err = unpopulate(val, "Reservations", &r.Reservations) + delete(rawMsg, key) + case "reviewDateTime": + err = unpopulateDateTimeRFC3339(val, "ReviewDateTime", &r.ReviewDateTime) + delete(rawMsg, key) + case "term": + err = unpopulate(val, "Term", &r.Term) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationPaymentDetail. +func (r ReservationPaymentDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "billingAccount", r.BillingAccount) + populate(objectMap, "billingCurrencyTotal", r.BillingCurrencyTotal) + populateDateType(objectMap, "dueDate", r.DueDate) + populate(objectMap, "extendedStatusInfo", r.ExtendedStatusInfo) + populateDateType(objectMap, "paymentDate", r.PaymentDate) + populate(objectMap, "pricingCurrencyTotal", r.PricingCurrencyTotal) + populate(objectMap, "status", r.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationPaymentDetail. +func (r *ReservationPaymentDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "billingAccount": + err = unpopulate(val, "BillingAccount", &r.BillingAccount) + delete(rawMsg, key) + case "billingCurrencyTotal": + err = unpopulate(val, "BillingCurrencyTotal", &r.BillingCurrencyTotal) + delete(rawMsg, key) + case "dueDate": + err = unpopulateDateType(val, "DueDate", &r.DueDate) + delete(rawMsg, key) + case "extendedStatusInfo": + err = unpopulate(val, "ExtendedStatusInfo", &r.ExtendedStatusInfo) + delete(rawMsg, key) + case "paymentDate": + err = unpopulateDateType(val, "PaymentDate", &r.PaymentDate) + delete(rawMsg, key) + case "pricingCurrencyTotal": + err = unpopulate(val, "PricingCurrencyTotal", &r.PricingCurrencyTotal) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &r.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationProperty. +func (r ReservationProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "appliedScopeProperties", r.AppliedScopeProperties) + populate(objectMap, "appliedScopeType", r.AppliedScopeType) + populate(objectMap, "appliedScopes", r.AppliedScopes) + populate(objectMap, "archived", r.Archived) + populateDateTimeRFC3339(objectMap, "benefitStartTime", r.BenefitStartTime) + populate(objectMap, "billingPlan", r.BillingPlan) + populate(objectMap, "billingScopeId", r.BillingScopeID) + populate(objectMap, "capabilities", r.Capabilities) + populate(objectMap, "displayName", r.DisplayName) + populate(objectMap, "displayProvisioningState", r.DisplayProvisioningState) + populateDateTimeRFC3339(objectMap, "effectiveDateTime", r.EffectiveDateTime) + populate(objectMap, "expiryDate", r.ExpiryDate) + populateDateTimeRFC3339(objectMap, "expiryDateTime", r.ExpiryDateTime) + populate(objectMap, "extendedStatusInfo", r.ExtendedStatusInfo) + populate(objectMap, "instanceFlexibility", r.InstanceFlexibility) + populateDateTimeRFC3339(objectMap, "lastUpdatedDateTime", r.LastUpdatedDateTime) + populate(objectMap, "mergeProperties", r.MergeProperties) + populate(objectMap, "productCode", r.ProductCode) + populate(objectMap, "provisioningState", r.ProvisioningState) + populate(objectMap, "provisioningSubState", r.ProvisioningSubState) + populateDateType(objectMap, "purchaseDate", r.PurchaseDate) + populateDateTimeRFC3339(objectMap, "purchaseDateTime", r.PurchaseDateTime) + populate(objectMap, "quantity", r.Quantity) + populate(objectMap, "renew", r.Renew) + populate(objectMap, "renewDestination", r.RenewDestination) + populate(objectMap, "renewProperties", r.RenewProperties) + populate(objectMap, "renewSource", r.RenewSource) + populate(objectMap, "reservedResourceType", r.ReservedResourceType) + populateDateTimeRFC3339(objectMap, "reviewDateTime", r.ReviewDateTime) + populate(objectMap, "skuDescription", r.SKUDescription) + populate(objectMap, "splitProperties", r.SplitProperties) + populate(objectMap, "swapProperties", r.SwapProperties) + populate(objectMap, "term", r.Term) + populate(objectMap, "userFriendlyAppliedScopeType", r.UserFriendlyAppliedScopeType) + populate(objectMap, "userFriendlyRenewState", r.UserFriendlyRenewState) + populate(objectMap, "utilization", r.Utilization) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationProperty. +func (r *ReservationProperty) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "appliedScopeProperties": + err = unpopulate(val, "AppliedScopeProperties", &r.AppliedScopeProperties) + delete(rawMsg, key) + case "appliedScopeType": + err = unpopulate(val, "AppliedScopeType", &r.AppliedScopeType) + delete(rawMsg, key) + case "appliedScopes": + err = unpopulate(val, "AppliedScopes", &r.AppliedScopes) + delete(rawMsg, key) + case "archived": + err = unpopulate(val, "Archived", &r.Archived) + delete(rawMsg, key) + case "benefitStartTime": + err = unpopulateDateTimeRFC3339(val, "BenefitStartTime", &r.BenefitStartTime) + delete(rawMsg, key) + case "billingPlan": + err = unpopulate(val, "BillingPlan", &r.BillingPlan) + delete(rawMsg, key) + case "billingScopeId": + err = unpopulate(val, "BillingScopeID", &r.BillingScopeID) + delete(rawMsg, key) + case "capabilities": + err = unpopulate(val, "Capabilities", &r.Capabilities) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &r.DisplayName) + delete(rawMsg, key) + case "displayProvisioningState": + err = unpopulate(val, "DisplayProvisioningState", &r.DisplayProvisioningState) + delete(rawMsg, key) + case "effectiveDateTime": + err = unpopulateDateTimeRFC3339(val, "EffectiveDateTime", &r.EffectiveDateTime) + delete(rawMsg, key) + case "expiryDate": + err = unpopulate(val, "ExpiryDate", &r.ExpiryDate) + delete(rawMsg, key) + case "expiryDateTime": + err = unpopulateDateTimeRFC3339(val, "ExpiryDateTime", &r.ExpiryDateTime) + delete(rawMsg, key) + case "extendedStatusInfo": + err = unpopulate(val, "ExtendedStatusInfo", &r.ExtendedStatusInfo) + delete(rawMsg, key) + case "instanceFlexibility": + err = unpopulate(val, "InstanceFlexibility", &r.InstanceFlexibility) + delete(rawMsg, key) + case "lastUpdatedDateTime": + err = unpopulateDateTimeRFC3339(val, "LastUpdatedDateTime", &r.LastUpdatedDateTime) + delete(rawMsg, key) + case "mergeProperties": + err = unpopulate(val, "MergeProperties", &r.MergeProperties) + delete(rawMsg, key) + case "productCode": + err = unpopulate(val, "ProductCode", &r.ProductCode) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) + delete(rawMsg, key) + case "provisioningSubState": + err = unpopulate(val, "ProvisioningSubState", &r.ProvisioningSubState) + delete(rawMsg, key) + case "purchaseDate": + err = unpopulateDateType(val, "PurchaseDate", &r.PurchaseDate) + delete(rawMsg, key) + case "purchaseDateTime": + err = unpopulateDateTimeRFC3339(val, "PurchaseDateTime", &r.PurchaseDateTime) + delete(rawMsg, key) + case "quantity": + err = unpopulate(val, "Quantity", &r.Quantity) + delete(rawMsg, key) + case "renew": + err = unpopulate(val, "Renew", &r.Renew) + delete(rawMsg, key) + case "renewDestination": + err = unpopulate(val, "RenewDestination", &r.RenewDestination) + delete(rawMsg, key) + case "renewProperties": + err = unpopulate(val, "RenewProperties", &r.RenewProperties) + delete(rawMsg, key) + case "renewSource": + err = unpopulate(val, "RenewSource", &r.RenewSource) + delete(rawMsg, key) + case "reservedResourceType": + err = unpopulate(val, "ReservedResourceType", &r.ReservedResourceType) + delete(rawMsg, key) + case "reviewDateTime": + err = unpopulateDateTimeRFC3339(val, "ReviewDateTime", &r.ReviewDateTime) + delete(rawMsg, key) + case "skuDescription": + err = unpopulate(val, "SKUDescription", &r.SKUDescription) + delete(rawMsg, key) + case "splitProperties": + err = unpopulate(val, "SplitProperties", &r.SplitProperties) + delete(rawMsg, key) + case "swapProperties": + err = unpopulate(val, "SwapProperties", &r.SwapProperties) + delete(rawMsg, key) + case "term": + err = unpopulate(val, "Term", &r.Term) + delete(rawMsg, key) + case "userFriendlyAppliedScopeType": + err = unpopulate(val, "UserFriendlyAppliedScopeType", &r.UserFriendlyAppliedScopeType) + delete(rawMsg, key) + case "userFriendlyRenewState": + err = unpopulate(val, "UserFriendlyRenewState", &r.UserFriendlyRenewState) + delete(rawMsg, key) + case "utilization": + err = unpopulate(val, "Utilization", &r.Utilization) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationPropertyUtilization. +func (r ReservationPropertyUtilization) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "aggregates", r.Aggregates) + populate(objectMap, "trend", r.Trend) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationPropertyUtilization. +func (r *ReservationPropertyUtilization) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "aggregates": + err = unpopulate(val, "Aggregates", &r.Aggregates) + delete(rawMsg, key) + case "trend": + err = unpopulate(val, "Trend", &r.Trend) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationPurchaseRequest. +func (r ReservationPurchaseRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "location", r.Location) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "sku", r.SKU) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationPurchaseRequest. +func (r *ReservationPurchaseRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "location": + err = unpopulate(val, "Location", &r.Location) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &r.SKU) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationPurchaseRequestProperties. +func (r ReservationPurchaseRequestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "appliedScopeProperties", r.AppliedScopeProperties) + populate(objectMap, "appliedScopeType", r.AppliedScopeType) + populate(objectMap, "appliedScopes", r.AppliedScopes) + populate(objectMap, "billingPlan", r.BillingPlan) + populate(objectMap, "billingScopeId", r.BillingScopeID) + populate(objectMap, "displayName", r.DisplayName) + populate(objectMap, "instanceFlexibility", r.InstanceFlexibility) + populate(objectMap, "quantity", r.Quantity) + populate(objectMap, "renew", r.Renew) + populate(objectMap, "reservedResourceProperties", r.ReservedResourceProperties) + populate(objectMap, "reservedResourceType", r.ReservedResourceType) + populateDateTimeRFC3339(objectMap, "reviewDateTime", r.ReviewDateTime) + populate(objectMap, "term", r.Term) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationPurchaseRequestProperties. +func (r *ReservationPurchaseRequestProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "appliedScopeProperties": + err = unpopulate(val, "AppliedScopeProperties", &r.AppliedScopeProperties) + delete(rawMsg, key) + case "appliedScopeType": + err = unpopulate(val, "AppliedScopeType", &r.AppliedScopeType) + delete(rawMsg, key) + case "appliedScopes": + err = unpopulate(val, "AppliedScopes", &r.AppliedScopes) + delete(rawMsg, key) + case "billingPlan": + err = unpopulate(val, "BillingPlan", &r.BillingPlan) + delete(rawMsg, key) + case "billingScopeId": + err = unpopulate(val, "BillingScopeID", &r.BillingScopeID) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &r.DisplayName) + delete(rawMsg, key) + case "instanceFlexibility": + err = unpopulate(val, "InstanceFlexibility", &r.InstanceFlexibility) + delete(rawMsg, key) + case "quantity": + err = unpopulate(val, "Quantity", &r.Quantity) + delete(rawMsg, key) + case "renew": + err = unpopulate(val, "Renew", &r.Renew) + delete(rawMsg, key) + case "reservedResourceProperties": + err = unpopulate(val, "ReservedResourceProperties", &r.ReservedResourceProperties) + delete(rawMsg, key) + case "reservedResourceType": + err = unpopulate(val, "ReservedResourceType", &r.ReservedResourceType) + delete(rawMsg, key) + case "reviewDateTime": + err = unpopulateDateTimeRFC3339(val, "ReviewDateTime", &r.ReviewDateTime) + delete(rawMsg, key) + case "term": + err = unpopulate(val, "Term", &r.Term) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationPurchaseRequestPropertiesReservedResourceProperties. +func (r ReservationPurchaseRequestPropertiesReservedResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "instanceFlexibility", r.InstanceFlexibility) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationPurchaseRequestPropertiesReservedResourceProperties. +func (r *ReservationPurchaseRequestPropertiesReservedResourceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "instanceFlexibility": + err = unpopulate(val, "InstanceFlexibility", &r.InstanceFlexibility) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationSKUProperty. +func (r ReservationSKUProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", r.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationSKUProperty. +func (r *ReservationSKUProperty) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationSplitProperties. +func (r ReservationSplitProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "splitDestinations", r.SplitDestinations) + populate(objectMap, "splitSource", r.SplitSource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationSplitProperties. +func (r *ReservationSplitProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "splitDestinations": + err = unpopulate(val, "SplitDestinations", &r.SplitDestinations) + delete(rawMsg, key) + case "splitSource": + err = unpopulate(val, "SplitSource", &r.SplitSource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationSummary. +func (r ReservationSummary) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "cancelledCount", r.CancelledCount) + populate(objectMap, "expiredCount", r.ExpiredCount) + populate(objectMap, "expiringCount", r.ExpiringCount) + populate(objectMap, "failedCount", r.FailedCount) + populate(objectMap, "noBenefitCount", r.NoBenefitCount) + populate(objectMap, "pendingCount", r.PendingCount) + populate(objectMap, "processingCount", r.ProcessingCount) + populate(objectMap, "succeededCount", r.SucceededCount) + populate(objectMap, "warningCount", r.WarningCount) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationSummary. +func (r *ReservationSummary) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "cancelledCount": + err = unpopulate(val, "CancelledCount", &r.CancelledCount) + delete(rawMsg, key) + case "expiredCount": + err = unpopulate(val, "ExpiredCount", &r.ExpiredCount) + delete(rawMsg, key) + case "expiringCount": + err = unpopulate(val, "ExpiringCount", &r.ExpiringCount) + delete(rawMsg, key) + case "failedCount": + err = unpopulate(val, "FailedCount", &r.FailedCount) + delete(rawMsg, key) + case "noBenefitCount": + err = unpopulate(val, "NoBenefitCount", &r.NoBenefitCount) + delete(rawMsg, key) + case "pendingCount": + err = unpopulate(val, "PendingCount", &r.PendingCount) + delete(rawMsg, key) + case "processingCount": + err = unpopulate(val, "ProcessingCount", &r.ProcessingCount) + delete(rawMsg, key) + case "succeededCount": + err = unpopulate(val, "SucceededCount", &r.SucceededCount) + delete(rawMsg, key) + case "warningCount": + err = unpopulate(val, "WarningCount", &r.WarningCount) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationSwapProperties. +func (r ReservationSwapProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "swapDestination", r.SwapDestination) + populate(objectMap, "swapSource", r.SwapSource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationSwapProperties. +func (r *ReservationSwapProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "swapDestination": + err = unpopulate(val, "SwapDestination", &r.SwapDestination) + delete(rawMsg, key) + case "swapSource": + err = unpopulate(val, "SwapSource", &r.SwapSource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationUtilizationAggregates. +func (r ReservationUtilizationAggregates) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "grain", r.Grain) + populate(objectMap, "grainUnit", r.GrainUnit) + populate(objectMap, "value", r.Value) + populate(objectMap, "valueUnit", r.ValueUnit) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationUtilizationAggregates. +func (r *ReservationUtilizationAggregates) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "grain": + err = unpopulate(val, "Grain", &r.Grain) + delete(rawMsg, key) + case "grainUnit": + err = unpopulate(val, "GrainUnit", &r.GrainUnit) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + case "valueUnit": + err = unpopulate(val, "ValueUnit", &r.ValueUnit) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationsListResult. +func (r ReservationsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "summary", r.Summary) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationsListResult. +func (r *ReservationsListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "summary": + err = unpopulate(val, "Summary", &r.Summary) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RoleAssignment. +func (r RoleAssignment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RoleAssignment. +func (r *RoleAssignment) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RoleAssignmentListResult. +func (r RoleAssignmentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RoleAssignmentListResult. +func (r *RoleAssignmentListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RoleAssignmentProperties. +func (r RoleAssignmentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "billingAccountDisplayName", r.BillingAccountDisplayName) + populate(objectMap, "billingAccountId", r.BillingAccountID) + populate(objectMap, "billingProfileDisplayName", r.BillingProfileDisplayName) + populate(objectMap, "billingProfileId", r.BillingProfileID) + populate(objectMap, "billingRequestId", r.BillingRequestID) + populate(objectMap, "createdByPrincipalId", r.CreatedByPrincipalID) + populate(objectMap, "createdByPrincipalPuid", r.CreatedByPrincipalPuid) + populate(objectMap, "createdByPrincipalTenantId", r.CreatedByPrincipalTenantID) + populate(objectMap, "createdByUserEmailAddress", r.CreatedByUserEmailAddress) + populateDateTimeRFC3339(objectMap, "createdOn", r.CreatedOn) + populate(objectMap, "customerDisplayName", r.CustomerDisplayName) + populate(objectMap, "customerId", r.CustomerID) + populate(objectMap, "invoiceSectionDisplayName", r.InvoiceSectionDisplayName) + populate(objectMap, "invoiceSectionId", r.InvoiceSectionID) + populate(objectMap, "modifiedByPrincipalId", r.ModifiedByPrincipalID) + populate(objectMap, "modifiedByPrincipalPuid", r.ModifiedByPrincipalPuid) + populate(objectMap, "modifiedByPrincipalTenantId", r.ModifiedByPrincipalTenantID) + populate(objectMap, "modifiedByUserEmailAddress", r.ModifiedByUserEmailAddress) + populateDateTimeRFC3339(objectMap, "modifiedOn", r.ModifiedOn) + populate(objectMap, "principalDisplayName", r.PrincipalDisplayName) + populate(objectMap, "principalId", r.PrincipalID) + populate(objectMap, "principalPuid", r.PrincipalPuid) + populate(objectMap, "principalTenantId", r.PrincipalTenantID) + populate(objectMap, "principalTenantName", r.PrincipalTenantName) + populate(objectMap, "principalType", r.PrincipalType) + populate(objectMap, "provisioningState", r.ProvisioningState) + populate(objectMap, "roleDefinitionId", r.RoleDefinitionID) + populate(objectMap, "scope", r.Scope) + populate(objectMap, "userAuthenticationType", r.UserAuthenticationType) + populate(objectMap, "userEmailAddress", r.UserEmailAddress) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RoleAssignmentProperties. +func (r *RoleAssignmentProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "billingAccountDisplayName": + err = unpopulate(val, "BillingAccountDisplayName", &r.BillingAccountDisplayName) + delete(rawMsg, key) + case "billingAccountId": + err = unpopulate(val, "BillingAccountID", &r.BillingAccountID) + delete(rawMsg, key) + case "billingProfileDisplayName": + err = unpopulate(val, "BillingProfileDisplayName", &r.BillingProfileDisplayName) + delete(rawMsg, key) + case "billingProfileId": + err = unpopulate(val, "BillingProfileID", &r.BillingProfileID) + delete(rawMsg, key) + case "billingRequestId": + err = unpopulate(val, "BillingRequestID", &r.BillingRequestID) + delete(rawMsg, key) + case "createdByPrincipalId": + err = unpopulate(val, "CreatedByPrincipalID", &r.CreatedByPrincipalID) + delete(rawMsg, key) + case "createdByPrincipalPuid": + err = unpopulate(val, "CreatedByPrincipalPuid", &r.CreatedByPrincipalPuid) + delete(rawMsg, key) + case "createdByPrincipalTenantId": + err = unpopulate(val, "CreatedByPrincipalTenantID", &r.CreatedByPrincipalTenantID) + delete(rawMsg, key) + case "createdByUserEmailAddress": + err = unpopulate(val, "CreatedByUserEmailAddress", &r.CreatedByUserEmailAddress) + delete(rawMsg, key) + case "createdOn": + err = unpopulateDateTimeRFC3339(val, "CreatedOn", &r.CreatedOn) + delete(rawMsg, key) + case "customerDisplayName": + err = unpopulate(val, "CustomerDisplayName", &r.CustomerDisplayName) + delete(rawMsg, key) + case "customerId": + err = unpopulate(val, "CustomerID", &r.CustomerID) + delete(rawMsg, key) + case "invoiceSectionDisplayName": + err = unpopulate(val, "InvoiceSectionDisplayName", &r.InvoiceSectionDisplayName) + delete(rawMsg, key) + case "invoiceSectionId": + err = unpopulate(val, "InvoiceSectionID", &r.InvoiceSectionID) + delete(rawMsg, key) + case "modifiedByPrincipalId": + err = unpopulate(val, "ModifiedByPrincipalID", &r.ModifiedByPrincipalID) + delete(rawMsg, key) + case "modifiedByPrincipalPuid": + err = unpopulate(val, "ModifiedByPrincipalPuid", &r.ModifiedByPrincipalPuid) + delete(rawMsg, key) + case "modifiedByPrincipalTenantId": + err = unpopulate(val, "ModifiedByPrincipalTenantID", &r.ModifiedByPrincipalTenantID) + delete(rawMsg, key) + case "modifiedByUserEmailAddress": + err = unpopulate(val, "ModifiedByUserEmailAddress", &r.ModifiedByUserEmailAddress) + delete(rawMsg, key) + case "modifiedOn": + err = unpopulateDateTimeRFC3339(val, "ModifiedOn", &r.ModifiedOn) + delete(rawMsg, key) + case "principalDisplayName": + err = unpopulate(val, "PrincipalDisplayName", &r.PrincipalDisplayName) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &r.PrincipalID) + delete(rawMsg, key) + case "principalPuid": + err = unpopulate(val, "PrincipalPuid", &r.PrincipalPuid) + delete(rawMsg, key) + case "principalTenantId": + err = unpopulate(val, "PrincipalTenantID", &r.PrincipalTenantID) + delete(rawMsg, key) + case "principalTenantName": + err = unpopulate(val, "PrincipalTenantName", &r.PrincipalTenantName) + delete(rawMsg, key) + case "principalType": + err = unpopulate(val, "PrincipalType", &r.PrincipalType) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) + delete(rawMsg, key) + case "roleDefinitionId": + err = unpopulate(val, "RoleDefinitionID", &r.RoleDefinitionID) + delete(rawMsg, key) + case "scope": + err = unpopulate(val, "Scope", &r.Scope) + delete(rawMsg, key) + case "userAuthenticationType": + err = unpopulate(val, "UserAuthenticationType", &r.UserAuthenticationType) + delete(rawMsg, key) + case "userEmailAddress": + err = unpopulate(val, "UserEmailAddress", &r.UserEmailAddress) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RoleDefinition. +func (r RoleDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RoleDefinition. +func (r *RoleDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RoleDefinitionListResult. +func (r RoleDefinitionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RoleDefinitionListResult. +func (r *RoleDefinitionListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RoleDefinitionProperties. +func (r RoleDefinitionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", r.Description) + populate(objectMap, "permissions", r.Permissions) + populate(objectMap, "roleName", r.RoleName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RoleDefinitionProperties. +func (r *RoleDefinitionProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &r.Description) + delete(rawMsg, key) + case "permissions": + err = unpopulate(val, "Permissions", &r.Permissions) + delete(rawMsg, key) + case "roleName": + err = unpopulate(val, "RoleName", &r.RoleName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SKU. +func (s SKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", s.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKU. +func (s *SKU) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SKUName. +func (s SKUName) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", s.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKUName. +func (s *SKUName) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanModel. +func (s SavingsPlanModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "sku", s.SKU) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "tags", s.Tags) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanModel. +func (s *SavingsPlanModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &s.SKU) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanModelList. +func (s SavingsPlanModelList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanModelList. +func (s *SavingsPlanModelList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanModelListResult. +func (s SavingsPlanModelListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "summary", s.Summary) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanModelListResult. +func (s *SavingsPlanModelListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "summary": + err = unpopulate(val, "Summary", &s.Summary) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanModelProperties. +func (s SavingsPlanModelProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "appliedScopeProperties", s.AppliedScopeProperties) + populate(objectMap, "appliedScopeType", s.AppliedScopeType) + populateDateTimeRFC3339(objectMap, "benefitStartTime", s.BenefitStartTime) + populate(objectMap, "billingAccountId", s.BillingAccountID) + populate(objectMap, "billingPlan", s.BillingPlan) + populate(objectMap, "billingProfileId", s.BillingProfileID) + populate(objectMap, "billingScopeId", s.BillingScopeID) + populate(objectMap, "commitment", s.Commitment) + populate(objectMap, "customerId", s.CustomerID) + populate(objectMap, "displayName", s.DisplayName) + populate(objectMap, "displayProvisioningState", s.DisplayProvisioningState) + populateDateTimeRFC3339(objectMap, "effectiveDateTime", s.EffectiveDateTime) + populateDateTimeRFC3339(objectMap, "expiryDateTime", s.ExpiryDateTime) + populate(objectMap, "extendedStatusInfo", s.ExtendedStatusInfo) + populate(objectMap, "productCode", s.ProductCode) + populate(objectMap, "provisioningState", s.ProvisioningState) + populateDateTimeRFC3339(objectMap, "purchaseDateTime", s.PurchaseDateTime) + populate(objectMap, "renew", s.Renew) + populate(objectMap, "renewDestination", s.RenewDestination) + populate(objectMap, "renewProperties", s.RenewProperties) + populate(objectMap, "renewSource", s.RenewSource) + populate(objectMap, "term", s.Term) + populate(objectMap, "userFriendlyAppliedScopeType", s.UserFriendlyAppliedScopeType) + populate(objectMap, "utilization", s.Utilization) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanModelProperties. +func (s *SavingsPlanModelProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "appliedScopeProperties": + err = unpopulate(val, "AppliedScopeProperties", &s.AppliedScopeProperties) + delete(rawMsg, key) + case "appliedScopeType": + err = unpopulate(val, "AppliedScopeType", &s.AppliedScopeType) + delete(rawMsg, key) + case "benefitStartTime": + err = unpopulateDateTimeRFC3339(val, "BenefitStartTime", &s.BenefitStartTime) + delete(rawMsg, key) + case "billingAccountId": + err = unpopulate(val, "BillingAccountID", &s.BillingAccountID) + delete(rawMsg, key) + case "billingPlan": + err = unpopulate(val, "BillingPlan", &s.BillingPlan) + delete(rawMsg, key) + case "billingProfileId": + err = unpopulate(val, "BillingProfileID", &s.BillingProfileID) + delete(rawMsg, key) + case "billingScopeId": + err = unpopulate(val, "BillingScopeID", &s.BillingScopeID) + delete(rawMsg, key) + case "commitment": + err = unpopulate(val, "Commitment", &s.Commitment) + delete(rawMsg, key) + case "customerId": + err = unpopulate(val, "CustomerID", &s.CustomerID) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &s.DisplayName) + delete(rawMsg, key) + case "displayProvisioningState": + err = unpopulate(val, "DisplayProvisioningState", &s.DisplayProvisioningState) + delete(rawMsg, key) + case "effectiveDateTime": + err = unpopulateDateTimeRFC3339(val, "EffectiveDateTime", &s.EffectiveDateTime) + delete(rawMsg, key) + case "expiryDateTime": + err = unpopulateDateTimeRFC3339(val, "ExpiryDateTime", &s.ExpiryDateTime) + delete(rawMsg, key) + case "extendedStatusInfo": + err = unpopulate(val, "ExtendedStatusInfo", &s.ExtendedStatusInfo) + delete(rawMsg, key) + case "productCode": + err = unpopulate(val, "ProductCode", &s.ProductCode) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + delete(rawMsg, key) + case "purchaseDateTime": + err = unpopulateDateTimeRFC3339(val, "PurchaseDateTime", &s.PurchaseDateTime) + delete(rawMsg, key) + case "renew": + err = unpopulate(val, "Renew", &s.Renew) + delete(rawMsg, key) + case "renewDestination": + err = unpopulate(val, "RenewDestination", &s.RenewDestination) + delete(rawMsg, key) + case "renewProperties": + err = unpopulate(val, "RenewProperties", &s.RenewProperties) + delete(rawMsg, key) + case "renewSource": + err = unpopulate(val, "RenewSource", &s.RenewSource) + delete(rawMsg, key) + case "term": + err = unpopulate(val, "Term", &s.Term) + delete(rawMsg, key) + case "userFriendlyAppliedScopeType": + err = unpopulate(val, "UserFriendlyAppliedScopeType", &s.UserFriendlyAppliedScopeType) + delete(rawMsg, key) + case "utilization": + err = unpopulate(val, "Utilization", &s.Utilization) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanOrderModel. +func (s SavingsPlanOrderModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "sku", s.SKU) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "tags", s.Tags) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanOrderModel. +func (s *SavingsPlanOrderModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &s.SKU) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanOrderModelList. +func (s SavingsPlanOrderModelList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanOrderModelList. +func (s *SavingsPlanOrderModelList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanOrderModelProperties. +func (s SavingsPlanOrderModelProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "benefitStartTime", s.BenefitStartTime) + populate(objectMap, "billingAccountId", s.BillingAccountID) + populate(objectMap, "billingPlan", s.BillingPlan) + populate(objectMap, "billingProfileId", s.BillingProfileID) + populate(objectMap, "billingScopeId", s.BillingScopeID) + populate(objectMap, "customerId", s.CustomerID) + populate(objectMap, "displayName", s.DisplayName) + populateDateTimeRFC3339(objectMap, "expiryDateTime", s.ExpiryDateTime) + populate(objectMap, "extendedStatusInfo", s.ExtendedStatusInfo) + populate(objectMap, "planInformation", s.PlanInformation) + populate(objectMap, "productCode", s.ProductCode) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "savingsPlans", s.SavingsPlans) + populate(objectMap, "term", s.Term) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanOrderModelProperties. +func (s *SavingsPlanOrderModelProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "benefitStartTime": + err = unpopulateDateTimeRFC3339(val, "BenefitStartTime", &s.BenefitStartTime) + delete(rawMsg, key) + case "billingAccountId": + err = unpopulate(val, "BillingAccountID", &s.BillingAccountID) + delete(rawMsg, key) + case "billingPlan": + err = unpopulate(val, "BillingPlan", &s.BillingPlan) + delete(rawMsg, key) + case "billingProfileId": + err = unpopulate(val, "BillingProfileID", &s.BillingProfileID) + delete(rawMsg, key) + case "billingScopeId": + err = unpopulate(val, "BillingScopeID", &s.BillingScopeID) + delete(rawMsg, key) + case "customerId": + err = unpopulate(val, "CustomerID", &s.CustomerID) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &s.DisplayName) + delete(rawMsg, key) + case "expiryDateTime": + err = unpopulateDateTimeRFC3339(val, "ExpiryDateTime", &s.ExpiryDateTime) + delete(rawMsg, key) + case "extendedStatusInfo": + err = unpopulate(val, "ExtendedStatusInfo", &s.ExtendedStatusInfo) + delete(rawMsg, key) + case "planInformation": + err = unpopulate(val, "PlanInformation", &s.PlanInformation) + delete(rawMsg, key) + case "productCode": + err = unpopulate(val, "ProductCode", &s.ProductCode) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + delete(rawMsg, key) + case "savingsPlans": + err = unpopulate(val, "SavingsPlans", &s.SavingsPlans) + delete(rawMsg, key) + case "term": + err = unpopulate(val, "Term", &s.Term) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanSummaryCount. +func (s SavingsPlanSummaryCount) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "cancelledCount", s.CancelledCount) + populate(objectMap, "expiredCount", s.ExpiredCount) + populate(objectMap, "expiringCount", s.ExpiringCount) + populate(objectMap, "failedCount", s.FailedCount) + populate(objectMap, "noBenefitCount", s.NoBenefitCount) + populate(objectMap, "pendingCount", s.PendingCount) + populate(objectMap, "processingCount", s.ProcessingCount) + populate(objectMap, "succeededCount", s.SucceededCount) + populate(objectMap, "warningCount", s.WarningCount) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanSummaryCount. +func (s *SavingsPlanSummaryCount) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "cancelledCount": + err = unpopulate(val, "CancelledCount", &s.CancelledCount) + delete(rawMsg, key) + case "expiredCount": + err = unpopulate(val, "ExpiredCount", &s.ExpiredCount) + delete(rawMsg, key) + case "expiringCount": + err = unpopulate(val, "ExpiringCount", &s.ExpiringCount) + delete(rawMsg, key) + case "failedCount": + err = unpopulate(val, "FailedCount", &s.FailedCount) + delete(rawMsg, key) + case "noBenefitCount": + err = unpopulate(val, "NoBenefitCount", &s.NoBenefitCount) + delete(rawMsg, key) + case "pendingCount": + err = unpopulate(val, "PendingCount", &s.PendingCount) + delete(rawMsg, key) + case "processingCount": + err = unpopulate(val, "ProcessingCount", &s.ProcessingCount) + delete(rawMsg, key) + case "succeededCount": + err = unpopulate(val, "SucceededCount", &s.SucceededCount) + delete(rawMsg, key) + case "warningCount": + err = unpopulate(val, "WarningCount", &s.WarningCount) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanUpdateRequest. +func (s SavingsPlanUpdateRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "sku", s.SKU) + populate(objectMap, "tags", s.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanUpdateRequest. +func (s *SavingsPlanUpdateRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &s.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanUpdateRequestProperties. +func (s SavingsPlanUpdateRequestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "appliedScopeProperties", s.AppliedScopeProperties) + populate(objectMap, "appliedScopeType", s.AppliedScopeType) + populate(objectMap, "displayName", s.DisplayName) + populate(objectMap, "renew", s.Renew) + populate(objectMap, "renewProperties", s.RenewProperties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanUpdateRequestProperties. +func (s *SavingsPlanUpdateRequestProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "appliedScopeProperties": + err = unpopulate(val, "AppliedScopeProperties", &s.AppliedScopeProperties) + delete(rawMsg, key) + case "appliedScopeType": + err = unpopulate(val, "AppliedScopeType", &s.AppliedScopeType) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &s.DisplayName) + delete(rawMsg, key) + case "renew": + err = unpopulate(val, "Renew", &s.Renew) + delete(rawMsg, key) + case "renewProperties": + err = unpopulate(val, "RenewProperties", &s.RenewProperties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanUpdateValidateRequest. +func (s SavingsPlanUpdateValidateRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "benefits", s.Benefits) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanUpdateValidateRequest. +func (s *SavingsPlanUpdateValidateRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "benefits": + err = unpopulate(val, "Benefits", &s.Benefits) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanValidResponseProperty. +func (s SavingsPlanValidResponseProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "reason", s.Reason) + populate(objectMap, "reasonCode", s.ReasonCode) + populate(objectMap, "valid", s.Valid) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanValidResponseProperty. +func (s *SavingsPlanValidResponseProperty) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "reason": + err = unpopulate(val, "Reason", &s.Reason) + delete(rawMsg, key) + case "reasonCode": + err = unpopulate(val, "ReasonCode", &s.ReasonCode) + delete(rawMsg, key) + case "valid": + err = unpopulate(val, "Valid", &s.Valid) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanValidateResponse. +func (s SavingsPlanValidateResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "benefits", s.Benefits) + populate(objectMap, "nextLink", s.NextLink) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanValidateResponse. +func (s *SavingsPlanValidateResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "benefits": + err = unpopulate(val, "Benefits", &s.Benefits) + delete(rawMsg, key) + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SpendingLimitDetails. +func (s SpendingLimitDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "amount", s.Amount) + populate(objectMap, "currency", s.Currency) + populateDateTimeRFC3339(objectMap, "endDate", s.EndDate) + populateDateTimeRFC3339(objectMap, "startDate", s.StartDate) + populate(objectMap, "status", s.Status) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SpendingLimitDetails. +func (s *SpendingLimitDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "amount": + err = unpopulate(val, "Amount", &s.Amount) + delete(rawMsg, key) + case "currency": + err = unpopulate(val, "Currency", &s.Currency) + delete(rawMsg, key) + case "endDate": + err = unpopulateDateTimeRFC3339(val, "EndDate", &s.EndDate) + delete(rawMsg, key) + case "startDate": + err = unpopulateDateTimeRFC3339(val, "StartDate", &s.StartDate) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &s.Status) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Subscription. +func (s Subscription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "tags", s.Tags) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Subscription. +func (s *Subscription) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionAlias. +func (s SubscriptionAlias) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "tags", s.Tags) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionAlias. +func (s *SubscriptionAlias) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionAliasListResult. +func (s SubscriptionAliasListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionAliasListResult. +func (s *SubscriptionAliasListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionAliasProperties. +func (s SubscriptionAliasProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "autoRenew", s.AutoRenew) + populate(objectMap, "beneficiary", s.Beneficiary) + populate(objectMap, "beneficiaryTenantId", s.BeneficiaryTenantID) + populate(objectMap, "billingFrequency", s.BillingFrequency) + populate(objectMap, "billingPolicies", s.BillingPolicies) + populate(objectMap, "billingProfileDisplayName", s.BillingProfileDisplayName) + populate(objectMap, "billingProfileId", s.BillingProfileID) + populate(objectMap, "billingProfileName", s.BillingProfileName) + populate(objectMap, "billingSubscriptionId", s.BillingSubscriptionID) + populate(objectMap, "consumptionCostCenter", s.ConsumptionCostCenter) + populate(objectMap, "customerDisplayName", s.CustomerDisplayName) + populate(objectMap, "customerId", s.CustomerID) + populate(objectMap, "customerName", s.CustomerName) + populate(objectMap, "displayName", s.DisplayName) + populate(objectMap, "enrollmentAccountDisplayName", s.EnrollmentAccountDisplayName) + populate(objectMap, "enrollmentAccountId", s.EnrollmentAccountID) + populate(objectMap, "enrollmentAccountSubscriptionDetails", s.EnrollmentAccountSubscriptionDetails) + populate(objectMap, "invoiceSectionDisplayName", s.InvoiceSectionDisplayName) + populate(objectMap, "invoiceSectionId", s.InvoiceSectionID) + populate(objectMap, "invoiceSectionName", s.InvoiceSectionName) + populate(objectMap, "lastMonthCharges", s.LastMonthCharges) + populate(objectMap, "monthToDateCharges", s.MonthToDateCharges) + populate(objectMap, "nextBillingCycleDetails", s.NextBillingCycleDetails) + populate(objectMap, "offerId", s.OfferID) + populate(objectMap, "operationStatus", s.OperationStatus) + populate(objectMap, "productCategory", s.ProductCategory) + populate(objectMap, "productType", s.ProductType) + populate(objectMap, "productTypeId", s.ProductTypeID) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "provisioningTenantId", s.ProvisioningTenantID) + populateDateTimeRFC3339(objectMap, "purchaseDate", s.PurchaseDate) + populate(objectMap, "quantity", s.Quantity) + populate(objectMap, "renewalTermDetails", s.RenewalTermDetails) + populate(objectMap, "reseller", s.Reseller) + populate(objectMap, "resourceUri", s.ResourceURI) + populate(objectMap, "skuDescription", s.SKUDescription) + populate(objectMap, "skuId", s.SKUID) + populate(objectMap, "status", s.Status) + populate(objectMap, "subscriptionId", s.SubscriptionID) + populate(objectMap, "suspensionReasonDetails", s.SuspensionReasonDetails) + populate(objectMap, "suspensionReasons", s.SuspensionReasons) + populate(objectMap, "systemOverrides", s.SystemOverrides) + populate(objectMap, "termDuration", s.TermDuration) + populateDateTimeRFC3339(objectMap, "termEndDate", s.TermEndDate) + populateDateTimeRFC3339(objectMap, "termStartDate", s.TermStartDate) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionAliasProperties. +func (s *SubscriptionAliasProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "autoRenew": + err = unpopulate(val, "AutoRenew", &s.AutoRenew) + delete(rawMsg, key) + case "beneficiary": + err = unpopulate(val, "Beneficiary", &s.Beneficiary) + delete(rawMsg, key) + case "beneficiaryTenantId": + err = unpopulate(val, "BeneficiaryTenantID", &s.BeneficiaryTenantID) + delete(rawMsg, key) + case "billingFrequency": + err = unpopulate(val, "BillingFrequency", &s.BillingFrequency) + delete(rawMsg, key) + case "billingPolicies": + err = unpopulate(val, "BillingPolicies", &s.BillingPolicies) + delete(rawMsg, key) + case "billingProfileDisplayName": + err = unpopulate(val, "BillingProfileDisplayName", &s.BillingProfileDisplayName) + delete(rawMsg, key) + case "billingProfileId": + err = unpopulate(val, "BillingProfileID", &s.BillingProfileID) + delete(rawMsg, key) + case "billingProfileName": + err = unpopulate(val, "BillingProfileName", &s.BillingProfileName) + delete(rawMsg, key) + case "billingSubscriptionId": + err = unpopulate(val, "BillingSubscriptionID", &s.BillingSubscriptionID) + delete(rawMsg, key) + case "consumptionCostCenter": + err = unpopulate(val, "ConsumptionCostCenter", &s.ConsumptionCostCenter) + delete(rawMsg, key) + case "customerDisplayName": + err = unpopulate(val, "CustomerDisplayName", &s.CustomerDisplayName) + delete(rawMsg, key) + case "customerId": + err = unpopulate(val, "CustomerID", &s.CustomerID) + delete(rawMsg, key) + case "customerName": + err = unpopulate(val, "CustomerName", &s.CustomerName) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &s.DisplayName) + delete(rawMsg, key) + case "enrollmentAccountDisplayName": + err = unpopulate(val, "EnrollmentAccountDisplayName", &s.EnrollmentAccountDisplayName) + delete(rawMsg, key) + case "enrollmentAccountId": + err = unpopulate(val, "EnrollmentAccountID", &s.EnrollmentAccountID) + delete(rawMsg, key) + case "enrollmentAccountSubscriptionDetails": + err = unpopulate(val, "EnrollmentAccountSubscriptionDetails", &s.EnrollmentAccountSubscriptionDetails) + delete(rawMsg, key) + case "invoiceSectionDisplayName": + err = unpopulate(val, "InvoiceSectionDisplayName", &s.InvoiceSectionDisplayName) + delete(rawMsg, key) + case "invoiceSectionId": + err = unpopulate(val, "InvoiceSectionID", &s.InvoiceSectionID) + delete(rawMsg, key) + case "invoiceSectionName": + err = unpopulate(val, "InvoiceSectionName", &s.InvoiceSectionName) + delete(rawMsg, key) + case "lastMonthCharges": + err = unpopulate(val, "LastMonthCharges", &s.LastMonthCharges) + delete(rawMsg, key) + case "monthToDateCharges": + err = unpopulate(val, "MonthToDateCharges", &s.MonthToDateCharges) + delete(rawMsg, key) + case "nextBillingCycleDetails": + err = unpopulate(val, "NextBillingCycleDetails", &s.NextBillingCycleDetails) + delete(rawMsg, key) + case "offerId": + err = unpopulate(val, "OfferID", &s.OfferID) + delete(rawMsg, key) + case "operationStatus": + err = unpopulate(val, "OperationStatus", &s.OperationStatus) + delete(rawMsg, key) + case "productCategory": + err = unpopulate(val, "ProductCategory", &s.ProductCategory) + delete(rawMsg, key) + case "productType": + err = unpopulate(val, "ProductType", &s.ProductType) + delete(rawMsg, key) + case "productTypeId": + err = unpopulate(val, "ProductTypeID", &s.ProductTypeID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + delete(rawMsg, key) + case "provisioningTenantId": + err = unpopulate(val, "ProvisioningTenantID", &s.ProvisioningTenantID) + delete(rawMsg, key) + case "purchaseDate": + err = unpopulateDateTimeRFC3339(val, "PurchaseDate", &s.PurchaseDate) + delete(rawMsg, key) + case "quantity": + err = unpopulate(val, "Quantity", &s.Quantity) + delete(rawMsg, key) + case "renewalTermDetails": + err = unpopulate(val, "RenewalTermDetails", &s.RenewalTermDetails) + delete(rawMsg, key) + case "reseller": + err = unpopulate(val, "Reseller", &s.Reseller) + delete(rawMsg, key) + case "resourceUri": + err = unpopulate(val, "ResourceURI", &s.ResourceURI) + delete(rawMsg, key) + case "skuDescription": + err = unpopulate(val, "SKUDescription", &s.SKUDescription) + delete(rawMsg, key) + case "skuId": + err = unpopulate(val, "SKUID", &s.SKUID) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &s.Status) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &s.SubscriptionID) + delete(rawMsg, key) + case "suspensionReasonDetails": + err = unpopulate(val, "SuspensionReasonDetails", &s.SuspensionReasonDetails) + delete(rawMsg, key) + case "suspensionReasons": + err = unpopulate(val, "SuspensionReasons", &s.SuspensionReasons) + delete(rawMsg, key) + case "systemOverrides": + err = unpopulate(val, "SystemOverrides", &s.SystemOverrides) + delete(rawMsg, key) + case "termDuration": + err = unpopulate(val, "TermDuration", &s.TermDuration) + delete(rawMsg, key) + case "termEndDate": + err = unpopulateDateTimeRFC3339(val, "TermEndDate", &s.TermEndDate) + delete(rawMsg, key) + case "termStartDate": + err = unpopulateDateTimeRFC3339(val, "TermStartDate", &s.TermStartDate) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionEnrollmentDetails. +func (s SubscriptionEnrollmentDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "departmentDisplayName", s.DepartmentDisplayName) + populate(objectMap, "departmentId", s.DepartmentID) + populate(objectMap, "enrollmentAccountDisplayName", s.EnrollmentAccountDisplayName) + populate(objectMap, "enrollmentAccountId", s.EnrollmentAccountID) + populate(objectMap, "enrollmentAccountStatus", s.EnrollmentAccountStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionEnrollmentDetails. +func (s *SubscriptionEnrollmentDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "departmentDisplayName": + err = unpopulate(val, "DepartmentDisplayName", &s.DepartmentDisplayName) + delete(rawMsg, key) + case "departmentId": + err = unpopulate(val, "DepartmentID", &s.DepartmentID) + delete(rawMsg, key) + case "enrollmentAccountDisplayName": + err = unpopulate(val, "EnrollmentAccountDisplayName", &s.EnrollmentAccountDisplayName) + delete(rawMsg, key) + case "enrollmentAccountId": + err = unpopulate(val, "EnrollmentAccountID", &s.EnrollmentAccountID) + delete(rawMsg, key) + case "enrollmentAccountStatus": + err = unpopulate(val, "EnrollmentAccountStatus", &s.EnrollmentAccountStatus) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionListResult. +func (s SubscriptionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "totalCount", s.TotalCount) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionListResult. +func (s *SubscriptionListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "totalCount": + err = unpopulate(val, "TotalCount", &s.TotalCount) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionMergeRequest. +func (s SubscriptionMergeRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "quantity", s.Quantity) + populate(objectMap, "targetBillingSubscriptionName", s.TargetBillingSubscriptionName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionMergeRequest. +func (s *SubscriptionMergeRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "quantity": + err = unpopulate(val, "Quantity", &s.Quantity) + delete(rawMsg, key) + case "targetBillingSubscriptionName": + err = unpopulate(val, "TargetBillingSubscriptionName", &s.TargetBillingSubscriptionName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionPatch. +func (s SubscriptionPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "tags", s.Tags) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionPatch. +func (s *SubscriptionPatch) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionPolicy. +func (s SubscriptionPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "tags", s.Tags) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionPolicy. +func (s *SubscriptionPolicy) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionPolicyProperties. +func (s SubscriptionPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "policies", s.Policies) + populate(objectMap, "provisioningState", s.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionPolicyProperties. +func (s *SubscriptionPolicyProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "policies": + err = unpopulate(val, "Policies", &s.Policies) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionProperties. +func (s SubscriptionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "autoRenew", s.AutoRenew) + populate(objectMap, "beneficiary", s.Beneficiary) + populate(objectMap, "beneficiaryTenantId", s.BeneficiaryTenantID) + populate(objectMap, "billingFrequency", s.BillingFrequency) + populate(objectMap, "billingPolicies", s.BillingPolicies) + populate(objectMap, "billingProfileDisplayName", s.BillingProfileDisplayName) + populate(objectMap, "billingProfileId", s.BillingProfileID) + populate(objectMap, "billingProfileName", s.BillingProfileName) + populate(objectMap, "consumptionCostCenter", s.ConsumptionCostCenter) + populate(objectMap, "customerDisplayName", s.CustomerDisplayName) + populate(objectMap, "customerId", s.CustomerID) + populate(objectMap, "customerName", s.CustomerName) + populate(objectMap, "displayName", s.DisplayName) + populate(objectMap, "enrollmentAccountDisplayName", s.EnrollmentAccountDisplayName) + populate(objectMap, "enrollmentAccountId", s.EnrollmentAccountID) + populate(objectMap, "enrollmentAccountSubscriptionDetails", s.EnrollmentAccountSubscriptionDetails) + populate(objectMap, "invoiceSectionDisplayName", s.InvoiceSectionDisplayName) + populate(objectMap, "invoiceSectionId", s.InvoiceSectionID) + populate(objectMap, "invoiceSectionName", s.InvoiceSectionName) + populate(objectMap, "lastMonthCharges", s.LastMonthCharges) + populate(objectMap, "monthToDateCharges", s.MonthToDateCharges) + populate(objectMap, "nextBillingCycleDetails", s.NextBillingCycleDetails) + populate(objectMap, "offerId", s.OfferID) + populate(objectMap, "operationStatus", s.OperationStatus) + populate(objectMap, "productCategory", s.ProductCategory) + populate(objectMap, "productType", s.ProductType) + populate(objectMap, "productTypeId", s.ProductTypeID) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "provisioningTenantId", s.ProvisioningTenantID) + populateDateTimeRFC3339(objectMap, "purchaseDate", s.PurchaseDate) + populate(objectMap, "quantity", s.Quantity) + populate(objectMap, "renewalTermDetails", s.RenewalTermDetails) + populate(objectMap, "reseller", s.Reseller) + populate(objectMap, "resourceUri", s.ResourceURI) + populate(objectMap, "skuDescription", s.SKUDescription) + populate(objectMap, "skuId", s.SKUID) + populate(objectMap, "status", s.Status) + populate(objectMap, "subscriptionId", s.SubscriptionID) + populate(objectMap, "suspensionReasonDetails", s.SuspensionReasonDetails) + populate(objectMap, "suspensionReasons", s.SuspensionReasons) + populate(objectMap, "systemOverrides", s.SystemOverrides) + populate(objectMap, "termDuration", s.TermDuration) + populateDateTimeRFC3339(objectMap, "termEndDate", s.TermEndDate) + populateDateTimeRFC3339(objectMap, "termStartDate", s.TermStartDate) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionProperties. +func (s *SubscriptionProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "autoRenew": + err = unpopulate(val, "AutoRenew", &s.AutoRenew) + delete(rawMsg, key) + case "beneficiary": + err = unpopulate(val, "Beneficiary", &s.Beneficiary) + delete(rawMsg, key) + case "beneficiaryTenantId": + err = unpopulate(val, "BeneficiaryTenantID", &s.BeneficiaryTenantID) + delete(rawMsg, key) + case "billingFrequency": + err = unpopulate(val, "BillingFrequency", &s.BillingFrequency) + delete(rawMsg, key) + case "billingPolicies": + err = unpopulate(val, "BillingPolicies", &s.BillingPolicies) + delete(rawMsg, key) + case "billingProfileDisplayName": + err = unpopulate(val, "BillingProfileDisplayName", &s.BillingProfileDisplayName) + delete(rawMsg, key) + case "billingProfileId": + err = unpopulate(val, "BillingProfileID", &s.BillingProfileID) + delete(rawMsg, key) + case "billingProfileName": + err = unpopulate(val, "BillingProfileName", &s.BillingProfileName) + delete(rawMsg, key) + case "consumptionCostCenter": + err = unpopulate(val, "ConsumptionCostCenter", &s.ConsumptionCostCenter) + delete(rawMsg, key) + case "customerDisplayName": + err = unpopulate(val, "CustomerDisplayName", &s.CustomerDisplayName) + delete(rawMsg, key) + case "customerId": + err = unpopulate(val, "CustomerID", &s.CustomerID) + delete(rawMsg, key) + case "customerName": + err = unpopulate(val, "CustomerName", &s.CustomerName) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &s.DisplayName) + delete(rawMsg, key) + case "enrollmentAccountDisplayName": + err = unpopulate(val, "EnrollmentAccountDisplayName", &s.EnrollmentAccountDisplayName) + delete(rawMsg, key) + case "enrollmentAccountId": + err = unpopulate(val, "EnrollmentAccountID", &s.EnrollmentAccountID) + delete(rawMsg, key) + case "enrollmentAccountSubscriptionDetails": + err = unpopulate(val, "EnrollmentAccountSubscriptionDetails", &s.EnrollmentAccountSubscriptionDetails) + delete(rawMsg, key) + case "invoiceSectionDisplayName": + err = unpopulate(val, "InvoiceSectionDisplayName", &s.InvoiceSectionDisplayName) + delete(rawMsg, key) + case "invoiceSectionId": + err = unpopulate(val, "InvoiceSectionID", &s.InvoiceSectionID) + delete(rawMsg, key) + case "invoiceSectionName": + err = unpopulate(val, "InvoiceSectionName", &s.InvoiceSectionName) + delete(rawMsg, key) + case "lastMonthCharges": + err = unpopulate(val, "LastMonthCharges", &s.LastMonthCharges) + delete(rawMsg, key) + case "monthToDateCharges": + err = unpopulate(val, "MonthToDateCharges", &s.MonthToDateCharges) + delete(rawMsg, key) + case "nextBillingCycleDetails": + err = unpopulate(val, "NextBillingCycleDetails", &s.NextBillingCycleDetails) + delete(rawMsg, key) + case "offerId": + err = unpopulate(val, "OfferID", &s.OfferID) + delete(rawMsg, key) + case "operationStatus": + err = unpopulate(val, "OperationStatus", &s.OperationStatus) + delete(rawMsg, key) + case "productCategory": + err = unpopulate(val, "ProductCategory", &s.ProductCategory) + delete(rawMsg, key) + case "productType": + err = unpopulate(val, "ProductType", &s.ProductType) + delete(rawMsg, key) + case "productTypeId": + err = unpopulate(val, "ProductTypeID", &s.ProductTypeID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + delete(rawMsg, key) + case "provisioningTenantId": + err = unpopulate(val, "ProvisioningTenantID", &s.ProvisioningTenantID) + delete(rawMsg, key) + case "purchaseDate": + err = unpopulateDateTimeRFC3339(val, "PurchaseDate", &s.PurchaseDate) + delete(rawMsg, key) + case "quantity": + err = unpopulate(val, "Quantity", &s.Quantity) + delete(rawMsg, key) + case "renewalTermDetails": + err = unpopulate(val, "RenewalTermDetails", &s.RenewalTermDetails) + delete(rawMsg, key) + case "reseller": + err = unpopulate(val, "Reseller", &s.Reseller) + delete(rawMsg, key) + case "resourceUri": + err = unpopulate(val, "ResourceURI", &s.ResourceURI) + delete(rawMsg, key) + case "skuDescription": + err = unpopulate(val, "SKUDescription", &s.SKUDescription) + delete(rawMsg, key) + case "skuId": + err = unpopulate(val, "SKUID", &s.SKUID) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &s.Status) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &s.SubscriptionID) + delete(rawMsg, key) + case "suspensionReasonDetails": + err = unpopulate(val, "SuspensionReasonDetails", &s.SuspensionReasonDetails) + delete(rawMsg, key) + case "suspensionReasons": + err = unpopulate(val, "SuspensionReasons", &s.SuspensionReasons) + delete(rawMsg, key) + case "systemOverrides": + err = unpopulate(val, "SystemOverrides", &s.SystemOverrides) + delete(rawMsg, key) + case "termDuration": + err = unpopulate(val, "TermDuration", &s.TermDuration) + delete(rawMsg, key) + case "termEndDate": + err = unpopulateDateTimeRFC3339(val, "TermEndDate", &s.TermEndDate) + delete(rawMsg, key) + case "termStartDate": + err = unpopulateDateTimeRFC3339(val, "TermStartDate", &s.TermStartDate) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionSplitRequest. +func (s SubscriptionSplitRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "billingFrequency", s.BillingFrequency) + populate(objectMap, "quantity", s.Quantity) + populate(objectMap, "targetProductTypeId", s.TargetProductTypeID) + populate(objectMap, "targetSkuId", s.TargetSKUID) + populate(objectMap, "termDuration", s.TermDuration) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionSplitRequest. +func (s *SubscriptionSplitRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "billingFrequency": + err = unpopulate(val, "BillingFrequency", &s.BillingFrequency) + delete(rawMsg, key) + case "quantity": + err = unpopulate(val, "Quantity", &s.Quantity) + delete(rawMsg, key) + case "targetProductTypeId": + err = unpopulate(val, "TargetProductTypeID", &s.TargetProductTypeID) + delete(rawMsg, key) + case "targetSkuId": + err = unpopulate(val, "TargetSKUID", &s.TargetSKUID) + delete(rawMsg, key) + case "termDuration": + err = unpopulate(val, "TermDuration", &s.TermDuration) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionStatusDetails. +func (s SubscriptionStatusDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "effectiveDate", s.EffectiveDate) + populate(objectMap, "reason", s.Reason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionStatusDetails. +func (s *SubscriptionStatusDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "effectiveDate": + err = unpopulateDateTimeRFC3339(val, "EffectiveDate", &s.EffectiveDate) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &s.Reason) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemOverrides. +func (s SystemOverrides) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "cancellation", s.Cancellation) + populateDateTimeRFC3339(objectMap, "cancellationAllowedEndDate", s.CancellationAllowedEndDate) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemOverrides. +func (s *SystemOverrides) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "cancellation": + err = unpopulate(val, "Cancellation", &s.Cancellation) + delete(rawMsg, key) + case "cancellationAllowedEndDate": + err = unpopulateDateTimeRFC3339(val, "CancellationAllowedEndDate", &s.CancellationAllowedEndDate) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TaxIdentifier. +func (t TaxIdentifier) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "country", t.Country) + populate(objectMap, "id", t.ID) + populate(objectMap, "scope", t.Scope) + populate(objectMap, "status", t.Status) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TaxIdentifier. +func (t *TaxIdentifier) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "country": + err = unpopulate(val, "Country", &t.Country) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "scope": + err = unpopulate(val, "Scope", &t.Scope) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &t.Status) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Transaction. +func (t Transaction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "name", t.Name) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "systemData", t.SystemData) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Transaction. +func (t *Transaction) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TransactionListResult. +func (t TransactionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TransactionListResult. +func (t *TransactionListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &t.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &t.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TransactionProperties. +func (t TransactionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "azureCreditApplied", t.AzureCreditApplied) + populate(objectMap, "azurePlan", t.AzurePlan) + populate(objectMap, "billingCurrency", t.BillingCurrency) + populateAny(objectMap, "billingProfileDisplayName", t.BillingProfileDisplayName) + populate(objectMap, "billingProfileId", t.BillingProfileID) + populate(objectMap, "consumptionCommitmentDecremented", t.ConsumptionCommitmentDecremented) + populate(objectMap, "creditType", t.CreditType) + populate(objectMap, "customerDisplayName", t.CustomerDisplayName) + populate(objectMap, "customerId", t.CustomerID) + populateDateTimeRFC3339(objectMap, "date", t.Date) + populate(objectMap, "discount", t.Discount) + populate(objectMap, "effectivePrice", t.EffectivePrice) + populate(objectMap, "exchangeRate", t.ExchangeRate) + populate(objectMap, "invoice", t.Invoice) + populate(objectMap, "invoiceId", t.InvoiceID) + populate(objectMap, "invoiceSectionDisplayName", t.InvoiceSectionDisplayName) + populate(objectMap, "invoiceSectionId", t.InvoiceSectionID) + populate(objectMap, "isThirdParty", t.IsThirdParty) + populate(objectMap, "kind", t.Kind) + populate(objectMap, "marketPrice", t.MarketPrice) + populate(objectMap, "partNumber", t.PartNumber) + populate(objectMap, "pricingCurrency", t.PricingCurrency) + populate(objectMap, "productDescription", t.ProductDescription) + populate(objectMap, "productFamily", t.ProductFamily) + populate(objectMap, "productType", t.ProductType) + populate(objectMap, "productTypeId", t.ProductTypeID) + populate(objectMap, "quantity", t.Quantity) + populate(objectMap, "reasonCode", t.ReasonCode) + populate(objectMap, "refundTransactionDetails", t.RefundTransactionDetails) + populateDateTimeRFC3339(objectMap, "servicePeriodEndDate", t.ServicePeriodEndDate) + populateDateTimeRFC3339(objectMap, "servicePeriodStartDate", t.ServicePeriodStartDate) + populate(objectMap, "specialTaxationType", t.SpecialTaxationType) + populate(objectMap, "subTotal", t.SubTotal) + populate(objectMap, "tax", t.Tax) + populate(objectMap, "transactionAmount", t.TransactionAmount) + populate(objectMap, "transactionType", t.TransactionType) + populate(objectMap, "unitOfMeasure", t.UnitOfMeasure) + populate(objectMap, "unitType", t.UnitType) + populate(objectMap, "units", t.Units) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TransactionProperties. +func (t *TransactionProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "azureCreditApplied": + err = unpopulate(val, "AzureCreditApplied", &t.AzureCreditApplied) + delete(rawMsg, key) + case "azurePlan": + err = unpopulate(val, "AzurePlan", &t.AzurePlan) + delete(rawMsg, key) + case "billingCurrency": + err = unpopulate(val, "BillingCurrency", &t.BillingCurrency) + delete(rawMsg, key) + case "billingProfileDisplayName": + err = unpopulate(val, "BillingProfileDisplayName", &t.BillingProfileDisplayName) + delete(rawMsg, key) + case "billingProfileId": + err = unpopulate(val, "BillingProfileID", &t.BillingProfileID) + delete(rawMsg, key) + case "consumptionCommitmentDecremented": + err = unpopulate(val, "ConsumptionCommitmentDecremented", &t.ConsumptionCommitmentDecremented) + delete(rawMsg, key) + case "creditType": + err = unpopulate(val, "CreditType", &t.CreditType) + delete(rawMsg, key) + case "customerDisplayName": + err = unpopulate(val, "CustomerDisplayName", &t.CustomerDisplayName) + delete(rawMsg, key) + case "customerId": + err = unpopulate(val, "CustomerID", &t.CustomerID) + delete(rawMsg, key) + case "date": + err = unpopulateDateTimeRFC3339(val, "Date", &t.Date) + delete(rawMsg, key) + case "discount": + err = unpopulate(val, "Discount", &t.Discount) + delete(rawMsg, key) + case "effectivePrice": + err = unpopulate(val, "EffectivePrice", &t.EffectivePrice) + delete(rawMsg, key) + case "exchangeRate": + err = unpopulate(val, "ExchangeRate", &t.ExchangeRate) + delete(rawMsg, key) + case "invoice": + err = unpopulate(val, "Invoice", &t.Invoice) + delete(rawMsg, key) + case "invoiceId": + err = unpopulate(val, "InvoiceID", &t.InvoiceID) + delete(rawMsg, key) + case "invoiceSectionDisplayName": + err = unpopulate(val, "InvoiceSectionDisplayName", &t.InvoiceSectionDisplayName) + delete(rawMsg, key) + case "invoiceSectionId": + err = unpopulate(val, "InvoiceSectionID", &t.InvoiceSectionID) + delete(rawMsg, key) + case "isThirdParty": + err = unpopulate(val, "IsThirdParty", &t.IsThirdParty) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &t.Kind) + delete(rawMsg, key) + case "marketPrice": + err = unpopulate(val, "MarketPrice", &t.MarketPrice) + delete(rawMsg, key) + case "partNumber": + err = unpopulate(val, "PartNumber", &t.PartNumber) + delete(rawMsg, key) + case "pricingCurrency": + err = unpopulate(val, "PricingCurrency", &t.PricingCurrency) + delete(rawMsg, key) + case "productDescription": + err = unpopulate(val, "ProductDescription", &t.ProductDescription) + delete(rawMsg, key) + case "productFamily": + err = unpopulate(val, "ProductFamily", &t.ProductFamily) + delete(rawMsg, key) + case "productType": + err = unpopulate(val, "ProductType", &t.ProductType) + delete(rawMsg, key) + case "productTypeId": + err = unpopulate(val, "ProductTypeID", &t.ProductTypeID) + delete(rawMsg, key) + case "quantity": + err = unpopulate(val, "Quantity", &t.Quantity) + delete(rawMsg, key) + case "reasonCode": + err = unpopulate(val, "ReasonCode", &t.ReasonCode) + delete(rawMsg, key) + case "refundTransactionDetails": + err = unpopulate(val, "RefundTransactionDetails", &t.RefundTransactionDetails) + delete(rawMsg, key) + case "servicePeriodEndDate": + err = unpopulateDateTimeRFC3339(val, "ServicePeriodEndDate", &t.ServicePeriodEndDate) + delete(rawMsg, key) + case "servicePeriodStartDate": + err = unpopulateDateTimeRFC3339(val, "ServicePeriodStartDate", &t.ServicePeriodStartDate) + delete(rawMsg, key) + case "specialTaxationType": + err = unpopulate(val, "SpecialTaxationType", &t.SpecialTaxationType) + delete(rawMsg, key) + case "subTotal": + err = unpopulate(val, "SubTotal", &t.SubTotal) + delete(rawMsg, key) + case "tax": + err = unpopulate(val, "Tax", &t.Tax) + delete(rawMsg, key) + case "transactionAmount": + err = unpopulate(val, "TransactionAmount", &t.TransactionAmount) + delete(rawMsg, key) + case "transactionType": + err = unpopulate(val, "TransactionType", &t.TransactionType) + delete(rawMsg, key) + case "unitOfMeasure": + err = unpopulate(val, "UnitOfMeasure", &t.UnitOfMeasure) + delete(rawMsg, key) + case "unitType": + err = unpopulate(val, "UnitType", &t.UnitType) + delete(rawMsg, key) + case "units": + err = unpopulate(val, "Units", &t.Units) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TransactionPropertiesAzureCreditApplied. +func (t TransactionPropertiesAzureCreditApplied) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "currency", t.Currency) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TransactionPropertiesAzureCreditApplied. +func (t *TransactionPropertiesAzureCreditApplied) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &r.Properties) + case "currency": + err = unpopulate(val, "Currency", &t.Currency) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &r.Type) + case "value": + err = unpopulate(val, "Value", &t.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type RoleAssignmentListResult. -func (r RoleAssignmentListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TransactionPropertiesConsumptionCommitmentDecremented. +func (t TransactionPropertiesConsumptionCommitmentDecremented) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", r.NextLink) - populate(objectMap, "value", r.Value) + populate(objectMap, "currency", t.Currency) + populate(objectMap, "value", t.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type RoleAssignmentListResult. -func (r *RoleAssignmentListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TransactionPropertiesConsumptionCommitmentDecremented. +func (t *TransactionPropertiesConsumptionCommitmentDecremented) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &r.NextLink) + case "currency": + err = unpopulate(val, "Currency", &t.Currency) delete(rawMsg, key) case "value": - err = unpopulate(val, "Value", &r.Value) + err = unpopulate(val, "Value", &t.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type RoleAssignmentProperties. -func (r RoleAssignmentProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TransactionPropertiesEffectivePrice. +func (t TransactionPropertiesEffectivePrice) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "createdByPrincipalId", r.CreatedByPrincipalID) - populate(objectMap, "createdByPrincipalTenantId", r.CreatedByPrincipalTenantID) - populate(objectMap, "createdByUserEmailAddress", r.CreatedByUserEmailAddress) - populate(objectMap, "createdOn", r.CreatedOn) - populate(objectMap, "principalId", r.PrincipalID) - populate(objectMap, "principalTenantId", r.PrincipalTenantID) - populate(objectMap, "roleDefinitionId", r.RoleDefinitionID) - populate(objectMap, "scope", r.Scope) - populate(objectMap, "userAuthenticationType", r.UserAuthenticationType) - populate(objectMap, "userEmailAddress", r.UserEmailAddress) + populate(objectMap, "currency", t.Currency) + populate(objectMap, "value", t.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type RoleAssignmentProperties. -func (r *RoleAssignmentProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TransactionPropertiesEffectivePrice. +func (t *TransactionPropertiesEffectivePrice) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } for key, val := range rawMsg { var err error switch key { - case "createdByPrincipalId": - err = unpopulate(val, "CreatedByPrincipalID", &r.CreatedByPrincipalID) - delete(rawMsg, key) - case "createdByPrincipalTenantId": - err = unpopulate(val, "CreatedByPrincipalTenantID", &r.CreatedByPrincipalTenantID) - delete(rawMsg, key) - case "createdByUserEmailAddress": - err = unpopulate(val, "CreatedByUserEmailAddress", &r.CreatedByUserEmailAddress) - delete(rawMsg, key) - case "createdOn": - err = unpopulate(val, "CreatedOn", &r.CreatedOn) - delete(rawMsg, key) - case "principalId": - err = unpopulate(val, "PrincipalID", &r.PrincipalID) - delete(rawMsg, key) - case "principalTenantId": - err = unpopulate(val, "PrincipalTenantID", &r.PrincipalTenantID) - delete(rawMsg, key) - case "roleDefinitionId": - err = unpopulate(val, "RoleDefinitionID", &r.RoleDefinitionID) - delete(rawMsg, key) - case "scope": - err = unpopulate(val, "Scope", &r.Scope) - delete(rawMsg, key) - case "userAuthenticationType": - err = unpopulate(val, "UserAuthenticationType", &r.UserAuthenticationType) + case "currency": + err = unpopulate(val, "Currency", &t.Currency) delete(rawMsg, key) - case "userEmailAddress": - err = unpopulate(val, "UserEmailAddress", &r.UserEmailAddress) + case "value": + err = unpopulate(val, "Value", &t.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type RoleDefinition. -func (r RoleDefinition) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TransactionPropertiesMarketPrice. +func (t TransactionPropertiesMarketPrice) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", r.ID) - populate(objectMap, "name", r.Name) - populate(objectMap, "properties", r.Properties) - populate(objectMap, "type", r.Type) + populate(objectMap, "currency", t.Currency) + populate(objectMap, "value", t.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type RoleDefinition. -func (r *RoleDefinition) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TransactionPropertiesMarketPrice. +func (t *TransactionPropertiesMarketPrice) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &r.Properties) + case "currency": + err = unpopulate(val, "Currency", &t.Currency) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &r.Type) + case "value": + err = unpopulate(val, "Value", &t.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type RoleDefinitionListResult. -func (r RoleDefinitionListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TransactionPropertiesRefundTransactionDetails. +func (t TransactionPropertiesRefundTransactionDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", r.NextLink) - populate(objectMap, "value", r.Value) + populate(objectMap, "amountRefunded", t.AmountRefunded) + populate(objectMap, "amountRequested", t.AmountRequested) + populate(objectMap, "refundOperationId", t.RefundOperationID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type RoleDefinitionListResult. -func (r *RoleDefinitionListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TransactionPropertiesRefundTransactionDetails. +func (t *TransactionPropertiesRefundTransactionDetails) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &r.NextLink) + case "amountRefunded": + err = unpopulate(val, "AmountRefunded", &t.AmountRefunded) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &r.Value) + case "amountRequested": + err = unpopulate(val, "AmountRequested", &t.AmountRequested) + delete(rawMsg, key) + case "refundOperationId": + err = unpopulate(val, "RefundOperationID", &t.RefundOperationID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type RoleDefinitionProperties. -func (r RoleDefinitionProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TransactionPropertiesSubTotal. +func (t TransactionPropertiesSubTotal) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "description", r.Description) - populate(objectMap, "permissions", r.Permissions) - populate(objectMap, "roleName", r.RoleName) + populate(objectMap, "currency", t.Currency) + populate(objectMap, "value", t.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type RoleDefinitionProperties. -func (r *RoleDefinitionProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TransactionPropertiesSubTotal. +func (t *TransactionPropertiesSubTotal) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } for key, val := range rawMsg { var err error switch key { - case "description": - err = unpopulate(val, "Description", &r.Description) - delete(rawMsg, key) - case "permissions": - err = unpopulate(val, "Permissions", &r.Permissions) + case "currency": + err = unpopulate(val, "Currency", &t.Currency) delete(rawMsg, key) - case "roleName": - err = unpopulate(val, "RoleName", &r.RoleName) + case "value": + err = unpopulate(val, "Value", &t.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Subscription. -func (s Subscription) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TransactionPropertiesTax. +func (t TransactionPropertiesTax) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", s.ID) - populate(objectMap, "name", s.Name) - populate(objectMap, "properties", s.Properties) - populate(objectMap, "type", s.Type) + populate(objectMap, "currency", t.Currency) + populate(objectMap, "value", t.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Subscription. -func (s *Subscription) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TransactionPropertiesTax. +func (t *TransactionPropertiesTax) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &s.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &s.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &s.Properties) + case "currency": + err = unpopulate(val, "Currency", &t.Currency) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &s.Type) + case "value": + err = unpopulate(val, "Value", &t.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type SubscriptionProperties. -func (s SubscriptionProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TransactionPropertiesTransactionAmount. +func (t TransactionPropertiesTransactionAmount) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "billingProfileDisplayName", s.BillingProfileDisplayName) - populate(objectMap, "billingProfileId", s.BillingProfileID) - populate(objectMap, "costCenter", s.CostCenter) - populate(objectMap, "customerDisplayName", s.CustomerDisplayName) - populate(objectMap, "customerId", s.CustomerID) - populate(objectMap, "displayName", s.DisplayName) - populate(objectMap, "invoiceSectionDisplayName", s.InvoiceSectionDisplayName) - populate(objectMap, "invoiceSectionId", s.InvoiceSectionID) - populate(objectMap, "lastMonthCharges", s.LastMonthCharges) - populate(objectMap, "monthToDateCharges", s.MonthToDateCharges) - populate(objectMap, "reseller", s.Reseller) - populate(objectMap, "skuDescription", s.SKUDescription) - populate(objectMap, "skuId", s.SKUID) - populate(objectMap, "subscriptionBillingStatus", s.SubscriptionBillingStatus) - populate(objectMap, "subscriptionId", s.SubscriptionID) - populate(objectMap, "suspensionReasons", s.SuspensionReasons) + populate(objectMap, "currency", t.Currency) + populate(objectMap, "value", t.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionProperties. -func (s *SubscriptionProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TransactionPropertiesTransactionAmount. +func (t *TransactionPropertiesTransactionAmount) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } for key, val := range rawMsg { var err error switch key { - case "billingProfileDisplayName": - err = unpopulate(val, "BillingProfileDisplayName", &s.BillingProfileDisplayName) - delete(rawMsg, key) - case "billingProfileId": - err = unpopulate(val, "BillingProfileID", &s.BillingProfileID) - delete(rawMsg, key) - case "costCenter": - err = unpopulate(val, "CostCenter", &s.CostCenter) - delete(rawMsg, key) - case "customerDisplayName": - err = unpopulate(val, "CustomerDisplayName", &s.CustomerDisplayName) - delete(rawMsg, key) - case "customerId": - err = unpopulate(val, "CustomerID", &s.CustomerID) - delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &s.DisplayName) - delete(rawMsg, key) - case "invoiceSectionDisplayName": - err = unpopulate(val, "InvoiceSectionDisplayName", &s.InvoiceSectionDisplayName) - delete(rawMsg, key) - case "invoiceSectionId": - err = unpopulate(val, "InvoiceSectionID", &s.InvoiceSectionID) - delete(rawMsg, key) - case "lastMonthCharges": - err = unpopulate(val, "LastMonthCharges", &s.LastMonthCharges) - delete(rawMsg, key) - case "monthToDateCharges": - err = unpopulate(val, "MonthToDateCharges", &s.MonthToDateCharges) - delete(rawMsg, key) - case "reseller": - err = unpopulate(val, "Reseller", &s.Reseller) - delete(rawMsg, key) - case "skuDescription": - err = unpopulate(val, "SKUDescription", &s.SKUDescription) - delete(rawMsg, key) - case "skuId": - err = unpopulate(val, "SKUID", &s.SKUID) - delete(rawMsg, key) - case "subscriptionBillingStatus": - err = unpopulate(val, "SubscriptionBillingStatus", &s.SubscriptionBillingStatus) - delete(rawMsg, key) - case "subscriptionId": - err = unpopulate(val, "SubscriptionID", &s.SubscriptionID) + case "currency": + err = unpopulate(val, "Currency", &t.Currency) delete(rawMsg, key) - case "suspensionReasons": - err = unpopulate(val, "SuspensionReasons", &s.SuspensionReasons) + case "value": + err = unpopulate(val, "Value", &t.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type SubscriptionsListResult. -func (s SubscriptionsListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TransactionSummary. +func (t TransactionSummary) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", s.NextLink) - populate(objectMap, "totalCount", s.TotalCount) - populate(objectMap, "value", s.Value) + populate(objectMap, "azureCreditApplied", t.AzureCreditApplied) + populate(objectMap, "billingCurrency", t.BillingCurrency) + populate(objectMap, "consumptionCommitmentDecremented", t.ConsumptionCommitmentDecremented) + populate(objectMap, "subTotal", t.SubTotal) + populate(objectMap, "tax", t.Tax) + populate(objectMap, "total", t.Total) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionsListResult. -func (s *SubscriptionsListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TransactionSummary. +func (t *TransactionSummary) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &s.NextLink) + case "azureCreditApplied": + err = unpopulate(val, "AzureCreditApplied", &t.AzureCreditApplied) + delete(rawMsg, key) + case "billingCurrency": + err = unpopulate(val, "BillingCurrency", &t.BillingCurrency) delete(rawMsg, key) - case "totalCount": - err = unpopulate(val, "TotalCount", &s.TotalCount) + case "consumptionCommitmentDecremented": + err = unpopulate(val, "ConsumptionCommitmentDecremented", &t.ConsumptionCommitmentDecremented) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &s.Value) + case "subTotal": + err = unpopulate(val, "SubTotal", &t.SubTotal) + delete(rawMsg, key) + case "tax": + err = unpopulate(val, "Tax", &t.Tax) + delete(rawMsg, key) + case "total": + err = unpopulate(val, "Total", &t.Total) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Transaction. -func (t Transaction) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TransferDetails. +func (t TransferDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", t.ID) populate(objectMap, "name", t.Name) populate(objectMap, "properties", t.Properties) + populate(objectMap, "systemData", t.SystemData) + populate(objectMap, "tags", t.Tags) populate(objectMap, "type", t.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Transaction. -func (t *Transaction) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TransferDetails. +func (t *TransferDetails) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", t, err) @@ -3801,6 +11129,12 @@ func (t *Transaction) UnmarshalJSON(data []byte) error { case "properties": err = unpopulate(val, "Properties", &t.Properties) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &t.Type) delete(rawMsg, key) @@ -3812,17 +11146,16 @@ func (t *Transaction) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type TransactionListResult. -func (t TransactionListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TransferDetailsListResult. +func (t TransferDetailsListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "nextLink", t.NextLink) - populate(objectMap, "totalCount", t.TotalCount) populate(objectMap, "value", t.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type TransactionListResult. -func (t *TransactionListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TransferDetailsListResult. +func (t *TransferDetailsListResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", t, err) @@ -3833,9 +11166,6 @@ func (t *TransactionListResult) UnmarshalJSON(data []byte) error { case "nextLink": err = unpopulate(val, "NextLink", &t.NextLink) delete(rawMsg, key) - case "totalCount": - err = unpopulate(val, "TotalCount", &t.TotalCount) - delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &t.Value) delete(rawMsg, key) @@ -3847,50 +11177,16 @@ func (t *TransactionListResult) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type TransactionProperties. -func (t TransactionProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TransferError. +func (t TransferError) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "azureCreditApplied", t.AzureCreditApplied) - populate(objectMap, "azurePlan", t.AzurePlan) - populate(objectMap, "billingCurrency", t.BillingCurrency) - populate(objectMap, "billingProfileDisplayName", t.BillingProfileDisplayName) - populate(objectMap, "billingProfileId", t.BillingProfileID) - populate(objectMap, "customerDisplayName", t.CustomerDisplayName) - populate(objectMap, "customerId", t.CustomerID) - populateDateTimeRFC3339(objectMap, "date", t.Date) - populate(objectMap, "discount", t.Discount) - populate(objectMap, "effectivePrice", t.EffectivePrice) - populate(objectMap, "exchangeRate", t.ExchangeRate) - populate(objectMap, "invoice", t.Invoice) - populate(objectMap, "invoiceId", t.InvoiceID) - populate(objectMap, "invoiceSectionDisplayName", t.InvoiceSectionDisplayName) - populate(objectMap, "invoiceSectionId", t.InvoiceSectionID) - populate(objectMap, "kind", t.Kind) - populate(objectMap, "marketPrice", t.MarketPrice) - populate(objectMap, "orderId", t.OrderID) - populate(objectMap, "orderName", t.OrderName) - populate(objectMap, "pricingCurrency", t.PricingCurrency) - populate(objectMap, "productDescription", t.ProductDescription) - populate(objectMap, "productFamily", t.ProductFamily) - populate(objectMap, "productType", t.ProductType) - populate(objectMap, "productTypeId", t.ProductTypeID) - populate(objectMap, "quantity", t.Quantity) - populateDateTimeRFC3339(objectMap, "servicePeriodEndDate", t.ServicePeriodEndDate) - populateDateTimeRFC3339(objectMap, "servicePeriodStartDate", t.ServicePeriodStartDate) - populate(objectMap, "subTotal", t.SubTotal) - populate(objectMap, "subscriptionId", t.SubscriptionID) - populate(objectMap, "subscriptionName", t.SubscriptionName) - populate(objectMap, "tax", t.Tax) - populate(objectMap, "transactionAmount", t.TransactionAmount) - populate(objectMap, "transactionType", t.TransactionType) - populate(objectMap, "unitOfMeasure", t.UnitOfMeasure) - populate(objectMap, "unitType", t.UnitType) - populate(objectMap, "units", t.Units) + populate(objectMap, "code", t.Code) + populate(objectMap, "message", t.Message) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type TransactionProperties. -func (t *TransactionProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TransferError. +func (t *TransferError) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", t, err) @@ -3898,113 +11194,85 @@ func (t *TransactionProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "azureCreditApplied": - err = unpopulate(val, "AzureCreditApplied", &t.AzureCreditApplied) - delete(rawMsg, key) - case "azurePlan": - err = unpopulate(val, "AzurePlan", &t.AzurePlan) - delete(rawMsg, key) - case "billingCurrency": - err = unpopulate(val, "BillingCurrency", &t.BillingCurrency) - delete(rawMsg, key) - case "billingProfileDisplayName": - err = unpopulate(val, "BillingProfileDisplayName", &t.BillingProfileDisplayName) - delete(rawMsg, key) - case "billingProfileId": - err = unpopulate(val, "BillingProfileID", &t.BillingProfileID) - delete(rawMsg, key) - case "customerDisplayName": - err = unpopulate(val, "CustomerDisplayName", &t.CustomerDisplayName) - delete(rawMsg, key) - case "customerId": - err = unpopulate(val, "CustomerID", &t.CustomerID) - delete(rawMsg, key) - case "date": - err = unpopulateDateTimeRFC3339(val, "Date", &t.Date) - delete(rawMsg, key) - case "discount": - err = unpopulate(val, "Discount", &t.Discount) - delete(rawMsg, key) - case "effectivePrice": - err = unpopulate(val, "EffectivePrice", &t.EffectivePrice) - delete(rawMsg, key) - case "exchangeRate": - err = unpopulate(val, "ExchangeRate", &t.ExchangeRate) - delete(rawMsg, key) - case "invoice": - err = unpopulate(val, "Invoice", &t.Invoice) - delete(rawMsg, key) - case "invoiceId": - err = unpopulate(val, "InvoiceID", &t.InvoiceID) - delete(rawMsg, key) - case "invoiceSectionDisplayName": - err = unpopulate(val, "InvoiceSectionDisplayName", &t.InvoiceSectionDisplayName) - delete(rawMsg, key) - case "invoiceSectionId": - err = unpopulate(val, "InvoiceSectionID", &t.InvoiceSectionID) - delete(rawMsg, key) - case "kind": - err = unpopulate(val, "Kind", &t.Kind) - delete(rawMsg, key) - case "marketPrice": - err = unpopulate(val, "MarketPrice", &t.MarketPrice) - delete(rawMsg, key) - case "orderId": - err = unpopulate(val, "OrderID", &t.OrderID) - delete(rawMsg, key) - case "orderName": - err = unpopulate(val, "OrderName", &t.OrderName) - delete(rawMsg, key) - case "pricingCurrency": - err = unpopulate(val, "PricingCurrency", &t.PricingCurrency) - delete(rawMsg, key) - case "productDescription": - err = unpopulate(val, "ProductDescription", &t.ProductDescription) - delete(rawMsg, key) - case "productFamily": - err = unpopulate(val, "ProductFamily", &t.ProductFamily) - delete(rawMsg, key) - case "productType": - err = unpopulate(val, "ProductType", &t.ProductType) - delete(rawMsg, key) - case "productTypeId": - err = unpopulate(val, "ProductTypeID", &t.ProductTypeID) - delete(rawMsg, key) - case "quantity": - err = unpopulate(val, "Quantity", &t.Quantity) - delete(rawMsg, key) - case "servicePeriodEndDate": - err = unpopulateDateTimeRFC3339(val, "ServicePeriodEndDate", &t.ServicePeriodEndDate) - delete(rawMsg, key) - case "servicePeriodStartDate": - err = unpopulateDateTimeRFC3339(val, "ServicePeriodStartDate", &t.ServicePeriodStartDate) - delete(rawMsg, key) - case "subTotal": - err = unpopulate(val, "SubTotal", &t.SubTotal) + case "code": + err = unpopulate(val, "Code", &t.Code) delete(rawMsg, key) - case "subscriptionId": - err = unpopulate(val, "SubscriptionID", &t.SubscriptionID) + case "message": + err = unpopulate(val, "Message", &t.Message) delete(rawMsg, key) - case "subscriptionName": - err = unpopulate(val, "SubscriptionName", &t.SubscriptionName) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TransferItemQueryParameter. +func (t TransferItemQueryParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "state", t.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TransferItemQueryParameter. +func (t *TransferItemQueryParameter) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "state": + err = unpopulate(val, "State", &t.State) delete(rawMsg, key) - case "tax": - err = unpopulate(val, "Tax", &t.Tax) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TransferProperties. +func (t TransferProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "canceledBy", t.CanceledBy) + populate(objectMap, "detailedTransferStatus", t.DetailedTransferStatus) + populateDateTimeRFC3339(objectMap, "expirationTime", t.ExpirationTime) + populate(objectMap, "initiatorEmailId", t.InitiatorEmailID) + populate(objectMap, "recipientEmailId", t.RecipientEmailID) + populate(objectMap, "transferStatus", t.TransferStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TransferProperties. +func (t *TransferProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "canceledBy": + err = unpopulate(val, "CanceledBy", &t.CanceledBy) delete(rawMsg, key) - case "transactionAmount": - err = unpopulate(val, "TransactionAmount", &t.TransactionAmount) + case "detailedTransferStatus": + err = unpopulate(val, "DetailedTransferStatus", &t.DetailedTransferStatus) delete(rawMsg, key) - case "transactionType": - err = unpopulate(val, "TransactionType", &t.TransactionType) + case "expirationTime": + err = unpopulateDateTimeRFC3339(val, "ExpirationTime", &t.ExpirationTime) delete(rawMsg, key) - case "unitOfMeasure": - err = unpopulate(val, "UnitOfMeasure", &t.UnitOfMeasure) + case "initiatorEmailId": + err = unpopulate(val, "InitiatorEmailID", &t.InitiatorEmailID) delete(rawMsg, key) - case "unitType": - err = unpopulate(val, "UnitType", &t.UnitType) + case "recipientEmailId": + err = unpopulate(val, "RecipientEmailID", &t.RecipientEmailID) delete(rawMsg, key) - case "units": - err = unpopulate(val, "Units", &t.Units) + case "transferStatus": + err = unpopulate(val, "TransferStatus", &t.TransferStatus) delete(rawMsg, key) } if err != nil { @@ -4014,15 +11282,16 @@ func (t *TransactionProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type TransferBillingSubscriptionRequestProperties. -func (t TransferBillingSubscriptionRequestProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TransitionDetails. +func (t TransitionDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "destinationInvoiceSectionId", t.DestinationInvoiceSectionID) + populate(objectMap, "anniversaryDay", t.AnniversaryDay) + populateDateTimeRFC3339(objectMap, "transitionDate", t.TransitionDate) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type TransferBillingSubscriptionRequestProperties. -func (t *TransferBillingSubscriptionRequestProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TransitionDetails. +func (t *TransitionDetails) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", t, err) @@ -4030,8 +11299,11 @@ func (t *TransferBillingSubscriptionRequestProperties) UnmarshalJSON(data []byte for key, val := range rawMsg { var err error switch key { - case "destinationInvoiceSectionId": - err = unpopulate(val, "DestinationInvoiceSectionID", &t.DestinationInvoiceSectionID) + case "anniversaryDay": + err = unpopulate(val, "AnniversaryDay", &t.AnniversaryDay) + delete(rawMsg, key) + case "transitionDate": + err = unpopulateDateTimeRFC3339(val, "TransitionDate", &t.TransitionDate) delete(rawMsg, key) } if err != nil { @@ -4041,79 +11313,85 @@ func (t *TransferBillingSubscriptionRequestProperties) UnmarshalJSON(data []byte return nil } -// MarshalJSON implements the json.Marshaller interface for type TransferProductRequestProperties. -func (t TransferProductRequestProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Utilization. +func (u Utilization) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "destinationInvoiceSectionId", t.DestinationInvoiceSectionID) + populate(objectMap, "aggregates", u.Aggregates) + populate(objectMap, "trend", u.Trend) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type TransferProductRequestProperties. -func (t *TransferProductRequestProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Utilization. +func (u *Utilization) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", t, err) + return fmt.Errorf("unmarshalling type %T: %v", u, err) } for key, val := range rawMsg { var err error switch key { - case "destinationInvoiceSectionId": - err = unpopulate(val, "DestinationInvoiceSectionID", &t.DestinationInvoiceSectionID) + case "aggregates": + err = unpopulate(val, "Aggregates", &u.Aggregates) + delete(rawMsg, key) + case "trend": + err = unpopulate(val, "Trend", &u.Trend) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", t, err) + return fmt.Errorf("unmarshalling type %T: %v", u, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ValidateAddressResponse. -func (v ValidateAddressResponse) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type UtilizationAggregates. +func (u UtilizationAggregates) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "status", v.Status) - populate(objectMap, "suggestedAddresses", v.SuggestedAddresses) - populate(objectMap, "validationMessage", v.ValidationMessage) + populate(objectMap, "grain", u.Grain) + populate(objectMap, "grainUnit", u.GrainUnit) + populate(objectMap, "value", u.Value) + populate(objectMap, "valueUnit", u.ValueUnit) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ValidateAddressResponse. -func (v *ValidateAddressResponse) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type UtilizationAggregates. +func (u *UtilizationAggregates) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) + return fmt.Errorf("unmarshalling type %T: %v", u, err) } for key, val := range rawMsg { var err error switch key { - case "status": - err = unpopulate(val, "Status", &v.Status) + case "grain": + err = unpopulate(val, "Grain", &u.Grain) delete(rawMsg, key) - case "suggestedAddresses": - err = unpopulate(val, "SuggestedAddresses", &v.SuggestedAddresses) + case "grainUnit": + err = unpopulate(val, "GrainUnit", &u.GrainUnit) delete(rawMsg, key) - case "validationMessage": - err = unpopulate(val, "ValidationMessage", &v.ValidationMessage) + case "value": + err = unpopulate(val, "Value", &u.Value) + delete(rawMsg, key) + case "valueUnit": + err = unpopulate(val, "ValueUnit", &u.ValueUnit) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) + return fmt.Errorf("unmarshalling type %T: %v", u, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ValidateProductTransferEligibilityError. -func (v ValidateProductTransferEligibilityError) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ValidateTransferListResponse. +func (v ValidateTransferListResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "code", v.Code) - populate(objectMap, "details", v.Details) - populate(objectMap, "message", v.Message) + populate(objectMap, "value", v.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ValidateProductTransferEligibilityError. -func (v *ValidateProductTransferEligibilityError) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ValidateTransferListResponse. +func (v *ValidateTransferListResponse) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", v, err) @@ -4121,14 +11399,8 @@ func (v *ValidateProductTransferEligibilityError) UnmarshalJSON(data []byte) err for key, val := range rawMsg { var err error switch key { - case "code": - err = unpopulate(val, "Code", &v.Code) - delete(rawMsg, key) - case "details": - err = unpopulate(val, "Details", &v.Details) - delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &v.Message) + case "value": + err = unpopulate(val, "Value", &v.Value) delete(rawMsg, key) } if err != nil { @@ -4138,16 +11410,15 @@ func (v *ValidateProductTransferEligibilityError) UnmarshalJSON(data []byte) err return nil } -// MarshalJSON implements the json.Marshaller interface for type ValidateProductTransferEligibilityResult. -func (v ValidateProductTransferEligibilityResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ValidateTransferResponse. +func (v ValidateTransferResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "errorDetails", v.ErrorDetails) - populate(objectMap, "isMoveEligible", v.IsMoveEligible) + populate(objectMap, "properties", v.Properties) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ValidateProductTransferEligibilityResult. -func (v *ValidateProductTransferEligibilityResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ValidateTransferResponse. +func (v *ValidateTransferResponse) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", v, err) @@ -4155,11 +11426,8 @@ func (v *ValidateProductTransferEligibilityResult) UnmarshalJSON(data []byte) er for key, val := range rawMsg { var err error switch key { - case "errorDetails": - err = unpopulate(val, "ErrorDetails", &v.ErrorDetails) - delete(rawMsg, key) - case "isMoveEligible": - err = unpopulate(val, "IsMoveEligible", &v.IsMoveEligible) + case "properties": + err = unpopulate(val, "Properties", &v.Properties) delete(rawMsg, key) } if err != nil { @@ -4169,17 +11437,17 @@ func (v *ValidateProductTransferEligibilityResult) UnmarshalJSON(data []byte) er return nil } -// MarshalJSON implements the json.Marshaller interface for type ValidateSubscriptionTransferEligibilityError. -func (v ValidateSubscriptionTransferEligibilityError) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ValidateTransferResponseProperties. +func (v ValidateTransferResponseProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "code", v.Code) - populate(objectMap, "details", v.Details) - populate(objectMap, "message", v.Message) + populate(objectMap, "productId", v.ProductID) + populate(objectMap, "results", v.Results) + populate(objectMap, "status", v.Status) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ValidateSubscriptionTransferEligibilityError. -func (v *ValidateSubscriptionTransferEligibilityError) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ValidateTransferResponseProperties. +func (v *ValidateTransferResponseProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", v, err) @@ -4187,14 +11455,14 @@ func (v *ValidateSubscriptionTransferEligibilityError) UnmarshalJSON(data []byte for key, val := range rawMsg { var err error switch key { - case "code": - err = unpopulate(val, "Code", &v.Code) + case "productId": + err = unpopulate(val, "ProductID", &v.ProductID) delete(rawMsg, key) - case "details": - err = unpopulate(val, "Details", &v.Details) + case "results": + err = unpopulate(val, "Results", &v.Results) delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &v.Message) + case "status": + err = unpopulate(val, "Status", &v.Status) delete(rawMsg, key) } if err != nil { @@ -4204,16 +11472,17 @@ func (v *ValidateSubscriptionTransferEligibilityError) UnmarshalJSON(data []byte return nil } -// MarshalJSON implements the json.Marshaller interface for type ValidateSubscriptionTransferEligibilityResult. -func (v ValidateSubscriptionTransferEligibilityResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ValidationResultProperties. +func (v ValidationResultProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "errorDetails", v.ErrorDetails) - populate(objectMap, "isMoveEligible", v.IsMoveEligible) + populate(objectMap, "code", v.Code) + populate(objectMap, "level", v.Level) + populate(objectMap, "message", v.Message) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ValidateSubscriptionTransferEligibilityResult. -func (v *ValidateSubscriptionTransferEligibilityResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ValidationResultProperties. +func (v *ValidationResultProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", v, err) @@ -4221,11 +11490,14 @@ func (v *ValidateSubscriptionTransferEligibilityResult) UnmarshalJSON(data []byt for key, val := range rawMsg { var err error switch key { - case "errorDetails": - err = unpopulate(val, "ErrorDetails", &v.ErrorDetails) + case "code": + err = unpopulate(val, "Code", &v.Code) delete(rawMsg, key) - case "isMoveEligible": - err = unpopulate(val, "IsMoveEligible", &v.IsMoveEligible) + case "level": + err = unpopulate(val, "Level", &v.Level) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &v.Message) delete(rawMsg, key) } if err != nil { @@ -4245,8 +11517,18 @@ func populate(m map[string]any, k string, v any) { } } +func populateAny(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else { + m[k] = v + } +} + func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/sdk/resourcemanager/billing/armbilling/operations_client.go b/sdk/resourcemanager/billing/armbilling/operations_client.go index ff0dcda085e9..7c2900a26b2d 100644 --- a/sdk/resourcemanager/billing/armbilling/operations_client.go +++ b/sdk/resourcemanager/billing/armbilling/operations_client.go @@ -10,11 +10,12 @@ package armbilling import ( "context" + "net/http" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" ) // OperationsClient contains the methods for the Operations group. @@ -37,9 +38,9 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO return client, nil } -// NewListPager - Lists the available billing REST API operations. +// NewListPager - List of operations supported by provider. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ @@ -72,7 +73,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/billing/armbilling/operations_client_example_test.go b/sdk/resourcemanager/billing/armbilling/operations_client_example_test.go new file mode 100644 index 000000000000..ed301cbe01bc --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/operations_client_example_test.go @@ -0,0 +1,54 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armbilling_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/operationsList.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.OperationListResult = armbilling.OperationListResult{ + // Value: []*armbilling.Operation{ + // { + // Name: to.Ptr("{namespace}/resource/read"), + // Display: &armbilling.OperationDisplay{ + // Operation: to.Ptr("List resources"), + // Provider: to.Ptr("{namespace}"), + // Resource: to.Ptr("resource"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/billing/armbilling/options.go b/sdk/resourcemanager/billing/armbilling/options.go index b3f7fa7a6c64..3b4d66fe3acc 100644 --- a/sdk/resourcemanager/billing/armbilling/options.go +++ b/sdk/resourcemanager/billing/armbilling/options.go @@ -8,28 +8,96 @@ package armbilling +import "time" + +// AccountsClientBeginAddPaymentTermsOptions contains the optional parameters for the AccountsClient.BeginAddPaymentTerms +// method. +type AccountsClientBeginAddPaymentTermsOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// AccountsClientBeginCancelPaymentTermsOptions contains the optional parameters for the AccountsClient.BeginCancelPaymentTerms +// method. +type AccountsClientBeginCancelPaymentTermsOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + // AccountsClientBeginUpdateOptions contains the optional parameters for the AccountsClient.BeginUpdate method. type AccountsClientBeginUpdateOptions struct { // Resumes the LRO from the provided token. ResumeToken string } +// AccountsClientConfirmTransitionOptions contains the optional parameters for the AccountsClient.ConfirmTransition method. +type AccountsClientConfirmTransitionOptions struct { + // placeholder for future optional parameters +} + // AccountsClientGetOptions contains the optional parameters for the AccountsClient.Get method. type AccountsClientGetOptions struct { - // May be used to expand the soldTo, invoice sections and billing profiles. - Expand *string + // placeholder for future optional parameters } // AccountsClientListInvoiceSectionsByCreateSubscriptionPermissionOptions contains the optional parameters for the AccountsClient.NewListInvoiceSectionsByCreateSubscriptionPermissionPager // method. type AccountsClientListInvoiceSectionsByCreateSubscriptionPermissionOptions struct { - // placeholder for future optional parameters + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string } // AccountsClientListOptions contains the optional parameters for the AccountsClient.NewListPager method. type AccountsClientListOptions struct { - // May be used to expand the soldTo, invoice sections and billing profiles. + // Expand is allowed for SoldTo and EnrollmentDetails/PONumber. Expand *string + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // When true, results will include Billing Accounts that the user does not have a direct role assignment on if the user has + // one of the following AAD roles: Global Administrator, Global Reader, Billing + // Administrator. + IncludeAll *bool + + // When true, results will include Billing Accounts that are not fully created if the user has one of the following AAD roles: + // Global Administrator, Global Reader, Billing Administrator. + IncludeAllWithoutBillingProfiles *bool + + // When true, results will include any billing accounts in a deleted state. + IncludeDeleted *bool + + // Includes billing accounts with agreement pending signature that the user has access to. + IncludePendingAgreement *bool + + // Includes the customer's billing account of Microsoft Partner Agreement that the user has access to. + IncludeResellee *bool + + // Must be combined with legalOwnerTID, results will only include Billing Accounts for whom is legally responsible for the + // Billing Accounts. Optional. + LegalOwnerOID *string + + // Must be combined with legalOwnerOID, results will only include Billing Accounts for whom is legally responsible for the + // Billing Accounts. Optional. + LegalOwnerTID *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 +} + +// AccountsClientValidatePaymentTermsOptions contains the optional parameters for the AccountsClient.ValidatePaymentTerms +// method. +type AccountsClientValidatePaymentTermsOptions struct { + // placeholder for future optional parameters } // AddressClientValidateOptions contains the optional parameters for the AddressClient.Validate method. @@ -39,8 +107,7 @@ type AddressClientValidateOptions struct { // AgreementsClientGetOptions contains the optional parameters for the AgreementsClient.Get method. type AgreementsClientGetOptions struct { - // May be used to expand the participants. - Expand *string + // placeholder for future optional parameters } // AgreementsClientListByBillingAccountOptions contains the optional parameters for the AgreementsClient.NewListByBillingAccountPager @@ -50,61 +117,218 @@ type AgreementsClientListByBillingAccountOptions struct { Expand *string } -// AvailableBalancesClientGetOptions contains the optional parameters for the AvailableBalancesClient.Get method. -type AvailableBalancesClientGetOptions struct { +// AssociatedTenantsClientBeginCreateOrUpdateOptions contains the optional parameters for the AssociatedTenantsClient.BeginCreateOrUpdate +// method. +type AssociatedTenantsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// AssociatedTenantsClientBeginDeleteOptions contains the optional parameters for the AssociatedTenantsClient.BeginDelete +// method. +type AssociatedTenantsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// AssociatedTenantsClientGetOptions contains the optional parameters for the AssociatedTenantsClient.Get method. +type AssociatedTenantsClientGetOptions struct { + // placeholder for future optional parameters +} + +// AssociatedTenantsClientListByBillingAccountOptions contains the optional parameters for the AssociatedTenantsClient.NewListByBillingAccountPager +// method. +type AssociatedTenantsClientListByBillingAccountOptions struct { + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // Can be used to get revoked associated tenants. + IncludeRevoked *bool + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 +} + +// AvailableBalancesClientGetByBillingAccountOptions contains the optional parameters for the AvailableBalancesClient.GetByBillingAccount +// method. +type AvailableBalancesClientGetByBillingAccountOptions struct { + // placeholder for future optional parameters +} + +// AvailableBalancesClientGetByBillingProfileOptions contains the optional parameters for the AvailableBalancesClient.GetByBillingProfile +// method. +type AvailableBalancesClientGetByBillingProfileOptions struct { + // placeholder for future optional parameters +} + +// CustomersClientGetByBillingAccountOptions contains the optional parameters for the CustomersClient.GetByBillingAccount +// method. +type CustomersClientGetByBillingAccountOptions struct { // placeholder for future optional parameters } // CustomersClientGetOptions contains the optional parameters for the CustomersClient.Get method. type CustomersClientGetOptions struct { - // May be used to expand enabledAzurePlans and resellers - Expand *string + // placeholder for future optional parameters } // CustomersClientListByBillingAccountOptions contains the optional parameters for the CustomersClient.NewListByBillingAccountPager // method. type CustomersClientListByBillingAccountOptions struct { - // May be used to filter the list of customers. + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // May be used to expand enabledAzurePlans and resellers + Expand *string + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. Filter *string - // Used for searching customers by their name. Any customer with name containing the search text will be included in the response + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 } // CustomersClientListByBillingProfileOptions contains the optional parameters for the CustomersClient.NewListByBillingProfilePager // method. type CustomersClientListByBillingProfileOptions struct { - // May be used to filter the list of customers. + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // May be used to expand enabledAzurePlans and resellers + Expand *string + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. Filter *string - // Used for searching customers by their name. Any customer with name containing the search text will be included in the response + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 } -// EnrollmentAccountsClientGetOptions contains the optional parameters for the EnrollmentAccountsClient.Get method. -type EnrollmentAccountsClientGetOptions struct { +// DepartmentsClientGetOptions contains the optional parameters for the DepartmentsClient.Get method. +type DepartmentsClientGetOptions struct { // placeholder for future optional parameters } -// EnrollmentAccountsClientListOptions contains the optional parameters for the EnrollmentAccountsClient.NewListPager method. -type EnrollmentAccountsClientListOptions struct { +// DepartmentsClientListByBillingAccountOptions contains the optional parameters for the DepartmentsClient.NewListByBillingAccountPager +// method. +type DepartmentsClientListByBillingAccountOptions struct { + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 +} + +// EnrollmentAccountsClientGetByDepartmentOptions contains the optional parameters for the EnrollmentAccountsClient.GetByDepartment +// method. +type EnrollmentAccountsClientGetByDepartmentOptions struct { // placeholder for future optional parameters } -// InstructionsClientGetOptions contains the optional parameters for the InstructionsClient.Get method. -type InstructionsClientGetOptions struct { +// EnrollmentAccountsClientGetOptions contains the optional parameters for the EnrollmentAccountsClient.Get method. +type EnrollmentAccountsClientGetOptions struct { // placeholder for future optional parameters } -// InstructionsClientListByBillingProfileOptions contains the optional parameters for the InstructionsClient.NewListByBillingProfilePager +// EnrollmentAccountsClientListByBillingAccountOptions contains the optional parameters for the EnrollmentAccountsClient.NewListByBillingAccountPager // method. -type InstructionsClientListByBillingProfileOptions struct { - // placeholder for future optional parameters +type EnrollmentAccountsClientListByBillingAccountOptions struct { + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 } -// InstructionsClientPutOptions contains the optional parameters for the InstructionsClient.Put method. -type InstructionsClientPutOptions struct { - // placeholder for future optional parameters +// EnrollmentAccountsClientListByDepartmentOptions contains the optional parameters for the EnrollmentAccountsClient.NewListByDepartmentPager +// method. +type EnrollmentAccountsClientListByDepartmentOptions struct { + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 } // InvoiceSectionsClientBeginCreateOrUpdateOptions contains the optional parameters for the InvoiceSectionsClient.BeginCreateOrUpdate @@ -114,6 +338,12 @@ type InvoiceSectionsClientBeginCreateOrUpdateOptions struct { ResumeToken string } +// InvoiceSectionsClientBeginDeleteOptions contains the optional parameters for the InvoiceSectionsClient.BeginDelete method. +type InvoiceSectionsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + // InvoiceSectionsClientGetOptions contains the optional parameters for the InvoiceSectionsClient.Get method. type InvoiceSectionsClientGetOptions struct { // placeholder for future optional parameters @@ -122,45 +352,94 @@ type InvoiceSectionsClientGetOptions struct { // InvoiceSectionsClientListByBillingProfileOptions contains the optional parameters for the InvoiceSectionsClient.NewListByBillingProfilePager // method. type InvoiceSectionsClientListByBillingProfileOptions struct { + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // Can be used to get deleted invoice sections. + IncludeDeleted *bool + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 +} + +// InvoiceSectionsClientValidateDeleteEligibilityOptions contains the optional parameters for the InvoiceSectionsClient.ValidateDeleteEligibility +// method. +type InvoiceSectionsClientValidateDeleteEligibilityOptions struct { // placeholder for future optional parameters } -// InvoicesClientBeginDownloadBillingSubscriptionInvoiceOptions contains the optional parameters for the InvoicesClient.BeginDownloadBillingSubscriptionInvoice +// InvoicesClientBeginAmendOptions contains the optional parameters for the InvoicesClient.BeginAmend method. +type InvoicesClientBeginAmendOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// InvoicesClientBeginDownloadByBillingAccountOptions contains the optional parameters for the InvoicesClient.BeginDownloadByBillingAccount +// method. +type InvoicesClientBeginDownloadByBillingAccountOptions struct { + // The ID that uniquely identifies an invoice document. This ID may be an identifier for an invoice PDF, a credit note, or + // a tax receipt. + DocumentName *string + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// InvoicesClientBeginDownloadByBillingSubscriptionOptions contains the optional parameters for the InvoicesClient.BeginDownloadByBillingSubscription // method. -type InvoicesClientBeginDownloadBillingSubscriptionInvoiceOptions struct { +type InvoicesClientBeginDownloadByBillingSubscriptionOptions struct { + // The ID that uniquely identifies an invoice document. This ID may be an identifier for an invoice PDF, a credit note, or + // a tax receipt. + DocumentName *string + // Resumes the LRO from the provided token. ResumeToken string } -// InvoicesClientBeginDownloadInvoiceOptions contains the optional parameters for the InvoicesClient.BeginDownloadInvoice +// InvoicesClientBeginDownloadDocumentsByBillingAccountOptions contains the optional parameters for the InvoicesClient.BeginDownloadDocumentsByBillingAccount // method. -type InvoicesClientBeginDownloadInvoiceOptions struct { +type InvoicesClientBeginDownloadDocumentsByBillingAccountOptions struct { // Resumes the LRO from the provided token. ResumeToken string } -// InvoicesClientBeginDownloadMultipleBillingProfileInvoicesOptions contains the optional parameters for the InvoicesClient.BeginDownloadMultipleBillingProfileInvoices +// InvoicesClientBeginDownloadDocumentsByBillingSubscriptionOptions contains the optional parameters for the InvoicesClient.BeginDownloadDocumentsByBillingSubscription // method. -type InvoicesClientBeginDownloadMultipleBillingProfileInvoicesOptions struct { +type InvoicesClientBeginDownloadDocumentsByBillingSubscriptionOptions struct { // Resumes the LRO from the provided token. ResumeToken string } -// InvoicesClientBeginDownloadMultipleBillingSubscriptionInvoicesOptions contains the optional parameters for the InvoicesClient.BeginDownloadMultipleBillingSubscriptionInvoices +// InvoicesClientBeginDownloadSummaryByBillingAccountOptions contains the optional parameters for the InvoicesClient.BeginDownloadSummaryByBillingAccount // method. -type InvoicesClientBeginDownloadMultipleBillingSubscriptionInvoicesOptions struct { +type InvoicesClientBeginDownloadSummaryByBillingAccountOptions struct { // Resumes the LRO from the provided token. ResumeToken string } -// InvoicesClientGetByIDOptions contains the optional parameters for the InvoicesClient.GetByID method. -type InvoicesClientGetByIDOptions struct { +// InvoicesClientGetByBillingAccountOptions contains the optional parameters for the InvoicesClient.GetByBillingAccount method. +type InvoicesClientGetByBillingAccountOptions struct { // placeholder for future optional parameters } -// InvoicesClientGetBySubscriptionAndInvoiceIDOptions contains the optional parameters for the InvoicesClient.GetBySubscriptionAndInvoiceID +// InvoicesClientGetByBillingSubscriptionOptions contains the optional parameters for the InvoicesClient.GetByBillingSubscription // method. -type InvoicesClientGetBySubscriptionAndInvoiceIDOptions struct { +type InvoicesClientGetByBillingSubscriptionOptions struct { // placeholder for future optional parameters } @@ -172,19 +451,94 @@ type InvoicesClientGetOptions struct { // InvoicesClientListByBillingAccountOptions contains the optional parameters for the InvoicesClient.NewListByBillingAccountPager // method. type InvoicesClientListByBillingAccountOptions struct { - // placeholder for future optional parameters + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The end date of the billing period for which the invoice is generated. The date is in MM-DD-YYYY format. + PeriodEndDate *time.Time + + // The start date of the billing period for which the invoice is generated. The date is in MM-DD-YYYY format. + PeriodStartDate *time.Time + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 } // InvoicesClientListByBillingProfileOptions contains the optional parameters for the InvoicesClient.NewListByBillingProfilePager // method. type InvoicesClientListByBillingProfileOptions struct { - // placeholder for future optional parameters + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The end date of the billing period for which the invoice is generated. The date is in MM-DD-YYYY format. + PeriodEndDate *time.Time + + // The start date of the billing period for which the invoice is generated. The date is in MM-DD-YYYY format. + PeriodStartDate *time.Time + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 } // InvoicesClientListByBillingSubscriptionOptions contains the optional parameters for the InvoicesClient.NewListByBillingSubscriptionPager // method. type InvoicesClientListByBillingSubscriptionOptions struct { - // placeholder for future optional parameters + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The end date of the billing period for which the invoice is generated. The date is in MM-DD-YYYY format. + PeriodEndDate *time.Time + + // The start date of the billing period for which the invoice is generated. The date is in MM-DD-YYYY format. + PeriodStartDate *time.Time + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 } // OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. @@ -192,322 +546,1427 @@ type OperationsClientListOptions struct { // placeholder for future optional parameters } -// PeriodsClientGetOptions contains the optional parameters for the PeriodsClient.Get method. -type PeriodsClientGetOptions struct { +// PartnerTransfersClientCancelOptions contains the optional parameters for the PartnerTransfersClient.Cancel method. +type PartnerTransfersClientCancelOptions struct { // placeholder for future optional parameters } -// PeriodsClientListOptions contains the optional parameters for the PeriodsClient.NewListPager method. -type PeriodsClientListOptions struct { - // May be used to filter billing periods by billingPeriodEndDate. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. - // It does not currently support 'ne', 'or', or 'not'. - Filter *string - - // Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, - // the value of the nextLink element will include a skiptoken parameter that - // specifies a starting point to use for subsequent calls. - Skiptoken *string +// PartnerTransfersClientGetOptions contains the optional parameters for the PartnerTransfersClient.Get method. +type PartnerTransfersClientGetOptions struct { + // placeholder for future optional parameters +} - // May be used to limit the number of results to the most recent N billing periods. - Top *int32 +// PartnerTransfersClientInitiateOptions contains the optional parameters for the PartnerTransfersClient.Initiate method. +type PartnerTransfersClientInitiateOptions struct { + // placeholder for future optional parameters } -// PermissionsClientListByBillingAccountOptions contains the optional parameters for the PermissionsClient.NewListByBillingAccountPager -// method. -type PermissionsClientListByBillingAccountOptions struct { +// PartnerTransfersClientListOptions contains the optional parameters for the PartnerTransfersClient.NewListPager method. +type PartnerTransfersClientListOptions struct { // placeholder for future optional parameters } -// PermissionsClientListByBillingProfileOptions contains the optional parameters for the PermissionsClient.NewListByBillingProfilePager -// method. -type PermissionsClientListByBillingProfileOptions struct { +// PaymentMethodsClientDeleteByUserOptions contains the optional parameters for the PaymentMethodsClient.DeleteByUser method. +type PaymentMethodsClientDeleteByUserOptions struct { // placeholder for future optional parameters } -// PermissionsClientListByCustomerOptions contains the optional parameters for the PermissionsClient.NewListByCustomerPager +// PaymentMethodsClientGetByBillingAccountOptions contains the optional parameters for the PaymentMethodsClient.GetByBillingAccount // method. -type PermissionsClientListByCustomerOptions struct { +type PaymentMethodsClientGetByBillingAccountOptions struct { // placeholder for future optional parameters } -// PermissionsClientListByInvoiceSectionsOptions contains the optional parameters for the PermissionsClient.NewListByInvoiceSectionsPager +// PaymentMethodsClientGetByBillingProfileOptions contains the optional parameters for the PaymentMethodsClient.GetByBillingProfile // method. -type PermissionsClientListByInvoiceSectionsOptions struct { +type PaymentMethodsClientGetByBillingProfileOptions struct { // placeholder for future optional parameters } -// PoliciesClientGetByBillingProfileOptions contains the optional parameters for the PoliciesClient.GetByBillingProfile method. -type PoliciesClientGetByBillingProfileOptions struct { +// PaymentMethodsClientGetByUserOptions contains the optional parameters for the PaymentMethodsClient.GetByUser method. +type PaymentMethodsClientGetByUserOptions struct { // placeholder for future optional parameters } -// PoliciesClientGetByCustomerOptions contains the optional parameters for the PoliciesClient.GetByCustomer method. -type PoliciesClientGetByCustomerOptions struct { +// PaymentMethodsClientListByBillingAccountOptions contains the optional parameters for the PaymentMethodsClient.NewListByBillingAccountPager +// method. +type PaymentMethodsClientListByBillingAccountOptions struct { // placeholder for future optional parameters } -// PoliciesClientUpdateCustomerOptions contains the optional parameters for the PoliciesClient.UpdateCustomer method. -type PoliciesClientUpdateCustomerOptions struct { +// PaymentMethodsClientListByBillingProfileOptions contains the optional parameters for the PaymentMethodsClient.NewListByBillingProfilePager +// method. +type PaymentMethodsClientListByBillingProfileOptions struct { // placeholder for future optional parameters } -// PoliciesClientUpdateOptions contains the optional parameters for the PoliciesClient.Update method. -type PoliciesClientUpdateOptions struct { +// PaymentMethodsClientListByUserOptions contains the optional parameters for the PaymentMethodsClient.NewListByUserPager +// method. +type PaymentMethodsClientListByUserOptions struct { // placeholder for future optional parameters } -// ProductsClientGetOptions contains the optional parameters for the ProductsClient.Get method. -type ProductsClientGetOptions struct { +// PermissionsClientCheckAccessByBillingAccountOptions contains the optional parameters for the PermissionsClient.CheckAccessByBillingAccount +// method. +type PermissionsClientCheckAccessByBillingAccountOptions struct { // placeholder for future optional parameters } -// ProductsClientListByBillingAccountOptions contains the optional parameters for the ProductsClient.NewListByBillingAccountPager +// PermissionsClientCheckAccessByBillingProfileOptions contains the optional parameters for the PermissionsClient.CheckAccessByBillingProfile // method. -type ProductsClientListByBillingAccountOptions struct { - // 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 are separated by a colon (:). - Filter *string +type PermissionsClientCheckAccessByBillingProfileOptions struct { + // placeholder for future optional parameters } -// ProductsClientListByBillingProfileOptions contains the optional parameters for the ProductsClient.NewListByBillingProfilePager +// PermissionsClientCheckAccessByCustomerOptions contains the optional parameters for the PermissionsClient.CheckAccessByCustomer // method. -type ProductsClientListByBillingProfileOptions struct { - // 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 are separated by a colon (:). - Filter *string +type PermissionsClientCheckAccessByCustomerOptions struct { + // placeholder for future optional parameters } -// ProductsClientListByCustomerOptions contains the optional parameters for the ProductsClient.NewListByCustomerPager method. -type ProductsClientListByCustomerOptions struct { +// PermissionsClientCheckAccessByDepartmentOptions contains the optional parameters for the PermissionsClient.CheckAccessByDepartment +// method. +type PermissionsClientCheckAccessByDepartmentOptions struct { // placeholder for future optional parameters } -// ProductsClientListByInvoiceSectionOptions contains the optional parameters for the ProductsClient.NewListByInvoiceSectionPager +// PermissionsClientCheckAccessByEnrollmentAccountOptions contains the optional parameters for the PermissionsClient.CheckAccessByEnrollmentAccount // method. -type ProductsClientListByInvoiceSectionOptions struct { - // 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 are separated by a colon (:). - Filter *string +type PermissionsClientCheckAccessByEnrollmentAccountOptions struct { + // placeholder for future optional parameters } -// ProductsClientMoveOptions contains the optional parameters for the ProductsClient.Move method. -type ProductsClientMoveOptions struct { +// PermissionsClientCheckAccessByInvoiceSectionOptions contains the optional parameters for the PermissionsClient.CheckAccessByInvoiceSection +// method. +type PermissionsClientCheckAccessByInvoiceSectionOptions struct { // placeholder for future optional parameters } -// ProductsClientUpdateOptions contains the optional parameters for the ProductsClient.Update method. -type ProductsClientUpdateOptions struct { +// PermissionsClientListByBillingAccountOptions contains the optional parameters for the PermissionsClient.NewListByBillingAccountPager +// method. +type PermissionsClientListByBillingAccountOptions struct { // placeholder for future optional parameters } -// ProductsClientValidateMoveOptions contains the optional parameters for the ProductsClient.ValidateMove method. -type ProductsClientValidateMoveOptions struct { +// PermissionsClientListByBillingProfileOptions contains the optional parameters for the PermissionsClient.NewListByBillingProfilePager +// method. +type PermissionsClientListByBillingProfileOptions struct { // placeholder for future optional parameters } -// ProfilesClientBeginCreateOrUpdateOptions contains the optional parameters for the ProfilesClient.BeginCreateOrUpdate method. -type ProfilesClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string +// PermissionsClientListByCustomerAtBillingAccountOptions contains the optional parameters for the PermissionsClient.NewListByCustomerAtBillingAccountPager +// method. +type PermissionsClientListByCustomerAtBillingAccountOptions struct { + // placeholder for future optional parameters } -// ProfilesClientGetOptions contains the optional parameters for the ProfilesClient.Get method. -type ProfilesClientGetOptions struct { - // May be used to expand the invoice sections. - Expand *string +// PermissionsClientListByCustomerOptions contains the optional parameters for the PermissionsClient.NewListByCustomerPager +// method. +type PermissionsClientListByCustomerOptions struct { + // placeholder for future optional parameters } -// ProfilesClientListByBillingAccountOptions contains the optional parameters for the ProfilesClient.NewListByBillingAccountPager +// PermissionsClientListByDepartmentOptions contains the optional parameters for the PermissionsClient.NewListByDepartmentPager // method. -type ProfilesClientListByBillingAccountOptions struct { - // May be used to expand the invoice sections. - Expand *string +type PermissionsClientListByDepartmentOptions struct { + // placeholder for future optional parameters } -// PropertyClientGetOptions contains the optional parameters for the PropertyClient.Get method. -type PropertyClientGetOptions struct { +// PermissionsClientListByEnrollmentAccountOptions contains the optional parameters for the PermissionsClient.NewListByEnrollmentAccountPager +// method. +type PermissionsClientListByEnrollmentAccountOptions struct { // placeholder for future optional parameters } -// PropertyClientUpdateOptions contains the optional parameters for the PropertyClient.Update method. -type PropertyClientUpdateOptions struct { +// PermissionsClientListByInvoiceSectionOptions contains the optional parameters for the PermissionsClient.NewListByInvoiceSectionPager +// method. +type PermissionsClientListByInvoiceSectionOptions struct { // placeholder for future optional parameters } -// ReservationsClientListByBillingAccountOptions contains the optional parameters for the ReservationsClient.NewListByBillingAccountPager +// PoliciesClientBeginCreateOrUpdateByBillingAccountOptions contains the optional parameters for the PoliciesClient.BeginCreateOrUpdateByBillingAccount // method. -type ReservationsClientListByBillingAccountOptions struct { - // May be used to filter by reservation properties. The filter supports 'eq', 'or', and 'and'. It does not currently support - // 'ne', 'gt', 'le', 'ge', or 'not'. - Filter *string +type PoliciesClientBeginCreateOrUpdateByBillingAccountOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} - // May be used to sort order by reservation properties. - Orderby *string +// PoliciesClientBeginCreateOrUpdateByBillingProfileOptions contains the optional parameters for the PoliciesClient.BeginCreateOrUpdateByBillingProfile +// method. +type PoliciesClientBeginCreateOrUpdateByBillingProfileOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} - // To indicate whether to refresh the roll up counts of the reservations group by provisioning states +// PoliciesClientBeginCreateOrUpdateByCustomerAtBillingAccountOptions contains the optional parameters for the PoliciesClient.BeginCreateOrUpdateByCustomerAtBillingAccount +// method. +type PoliciesClientBeginCreateOrUpdateByCustomerAtBillingAccountOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PoliciesClientBeginCreateOrUpdateByCustomerOptions contains the optional parameters for the PoliciesClient.BeginCreateOrUpdateByCustomer +// method. +type PoliciesClientBeginCreateOrUpdateByCustomerOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PoliciesClientGetByBillingAccountOptions contains the optional parameters for the PoliciesClient.GetByBillingAccount method. +type PoliciesClientGetByBillingAccountOptions struct { + // placeholder for future optional parameters +} + +// PoliciesClientGetByBillingProfileOptions contains the optional parameters for the PoliciesClient.GetByBillingProfile method. +type PoliciesClientGetByBillingProfileOptions struct { + // placeholder for future optional parameters +} + +// PoliciesClientGetByCustomerAtBillingAccountOptions contains the optional parameters for the PoliciesClient.GetByCustomerAtBillingAccount +// method. +type PoliciesClientGetByCustomerAtBillingAccountOptions struct { + // placeholder for future optional parameters +} + +// PoliciesClientGetByCustomerOptions contains the optional parameters for the PoliciesClient.GetByCustomer method. +type PoliciesClientGetByCustomerOptions struct { + // placeholder for future optional parameters +} + +// PoliciesClientGetBySubscriptionOptions contains the optional parameters for the PoliciesClient.GetBySubscription method. +type PoliciesClientGetBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// ProductsClientBeginMoveOptions contains the optional parameters for the ProductsClient.BeginMove method. +type ProductsClientBeginMoveOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ProductsClientGetOptions contains the optional parameters for the ProductsClient.Get method. +type ProductsClientGetOptions struct { + // placeholder for future optional parameters +} + +// ProductsClientListByBillingAccountOptions contains the optional parameters for the ProductsClient.NewListByBillingAccountPager +// method. +type ProductsClientListByBillingAccountOptions struct { + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 +} + +// ProductsClientListByBillingProfileOptions contains the optional parameters for the ProductsClient.NewListByBillingProfilePager +// method. +type ProductsClientListByBillingProfileOptions struct { + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 +} + +// ProductsClientListByCustomerOptions contains the optional parameters for the ProductsClient.NewListByCustomerPager method. +type ProductsClientListByCustomerOptions struct { + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 +} + +// ProductsClientListByInvoiceSectionOptions contains the optional parameters for the ProductsClient.NewListByInvoiceSectionPager +// method. +type ProductsClientListByInvoiceSectionOptions struct { + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 +} + +// ProductsClientUpdateOptions contains the optional parameters for the ProductsClient.Update method. +type ProductsClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// ProductsClientValidateMoveEligibilityOptions contains the optional parameters for the ProductsClient.ValidateMoveEligibility +// method. +type ProductsClientValidateMoveEligibilityOptions struct { + // placeholder for future optional parameters +} + +// ProfilesClientBeginCreateOrUpdateOptions contains the optional parameters for the ProfilesClient.BeginCreateOrUpdate method. +type ProfilesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ProfilesClientBeginDeleteOptions contains the optional parameters for the ProfilesClient.BeginDelete method. +type ProfilesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ProfilesClientGetOptions contains the optional parameters for the ProfilesClient.Get method. +type ProfilesClientGetOptions struct { + // placeholder for future optional parameters +} + +// ProfilesClientListByBillingAccountOptions contains the optional parameters for the ProfilesClient.NewListByBillingAccountPager +// method. +type ProfilesClientListByBillingAccountOptions struct { + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // Can be used to get deleted billing profiles. + IncludeDeleted *bool + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 +} + +// ProfilesClientValidateDeleteEligibilityOptions contains the optional parameters for the ProfilesClient.ValidateDeleteEligibility +// method. +type ProfilesClientValidateDeleteEligibilityOptions struct { + // placeholder for future optional parameters +} + +// PropertyClientGetOptions contains the optional parameters for the PropertyClient.Get method. +type PropertyClientGetOptions struct { + // A flag that specifies whether or not to include billing country. + IncludeBillingCountry *bool + + // A flag that specifies whether or not to include transition status for billing accounts with agreement type Microsoft Customer + // Agreement. + IncludeTransitionStatus *bool +} + +// PropertyClientUpdateOptions contains the optional parameters for the PropertyClient.Update method. +type PropertyClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// RecipientTransfersClientAcceptOptions contains the optional parameters for the RecipientTransfersClient.Accept method. +type RecipientTransfersClientAcceptOptions struct { + // placeholder for future optional parameters +} + +// RecipientTransfersClientDeclineOptions contains the optional parameters for the RecipientTransfersClient.Decline method. +type RecipientTransfersClientDeclineOptions struct { + // placeholder for future optional parameters +} + +// RecipientTransfersClientGetOptions contains the optional parameters for the RecipientTransfersClient.Get method. +type RecipientTransfersClientGetOptions struct { + // placeholder for future optional parameters +} + +// RecipientTransfersClientListOptions contains the optional parameters for the RecipientTransfersClient.NewListPager method. +type RecipientTransfersClientListOptions struct { + // placeholder for future optional parameters +} + +// RecipientTransfersClientValidateOptions contains the optional parameters for the RecipientTransfersClient.Validate method. +type RecipientTransfersClientValidateOptions struct { + // placeholder for future optional parameters +} + +// RequestsClientBeginCreateOrUpdateOptions contains the optional parameters for the RequestsClient.BeginCreateOrUpdate method. +type RequestsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// RequestsClientGetOptions contains the optional parameters for the RequestsClient.Get method. +type RequestsClientGetOptions struct { + // placeholder for future optional parameters +} + +// RequestsClientListByBillingAccountOptions contains the optional parameters for the RequestsClient.NewListByBillingAccountPager +// method. +type RequestsClientListByBillingAccountOptions struct { + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 +} + +// RequestsClientListByBillingProfileOptions contains the optional parameters for the RequestsClient.NewListByBillingProfilePager +// method. +type RequestsClientListByBillingProfileOptions struct { + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 +} + +// RequestsClientListByCustomerOptions contains the optional parameters for the RequestsClient.NewListByCustomerPager method. +type RequestsClientListByCustomerOptions struct { + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 +} + +// RequestsClientListByInvoiceSectionOptions contains the optional parameters for the RequestsClient.NewListByInvoiceSectionPager +// method. +type RequestsClientListByInvoiceSectionOptions struct { + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 +} + +// RequestsClientListByUserOptions contains the optional parameters for the RequestsClient.NewListByUserPager method. +type RequestsClientListByUserOptions struct { + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 +} + +// ReservationOrdersClientGetByBillingAccountOptions contains the optional parameters for the ReservationOrdersClient.GetByBillingAccount +// method. +type ReservationOrdersClientGetByBillingAccountOptions struct { + // May be used to expand the detail information of some properties. + Expand *string +} + +// ReservationOrdersClientListByBillingAccountOptions contains the optional parameters for the ReservationOrdersClient.NewListByBillingAccountPager +// method. +type ReservationOrdersClientListByBillingAccountOptions struct { + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The number of reservations to skip from the list before returning results + Skiptoken *float32 +} + +// ReservationsClientBeginUpdateByBillingAccountOptions contains the optional parameters for the ReservationsClient.BeginUpdateByBillingAccount +// method. +type ReservationsClientBeginUpdateByBillingAccountOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ReservationsClientGetByReservationOrderOptions contains the optional parameters for the ReservationsClient.GetByReservationOrder +// method. +type ReservationsClientGetByReservationOrderOptions struct { + // May be used to expand the detail information of some properties. + Expand *string +} + +// ReservationsClientListByBillingAccountOptions contains the optional parameters for the ReservationsClient.NewListByBillingAccountPager +// method. +type ReservationsClientListByBillingAccountOptions struct { + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // To indicate whether to refresh the roll up counts of the reservations group by provisioning states + RefreshSummary *string + + // The selected provisioning state + SelectedState *string + + // The number of reservations to skip from the list before returning results + Skiptoken *float32 + + // The number of reservations to return in API response. + Take *float32 +} + +// ReservationsClientListByBillingProfileOptions contains the optional parameters for the ReservationsClient.NewListByBillingProfilePager +// method. +type ReservationsClientListByBillingProfileOptions struct { + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // To indicate whether to refresh the roll up counts of the reservations group by provisioning states RefreshSummary *string - // The selected provisioning state - SelectedState *string + // The selected provisioning state + SelectedState *string + + // The number of reservations to skip from the list before returning results + Skiptoken *float32 + + // The number of reservations to return in API response. + Take *float32 +} + +// ReservationsClientListByReservationOrderOptions contains the optional parameters for the ReservationsClient.NewListByReservationOrderPager +// method. +type ReservationsClientListByReservationOrderOptions struct { + // placeholder for future optional parameters +} + +// RoleAssignmentsClientBeginCreateByBillingAccountOptions contains the optional parameters for the RoleAssignmentsClient.BeginCreateByBillingAccount +// method. +type RoleAssignmentsClientBeginCreateByBillingAccountOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// RoleAssignmentsClientBeginCreateByBillingProfileOptions contains the optional parameters for the RoleAssignmentsClient.BeginCreateByBillingProfile +// method. +type RoleAssignmentsClientBeginCreateByBillingProfileOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// RoleAssignmentsClientBeginCreateByCustomerOptions contains the optional parameters for the RoleAssignmentsClient.BeginCreateByCustomer +// method. +type RoleAssignmentsClientBeginCreateByCustomerOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// RoleAssignmentsClientBeginCreateByInvoiceSectionOptions contains the optional parameters for the RoleAssignmentsClient.BeginCreateByInvoiceSection +// method. +type RoleAssignmentsClientBeginCreateByInvoiceSectionOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// RoleAssignmentsClientBeginCreateOrUpdateByBillingAccountOptions contains the optional parameters for the RoleAssignmentsClient.BeginCreateOrUpdateByBillingAccount +// method. +type RoleAssignmentsClientBeginCreateOrUpdateByBillingAccountOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// RoleAssignmentsClientBeginCreateOrUpdateByDepartmentOptions contains the optional parameters for the RoleAssignmentsClient.BeginCreateOrUpdateByDepartment +// method. +type RoleAssignmentsClientBeginCreateOrUpdateByDepartmentOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// RoleAssignmentsClientBeginCreateOrUpdateByEnrollmentAccountOptions contains the optional parameters for the RoleAssignmentsClient.BeginCreateOrUpdateByEnrollmentAccount +// method. +type RoleAssignmentsClientBeginCreateOrUpdateByEnrollmentAccountOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// RoleAssignmentsClientBeginResolveByBillingAccountOptions contains the optional parameters for the RoleAssignmentsClient.BeginResolveByBillingAccount +// method. +type RoleAssignmentsClientBeginResolveByBillingAccountOptions struct { + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // Resolves the scope display name for each of the role assignments. + ResolveScopeDisplayNames *bool + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// RoleAssignmentsClientBeginResolveByBillingProfileOptions contains the optional parameters for the RoleAssignmentsClient.BeginResolveByBillingProfile +// method. +type RoleAssignmentsClientBeginResolveByBillingProfileOptions struct { + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // Resolves the scope display name for each of the role assignments. + ResolveScopeDisplayNames *bool + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// RoleAssignmentsClientBeginResolveByCustomerOptions contains the optional parameters for the RoleAssignmentsClient.BeginResolveByCustomer +// method. +type RoleAssignmentsClientBeginResolveByCustomerOptions struct { + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // Resolves the scope display name for each of the role assignments. + ResolveScopeDisplayNames *bool + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// RoleAssignmentsClientBeginResolveByInvoiceSectionOptions contains the optional parameters for the RoleAssignmentsClient.BeginResolveByInvoiceSection +// method. +type RoleAssignmentsClientBeginResolveByInvoiceSectionOptions struct { + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // Resolves the scope display name for each of the role assignments. + ResolveScopeDisplayNames *bool + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// RoleAssignmentsClientDeleteByBillingAccountOptions contains the optional parameters for the RoleAssignmentsClient.DeleteByBillingAccount +// method. +type RoleAssignmentsClientDeleteByBillingAccountOptions struct { + // placeholder for future optional parameters +} + +// RoleAssignmentsClientDeleteByBillingProfileOptions contains the optional parameters for the RoleAssignmentsClient.DeleteByBillingProfile +// method. +type RoleAssignmentsClientDeleteByBillingProfileOptions struct { + // placeholder for future optional parameters +} + +// RoleAssignmentsClientDeleteByCustomerOptions contains the optional parameters for the RoleAssignmentsClient.DeleteByCustomer +// method. +type RoleAssignmentsClientDeleteByCustomerOptions struct { + // placeholder for future optional parameters +} + +// RoleAssignmentsClientDeleteByDepartmentOptions contains the optional parameters for the RoleAssignmentsClient.DeleteByDepartment +// method. +type RoleAssignmentsClientDeleteByDepartmentOptions struct { + // placeholder for future optional parameters +} + +// RoleAssignmentsClientDeleteByEnrollmentAccountOptions contains the optional parameters for the RoleAssignmentsClient.DeleteByEnrollmentAccount +// method. +type RoleAssignmentsClientDeleteByEnrollmentAccountOptions struct { + // placeholder for future optional parameters +} + +// RoleAssignmentsClientDeleteByInvoiceSectionOptions contains the optional parameters for the RoleAssignmentsClient.DeleteByInvoiceSection +// method. +type RoleAssignmentsClientDeleteByInvoiceSectionOptions struct { + // placeholder for future optional parameters +} + +// RoleAssignmentsClientGetByBillingAccountOptions contains the optional parameters for the RoleAssignmentsClient.GetByBillingAccount +// method. +type RoleAssignmentsClientGetByBillingAccountOptions struct { + // placeholder for future optional parameters +} + +// RoleAssignmentsClientGetByBillingProfileOptions contains the optional parameters for the RoleAssignmentsClient.GetByBillingProfile +// method. +type RoleAssignmentsClientGetByBillingProfileOptions struct { + // placeholder for future optional parameters +} + +// RoleAssignmentsClientGetByCustomerOptions contains the optional parameters for the RoleAssignmentsClient.GetByCustomer +// method. +type RoleAssignmentsClientGetByCustomerOptions struct { + // placeholder for future optional parameters +} + +// RoleAssignmentsClientGetByDepartmentOptions contains the optional parameters for the RoleAssignmentsClient.GetByDepartment +// method. +type RoleAssignmentsClientGetByDepartmentOptions struct { + // placeholder for future optional parameters +} + +// RoleAssignmentsClientGetByEnrollmentAccountOptions contains the optional parameters for the RoleAssignmentsClient.GetByEnrollmentAccount +// method. +type RoleAssignmentsClientGetByEnrollmentAccountOptions struct { + // placeholder for future optional parameters +} + +// RoleAssignmentsClientGetByInvoiceSectionOptions contains the optional parameters for the RoleAssignmentsClient.GetByInvoiceSection +// method. +type RoleAssignmentsClientGetByInvoiceSectionOptions struct { + // placeholder for future optional parameters +} + +// RoleAssignmentsClientListByBillingAccountOptions contains the optional parameters for the RoleAssignmentsClient.NewListByBillingAccountPager +// method. +type RoleAssignmentsClientListByBillingAccountOptions struct { + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 } -// ReservationsClientListByBillingProfileOptions contains the optional parameters for the ReservationsClient.NewListByBillingProfilePager +// RoleAssignmentsClientListByBillingProfileOptions contains the optional parameters for the RoleAssignmentsClient.NewListByBillingProfilePager // method. -type ReservationsClientListByBillingProfileOptions struct { - // May be used to filter by reservation properties. The filter supports 'eq', 'or', and 'and'. It does not currently support - // 'ne', 'gt', 'le', 'ge', or 'not'. +type RoleAssignmentsClientListByBillingProfileOptions struct { + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. Filter *string - // May be used to sort order by reservation properties. - Orderby *string + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 - // To indicate whether to refresh the roll up counts of the reservations group by provisioning state - RefreshSummary *string + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 +} - // The selected provisioning state - SelectedState *string +// RoleAssignmentsClientListByCustomerOptions contains the optional parameters for the RoleAssignmentsClient.NewListByCustomerPager +// method. +type RoleAssignmentsClientListByCustomerOptions struct { + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 } -// RoleAssignmentsClientDeleteByBillingAccountOptions contains the optional parameters for the RoleAssignmentsClient.DeleteByBillingAccount +// RoleAssignmentsClientListByDepartmentOptions contains the optional parameters for the RoleAssignmentsClient.NewListByDepartmentPager // method. -type RoleAssignmentsClientDeleteByBillingAccountOptions struct { +type RoleAssignmentsClientListByDepartmentOptions struct { // placeholder for future optional parameters } -// RoleAssignmentsClientDeleteByBillingProfileOptions contains the optional parameters for the RoleAssignmentsClient.DeleteByBillingProfile +// RoleAssignmentsClientListByEnrollmentAccountOptions contains the optional parameters for the RoleAssignmentsClient.NewListByEnrollmentAccountPager // method. -type RoleAssignmentsClientDeleteByBillingProfileOptions struct { +type RoleAssignmentsClientListByEnrollmentAccountOptions struct { // placeholder for future optional parameters } -// RoleAssignmentsClientDeleteByInvoiceSectionOptions contains the optional parameters for the RoleAssignmentsClient.DeleteByInvoiceSection +// RoleAssignmentsClientListByInvoiceSectionOptions contains the optional parameters for the RoleAssignmentsClient.NewListByInvoiceSectionPager // method. -type RoleAssignmentsClientDeleteByInvoiceSectionOptions struct { +type RoleAssignmentsClientListByInvoiceSectionOptions struct { + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 +} + +// RoleDefinitionClientGetByBillingAccountOptions contains the optional parameters for the RoleDefinitionClient.GetByBillingAccount +// method. +type RoleDefinitionClientGetByBillingAccountOptions struct { // placeholder for future optional parameters } -// RoleAssignmentsClientGetByBillingAccountOptions contains the optional parameters for the RoleAssignmentsClient.GetByBillingAccount +// RoleDefinitionClientGetByBillingProfileOptions contains the optional parameters for the RoleDefinitionClient.GetByBillingProfile // method. -type RoleAssignmentsClientGetByBillingAccountOptions struct { +type RoleDefinitionClientGetByBillingProfileOptions struct { // placeholder for future optional parameters } -// RoleAssignmentsClientGetByBillingProfileOptions contains the optional parameters for the RoleAssignmentsClient.GetByBillingProfile +// RoleDefinitionClientGetByCustomerOptions contains the optional parameters for the RoleDefinitionClient.GetByCustomer method. +type RoleDefinitionClientGetByCustomerOptions struct { + // placeholder for future optional parameters +} + +// RoleDefinitionClientGetByDepartmentOptions contains the optional parameters for the RoleDefinitionClient.GetByDepartment // method. -type RoleAssignmentsClientGetByBillingProfileOptions struct { +type RoleDefinitionClientGetByDepartmentOptions struct { // placeholder for future optional parameters } -// RoleAssignmentsClientGetByInvoiceSectionOptions contains the optional parameters for the RoleAssignmentsClient.GetByInvoiceSection +// RoleDefinitionClientGetByEnrollmentAccountOptions contains the optional parameters for the RoleDefinitionClient.GetByEnrollmentAccount // method. -type RoleAssignmentsClientGetByInvoiceSectionOptions struct { +type RoleDefinitionClientGetByEnrollmentAccountOptions struct { // placeholder for future optional parameters } -// RoleAssignmentsClientListByBillingAccountOptions contains the optional parameters for the RoleAssignmentsClient.NewListByBillingAccountPager +// RoleDefinitionClientGetByInvoiceSectionOptions contains the optional parameters for the RoleDefinitionClient.GetByInvoiceSection // method. -type RoleAssignmentsClientListByBillingAccountOptions struct { +type RoleDefinitionClientGetByInvoiceSectionOptions struct { // placeholder for future optional parameters } -// RoleAssignmentsClientListByBillingProfileOptions contains the optional parameters for the RoleAssignmentsClient.NewListByBillingProfilePager +// RoleDefinitionClientListByBillingAccountOptions contains the optional parameters for the RoleDefinitionClient.NewListByBillingAccountPager // method. -type RoleAssignmentsClientListByBillingProfileOptions struct { +type RoleDefinitionClientListByBillingAccountOptions struct { // placeholder for future optional parameters } -// RoleAssignmentsClientListByInvoiceSectionOptions contains the optional parameters for the RoleAssignmentsClient.NewListByInvoiceSectionPager +// RoleDefinitionClientListByBillingProfileOptions contains the optional parameters for the RoleDefinitionClient.NewListByBillingProfilePager // method. -type RoleAssignmentsClientListByInvoiceSectionOptions struct { +type RoleDefinitionClientListByBillingProfileOptions struct { + // placeholder for future optional parameters +} + +// RoleDefinitionClientListByCustomerOptions contains the optional parameters for the RoleDefinitionClient.NewListByCustomerPager +// method. +type RoleDefinitionClientListByCustomerOptions struct { // placeholder for future optional parameters } -// RoleDefinitionsClientGetByBillingAccountOptions contains the optional parameters for the RoleDefinitionsClient.GetByBillingAccount +// RoleDefinitionClientListByDepartmentOptions contains the optional parameters for the RoleDefinitionClient.NewListByDepartmentPager // method. -type RoleDefinitionsClientGetByBillingAccountOptions struct { +type RoleDefinitionClientListByDepartmentOptions struct { // placeholder for future optional parameters } -// RoleDefinitionsClientGetByBillingProfileOptions contains the optional parameters for the RoleDefinitionsClient.GetByBillingProfile +// RoleDefinitionClientListByEnrollmentAccountOptions contains the optional parameters for the RoleDefinitionClient.NewListByEnrollmentAccountPager // method. -type RoleDefinitionsClientGetByBillingProfileOptions struct { +type RoleDefinitionClientListByEnrollmentAccountOptions struct { // placeholder for future optional parameters } -// RoleDefinitionsClientGetByInvoiceSectionOptions contains the optional parameters for the RoleDefinitionsClient.GetByInvoiceSection +// RoleDefinitionClientListByInvoiceSectionOptions contains the optional parameters for the RoleDefinitionClient.NewListByInvoiceSectionPager // method. -type RoleDefinitionsClientGetByInvoiceSectionOptions struct { +type RoleDefinitionClientListByInvoiceSectionOptions struct { // placeholder for future optional parameters } -// RoleDefinitionsClientListByBillingAccountOptions contains the optional parameters for the RoleDefinitionsClient.NewListByBillingAccountPager +// SavingsPlanOrdersClientGetByBillingAccountOptions contains the optional parameters for the SavingsPlanOrdersClient.GetByBillingAccount +// method. +type SavingsPlanOrdersClientGetByBillingAccountOptions struct { + // May be used to expand the planInformation. + Expand *string +} + +// SavingsPlanOrdersClientListByBillingAccountOptions contains the optional parameters for the SavingsPlanOrdersClient.NewListByBillingAccountPager +// method. +type SavingsPlanOrdersClientListByBillingAccountOptions struct { + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The number of savings plans to skip from the list before returning results + Skiptoken *float32 +} + +// SavingsPlansClientBeginUpdateByBillingAccountOptions contains the optional parameters for the SavingsPlansClient.BeginUpdateByBillingAccount +// method. +type SavingsPlansClientBeginUpdateByBillingAccountOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SavingsPlansClientGetByBillingAccountOptions contains the optional parameters for the SavingsPlansClient.GetByBillingAccount +// method. +type SavingsPlansClientGetByBillingAccountOptions struct { + // May be used to expand the planInformation. + Expand *string +} + +// SavingsPlansClientListByBillingAccountOptions contains the optional parameters for the SavingsPlansClient.NewListByBillingAccountPager +// method. +type SavingsPlansClientListByBillingAccountOptions struct { + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // To indicate whether to refresh the roll up counts of the savings plans group by provisioning states + RefreshSummary *string + + // The selected provisioning state + SelectedState *string + + // The number of savings plans to skip from the list before returning results + Skiptoken *float32 + + // The number of savings plans to return + Take *float32 +} + +// SavingsPlansClientListBySavingsPlanOrderOptions contains the optional parameters for the SavingsPlansClient.NewListBySavingsPlanOrderPager // method. -type RoleDefinitionsClientListByBillingAccountOptions struct { +type SavingsPlansClientListBySavingsPlanOrderOptions struct { // placeholder for future optional parameters } -// RoleDefinitionsClientListByBillingProfileOptions contains the optional parameters for the RoleDefinitionsClient.NewListByBillingProfilePager +// SavingsPlansClientValidateUpdateByBillingAccountOptions contains the optional parameters for the SavingsPlansClient.ValidateUpdateByBillingAccount // method. -type RoleDefinitionsClientListByBillingProfileOptions struct { +type SavingsPlansClientValidateUpdateByBillingAccountOptions struct { // placeholder for future optional parameters } -// RoleDefinitionsClientListByInvoiceSectionOptions contains the optional parameters for the RoleDefinitionsClient.NewListByInvoiceSectionPager +// SubscriptionsAliasesClientBeginCreateOrUpdateOptions contains the optional parameters for the SubscriptionsAliasesClient.BeginCreateOrUpdate // method. -type RoleDefinitionsClientListByInvoiceSectionOptions struct { +type SubscriptionsAliasesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SubscriptionsAliasesClientGetOptions contains the optional parameters for the SubscriptionsAliasesClient.Get method. +type SubscriptionsAliasesClientGetOptions struct { // placeholder for future optional parameters } +// SubscriptionsAliasesClientListByBillingAccountOptions contains the optional parameters for the SubscriptionsAliasesClient.NewListByBillingAccountPager +// method. +type SubscriptionsAliasesClientListByBillingAccountOptions struct { + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // Can be used to get deleted billing subscriptions. + IncludeDeleted *bool + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 +} + +// SubscriptionsClientBeginCancelOptions contains the optional parameters for the SubscriptionsClient.BeginCancel method. +type SubscriptionsClientBeginCancelOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SubscriptionsClientBeginDeleteOptions contains the optional parameters for the SubscriptionsClient.BeginDelete method. +type SubscriptionsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SubscriptionsClientBeginMergeOptions contains the optional parameters for the SubscriptionsClient.BeginMerge method. +type SubscriptionsClientBeginMergeOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + // SubscriptionsClientBeginMoveOptions contains the optional parameters for the SubscriptionsClient.BeginMove method. type SubscriptionsClientBeginMoveOptions struct { // Resumes the LRO from the provided token. ResumeToken string } +// SubscriptionsClientBeginSplitOptions contains the optional parameters for the SubscriptionsClient.BeginSplit method. +type SubscriptionsClientBeginSplitOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SubscriptionsClientBeginUpdateOptions contains the optional parameters for the SubscriptionsClient.BeginUpdate method. +type SubscriptionsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SubscriptionsClientGetByBillingProfileOptions contains the optional parameters for the SubscriptionsClient.GetByBillingProfile +// method. +type SubscriptionsClientGetByBillingProfileOptions struct { + // Can be used to expand Reseller, ConsumptionCostCenter, LastMonthCharges and MonthToDateCharges + Expand *string +} + // SubscriptionsClientGetOptions contains the optional parameters for the SubscriptionsClient.Get method. type SubscriptionsClientGetOptions struct { - // placeholder for future optional parameters + // Can be used to expand Reseller, ConsumptionCostCenter, LastMonthCharges and MonthToDateCharges + Expand *string } // SubscriptionsClientListByBillingAccountOptions contains the optional parameters for the SubscriptionsClient.NewListByBillingAccountPager // method. type SubscriptionsClientListByBillingAccountOptions struct { - // placeholder for future optional parameters + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // Can be used to expand Reseller, ConsumptionCostCenter, LastMonthCharges and MonthToDateCharges + Expand *string + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // Can be used to get deleted billing subscriptions. + IncludeDeleted *bool + + // Can be used to get failed billing subscriptions. + IncludeFailed *bool + + // Can be used to get tenant-owned billing subscriptions. This field is only applies to Microsoft Online Services Program + // billing accounts. + IncludeTenantSubscriptions *bool + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 } // SubscriptionsClientListByBillingProfileOptions contains the optional parameters for the SubscriptionsClient.NewListByBillingProfilePager // method. type SubscriptionsClientListByBillingProfileOptions struct { - // placeholder for future optional parameters + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // Can be used to expand Reseller, ConsumptionCostCenter, LastMonthCharges and MonthToDateCharges + Expand *string + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // Can be used to get deleted billing subscriptions. + IncludeDeleted *bool + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 +} + +// SubscriptionsClientListByCustomerAtBillingAccountOptions contains the optional parameters for the SubscriptionsClient.NewListByCustomerAtBillingAccountPager +// method. +type SubscriptionsClientListByCustomerAtBillingAccountOptions struct { + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // Can be used to expand Reseller, ConsumptionCostCenter, LastMonthCharges and MonthToDateCharges + Expand *string + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // Can be used to get deleted billing subscriptions. + IncludeDeleted *bool + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 } // SubscriptionsClientListByCustomerOptions contains the optional parameters for the SubscriptionsClient.NewListByCustomerPager // method. type SubscriptionsClientListByCustomerOptions struct { - // placeholder for future optional parameters + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // Can be used to expand Reseller, ConsumptionCostCenter, LastMonthCharges and MonthToDateCharges + Expand *string + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // Can be used to get deleted billing subscriptions. + IncludeDeleted *bool + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 +} + +// SubscriptionsClientListByEnrollmentAccountOptions contains the optional parameters for the SubscriptionsClient.NewListByEnrollmentAccountPager +// method. +type SubscriptionsClientListByEnrollmentAccountOptions struct { + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 } // SubscriptionsClientListByInvoiceSectionOptions contains the optional parameters for the SubscriptionsClient.NewListByInvoiceSectionPager // method. type SubscriptionsClientListByInvoiceSectionOptions struct { - // placeholder for future optional parameters + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // Can be used to expand Reseller, ConsumptionCostCenter, LastMonthCharges and MonthToDateCharges + Expand *string + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // Can be used to get deleted billing subscriptions. + IncludeDeleted *bool + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 } -// SubscriptionsClientUpdateOptions contains the optional parameters for the SubscriptionsClient.Update method. -type SubscriptionsClientUpdateOptions struct { +// SubscriptionsClientValidateMoveEligibilityOptions contains the optional parameters for the SubscriptionsClient.ValidateMoveEligibility +// method. +type SubscriptionsClientValidateMoveEligibilityOptions struct { // placeholder for future optional parameters } -// SubscriptionsClientValidateMoveOptions contains the optional parameters for the SubscriptionsClient.ValidateMove method. -type SubscriptionsClientValidateMoveOptions struct { - // placeholder for future optional parameters +// TransactionsClientBeginTransactionsDownloadByInvoiceOptions contains the optional parameters for the TransactionsClient.BeginTransactionsDownloadByInvoice +// method. +type TransactionsClientBeginTransactionsDownloadByInvoiceOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// TransactionsClientGetTransactionSummaryByInvoiceOptions contains the optional parameters for the TransactionsClient.GetTransactionSummaryByInvoice +// method. +type TransactionsClientGetTransactionSummaryByInvoiceOptions struct { + // The filter query option allows clients to filter the line items that are aggregated to create the line item summary. + Filter *string + + // The search query option allows clients to filter the line items that are aggregated to create the line item summary. + Search *string +} + +// TransactionsClientListByBillingProfileOptions contains the optional parameters for the TransactionsClient.NewListByBillingProfilePager +// method. +type TransactionsClientListByBillingProfileOptions struct { + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 +} + +// TransactionsClientListByCustomerOptions contains the optional parameters for the TransactionsClient.NewListByCustomerPager +// method. +type TransactionsClientListByCustomerOptions struct { + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 } // TransactionsClientListByInvoiceOptions contains the optional parameters for the TransactionsClient.NewListByInvoicePager // method. type TransactionsClientListByInvoiceOptions struct { + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 +} + +// TransactionsClientListByInvoiceSectionOptions contains the optional parameters for the TransactionsClient.NewListByInvoiceSectionPager +// method. +type TransactionsClientListByInvoiceSectionOptions struct { + // The count query option allows clients to request a count of the matching resources included with the resources in the response. + Count *bool + + // The filter query option allows clients to filter a collection of resources that are addressed by a request URL. + Filter *string + + // The orderby query option allows clients to request resources in a particular order. + OrderBy *string + + // The search query option allows clients to request items within a collection matching a free-text search expression. search + // is only supported for string fields. + Search *string + + // The skip query option requests the number of items in the queried collection that are to be skipped and not included in + // the result. + Skip *int64 + + // The top query option requests the number of items in the queried collection to be included in the result. The maximum supported + // value for top is 50. + Top *int64 +} + +// TransfersClientCancelOptions contains the optional parameters for the TransfersClient.Cancel method. +type TransfersClientCancelOptions struct { + // placeholder for future optional parameters +} + +// TransfersClientGetOptions contains the optional parameters for the TransfersClient.Get method. +type TransfersClientGetOptions struct { + // placeholder for future optional parameters +} + +// TransfersClientInitiateOptions contains the optional parameters for the TransfersClient.Initiate method. +type TransfersClientInitiateOptions struct { + // placeholder for future optional parameters +} + +// TransfersClientListOptions contains the optional parameters for the TransfersClient.NewListPager method. +type TransfersClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/billing/armbilling/partnertransfers_client.go b/sdk/resourcemanager/billing/armbilling/partnertransfers_client.go new file mode 100644 index 000000000000..6db7ce894aa6 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/partnertransfers_client.go @@ -0,0 +1,328 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armbilling + +import ( + "context" + "errors" + "net/http" + "net/url" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// PartnerTransfersClient contains the methods for the PartnerTransfers group. +// Don't use this type directly, use NewPartnerTransfersClient() instead. +type PartnerTransfersClient struct { + internal *arm.Client +} + +// NewPartnerTransfersClient creates a new instance of PartnerTransfersClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewPartnerTransfersClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*PartnerTransfersClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &PartnerTransfersClient{ + internal: cl, + } + return client, nil +} + +// Cancel - Cancels a transfer request. The operation is supported only for billing accounts with agreement type Microsoft +// Partner Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - customerName - The ID that uniquely identifies a customer. +// - transferName - The ID that uniquely identifies a transfer request. +// - options - PartnerTransfersClientCancelOptions contains the optional parameters for the PartnerTransfersClient.Cancel method. +func (client *PartnerTransfersClient) Cancel(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, transferName string, options *PartnerTransfersClientCancelOptions) (PartnerTransfersClientCancelResponse, error) { + var err error + const operationName = "PartnerTransfersClient.Cancel" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.cancelCreateRequest(ctx, billingAccountName, billingProfileName, customerName, transferName, options) + if err != nil { + return PartnerTransfersClientCancelResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PartnerTransfersClientCancelResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PartnerTransfersClientCancelResponse{}, err + } + resp, err := client.cancelHandleResponse(httpResp) + return resp, err +} + +// cancelCreateRequest creates the Cancel request. +func (client *PartnerTransfersClient) cancelCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, transferName string, options *PartnerTransfersClientCancelOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/transfers/{transferName}/cancel" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if customerName == "" { + return nil, errors.New("parameter customerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{customerName}", url.PathEscape(customerName)) + if transferName == "" { + return nil, errors.New("parameter transferName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{transferName}", url.PathEscape(transferName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// cancelHandleResponse handles the Cancel response. +func (client *PartnerTransfersClient) cancelHandleResponse(resp *http.Response) (PartnerTransfersClientCancelResponse, error) { + result := PartnerTransfersClientCancelResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PartnerTransferDetails); err != nil { + return PartnerTransfersClientCancelResponse{}, err + } + return result, nil +} + +// Get - Gets a transfer request by ID. The operation is supported only for billing accounts with agreement type Microsoft +// Partner Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - customerName - The ID that uniquely identifies a customer. +// - transferName - The ID that uniquely identifies a transfer request. +// - options - PartnerTransfersClientGetOptions contains the optional parameters for the PartnerTransfersClient.Get method. +func (client *PartnerTransfersClient) Get(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, transferName string, options *PartnerTransfersClientGetOptions) (PartnerTransfersClientGetResponse, error) { + var err error + const operationName = "PartnerTransfersClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, billingAccountName, billingProfileName, customerName, transferName, options) + if err != nil { + return PartnerTransfersClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PartnerTransfersClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PartnerTransfersClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *PartnerTransfersClient) getCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, transferName string, options *PartnerTransfersClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/transfers/{transferName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if customerName == "" { + return nil, errors.New("parameter customerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{customerName}", url.PathEscape(customerName)) + if transferName == "" { + return nil, errors.New("parameter transferName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{transferName}", url.PathEscape(transferName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PartnerTransfersClient) getHandleResponse(resp *http.Response) (PartnerTransfersClientGetResponse, error) { + result := PartnerTransfersClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PartnerTransferDetails); err != nil { + return PartnerTransfersClientGetResponse{}, err + } + return result, nil +} + +// Initiate - Sends a request to a user in a customer's billing account to transfer billing ownership of their subscriptions. +// The operation is supported only for billing accounts with agreement type Microsoft +// Partner Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - customerName - The ID that uniquely identifies a customer. +// - transferName - The ID that uniquely identifies a transfer request. +// - parameters - Request parameters that are provided to the initiate transfer operation. +// - options - PartnerTransfersClientInitiateOptions contains the optional parameters for the PartnerTransfersClient.Initiate +// method. +func (client *PartnerTransfersClient) Initiate(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, transferName string, parameters PartnerInitiateTransferRequest, options *PartnerTransfersClientInitiateOptions) (PartnerTransfersClientInitiateResponse, error) { + var err error + const operationName = "PartnerTransfersClient.Initiate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.initiateCreateRequest(ctx, billingAccountName, billingProfileName, customerName, transferName, parameters, options) + if err != nil { + return PartnerTransfersClientInitiateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PartnerTransfersClientInitiateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return PartnerTransfersClientInitiateResponse{}, err + } + resp, err := client.initiateHandleResponse(httpResp) + return resp, err +} + +// initiateCreateRequest creates the Initiate request. +func (client *PartnerTransfersClient) initiateCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, transferName string, parameters PartnerInitiateTransferRequest, options *PartnerTransfersClientInitiateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/transfers/{transferName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if customerName == "" { + return nil, errors.New("parameter customerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{customerName}", url.PathEscape(customerName)) + if transferName == "" { + return nil, errors.New("parameter transferName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{transferName}", url.PathEscape(transferName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// initiateHandleResponse handles the Initiate response. +func (client *PartnerTransfersClient) initiateHandleResponse(resp *http.Response) (PartnerTransfersClientInitiateResponse, error) { + result := PartnerTransfersClientInitiateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PartnerTransferDetails); err != nil { + return PartnerTransfersClientInitiateResponse{}, err + } + return result, nil +} + +// NewListPager - Lists the transfer requests sent to a customer. The operation is supported only for billing accounts with +// agreement type Microsoft Partner Agreement. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - customerName - The ID that uniquely identifies a customer. +// - options - PartnerTransfersClientListOptions contains the optional parameters for the PartnerTransfersClient.NewListPager +// method. +func (client *PartnerTransfersClient) NewListPager(billingAccountName string, billingProfileName string, customerName string, options *PartnerTransfersClientListOptions) *runtime.Pager[PartnerTransfersClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[PartnerTransfersClientListResponse]{ + More: func(page PartnerTransfersClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PartnerTransfersClientListResponse) (PartnerTransfersClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PartnerTransfersClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, billingAccountName, billingProfileName, customerName, options) + }, nil) + if err != nil { + return PartnerTransfersClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *PartnerTransfersClient) listCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, options *PartnerTransfersClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/transfers" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if customerName == "" { + return nil, errors.New("parameter customerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{customerName}", url.PathEscape(customerName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PartnerTransfersClient) listHandleResponse(resp *http.Response) (PartnerTransfersClientListResponse, error) { + result := PartnerTransfersClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PartnerTransferDetailsListResult); err != nil { + return PartnerTransfersClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/partnertransfers_client_example_test.go b/sdk/resourcemanager/billing/armbilling/partnertransfers_client_example_test.go new file mode 100644 index 000000000000..11e35fdcff56 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/partnertransfers_client_example_test.go @@ -0,0 +1,190 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armbilling_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/partnerTransfersGet.json +func ExamplePartnerTransfersClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPartnerTransfersClient().Get(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "11111111-1111-1111-1111-111111111111", "aabb123", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PartnerTransferDetails = armbilling.PartnerTransferDetails{ + // Name: to.Ptr("aabb123"), + // Type: to.Ptr("Microsoft.Billing/transfers"), + // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/BillingProfiles/xxxx-xxxx-xxx-xxx/customers/11111111-1111-1111-1111-111111111111/transfers/aabb123"), + // Properties: &armbilling.PartnerTransferProperties{ + // DetailedTransferStatus: []*armbilling.DetailedTransferStatus{ + // { + // ProductID: to.Ptr("subscriptionId"), + // ProductName: to.Ptr("Azure subscription 1"), + // ProductType: to.Ptr(armbilling.ProductTypeAzureSubscription), + // SKUDescription: to.Ptr("MS-AZR-0017G"), + // TransferStatus: to.Ptr(armbilling.ProductTransferStatusInProgress), + // }, + // { + // ProductID: to.Ptr("reservedInstanceId"), + // ProductName: to.Ptr("Reservation name"), + // ProductType: to.Ptr(armbilling.ProductTypeAzureReservation), + // SKUDescription: to.Ptr("Standard_D2s_v3;VirtualMachines;P1Y"), + // TransferStatus: to.Ptr(armbilling.ProductTransferStatusInProgress), + // }}, + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-05T17:32:28.000Z"); return t}()), + // InitiatorCustomerType: to.Ptr(armbilling.InitiatorCustomerTypePartner), + // InitiatorEmailID: to.Ptr("xyz@contoso.com"), + // RecipientEmailID: to.Ptr("user@contoso.com"), + // TransferStatus: to.Ptr(armbilling.TransferStatusInProgress), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/partnerTransfersInitiate.json +func ExamplePartnerTransfersClient_Initiate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPartnerTransfersClient().Initiate(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "11111111-1111-1111-1111-111111111111", "aabb123", armbilling.PartnerInitiateTransferRequest{ + Properties: &armbilling.PartnerInitiateTransferProperties{ + RecipientEmailID: to.Ptr("user@contoso.com"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PartnerTransferDetails = armbilling.PartnerTransferDetails{ + // Name: to.Ptr("aabb123"), + // Type: to.Ptr("Microsoft.Billing/transfers"), + // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/BillingProfiles/xxxx-xxxx-xxx-xxx/customers/11111111-1111-1111-1111-111111111111/transfers/aabb123"), + // Properties: &armbilling.PartnerTransferProperties{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-05T17:32:28.000Z"); return t}()), + // InitiatorCustomerType: to.Ptr(armbilling.InitiatorCustomerTypePartner), + // InitiatorEmailID: to.Ptr("xyz@contoso.com"), + // RecipientEmailID: to.Ptr("user@contoso.com"), + // TransferStatus: to.Ptr(armbilling.TransferStatusPending), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/partnerTransfersCancel.json +func ExamplePartnerTransfersClient_Cancel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPartnerTransfersClient().Cancel(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "11111111-1111-1111-1111-111111111111", "aabb123", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PartnerTransferDetails = armbilling.PartnerTransferDetails{ + // Name: to.Ptr("aabb123"), + // Type: to.Ptr("Microsoft.Billing/transfers"), + // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/BillingProfiles/xxxx-xxxx-xxx-xxx/customers/11111111-1111-1111-1111-111111111111/transfers/aabb123"), + // Properties: &armbilling.PartnerTransferProperties{ + // CanceledBy: to.Ptr("user@contoso.com"), + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-05T17:32:28.000Z"); return t}()), + // InitiatorCustomerType: to.Ptr(armbilling.InitiatorCustomerTypePartner), + // InitiatorEmailID: to.Ptr("xyz@contoso.com"), + // RecipientEmailID: to.Ptr("user@contoso.com"), + // TransferStatus: to.Ptr(armbilling.TransferStatusPending), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/partnerTransfersList.json +func ExamplePartnerTransfersClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewPartnerTransfersClient().NewListPager("10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "11111111-1111-1111-1111-111111111111", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.PartnerTransferDetailsListResult = armbilling.PartnerTransferDetailsListResult{ + // Value: []*armbilling.PartnerTransferDetails{ + // { + // Name: to.Ptr("aabb123"), + // Type: to.Ptr("Microsoft.Billing/transfers"), + // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/BillingProfiles/xxxx-xxxx-xxx-xxx/customers/11111111-1111-1111-1111-111111111111/transfers/aabb123"), + // Properties: &armbilling.PartnerTransferProperties{ + // DetailedTransferStatus: []*armbilling.DetailedTransferStatus{ + // { + // ProductID: to.Ptr("subscriptionId"), + // ProductName: to.Ptr("Azure subscription 1"), + // ProductType: to.Ptr(armbilling.ProductTypeAzureSubscription), + // SKUDescription: to.Ptr("MS-AZR-0017G"), + // TransferStatus: to.Ptr(armbilling.ProductTransferStatusInProgress), + // }, + // { + // ProductID: to.Ptr("reservedInstanceId"), + // ProductName: to.Ptr("Reservation name"), + // ProductType: to.Ptr(armbilling.ProductTypeAzureReservation), + // SKUDescription: to.Ptr("Standard_D2s_v3;VirtualMachines;P1Y"), + // TransferStatus: to.Ptr(armbilling.ProductTransferStatusInProgress), + // }}, + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-05T17:32:28.000Z"); return t}()), + // InitiatorCustomerType: to.Ptr(armbilling.InitiatorCustomerTypePartner), + // InitiatorEmailID: to.Ptr("xyz@contoso.com"), + // RecipientEmailID: to.Ptr("user@contoso.com"), + // TransferStatus: to.Ptr(armbilling.TransferStatusInProgress), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/billing/armbilling/paymentmethods_client.go b/sdk/resourcemanager/billing/armbilling/paymentmethods_client.go new file mode 100644 index 000000000000..db5687885d09 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/paymentmethods_client.go @@ -0,0 +1,444 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armbilling + +import ( + "context" + "errors" + "net/http" + "net/url" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// PaymentMethodsClient contains the methods for the PaymentMethods group. +// Don't use this type directly, use NewPaymentMethodsClient() instead. +type PaymentMethodsClient struct { + internal *arm.Client +} + +// NewPaymentMethodsClient creates a new instance of PaymentMethodsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewPaymentMethodsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*PaymentMethodsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &PaymentMethodsClient{ + internal: cl, + } + return client, nil +} + +// DeleteByUser - Deletes a payment method owned by the caller. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - paymentMethodName - The ID that uniquely identifies a payment method. +// - options - PaymentMethodsClientDeleteByUserOptions contains the optional parameters for the PaymentMethodsClient.DeleteByUser +// method. +func (client *PaymentMethodsClient) DeleteByUser(ctx context.Context, paymentMethodName string, options *PaymentMethodsClientDeleteByUserOptions) (PaymentMethodsClientDeleteByUserResponse, error) { + var err error + const operationName = "PaymentMethodsClient.DeleteByUser" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteByUserCreateRequest(ctx, paymentMethodName, options) + if err != nil { + return PaymentMethodsClientDeleteByUserResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PaymentMethodsClientDeleteByUserResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return PaymentMethodsClientDeleteByUserResponse{}, err + } + return PaymentMethodsClientDeleteByUserResponse{}, nil +} + +// deleteByUserCreateRequest creates the DeleteByUser request. +func (client *PaymentMethodsClient) deleteByUserCreateRequest(ctx context.Context, paymentMethodName string, options *PaymentMethodsClientDeleteByUserOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/paymentMethods/{paymentMethodName}" + if paymentMethodName == "" { + return nil, errors.New("parameter paymentMethodName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{paymentMethodName}", url.PathEscape(paymentMethodName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// GetByBillingAccount - Gets a payment method available for a billing account. The operation is supported only for billing +// accounts with agreement type Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - paymentMethodName - The ID that uniquely identifies a payment method. +// - options - PaymentMethodsClientGetByBillingAccountOptions contains the optional parameters for the PaymentMethodsClient.GetByBillingAccount +// method. +func (client *PaymentMethodsClient) GetByBillingAccount(ctx context.Context, billingAccountName string, paymentMethodName string, options *PaymentMethodsClientGetByBillingAccountOptions) (PaymentMethodsClientGetByBillingAccountResponse, error) { + var err error + const operationName = "PaymentMethodsClient.GetByBillingAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByBillingAccountCreateRequest(ctx, billingAccountName, paymentMethodName, options) + if err != nil { + return PaymentMethodsClientGetByBillingAccountResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PaymentMethodsClientGetByBillingAccountResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PaymentMethodsClientGetByBillingAccountResponse{}, err + } + resp, err := client.getByBillingAccountHandleResponse(httpResp) + return resp, err +} + +// getByBillingAccountCreateRequest creates the GetByBillingAccount request. +func (client *PaymentMethodsClient) getByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, paymentMethodName string, options *PaymentMethodsClientGetByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/paymentMethods/{paymentMethodName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if paymentMethodName == "" { + return nil, errors.New("parameter paymentMethodName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{paymentMethodName}", url.PathEscape(paymentMethodName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByBillingAccountHandleResponse handles the GetByBillingAccount response. +func (client *PaymentMethodsClient) getByBillingAccountHandleResponse(resp *http.Response) (PaymentMethodsClientGetByBillingAccountResponse, error) { + result := PaymentMethodsClientGetByBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PaymentMethod); err != nil { + return PaymentMethodsClientGetByBillingAccountResponse{}, err + } + return result, nil +} + +// GetByBillingProfile - Gets a payment method linked with a billing profile. The operation is supported only for billing +// accounts with agreement type Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - paymentMethodName - The ID that uniquely identifies a payment method. +// - options - PaymentMethodsClientGetByBillingProfileOptions contains the optional parameters for the PaymentMethodsClient.GetByBillingProfile +// method. +func (client *PaymentMethodsClient) GetByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, paymentMethodName string, options *PaymentMethodsClientGetByBillingProfileOptions) (PaymentMethodsClientGetByBillingProfileResponse, error) { + var err error + const operationName = "PaymentMethodsClient.GetByBillingProfile" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, paymentMethodName, options) + if err != nil { + return PaymentMethodsClientGetByBillingProfileResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PaymentMethodsClientGetByBillingProfileResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PaymentMethodsClientGetByBillingProfileResponse{}, err + } + resp, err := client.getByBillingProfileHandleResponse(httpResp) + return resp, err +} + +// getByBillingProfileCreateRequest creates the GetByBillingProfile request. +func (client *PaymentMethodsClient) getByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, paymentMethodName string, options *PaymentMethodsClientGetByBillingProfileOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/paymentMethodLinks/{paymentMethodName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if paymentMethodName == "" { + return nil, errors.New("parameter paymentMethodName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{paymentMethodName}", url.PathEscape(paymentMethodName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByBillingProfileHandleResponse handles the GetByBillingProfile response. +func (client *PaymentMethodsClient) getByBillingProfileHandleResponse(resp *http.Response) (PaymentMethodsClientGetByBillingProfileResponse, error) { + result := PaymentMethodsClientGetByBillingProfileResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PaymentMethodLink); err != nil { + return PaymentMethodsClientGetByBillingProfileResponse{}, err + } + return result, nil +} + +// GetByUser - Gets a payment method owned by the caller. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - paymentMethodName - The ID that uniquely identifies a payment method. +// - options - PaymentMethodsClientGetByUserOptions contains the optional parameters for the PaymentMethodsClient.GetByUser +// method. +func (client *PaymentMethodsClient) GetByUser(ctx context.Context, paymentMethodName string, options *PaymentMethodsClientGetByUserOptions) (PaymentMethodsClientGetByUserResponse, error) { + var err error + const operationName = "PaymentMethodsClient.GetByUser" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByUserCreateRequest(ctx, paymentMethodName, options) + if err != nil { + return PaymentMethodsClientGetByUserResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PaymentMethodsClientGetByUserResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PaymentMethodsClientGetByUserResponse{}, err + } + resp, err := client.getByUserHandleResponse(httpResp) + return resp, err +} + +// getByUserCreateRequest creates the GetByUser request. +func (client *PaymentMethodsClient) getByUserCreateRequest(ctx context.Context, paymentMethodName string, options *PaymentMethodsClientGetByUserOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/paymentMethods/{paymentMethodName}" + if paymentMethodName == "" { + return nil, errors.New("parameter paymentMethodName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{paymentMethodName}", url.PathEscape(paymentMethodName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByUserHandleResponse handles the GetByUser response. +func (client *PaymentMethodsClient) getByUserHandleResponse(resp *http.Response) (PaymentMethodsClientGetByUserResponse, error) { + result := PaymentMethodsClientGetByUserResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PaymentMethod); err != nil { + return PaymentMethodsClientGetByUserResponse{}, err + } + return result, nil +} + +// NewListByBillingAccountPager - Lists the payment methods available for a billing account. Along with the payment methods +// owned by the caller, these payment methods can be attached to a billing profile to make payments. The +// operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - options - PaymentMethodsClientListByBillingAccountOptions contains the optional parameters for the PaymentMethodsClient.NewListByBillingAccountPager +// method. +func (client *PaymentMethodsClient) NewListByBillingAccountPager(billingAccountName string, options *PaymentMethodsClientListByBillingAccountOptions) *runtime.Pager[PaymentMethodsClientListByBillingAccountResponse] { + return runtime.NewPager(runtime.PagingHandler[PaymentMethodsClientListByBillingAccountResponse]{ + More: func(page PaymentMethodsClientListByBillingAccountResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PaymentMethodsClientListByBillingAccountResponse) (PaymentMethodsClientListByBillingAccountResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PaymentMethodsClient.NewListByBillingAccountPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByBillingAccountCreateRequest(ctx, billingAccountName, options) + }, nil) + if err != nil { + return PaymentMethodsClientListByBillingAccountResponse{}, err + } + return client.listByBillingAccountHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByBillingAccountCreateRequest creates the ListByBillingAccount request. +func (client *PaymentMethodsClient) listByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, options *PaymentMethodsClientListByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/paymentMethods" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByBillingAccountHandleResponse handles the ListByBillingAccount response. +func (client *PaymentMethodsClient) listByBillingAccountHandleResponse(resp *http.Response) (PaymentMethodsClientListByBillingAccountResponse, error) { + result := PaymentMethodsClientListByBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PaymentMethodsListResult); err != nil { + return PaymentMethodsClientListByBillingAccountResponse{}, err + } + return result, nil +} + +// NewListByBillingProfilePager - Lists payment methods attached to a billing profile. The operation is supported only for +// billing accounts with agreement type Microsoft Customer Agreement. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - options - PaymentMethodsClientListByBillingProfileOptions contains the optional parameters for the PaymentMethodsClient.NewListByBillingProfilePager +// method. +func (client *PaymentMethodsClient) NewListByBillingProfilePager(billingAccountName string, billingProfileName string, options *PaymentMethodsClientListByBillingProfileOptions) *runtime.Pager[PaymentMethodsClientListByBillingProfileResponse] { + return runtime.NewPager(runtime.PagingHandler[PaymentMethodsClientListByBillingProfileResponse]{ + More: func(page PaymentMethodsClientListByBillingProfileResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PaymentMethodsClientListByBillingProfileResponse) (PaymentMethodsClientListByBillingProfileResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PaymentMethodsClient.NewListByBillingProfilePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, options) + }, nil) + if err != nil { + return PaymentMethodsClientListByBillingProfileResponse{}, err + } + return client.listByBillingProfileHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByBillingProfileCreateRequest creates the ListByBillingProfile request. +func (client *PaymentMethodsClient) listByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, options *PaymentMethodsClientListByBillingProfileOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/paymentMethodLinks" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByBillingProfileHandleResponse handles the ListByBillingProfile response. +func (client *PaymentMethodsClient) listByBillingProfileHandleResponse(resp *http.Response) (PaymentMethodsClientListByBillingProfileResponse, error) { + result := PaymentMethodsClientListByBillingProfileResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PaymentMethodLinksListResult); err != nil { + return PaymentMethodsClientListByBillingProfileResponse{}, err + } + return result, nil +} + +// NewListByUserPager - Lists the payment methods owned by the caller. +// +// Generated from API version 2024-04-01 +// - options - PaymentMethodsClientListByUserOptions contains the optional parameters for the PaymentMethodsClient.NewListByUserPager +// method. +func (client *PaymentMethodsClient) NewListByUserPager(options *PaymentMethodsClientListByUserOptions) *runtime.Pager[PaymentMethodsClientListByUserResponse] { + return runtime.NewPager(runtime.PagingHandler[PaymentMethodsClientListByUserResponse]{ + More: func(page PaymentMethodsClientListByUserResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PaymentMethodsClientListByUserResponse) (PaymentMethodsClientListByUserResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PaymentMethodsClient.NewListByUserPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByUserCreateRequest(ctx, options) + }, nil) + if err != nil { + return PaymentMethodsClientListByUserResponse{}, err + } + return client.listByUserHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByUserCreateRequest creates the ListByUser request. +func (client *PaymentMethodsClient) listByUserCreateRequest(ctx context.Context, options *PaymentMethodsClientListByUserOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/paymentMethods" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByUserHandleResponse handles the ListByUser response. +func (client *PaymentMethodsClient) listByUserHandleResponse(resp *http.Response) (PaymentMethodsClientListByUserResponse, error) { + result := PaymentMethodsClientListByUserResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PaymentMethodsListResult); err != nil { + return PaymentMethodsClientListByUserResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/paymentmethods_client_example_test.go b/sdk/resourcemanager/billing/armbilling/paymentmethods_client_example_test.go new file mode 100644 index 000000000000..ba4d45539026 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/paymentmethods_client_example_test.go @@ -0,0 +1,316 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armbilling_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsListByBillingProfile.json +func ExamplePaymentMethodsClient_NewListByBillingProfilePager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewPaymentMethodsClient().NewListByBillingProfilePager("00000000-0000-0000-0000-000000000032:00000000-0000-0000-0000-000000000099_2019-05-31", "ABC1-A1CD-AB1-BP1", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.PaymentMethodLinksListResult = armbilling.PaymentMethodLinksListResult{ + // Value: []*armbilling.PaymentMethodLink{ + // { + // Name: to.Ptr("ABCDABCDABC0"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/paymentMethodLinks"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000032:00000000-0000-0000-0000-000000000099_2019-05-31/billingProfiles/ABC1-A1CD-AB1-BP1/paymentMethodLinks/ABCDABCDABC0"), + // Properties: &armbilling.PaymentMethodLinkProperties{ + // AccountHolderName: to.Ptr("abc"), + // DisplayName: to.Ptr("Master Card"), + // Expiration: to.Ptr("1/2035"), + // Family: to.Ptr(armbilling.PaymentMethodFamilyCreditCard), + // LastFourDigits: to.Ptr("1270"), + // Logos: []*armbilling.PaymentMethodLogo{ + // { + // MimeType: to.Ptr("image/png"), + // URL: to.Ptr("https://contoso.com/staticresourceservice/images/v4/logo_visa_rect.png"), + // }, + // { + // MimeType: to.Ptr("image/svg+xml"), + // URL: to.Ptr("https://contoso.com/staticresourceservice/images/v4/logo_visa.svg"), + // }}, + // PaymentMethodID: to.Ptr("/providers/Microsoft.Billing/paymentMethods/ABCDABCDABC0"), + // PaymentMethodType: to.Ptr("mc"), + // Status: to.Ptr(armbilling.PaymentMethodStatusActive), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsGetByBillingProfile.json +func ExamplePaymentMethodsClient_GetByBillingProfile() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPaymentMethodsClient().GetByBillingProfile(ctx, "00000000-0000-0000-0000-000000000032:00000000-0000-0000-0000-000000000099_2019-05-31", "ABC1-A1CD-AB1-BP1", "ABCDABCDABC0", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PaymentMethodLink = armbilling.PaymentMethodLink{ + // Name: to.Ptr("ABCDABCDABC0"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/paymentMethodLinks"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000032:00000000-0000-0000-0000-000000000099_2019-05-31/billingProfiles/ABC1-A1CD-AB1-BP1/paymentMethodLinks/ABCDABCDABC0"), + // Properties: &armbilling.PaymentMethodLinkProperties{ + // AccountHolderName: to.Ptr("abc"), + // DisplayName: to.Ptr("Master Card"), + // Expiration: to.Ptr("1/2035"), + // Family: to.Ptr(armbilling.PaymentMethodFamilyCreditCard), + // LastFourDigits: to.Ptr("1270"), + // Logos: []*armbilling.PaymentMethodLogo{ + // { + // MimeType: to.Ptr("image/png"), + // URL: to.Ptr("https://contoso.com/staticresourceservice/images/v4/logo_visa_rect.png"), + // }, + // { + // MimeType: to.Ptr("image/svg+xml"), + // URL: to.Ptr("https://contoso.com/staticresourceservice/images/v4/logo_visa.svg"), + // }}, + // PaymentMethodID: to.Ptr("/providers/Microsoft.Billing/paymentMethods/ABCDABCDABC0"), + // PaymentMethodType: to.Ptr("mc"), + // Status: to.Ptr(armbilling.PaymentMethodStatusActive), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsListByBillingAccount.json +func ExamplePaymentMethodsClient_NewListByBillingAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewPaymentMethodsClient().NewListByBillingAccountPager("00000000-0000-0000-0000-000000000032:00000000-0000-0000-0000-000000000099_2019-05-31", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.PaymentMethodsListResult = armbilling.PaymentMethodsListResult{ + // Value: []*armbilling.PaymentMethod{ + // { + // Name: to.Ptr("21dd9edc-af71-4d62-80ce-37151d475326"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/paymentMethods"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000032:00000000-0000-0000-0000-000000000099_2019-05-31/paymentMethods/21dd9edc-af71-4d62-80ce-37151d475326"), + // Properties: &armbilling.PaymentMethodProperties{ + // DisplayName: to.Ptr("Check/wire transfer"), + // Family: to.Ptr(armbilling.PaymentMethodFamilyCheckWire), + // PaymentMethodType: to.Ptr("check"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsGetByBillingAccount.json +func ExamplePaymentMethodsClient_GetByBillingAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPaymentMethodsClient().GetByBillingAccount(ctx, "00000000-0000-0000-0000-000000000032:00000000-0000-0000-0000-000000000099_2019-05-31", "21dd9edc-af71-4d62-80ce-37151d475326", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PaymentMethod = armbilling.PaymentMethod{ + // Name: to.Ptr("21dd9edc-af71-4d62-80ce-37151d475326"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/paymentMethods"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000032:00000000-0000-0000-0000-000000000099_2019-05-31/paymentMethods/21dd9edc-af71-4d62-80ce-37151d475326"), + // Properties: &armbilling.PaymentMethodProperties{ + // DisplayName: to.Ptr("Check/wire transfer"), + // Family: to.Ptr(armbilling.PaymentMethodFamilyCheckWire), + // PaymentMethodType: to.Ptr("check"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsListByUser.json +func ExamplePaymentMethodsClient_NewListByUserPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewPaymentMethodsClient().NewListByUserPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.PaymentMethodsListResult = armbilling.PaymentMethodsListResult{ + // Value: []*armbilling.PaymentMethod{ + // { + // Name: to.Ptr("ABCDABCDABC0"), + // Type: to.Ptr("Microsoft.Billing/paymentMethods"), + // ID: to.Ptr("/providers/Microsoft.Billing/paymentMethods/ABCDABCDABC0"), + // Properties: &armbilling.PaymentMethodProperties{ + // AccountHolderName: to.Ptr("abc"), + // DisplayName: to.Ptr("Master Card"), + // Expiration: to.Ptr("1/2035"), + // Family: to.Ptr(armbilling.PaymentMethodFamilyCreditCard), + // LastFourDigits: to.Ptr("1270"), + // Logos: []*armbilling.PaymentMethodLogo{ + // { + // MimeType: to.Ptr("image/png"), + // URL: to.Ptr("https://contoso.com/staticresourceservice/images/v4/logo_mc_rect.png"), + // }, + // { + // MimeType: to.Ptr("image/svg+xml"), + // URL: to.Ptr("https://contoso.com/staticresourceservice/images/v4/logo_mc.svg"), + // }}, + // PaymentMethodType: to.Ptr("mc"), + // Status: to.Ptr(armbilling.PaymentMethodStatusActive), + // }, + // }, + // { + // Name: to.Ptr("ABCDABCDABC1"), + // Type: to.Ptr("Microsoft.Billing/paymentMethods"), + // ID: to.Ptr("/providers/Microsoft.Billing/paymentMethods/ABCDABCDABC1"), + // Properties: &armbilling.PaymentMethodProperties{ + // AccountHolderName: to.Ptr("abc"), + // DisplayName: to.Ptr("Visa"), + // Expiration: to.Ptr("1/2025"), + // Family: to.Ptr(armbilling.PaymentMethodFamilyCreditCard), + // LastFourDigits: to.Ptr("7373"), + // Logos: []*armbilling.PaymentMethodLogo{ + // { + // MimeType: to.Ptr("image/png"), + // URL: to.Ptr("https://contoso.com/staticresourceservice/images/v4/logo_visa_rect.png"), + // }, + // { + // MimeType: to.Ptr("image/svg+xml"), + // URL: to.Ptr("https://contoso.com/staticresourceservice/images/v4/logo_visa.svg"), + // }}, + // PaymentMethodType: to.Ptr("visa"), + // Status: to.Ptr(armbilling.PaymentMethodStatusActive), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsDeleteByUser.json +func ExamplePaymentMethodsClient_DeleteByUser() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewPaymentMethodsClient().DeleteByUser(ctx, "ABCDABCDABC0", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsGetByUser.json +func ExamplePaymentMethodsClient_GetByUser() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPaymentMethodsClient().GetByUser(ctx, "ABCDABCDABC0", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PaymentMethod = armbilling.PaymentMethod{ + // Name: to.Ptr("ABCDABCDABC0"), + // Type: to.Ptr("Microsoft.Billing/paymentMethods"), + // ID: to.Ptr("/providers/Microsoft.Billing/paymentMethods/ABCDABCDABC0"), + // Properties: &armbilling.PaymentMethodProperties{ + // AccountHolderName: to.Ptr("abc"), + // DisplayName: to.Ptr("Master Card"), + // Expiration: to.Ptr("1/2035"), + // Family: to.Ptr(armbilling.PaymentMethodFamilyCreditCard), + // LastFourDigits: to.Ptr("1270"), + // Logos: []*armbilling.PaymentMethodLogo{ + // { + // MimeType: to.Ptr("image/png"), + // URL: to.Ptr("https://contoso.com/staticresourceservice/images/v4/logo_visa_rect.png"), + // }, + // { + // MimeType: to.Ptr("image/svg+xml"), + // URL: to.Ptr("https://contoso.com/staticresourceservice/images/v4/logo_visa.svg"), + // }}, + // PaymentMethodType: to.Ptr("mc"), + // Status: to.Ptr(armbilling.PaymentMethodStatusActive), + // }, + // } +} diff --git a/sdk/resourcemanager/billing/armbilling/periods_client.go b/sdk/resourcemanager/billing/armbilling/periods_client.go deleted file mode 100644 index b6a7248cb167..000000000000 --- a/sdk/resourcemanager/billing/armbilling/periods_client.go +++ /dev/null @@ -1,171 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armbilling - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strconv" - "strings" -) - -// PeriodsClient contains the methods for the BillingPeriods group. -// Don't use this type directly, use NewPeriodsClient() instead. -type PeriodsClient struct { - internal *arm.Client - subscriptionID string -} - -// NewPeriodsClient creates a new instance of PeriodsClient with the specified values. -// - subscriptionID - The ID that uniquely identifies an Azure subscription. -// - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. -func NewPeriodsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PeriodsClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &PeriodsClient{ - subscriptionID: subscriptionID, - internal: cl, - } - return client, nil -} - -// Get - Gets a named billing period. This is only supported for Azure Web-Direct subscriptions. Other subscription types -// which were not purchased directly through the Azure web portal are not supported -// through this preview API. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2018-03-01-preview -// - billingPeriodName - The name of a BillingPeriod resource. -// - options - PeriodsClientGetOptions contains the optional parameters for the PeriodsClient.Get method. -func (client *PeriodsClient) Get(ctx context.Context, billingPeriodName string, options *PeriodsClientGetOptions) (PeriodsClientGetResponse, error) { - var err error - const operationName = "PeriodsClient.Get" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, billingPeriodName, options) - if err != nil { - return PeriodsClientGetResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return PeriodsClientGetResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return PeriodsClientGetResponse{}, err - } - resp, err := client.getHandleResponse(httpResp) - return resp, err -} - -// getCreateRequest creates the Get request. -func (client *PeriodsClient) getCreateRequest(ctx context.Context, billingPeriodName string, options *PeriodsClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if billingPeriodName == "" { - return nil, errors.New("parameter billingPeriodName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingPeriodName}", url.PathEscape(billingPeriodName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2018-03-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *PeriodsClient) getHandleResponse(resp *http.Response) (PeriodsClientGetResponse, error) { - result := PeriodsClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Period); err != nil { - return PeriodsClientGetResponse{}, err - } - return result, nil -} - -// NewListPager - Lists the available billing periods for a subscription in reverse chronological order. This is only supported -// for Azure Web-Direct subscriptions. Other subscription types which were not purchased -// directly through the Azure web portal are not supported through this preview API. -// -// Generated from API version 2018-03-01-preview -// - options - PeriodsClientListOptions contains the optional parameters for the PeriodsClient.NewListPager method. -func (client *PeriodsClient) NewListPager(options *PeriodsClientListOptions) *runtime.Pager[PeriodsClientListResponse] { - return runtime.NewPager(runtime.PagingHandler[PeriodsClientListResponse]{ - More: func(page PeriodsClientListResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *PeriodsClientListResponse) (PeriodsClientListResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PeriodsClient.NewListPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, options) - }, nil) - if err != nil { - return PeriodsClientListResponse{}, err - } - return client.listHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listCreateRequest creates the List request. -func (client *PeriodsClient) listCreateRequest(ctx context.Context, options *PeriodsClientListOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2018-03-01-preview") - if options != nil && options.Filter != nil { - reqQP.Set("$filter", *options.Filter) - } - if options != nil && options.Skiptoken != nil { - reqQP.Set("$skiptoken", *options.Skiptoken) - } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listHandleResponse handles the List response. -func (client *PeriodsClient) listHandleResponse(resp *http.Response) (PeriodsClientListResponse, error) { - result := PeriodsClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.PeriodsListResult); err != nil { - return PeriodsClientListResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/billing/armbilling/periods_client_example_test.go b/sdk/resourcemanager/billing/armbilling/periods_client_example_test.go deleted file mode 100644 index 61d6d7c8d96b..000000000000 --- a/sdk/resourcemanager/billing/armbilling/periods_client_example_test.go +++ /dev/null @@ -1,93 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armbilling_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/preview/2018-03-01-preview/examples/BillingPeriodsList.json -func ExamplePeriodsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbilling.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewPeriodsClient().NewListPager(&armbilling.PeriodsClientListOptions{Filter: nil, - Skiptoken: nil, - Top: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.PeriodsListResult = armbilling.PeriodsListResult{ - // Value: []*armbilling.Period{ - // { - // Name: to.Ptr("201702-1"), - // Type: to.Ptr("Microsoft.Billing/billingPeriods"), - // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Billing/billingPeriods/201702-1"), - // Properties: &armbilling.PeriodProperties{ - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2017-02-01"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2017-01-01"); return t}()), - // InvoiceIDs: []*string{ - // to.Ptr("/subscriptions/subid/providers/Microsoft.Billing/invoices/2017-02-05-123456789"), - // to.Ptr("/subscriptions/subid/providers/Microsoft.Billing/invoices/2017-01-05-987654321")}, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/preview/2018-03-01-preview/examples/BillingPeriodsGet.json -func ExamplePeriodsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbilling.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPeriodsClient().Get(ctx, "201702-1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Period = armbilling.Period{ - // Name: to.Ptr("201702-1"), - // Type: to.Ptr("Microsoft.Billing/billingPeriods"), - // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Billing/billingPeriods/201702-1"), - // Properties: &armbilling.PeriodProperties{ - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2017-02-01"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2017-01-01"); return t}()), - // InvoiceIDs: []*string{ - // to.Ptr("/subscriptions/subid/providers/Microsoft.Billing/invoices/2017-02-05-123456789"), - // to.Ptr("/subscriptions/subid/providers/Microsoft.Billing/invoices/2017-01-05-987654321")}, - // }, - // } -} diff --git a/sdk/resourcemanager/billing/armbilling/permissions_client.go b/sdk/resourcemanager/billing/armbilling/permissions_client.go index 5bf2cb3bd4e2..fa0a628f0ce4 100644 --- a/sdk/resourcemanager/billing/armbilling/permissions_client.go +++ b/sdk/resourcemanager/billing/armbilling/permissions_client.go @@ -11,13 +11,14 @@ package armbilling import ( "context" "errors" + "net/http" + "net/url" + "strings" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" ) // PermissionsClient contains the methods for the BillingPermissions group. @@ -40,9 +41,404 @@ func NewPermissionsClient(credential azcore.TokenCredential, options *arm.Client return client, nil } +// CheckAccessByBillingAccount - Provides a list of check access response objects for a billing account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - parameters - The request object against which access of the caller will be checked. +// - options - PermissionsClientCheckAccessByBillingAccountOptions contains the optional parameters for the PermissionsClient.CheckAccessByBillingAccount +// method. +func (client *PermissionsClient) CheckAccessByBillingAccount(ctx context.Context, billingAccountName string, parameters CheckAccessRequest, options *PermissionsClientCheckAccessByBillingAccountOptions) (PermissionsClientCheckAccessByBillingAccountResponse, error) { + var err error + const operationName = "PermissionsClient.CheckAccessByBillingAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.checkAccessByBillingAccountCreateRequest(ctx, billingAccountName, parameters, options) + if err != nil { + return PermissionsClientCheckAccessByBillingAccountResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PermissionsClientCheckAccessByBillingAccountResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PermissionsClientCheckAccessByBillingAccountResponse{}, err + } + resp, err := client.checkAccessByBillingAccountHandleResponse(httpResp) + return resp, err +} + +// checkAccessByBillingAccountCreateRequest creates the CheckAccessByBillingAccount request. +func (client *PermissionsClient) checkAccessByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, parameters CheckAccessRequest, options *PermissionsClientCheckAccessByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/checkAccess" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// checkAccessByBillingAccountHandleResponse handles the CheckAccessByBillingAccount response. +func (client *PermissionsClient) checkAccessByBillingAccountHandleResponse(resp *http.Response) (PermissionsClientCheckAccessByBillingAccountResponse, error) { + result := PermissionsClientCheckAccessByBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckAccessResponseArray); err != nil { + return PermissionsClientCheckAccessByBillingAccountResponse{}, err + } + return result, nil +} + +// CheckAccessByBillingProfile - Provides a list of check access response objects for a billing profile. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - parameters - The request object against which access of the caller will be checked. +// - options - PermissionsClientCheckAccessByBillingProfileOptions contains the optional parameters for the PermissionsClient.CheckAccessByBillingProfile +// method. +func (client *PermissionsClient) CheckAccessByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, parameters CheckAccessRequest, options *PermissionsClientCheckAccessByBillingProfileOptions) (PermissionsClientCheckAccessByBillingProfileResponse, error) { + var err error + const operationName = "PermissionsClient.CheckAccessByBillingProfile" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.checkAccessByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, parameters, options) + if err != nil { + return PermissionsClientCheckAccessByBillingProfileResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PermissionsClientCheckAccessByBillingProfileResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PermissionsClientCheckAccessByBillingProfileResponse{}, err + } + resp, err := client.checkAccessByBillingProfileHandleResponse(httpResp) + return resp, err +} + +// checkAccessByBillingProfileCreateRequest creates the CheckAccessByBillingProfile request. +func (client *PermissionsClient) checkAccessByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, parameters CheckAccessRequest, options *PermissionsClientCheckAccessByBillingProfileOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/checkAccess" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// checkAccessByBillingProfileHandleResponse handles the CheckAccessByBillingProfile response. +func (client *PermissionsClient) checkAccessByBillingProfileHandleResponse(resp *http.Response) (PermissionsClientCheckAccessByBillingProfileResponse, error) { + result := PermissionsClientCheckAccessByBillingProfileResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckAccessResponseArray); err != nil { + return PermissionsClientCheckAccessByBillingProfileResponse{}, err + } + return result, nil +} + +// CheckAccessByCustomer - Provides a list of check access response objects for a customer. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - customerName - The ID that uniquely identifies a customer. +// - parameters - The request object against which access of the caller will be checked. +// - options - PermissionsClientCheckAccessByCustomerOptions contains the optional parameters for the PermissionsClient.CheckAccessByCustomer +// method. +func (client *PermissionsClient) CheckAccessByCustomer(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, parameters CheckAccessRequest, options *PermissionsClientCheckAccessByCustomerOptions) (PermissionsClientCheckAccessByCustomerResponse, error) { + var err error + const operationName = "PermissionsClient.CheckAccessByCustomer" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.checkAccessByCustomerCreateRequest(ctx, billingAccountName, billingProfileName, customerName, parameters, options) + if err != nil { + return PermissionsClientCheckAccessByCustomerResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PermissionsClientCheckAccessByCustomerResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PermissionsClientCheckAccessByCustomerResponse{}, err + } + resp, err := client.checkAccessByCustomerHandleResponse(httpResp) + return resp, err +} + +// checkAccessByCustomerCreateRequest creates the CheckAccessByCustomer request. +func (client *PermissionsClient) checkAccessByCustomerCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, parameters CheckAccessRequest, options *PermissionsClientCheckAccessByCustomerOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/checkAccess" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if customerName == "" { + return nil, errors.New("parameter customerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{customerName}", url.PathEscape(customerName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// checkAccessByCustomerHandleResponse handles the CheckAccessByCustomer response. +func (client *PermissionsClient) checkAccessByCustomerHandleResponse(resp *http.Response) (PermissionsClientCheckAccessByCustomerResponse, error) { + result := PermissionsClientCheckAccessByCustomerResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckAccessResponseArray); err != nil { + return PermissionsClientCheckAccessByCustomerResponse{}, err + } + return result, nil +} + +// CheckAccessByDepartment - Provides a list of check access response objects for a department. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - departmentName - The name of the department. +// - parameters - The request object against which access of the caller will be checked. +// - options - PermissionsClientCheckAccessByDepartmentOptions contains the optional parameters for the PermissionsClient.CheckAccessByDepartment +// method. +func (client *PermissionsClient) CheckAccessByDepartment(ctx context.Context, billingAccountName string, departmentName string, parameters CheckAccessRequest, options *PermissionsClientCheckAccessByDepartmentOptions) (PermissionsClientCheckAccessByDepartmentResponse, error) { + var err error + const operationName = "PermissionsClient.CheckAccessByDepartment" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.checkAccessByDepartmentCreateRequest(ctx, billingAccountName, departmentName, parameters, options) + if err != nil { + return PermissionsClientCheckAccessByDepartmentResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PermissionsClientCheckAccessByDepartmentResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PermissionsClientCheckAccessByDepartmentResponse{}, err + } + resp, err := client.checkAccessByDepartmentHandleResponse(httpResp) + return resp, err +} + +// checkAccessByDepartmentCreateRequest creates the CheckAccessByDepartment request. +func (client *PermissionsClient) checkAccessByDepartmentCreateRequest(ctx context.Context, billingAccountName string, departmentName string, parameters CheckAccessRequest, options *PermissionsClientCheckAccessByDepartmentOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}/checkAccess" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if departmentName == "" { + return nil, errors.New("parameter departmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{departmentName}", url.PathEscape(departmentName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// checkAccessByDepartmentHandleResponse handles the CheckAccessByDepartment response. +func (client *PermissionsClient) checkAccessByDepartmentHandleResponse(resp *http.Response) (PermissionsClientCheckAccessByDepartmentResponse, error) { + result := PermissionsClientCheckAccessByDepartmentResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckAccessResponseArray); err != nil { + return PermissionsClientCheckAccessByDepartmentResponse{}, err + } + return result, nil +} + +// CheckAccessByEnrollmentAccount - Provides a list of check access response objects for an enrollment account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - enrollmentAccountName - The name of the enrollment account. +// - parameters - The request object against which access of the caller will be checked. +// - options - PermissionsClientCheckAccessByEnrollmentAccountOptions contains the optional parameters for the PermissionsClient.CheckAccessByEnrollmentAccount +// method. +func (client *PermissionsClient) CheckAccessByEnrollmentAccount(ctx context.Context, billingAccountName string, enrollmentAccountName string, parameters CheckAccessRequest, options *PermissionsClientCheckAccessByEnrollmentAccountOptions) (PermissionsClientCheckAccessByEnrollmentAccountResponse, error) { + var err error + const operationName = "PermissionsClient.CheckAccessByEnrollmentAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.checkAccessByEnrollmentAccountCreateRequest(ctx, billingAccountName, enrollmentAccountName, parameters, options) + if err != nil { + return PermissionsClientCheckAccessByEnrollmentAccountResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PermissionsClientCheckAccessByEnrollmentAccountResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PermissionsClientCheckAccessByEnrollmentAccountResponse{}, err + } + resp, err := client.checkAccessByEnrollmentAccountHandleResponse(httpResp) + return resp, err +} + +// checkAccessByEnrollmentAccountCreateRequest creates the CheckAccessByEnrollmentAccount request. +func (client *PermissionsClient) checkAccessByEnrollmentAccountCreateRequest(ctx context.Context, billingAccountName string, enrollmentAccountName string, parameters CheckAccessRequest, options *PermissionsClientCheckAccessByEnrollmentAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}/checkAccess" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if enrollmentAccountName == "" { + return nil, errors.New("parameter enrollmentAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{enrollmentAccountName}", url.PathEscape(enrollmentAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// checkAccessByEnrollmentAccountHandleResponse handles the CheckAccessByEnrollmentAccount response. +func (client *PermissionsClient) checkAccessByEnrollmentAccountHandleResponse(resp *http.Response) (PermissionsClientCheckAccessByEnrollmentAccountResponse, error) { + result := PermissionsClientCheckAccessByEnrollmentAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckAccessResponseArray); err != nil { + return PermissionsClientCheckAccessByEnrollmentAccountResponse{}, err + } + return result, nil +} + +// CheckAccessByInvoiceSection - Provides a list of check access response objects for an invoice section. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - invoiceSectionName - The ID that uniquely identifies an invoice section. +// - parameters - The request object against which access of the caller will be checked. +// - options - PermissionsClientCheckAccessByInvoiceSectionOptions contains the optional parameters for the PermissionsClient.CheckAccessByInvoiceSection +// method. +func (client *PermissionsClient) CheckAccessByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, parameters CheckAccessRequest, options *PermissionsClientCheckAccessByInvoiceSectionOptions) (PermissionsClientCheckAccessByInvoiceSectionResponse, error) { + var err error + const operationName = "PermissionsClient.CheckAccessByInvoiceSection" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.checkAccessByInvoiceSectionCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, parameters, options) + if err != nil { + return PermissionsClientCheckAccessByInvoiceSectionResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PermissionsClientCheckAccessByInvoiceSectionResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PermissionsClientCheckAccessByInvoiceSectionResponse{}, err + } + resp, err := client.checkAccessByInvoiceSectionHandleResponse(httpResp) + return resp, err +} + +// checkAccessByInvoiceSectionCreateRequest creates the CheckAccessByInvoiceSection request. +func (client *PermissionsClient) checkAccessByInvoiceSectionCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, parameters CheckAccessRequest, options *PermissionsClientCheckAccessByInvoiceSectionOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/checkAccess" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if invoiceSectionName == "" { + return nil, errors.New("parameter invoiceSectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// checkAccessByInvoiceSectionHandleResponse handles the CheckAccessByInvoiceSection response. +func (client *PermissionsClient) checkAccessByInvoiceSectionHandleResponse(resp *http.Response) (PermissionsClientCheckAccessByInvoiceSectionResponse, error) { + result := PermissionsClientCheckAccessByInvoiceSectionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckAccessResponseArray); err != nil { + return PermissionsClientCheckAccessByInvoiceSectionResponse{}, err + } + return result, nil +} + // NewListByBillingAccountPager - Lists the billing permissions the caller has on a billing account. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - options - PermissionsClientListByBillingAccountOptions contains the optional parameters for the PermissionsClient.NewListByBillingAccountPager // method. @@ -81,7 +477,7 @@ func (client *PermissionsClient) listByBillingAccountCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -90,7 +486,7 @@ func (client *PermissionsClient) listByBillingAccountCreateRequest(ctx context.C // listByBillingAccountHandleResponse handles the ListByBillingAccount response. func (client *PermissionsClient) listByBillingAccountHandleResponse(resp *http.Response) (PermissionsClientListByBillingAccountResponse, error) { result := PermissionsClientListByBillingAccountResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.PermissionsListResult); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.PermissionListResult); err != nil { return PermissionsClientListByBillingAccountResponse{}, err } return result, nil @@ -98,7 +494,7 @@ func (client *PermissionsClient) listByBillingAccountHandleResponse(resp *http.R // NewListByBillingProfilePager - Lists the billing permissions the caller has on a billing profile. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingProfileName - The ID that uniquely identifies a billing profile. // - options - PermissionsClientListByBillingProfileOptions contains the optional parameters for the PermissionsClient.NewListByBillingProfilePager @@ -142,7 +538,7 @@ func (client *PermissionsClient) listByBillingProfileCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -151,7 +547,7 @@ func (client *PermissionsClient) listByBillingProfileCreateRequest(ctx context.C // listByBillingProfileHandleResponse handles the ListByBillingProfile response. func (client *PermissionsClient) listByBillingProfileHandleResponse(resp *http.Response) (PermissionsClientListByBillingProfileResponse, error) { result := PermissionsClientListByBillingProfileResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.PermissionsListResult); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.PermissionListResult); err != nil { return PermissionsClientListByBillingProfileResponse{}, err } return result, nil @@ -159,12 +555,13 @@ func (client *PermissionsClient) listByBillingProfileHandleResponse(resp *http.R // NewListByCustomerPager - Lists the billing permissions the caller has for a customer. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. // - customerName - The ID that uniquely identifies a customer. // - options - PermissionsClientListByCustomerOptions contains the optional parameters for the PermissionsClient.NewListByCustomerPager // method. -func (client *PermissionsClient) NewListByCustomerPager(billingAccountName string, customerName string, options *PermissionsClientListByCustomerOptions) *runtime.Pager[PermissionsClientListByCustomerResponse] { +func (client *PermissionsClient) NewListByCustomerPager(billingAccountName string, billingProfileName string, customerName string, options *PermissionsClientListByCustomerOptions) *runtime.Pager[PermissionsClientListByCustomerResponse] { return runtime.NewPager(runtime.PagingHandler[PermissionsClientListByCustomerResponse]{ More: func(page PermissionsClientListByCustomerResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 @@ -176,7 +573,7 @@ func (client *PermissionsClient) NewListByCustomerPager(billingAccountName strin nextLink = *page.NextLink } resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listByCustomerCreateRequest(ctx, billingAccountName, customerName, options) + return client.listByCustomerCreateRequest(ctx, billingAccountName, billingProfileName, customerName, options) }, nil) if err != nil { return PermissionsClientListByCustomerResponse{}, err @@ -188,12 +585,16 @@ func (client *PermissionsClient) NewListByCustomerPager(billingAccountName strin } // listByCustomerCreateRequest creates the ListByCustomer request. -func (client *PermissionsClient) listByCustomerCreateRequest(ctx context.Context, billingAccountName string, customerName string, options *PermissionsClientListByCustomerOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/billingPermissions" +func (client *PermissionsClient) listByCustomerCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, options *PermissionsClientListByCustomerOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/billingPermissions" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) if customerName == "" { return nil, errors.New("parameter customerName cannot be empty") } @@ -203,7 +604,7 @@ func (client *PermissionsClient) listByCustomerCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -212,45 +613,229 @@ func (client *PermissionsClient) listByCustomerCreateRequest(ctx context.Context // listByCustomerHandleResponse handles the ListByCustomer response. func (client *PermissionsClient) listByCustomerHandleResponse(resp *http.Response) (PermissionsClientListByCustomerResponse, error) { result := PermissionsClientListByCustomerResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.PermissionsListResult); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.PermissionListResult); err != nil { return PermissionsClientListByCustomerResponse{}, err } return result, nil } -// NewListByInvoiceSectionsPager - Lists the billing permissions the caller has on an invoice section. +// NewListByCustomerAtBillingAccountPager - Lists the billing permissions the caller has for a customer at billing account +// level. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - customerName - The ID that uniquely identifies a customer. +// - options - PermissionsClientListByCustomerAtBillingAccountOptions contains the optional parameters for the PermissionsClient.NewListByCustomerAtBillingAccountPager +// method. +func (client *PermissionsClient) NewListByCustomerAtBillingAccountPager(billingAccountName string, customerName string, options *PermissionsClientListByCustomerAtBillingAccountOptions) *runtime.Pager[PermissionsClientListByCustomerAtBillingAccountResponse] { + return runtime.NewPager(runtime.PagingHandler[PermissionsClientListByCustomerAtBillingAccountResponse]{ + More: func(page PermissionsClientListByCustomerAtBillingAccountResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PermissionsClientListByCustomerAtBillingAccountResponse) (PermissionsClientListByCustomerAtBillingAccountResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PermissionsClient.NewListByCustomerAtBillingAccountPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByCustomerAtBillingAccountCreateRequest(ctx, billingAccountName, customerName, options) + }, nil) + if err != nil { + return PermissionsClientListByCustomerAtBillingAccountResponse{}, err + } + return client.listByCustomerAtBillingAccountHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByCustomerAtBillingAccountCreateRequest creates the ListByCustomerAtBillingAccount request. +func (client *PermissionsClient) listByCustomerAtBillingAccountCreateRequest(ctx context.Context, billingAccountName string, customerName string, options *PermissionsClientListByCustomerAtBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/billingPermissions" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if customerName == "" { + return nil, errors.New("parameter customerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{customerName}", url.PathEscape(customerName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByCustomerAtBillingAccountHandleResponse handles the ListByCustomerAtBillingAccount response. +func (client *PermissionsClient) listByCustomerAtBillingAccountHandleResponse(resp *http.Response) (PermissionsClientListByCustomerAtBillingAccountResponse, error) { + result := PermissionsClientListByCustomerAtBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PermissionListResult); err != nil { + return PermissionsClientListByCustomerAtBillingAccountResponse{}, err + } + return result, nil +} + +// NewListByDepartmentPager - Lists the billing permissions the caller has for a department. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - departmentName - The name of the department. +// - options - PermissionsClientListByDepartmentOptions contains the optional parameters for the PermissionsClient.NewListByDepartmentPager +// method. +func (client *PermissionsClient) NewListByDepartmentPager(billingAccountName string, departmentName string, options *PermissionsClientListByDepartmentOptions) *runtime.Pager[PermissionsClientListByDepartmentResponse] { + return runtime.NewPager(runtime.PagingHandler[PermissionsClientListByDepartmentResponse]{ + More: func(page PermissionsClientListByDepartmentResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PermissionsClientListByDepartmentResponse) (PermissionsClientListByDepartmentResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PermissionsClient.NewListByDepartmentPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByDepartmentCreateRequest(ctx, billingAccountName, departmentName, options) + }, nil) + if err != nil { + return PermissionsClientListByDepartmentResponse{}, err + } + return client.listByDepartmentHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByDepartmentCreateRequest creates the ListByDepartment request. +func (client *PermissionsClient) listByDepartmentCreateRequest(ctx context.Context, billingAccountName string, departmentName string, options *PermissionsClientListByDepartmentOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}/billingPermissions" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if departmentName == "" { + return nil, errors.New("parameter departmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{departmentName}", url.PathEscape(departmentName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByDepartmentHandleResponse handles the ListByDepartment response. +func (client *PermissionsClient) listByDepartmentHandleResponse(resp *http.Response) (PermissionsClientListByDepartmentResponse, error) { + result := PermissionsClientListByDepartmentResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PermissionListResult); err != nil { + return PermissionsClientListByDepartmentResponse{}, err + } + return result, nil +} + +// NewListByEnrollmentAccountPager - Lists the billing permissions the caller has for an enrollment account. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - enrollmentAccountName - The name of the enrollment account. +// - options - PermissionsClientListByEnrollmentAccountOptions contains the optional parameters for the PermissionsClient.NewListByEnrollmentAccountPager +// method. +func (client *PermissionsClient) NewListByEnrollmentAccountPager(billingAccountName string, enrollmentAccountName string, options *PermissionsClientListByEnrollmentAccountOptions) *runtime.Pager[PermissionsClientListByEnrollmentAccountResponse] { + return runtime.NewPager(runtime.PagingHandler[PermissionsClientListByEnrollmentAccountResponse]{ + More: func(page PermissionsClientListByEnrollmentAccountResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PermissionsClientListByEnrollmentAccountResponse) (PermissionsClientListByEnrollmentAccountResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PermissionsClient.NewListByEnrollmentAccountPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByEnrollmentAccountCreateRequest(ctx, billingAccountName, enrollmentAccountName, options) + }, nil) + if err != nil { + return PermissionsClientListByEnrollmentAccountResponse{}, err + } + return client.listByEnrollmentAccountHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByEnrollmentAccountCreateRequest creates the ListByEnrollmentAccount request. +func (client *PermissionsClient) listByEnrollmentAccountCreateRequest(ctx context.Context, billingAccountName string, enrollmentAccountName string, options *PermissionsClientListByEnrollmentAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}/billingPermissions" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if enrollmentAccountName == "" { + return nil, errors.New("parameter enrollmentAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{enrollmentAccountName}", url.PathEscape(enrollmentAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByEnrollmentAccountHandleResponse handles the ListByEnrollmentAccount response. +func (client *PermissionsClient) listByEnrollmentAccountHandleResponse(resp *http.Response) (PermissionsClientListByEnrollmentAccountResponse, error) { + result := PermissionsClientListByEnrollmentAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PermissionListResult); err != nil { + return PermissionsClientListByEnrollmentAccountResponse{}, err + } + return result, nil +} + +// NewListByInvoiceSectionPager - Lists the billing permissions the caller has for an invoice section. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingProfileName - The ID that uniquely identifies a billing profile. // - invoiceSectionName - The ID that uniquely identifies an invoice section. -// - options - PermissionsClientListByInvoiceSectionsOptions contains the optional parameters for the PermissionsClient.NewListByInvoiceSectionsPager +// - options - PermissionsClientListByInvoiceSectionOptions contains the optional parameters for the PermissionsClient.NewListByInvoiceSectionPager // method. -func (client *PermissionsClient) NewListByInvoiceSectionsPager(billingAccountName string, billingProfileName string, invoiceSectionName string, options *PermissionsClientListByInvoiceSectionsOptions) *runtime.Pager[PermissionsClientListByInvoiceSectionsResponse] { - return runtime.NewPager(runtime.PagingHandler[PermissionsClientListByInvoiceSectionsResponse]{ - More: func(page PermissionsClientListByInvoiceSectionsResponse) bool { +func (client *PermissionsClient) NewListByInvoiceSectionPager(billingAccountName string, billingProfileName string, invoiceSectionName string, options *PermissionsClientListByInvoiceSectionOptions) *runtime.Pager[PermissionsClientListByInvoiceSectionResponse] { + return runtime.NewPager(runtime.PagingHandler[PermissionsClientListByInvoiceSectionResponse]{ + More: func(page PermissionsClientListByInvoiceSectionResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *PermissionsClientListByInvoiceSectionsResponse) (PermissionsClientListByInvoiceSectionsResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PermissionsClient.NewListByInvoiceSectionsPager") + Fetcher: func(ctx context.Context, page *PermissionsClientListByInvoiceSectionResponse) (PermissionsClientListByInvoiceSectionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PermissionsClient.NewListByInvoiceSectionPager") nextLink := "" if page != nil { nextLink = *page.NextLink } resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listByInvoiceSectionsCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, options) + return client.listByInvoiceSectionCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, options) }, nil) if err != nil { - return PermissionsClientListByInvoiceSectionsResponse{}, err + return PermissionsClientListByInvoiceSectionResponse{}, err } - return client.listByInvoiceSectionsHandleResponse(resp) + return client.listByInvoiceSectionHandleResponse(resp) }, Tracer: client.internal.Tracer(), }) } -// listByInvoiceSectionsCreateRequest creates the ListByInvoiceSections request. -func (client *PermissionsClient) listByInvoiceSectionsCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, options *PermissionsClientListByInvoiceSectionsOptions) (*policy.Request, error) { +// listByInvoiceSectionCreateRequest creates the ListByInvoiceSection request. +func (client *PermissionsClient) listByInvoiceSectionCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, options *PermissionsClientListByInvoiceSectionOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingPermissions" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") @@ -269,17 +854,17 @@ func (client *PermissionsClient) listByInvoiceSectionsCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } -// listByInvoiceSectionsHandleResponse handles the ListByInvoiceSections response. -func (client *PermissionsClient) listByInvoiceSectionsHandleResponse(resp *http.Response) (PermissionsClientListByInvoiceSectionsResponse, error) { - result := PermissionsClientListByInvoiceSectionsResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.PermissionsListResult); err != nil { - return PermissionsClientListByInvoiceSectionsResponse{}, err +// listByInvoiceSectionHandleResponse handles the ListByInvoiceSection response. +func (client *PermissionsClient) listByInvoiceSectionHandleResponse(resp *http.Response) (PermissionsClientListByInvoiceSectionResponse, error) { + result := PermissionsClientListByInvoiceSectionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PermissionListResult); err != nil { + return PermissionsClientListByInvoiceSectionResponse{}, err } return result, nil } diff --git a/sdk/resourcemanager/billing/armbilling/permissions_client_example_test.go b/sdk/resourcemanager/billing/armbilling/permissions_client_example_test.go index b06527916e52..3af160935fc7 100644 --- a/sdk/resourcemanager/billing/armbilling/permissions_client_example_test.go +++ b/sdk/resourcemanager/billing/armbilling/permissions_client_example_test.go @@ -13,12 +13,13 @@ import ( "context" "log" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/CustomerPermissionsList.json -func ExamplePermissionsClient_NewListByCustomerPager() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingPermissionsListByBillingAccount.json +func ExamplePermissionsClient_NewListByBillingAccountPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -28,7 +29,7 @@ func ExamplePermissionsClient_NewListByCustomerPager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewPermissionsClient().NewListByCustomerPager("{billingAccountName}", "{customerName}", nil) + pager := clientFactory.NewPermissionsClient().NewListByBillingAccountPager("10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -39,15 +40,28 @@ func ExamplePermissionsClient_NewListByCustomerPager() { _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.PermissionsListResult = armbilling.PermissionsListResult{ - // Value: []*armbilling.PermissionsProperties{ + // page.PermissionListResult = armbilling.PermissionListResult{ + // Value: []*armbilling.Permission{ // { // Actions: []*string{ + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000002"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000000"), // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), + // to.Ptr("20000000-aaaa-bbbb-cccc-200000000002"), // to.Ptr("30000000-aaaa-bbbb-cccc-200000000009"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000000"), // to.Ptr("30000000-aaaa-bbbb-cccc-200000000000"), + // to.Ptr("20000000-aaaa-bbbb-cccc-200000000000"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001")}, // NotActions: []*string{ @@ -57,8 +71,8 @@ func ExamplePermissionsClient_NewListByCustomerPager() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingAccountPermissionsList.json -func ExamplePermissionsClient_NewListByBillingAccountPager() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingPermissionsListByBillingProfile.json +func ExamplePermissionsClient_NewListByBillingProfilePager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -68,7 +82,7 @@ func ExamplePermissionsClient_NewListByBillingAccountPager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewPermissionsClient().NewListByBillingAccountPager("{billingAccountName}", nil) + pager := clientFactory.NewPermissionsClient().NewListByBillingProfilePager("10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -79,8 +93,8 @@ func ExamplePermissionsClient_NewListByBillingAccountPager() { _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.PermissionsListResult = armbilling.PermissionsListResult{ - // Value: []*armbilling.PermissionsProperties{ + // page.PermissionListResult = armbilling.PermissionListResult{ + // Value: []*armbilling.Permission{ // { // Actions: []*string{ // to.Ptr("10000000-aaaa-bbbb-cccc-200000000006"), @@ -110,8 +124,41 @@ func ExamplePermissionsClient_NewListByBillingAccountPager() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/InvoiceSectionPermissionsList.json -func ExamplePermissionsClient_NewListByInvoiceSectionsPager() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/checkAccessByBillingProfile.json +func ExamplePermissionsClient_CheckAccessByBillingProfile() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPermissionsClient().CheckAccessByBillingProfile(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", armbilling.CheckAccessRequest{ + Actions: []*string{ + to.Ptr("Microsoft.Billing/billingAccounts/read"), + to.Ptr("Microsoft.Subscription/subscriptions/write")}, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CheckAccessResponseArray = []*armbilling.CheckAccessResponse{ + // { + // AccessDecision: to.Ptr(armbilling.AccessDecisionAllowed), + // Action: to.Ptr("Microsoft.Billing/billingAccounts/read"), + // }, + // { + // AccessDecision: to.Ptr(armbilling.AccessDecisionNotAllowed), + // Action: to.Ptr("Microsoft.Subscription/subscriptions/write"), + // }} +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingPermissionsListByCustomer.json +func ExamplePermissionsClient_NewListByCustomerPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -121,7 +168,7 @@ func ExamplePermissionsClient_NewListByInvoiceSectionsPager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewPermissionsClient().NewListByInvoiceSectionsPager("{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", nil) + pager := clientFactory.NewPermissionsClient().NewListByCustomerPager("10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "BKM6-54VH-BG7-PGB", "11111111-1111-1111-1111-111111111111", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -132,28 +179,15 @@ func ExamplePermissionsClient_NewListByInvoiceSectionsPager() { _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.PermissionsListResult = armbilling.PermissionsListResult{ - // Value: []*armbilling.PermissionsProperties{ + // page.PermissionListResult = armbilling.PermissionListResult{ + // Value: []*armbilling.Permission{ // { // Actions: []*string{ - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000003"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000002"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000001"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000000"), // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), - // to.Ptr("20000000-aaaa-bbbb-cccc-200000000002"), // to.Ptr("30000000-aaaa-bbbb-cccc-200000000009"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000000"), // to.Ptr("30000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("20000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000008"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001")}, // NotActions: []*string{ @@ -163,8 +197,8 @@ func ExamplePermissionsClient_NewListByInvoiceSectionsPager() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingProfilePermissionsList.json -func ExamplePermissionsClient_NewListByBillingProfilePager() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/checkAccessByCustomer.json +func ExamplePermissionsClient_CheckAccessByCustomer() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -174,7 +208,40 @@ func ExamplePermissionsClient_NewListByBillingProfilePager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewPermissionsClient().NewListByBillingProfilePager("{billingAccountName}", "{billingProfileName}", nil) + res, err := clientFactory.NewPermissionsClient().CheckAccessByCustomer(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "703ab484-dda2-4402-827b-a74513b61e2d", armbilling.CheckAccessRequest{ + Actions: []*string{ + to.Ptr("Microsoft.Billing/billingAccounts/read"), + to.Ptr("Microsoft.Subscription/subscriptions/write")}, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CheckAccessResponseArray = []*armbilling.CheckAccessResponse{ + // { + // AccessDecision: to.Ptr(armbilling.AccessDecisionAllowed), + // Action: to.Ptr("Microsoft.Billing/billingAccounts/read"), + // }, + // { + // AccessDecision: to.Ptr(armbilling.AccessDecisionNotAllowed), + // Action: to.Ptr("Microsoft.Subscription/subscriptions/write"), + // }} +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingPermissionsListByInvoiceSection.json +func ExamplePermissionsClient_NewListByInvoiceSectionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewPermissionsClient().NewListByInvoiceSectionPager("10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "XXXX-XXXX-XXX-XXX", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -185,28 +252,121 @@ func ExamplePermissionsClient_NewListByBillingProfilePager() { _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.PermissionsListResult = armbilling.PermissionsListResult{ - // Value: []*armbilling.PermissionsProperties{ + // page.PermissionListResult = armbilling.PermissionListResult{ + // Value: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000009"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000000"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001")}, + // NotActions: []*string{ + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/checkAccessByInvoiceSection.json +func ExamplePermissionsClient_CheckAccessByInvoiceSection() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPermissionsClient().CheckAccessByInvoiceSection(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "Q7GV-UUVA-PJA-TGB", armbilling.CheckAccessRequest{ + Actions: []*string{ + to.Ptr("Microsoft.Billing/billingAccounts/read"), + to.Ptr("Microsoft.Subscription/subscriptions/write")}, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CheckAccessResponseArray = []*armbilling.CheckAccessResponse{ + // { + // AccessDecision: to.Ptr(armbilling.AccessDecisionAllowed), + // Action: to.Ptr("Microsoft.Billing/billingAccounts/read"), + // }, + // { + // AccessDecision: to.Ptr(armbilling.AccessDecisionNotAllowed), + // Action: to.Ptr("Microsoft.Subscription/subscriptions/write"), + // }} +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/checkAccessByBillingAccount.json +func ExamplePermissionsClient_CheckAccessByBillingAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPermissionsClient().CheckAccessByBillingAccount(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", armbilling.CheckAccessRequest{ + Actions: []*string{ + to.Ptr("Microsoft.Billing/billingAccounts/read"), + to.Ptr("Microsoft.Subscription/subscriptions/write")}, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CheckAccessResponseArray = []*armbilling.CheckAccessResponse{ + // { + // AccessDecision: to.Ptr(armbilling.AccessDecisionAllowed), + // Action: to.Ptr("Microsoft.Billing/billingAccounts/read"), + // }, + // { + // AccessDecision: to.Ptr(armbilling.AccessDecisionNotAllowed), + // Action: to.Ptr("Microsoft.Subscription/subscriptions/write"), + // }} +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingPermissionsListByCustomerAtBillingAccount.json +func ExamplePermissionsClient_NewListByCustomerAtBillingAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewPermissionsClient().NewListByCustomerAtBillingAccountPager("10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "11111111-1111-1111-1111-111111111111", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.PermissionListResult = armbilling.PermissionListResult{ + // Value: []*armbilling.Permission{ // { // Actions: []*string{ - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000003"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000002"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000001"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000000"), // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), - // to.Ptr("20000000-aaaa-bbbb-cccc-200000000002"), // to.Ptr("30000000-aaaa-bbbb-cccc-200000000009"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000000"), // to.Ptr("30000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("20000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000008"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001")}, // NotActions: []*string{ @@ -215,3 +375,145 @@ func ExamplePermissionsClient_NewListByBillingProfilePager() { // } } } + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingPermissionsListByDepartment.json +func ExamplePermissionsClient_NewListByDepartmentPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewPermissionsClient().NewListByDepartmentPager("6100092", "123456", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.PermissionListResult = armbilling.PermissionListResult{ + // Value: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("Microsoft.Billing/billingAccounts/departments/read"), + // to.Ptr("Microsoft.Billing/billingAccounts/departments/write"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/read"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/write"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/billingSubscriptions/read"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/billingSubscriptions/write")}, + // NotActions: []*string{ + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/checkAccessByDepartment.json +func ExamplePermissionsClient_CheckAccessByDepartment() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPermissionsClient().CheckAccessByDepartment(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "12345", armbilling.CheckAccessRequest{ + Actions: []*string{ + to.Ptr("Microsoft.Billing/billingAccounts/read"), + to.Ptr("Microsoft.Subscription/subscriptions/write")}, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CheckAccessResponseArray = []*armbilling.CheckAccessResponse{ + // { + // AccessDecision: to.Ptr(armbilling.AccessDecisionAllowed), + // Action: to.Ptr("Microsoft.Billing/billingAccounts/read"), + // }, + // { + // AccessDecision: to.Ptr(armbilling.AccessDecisionNotAllowed), + // Action: to.Ptr("Microsoft.Subscription/subscriptions/write"), + // }} +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingPermissionsListByEnrollmentAccount.json +func ExamplePermissionsClient_NewListByEnrollmentAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewPermissionsClient().NewListByEnrollmentAccountPager("6100092", "123456", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.PermissionListResult = armbilling.PermissionListResult{ + // Value: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/read"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/write"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/billingSubscriptions/read"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/billingSubscriptions/write")}, + // NotActions: []*string{ + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/checkAccessByEnrollmentAccount.json +func ExamplePermissionsClient_CheckAccessByEnrollmentAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPermissionsClient().CheckAccessByEnrollmentAccount(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "123456", armbilling.CheckAccessRequest{ + Actions: []*string{ + to.Ptr("Microsoft.Billing/billingAccounts/read"), + to.Ptr("Microsoft.Subscription/subscriptions/write")}, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CheckAccessResponseArray = []*armbilling.CheckAccessResponse{ + // { + // AccessDecision: to.Ptr(armbilling.AccessDecisionAllowed), + // Action: to.Ptr("Microsoft.Billing/billingAccounts/read"), + // }, + // { + // AccessDecision: to.Ptr(armbilling.AccessDecisionNotAllowed), + // Action: to.Ptr("Microsoft.Subscription/subscriptions/write"), + // }} +} diff --git a/sdk/resourcemanager/billing/armbilling/policies_client.go b/sdk/resourcemanager/billing/armbilling/policies_client.go index 353ca7649349..29c00c7fb82a 100644 --- a/sdk/resourcemanager/billing/armbilling/policies_client.go +++ b/sdk/resourcemanager/billing/armbilling/policies_client.go @@ -11,40 +11,410 @@ package armbilling import ( "context" "errors" + "net/http" + "net/url" + "strings" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" ) // PoliciesClient contains the methods for the Policies group. // Don't use this type directly, use NewPoliciesClient() instead. type PoliciesClient struct { - internal *arm.Client + internal *arm.Client + subscriptionID string } // NewPoliciesClient creates a new instance of PoliciesClient with the specified values. +// - subscriptionID - The ID that uniquely identifies a billing subscription. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. -func NewPoliciesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*PoliciesClient, error) { +func NewPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PoliciesClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } client := &PoliciesClient{ - internal: cl, + subscriptionID: subscriptionID, + internal: cl, } return client, nil } +// BeginCreateOrUpdateByBillingAccount - Update the policies for a billing account of Enterprise Agreement type. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - parameters - A policy at billing account scope. +// - options - PoliciesClientBeginCreateOrUpdateByBillingAccountOptions contains the optional parameters for the PoliciesClient.BeginCreateOrUpdateByBillingAccount +// method. +func (client *PoliciesClient) BeginCreateOrUpdateByBillingAccount(ctx context.Context, billingAccountName string, parameters AccountPolicy, options *PoliciesClientBeginCreateOrUpdateByBillingAccountOptions) (*runtime.Poller[PoliciesClientCreateOrUpdateByBillingAccountResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdateByBillingAccount(ctx, billingAccountName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PoliciesClientCreateOrUpdateByBillingAccountResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PoliciesClientCreateOrUpdateByBillingAccountResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdateByBillingAccount - Update the policies for a billing account of Enterprise Agreement type. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *PoliciesClient) createOrUpdateByBillingAccount(ctx context.Context, billingAccountName string, parameters AccountPolicy, options *PoliciesClientBeginCreateOrUpdateByBillingAccountOptions) (*http.Response, error) { + var err error + const operationName = "PoliciesClient.BeginCreateOrUpdateByBillingAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateByBillingAccountCreateRequest(ctx, billingAccountName, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateByBillingAccountCreateRequest creates the CreateOrUpdateByBillingAccount request. +func (client *PoliciesClient) createOrUpdateByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, parameters AccountPolicy, options *PoliciesClientBeginCreateOrUpdateByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/policies/default" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// BeginCreateOrUpdateByBillingProfile - Updates the policies for a billing profile. This operation is supported only for +// billing accounts with agreement type Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - parameters - A policy at billing profile scope. +// - options - PoliciesClientBeginCreateOrUpdateByBillingProfileOptions contains the optional parameters for the PoliciesClient.BeginCreateOrUpdateByBillingProfile +// method. +func (client *PoliciesClient) BeginCreateOrUpdateByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, parameters ProfilePolicy, options *PoliciesClientBeginCreateOrUpdateByBillingProfileOptions) (*runtime.Poller[PoliciesClientCreateOrUpdateByBillingProfileResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdateByBillingProfile(ctx, billingAccountName, billingProfileName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PoliciesClientCreateOrUpdateByBillingProfileResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PoliciesClientCreateOrUpdateByBillingProfileResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdateByBillingProfile - Updates the policies for a billing profile. This operation is supported only for billing +// accounts with agreement type Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *PoliciesClient) createOrUpdateByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, parameters ProfilePolicy, options *PoliciesClientBeginCreateOrUpdateByBillingProfileOptions) (*http.Response, error) { + var err error + const operationName = "PoliciesClient.BeginCreateOrUpdateByBillingProfile" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateByBillingProfileCreateRequest creates the CreateOrUpdateByBillingProfile request. +func (client *PoliciesClient) createOrUpdateByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, parameters ProfilePolicy, options *PoliciesClientBeginCreateOrUpdateByBillingProfileOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// BeginCreateOrUpdateByCustomer - Updates the policies for a customer. This operation is supported only for billing accounts +// with agreement type Microsoft Partner Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - customerName - The ID that uniquely identifies a customer. +// - parameters - A policy at customer scope. +// - options - PoliciesClientBeginCreateOrUpdateByCustomerOptions contains the optional parameters for the PoliciesClient.BeginCreateOrUpdateByCustomer +// method. +func (client *PoliciesClient) BeginCreateOrUpdateByCustomer(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, parameters CustomerPolicy, options *PoliciesClientBeginCreateOrUpdateByCustomerOptions) (*runtime.Poller[PoliciesClientCreateOrUpdateByCustomerResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdateByCustomer(ctx, billingAccountName, billingProfileName, customerName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PoliciesClientCreateOrUpdateByCustomerResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PoliciesClientCreateOrUpdateByCustomerResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdateByCustomer - Updates the policies for a customer. This operation is supported only for billing accounts with +// agreement type Microsoft Partner Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *PoliciesClient) createOrUpdateByCustomer(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, parameters CustomerPolicy, options *PoliciesClientBeginCreateOrUpdateByCustomerOptions) (*http.Response, error) { + var err error + const operationName = "PoliciesClient.BeginCreateOrUpdateByCustomer" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateByCustomerCreateRequest(ctx, billingAccountName, billingProfileName, customerName, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateByCustomerCreateRequest creates the CreateOrUpdateByCustomer request. +func (client *PoliciesClient) createOrUpdateByCustomerCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, parameters CustomerPolicy, options *PoliciesClientBeginCreateOrUpdateByCustomerOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/policies/default" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if customerName == "" { + return nil, errors.New("parameter customerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{customerName}", url.PathEscape(customerName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// BeginCreateOrUpdateByCustomerAtBillingAccount - Updates the policies for a customer at billing account scope. This operation +// is supported only for billing accounts with agreement type Microsoft Partner Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - customerName - The ID that uniquely identifies a customer. +// - parameters - A policy at customer scope. +// - options - PoliciesClientBeginCreateOrUpdateByCustomerAtBillingAccountOptions contains the optional parameters for the PoliciesClient.BeginCreateOrUpdateByCustomerAtBillingAccount +// method. +func (client *PoliciesClient) BeginCreateOrUpdateByCustomerAtBillingAccount(ctx context.Context, billingAccountName string, customerName string, parameters CustomerPolicy, options *PoliciesClientBeginCreateOrUpdateByCustomerAtBillingAccountOptions) (*runtime.Poller[PoliciesClientCreateOrUpdateByCustomerAtBillingAccountResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdateByCustomerAtBillingAccount(ctx, billingAccountName, customerName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PoliciesClientCreateOrUpdateByCustomerAtBillingAccountResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PoliciesClientCreateOrUpdateByCustomerAtBillingAccountResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdateByCustomerAtBillingAccount - Updates the policies for a customer at billing account scope. This operation +// is supported only for billing accounts with agreement type Microsoft Partner Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *PoliciesClient) createOrUpdateByCustomerAtBillingAccount(ctx context.Context, billingAccountName string, customerName string, parameters CustomerPolicy, options *PoliciesClientBeginCreateOrUpdateByCustomerAtBillingAccountOptions) (*http.Response, error) { + var err error + const operationName = "PoliciesClient.BeginCreateOrUpdateByCustomerAtBillingAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateByCustomerAtBillingAccountCreateRequest(ctx, billingAccountName, customerName, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateByCustomerAtBillingAccountCreateRequest creates the CreateOrUpdateByCustomerAtBillingAccount request. +func (client *PoliciesClient) createOrUpdateByCustomerAtBillingAccountCreateRequest(ctx context.Context, billingAccountName string, customerName string, parameters CustomerPolicy, options *PoliciesClientBeginCreateOrUpdateByCustomerAtBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if customerName == "" { + return nil, errors.New("parameter customerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{customerName}", url.PathEscape(customerName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// GetByBillingAccount - Get the policies for a billing account of Enterprise Agreement type. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - options - PoliciesClientGetByBillingAccountOptions contains the optional parameters for the PoliciesClient.GetByBillingAccount +// method. +func (client *PoliciesClient) GetByBillingAccount(ctx context.Context, billingAccountName string, options *PoliciesClientGetByBillingAccountOptions) (PoliciesClientGetByBillingAccountResponse, error) { + var err error + const operationName = "PoliciesClient.GetByBillingAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByBillingAccountCreateRequest(ctx, billingAccountName, options) + if err != nil { + return PoliciesClientGetByBillingAccountResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PoliciesClientGetByBillingAccountResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PoliciesClientGetByBillingAccountResponse{}, err + } + resp, err := client.getByBillingAccountHandleResponse(httpResp) + return resp, err +} + +// getByBillingAccountCreateRequest creates the GetByBillingAccount request. +func (client *PoliciesClient) getByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, options *PoliciesClientGetByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/policies/default" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByBillingAccountHandleResponse handles the GetByBillingAccount response. +func (client *PoliciesClient) getByBillingAccountHandleResponse(resp *http.Response) (PoliciesClientGetByBillingAccountResponse, error) { + result := PoliciesClientGetByBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AccountPolicy); err != nil { + return PoliciesClientGetByBillingAccountResponse{}, err + } + return result, nil +} + // GetByBillingProfile - Lists the policies for a billing profile. This operation is supported only for billing accounts with // agreement type Microsoft Customer Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingProfileName - The ID that uniquely identifies a billing profile. // - options - PoliciesClientGetByBillingProfileOptions contains the optional parameters for the PoliciesClient.GetByBillingProfile @@ -87,7 +457,7 @@ func (client *PoliciesClient) getByBillingProfileCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -96,7 +466,7 @@ func (client *PoliciesClient) getByBillingProfileCreateRequest(ctx context.Conte // getByBillingProfileHandleResponse handles the GetByBillingProfile response. func (client *PoliciesClient) getByBillingProfileHandleResponse(resp *http.Response) (PoliciesClientGetByBillingProfileResponse, error) { result := PoliciesClientGetByBillingProfileResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Policy); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.ProfilePolicy); err != nil { return PoliciesClientGetByBillingProfileResponse{}, err } return result, nil @@ -106,17 +476,19 @@ func (client *PoliciesClient) getByBillingProfileHandleResponse(resp *http.Respo // type Microsoft Partner Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. // - customerName - The ID that uniquely identifies a customer. +// - policyName - Service-defined resource names such as 'default' which are reserved resource names. // - options - PoliciesClientGetByCustomerOptions contains the optional parameters for the PoliciesClient.GetByCustomer method. -func (client *PoliciesClient) GetByCustomer(ctx context.Context, billingAccountName string, customerName string, options *PoliciesClientGetByCustomerOptions) (PoliciesClientGetByCustomerResponse, error) { +func (client *PoliciesClient) GetByCustomer(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, policyName ServiceDefinedResourceName, options *PoliciesClientGetByCustomerOptions) (PoliciesClientGetByCustomerResponse, error) { var err error const operationName = "PoliciesClient.GetByCustomer" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getByCustomerCreateRequest(ctx, billingAccountName, customerName, options) + req, err := client.getByCustomerCreateRequest(ctx, billingAccountName, billingProfileName, customerName, policyName, options) if err != nil { return PoliciesClientGetByCustomerResponse{}, err } @@ -133,22 +505,30 @@ func (client *PoliciesClient) GetByCustomer(ctx context.Context, billingAccountN } // getByCustomerCreateRequest creates the GetByCustomer request. -func (client *PoliciesClient) getByCustomerCreateRequest(ctx context.Context, billingAccountName string, customerName string, options *PoliciesClientGetByCustomerOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default" +func (client *PoliciesClient) getByCustomerCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, policyName ServiceDefinedResourceName, options *PoliciesClientGetByCustomerOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/policies/{policyName}" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) if customerName == "" { return nil, errors.New("parameter customerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{customerName}", url.PathEscape(customerName)) + if policyName == "" { + return nil, errors.New("parameter policyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyName}", url.PathEscape(string(policyName))) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -163,132 +543,121 @@ func (client *PoliciesClient) getByCustomerHandleResponse(resp *http.Response) ( return result, nil } -// Update - Updates the policies for a billing profile. This operation is supported only for billing accounts with agreement -// type Microsoft Customer Agreement. +// GetByCustomerAtBillingAccount - Lists the policies for a customer at billing account scope. This operation is supported +// only for billing accounts with agreement type Microsoft Partner Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. -// - billingProfileName - The ID that uniquely identifies a billing profile. -// - parameters - Request parameters that are provided to the update policies operation. -// - options - PoliciesClientUpdateOptions contains the optional parameters for the PoliciesClient.Update method. -func (client *PoliciesClient) Update(ctx context.Context, billingAccountName string, billingProfileName string, parameters Policy, options *PoliciesClientUpdateOptions) (PoliciesClientUpdateResponse, error) { +// - customerName - The ID that uniquely identifies a customer. +// - options - PoliciesClientGetByCustomerAtBillingAccountOptions contains the optional parameters for the PoliciesClient.GetByCustomerAtBillingAccount +// method. +func (client *PoliciesClient) GetByCustomerAtBillingAccount(ctx context.Context, billingAccountName string, customerName string, options *PoliciesClientGetByCustomerAtBillingAccountOptions) (PoliciesClientGetByCustomerAtBillingAccountResponse, error) { var err error - const operationName = "PoliciesClient.Update" + const operationName = "PoliciesClient.GetByCustomerAtBillingAccount" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.updateCreateRequest(ctx, billingAccountName, billingProfileName, parameters, options) + req, err := client.getByCustomerAtBillingAccountCreateRequest(ctx, billingAccountName, customerName, options) if err != nil { - return PoliciesClientUpdateResponse{}, err + return PoliciesClientGetByCustomerAtBillingAccountResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return PoliciesClientUpdateResponse{}, err + return PoliciesClientGetByCustomerAtBillingAccountResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return PoliciesClientUpdateResponse{}, err + return PoliciesClientGetByCustomerAtBillingAccountResponse{}, err } - resp, err := client.updateHandleResponse(httpResp) + resp, err := client.getByCustomerAtBillingAccountHandleResponse(httpResp) return resp, err } -// updateCreateRequest creates the Update request. -func (client *PoliciesClient) updateCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, parameters Policy, options *PoliciesClientUpdateOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default" +// getByCustomerAtBillingAccountCreateRequest creates the GetByCustomerAtBillingAccount request. +func (client *PoliciesClient) getByCustomerAtBillingAccountCreateRequest(ctx context.Context, billingAccountName string, customerName string, options *PoliciesClientGetByCustomerAtBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) - if billingProfileName == "" { - return nil, errors.New("parameter billingProfileName cannot be empty") + if customerName == "" { + return nil, errors.New("parameter customerName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + urlPath = strings.ReplaceAll(urlPath, "{customerName}", url.PathEscape(customerName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, parameters); err != nil { - return nil, err - } return req, nil } -// updateHandleResponse handles the Update response. -func (client *PoliciesClient) updateHandleResponse(resp *http.Response) (PoliciesClientUpdateResponse, error) { - result := PoliciesClientUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Policy); err != nil { - return PoliciesClientUpdateResponse{}, err +// getByCustomerAtBillingAccountHandleResponse handles the GetByCustomerAtBillingAccount response. +func (client *PoliciesClient) getByCustomerAtBillingAccountHandleResponse(resp *http.Response) (PoliciesClientGetByCustomerAtBillingAccountResponse, error) { + result := PoliciesClientGetByCustomerAtBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CustomerPolicy); err != nil { + return PoliciesClientGetByCustomerAtBillingAccountResponse{}, err } return result, nil } -// UpdateCustomer - Updates the policies for a customer. This operation is supported only for billing accounts with agreement -// type Microsoft Partner Agreement. +// GetBySubscription - Lists the policies that are managed by the Billing Admin for the defined subscriptions. This is supported +// for Microsoft Online Services Program, Microsoft Customer Agreement and Microsoft Partner +// Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 -// - billingAccountName - The ID that uniquely identifies a billing account. -// - customerName - The ID that uniquely identifies a customer. -// - parameters - Request parameters that are provided to the update policies operation. -// - options - PoliciesClientUpdateCustomerOptions contains the optional parameters for the PoliciesClient.UpdateCustomer method. -func (client *PoliciesClient) UpdateCustomer(ctx context.Context, billingAccountName string, customerName string, parameters CustomerPolicy, options *PoliciesClientUpdateCustomerOptions) (PoliciesClientUpdateCustomerResponse, error) { +// Generated from API version 2024-04-01 +// - options - PoliciesClientGetBySubscriptionOptions contains the optional parameters for the PoliciesClient.GetBySubscription +// method. +func (client *PoliciesClient) GetBySubscription(ctx context.Context, options *PoliciesClientGetBySubscriptionOptions) (PoliciesClientGetBySubscriptionResponse, error) { var err error - const operationName = "PoliciesClient.UpdateCustomer" + const operationName = "PoliciesClient.GetBySubscription" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.updateCustomerCreateRequest(ctx, billingAccountName, customerName, parameters, options) + req, err := client.getBySubscriptionCreateRequest(ctx, options) if err != nil { - return PoliciesClientUpdateCustomerResponse{}, err + return PoliciesClientGetBySubscriptionResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return PoliciesClientUpdateCustomerResponse{}, err + return PoliciesClientGetBySubscriptionResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return PoliciesClientUpdateCustomerResponse{}, err + return PoliciesClientGetBySubscriptionResponse{}, err } - resp, err := client.updateCustomerHandleResponse(httpResp) + resp, err := client.getBySubscriptionHandleResponse(httpResp) return resp, err } -// updateCustomerCreateRequest creates the UpdateCustomer request. -func (client *PoliciesClient) updateCustomerCreateRequest(ctx context.Context, billingAccountName string, customerName string, parameters CustomerPolicy, options *PoliciesClientUpdateCustomerOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default" - if billingAccountName == "" { - return nil, errors.New("parameter billingAccountName cannot be empty") +// getBySubscriptionCreateRequest creates the GetBySubscription request. +func (client *PoliciesClient) getBySubscriptionCreateRequest(ctx context.Context, options *PoliciesClientGetBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Billing/policies/default" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) - if customerName == "" { - return nil, errors.New("parameter customerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{customerName}", url.PathEscape(customerName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, parameters); err != nil { - return nil, err - } return req, nil } -// updateCustomerHandleResponse handles the UpdateCustomer response. -func (client *PoliciesClient) updateCustomerHandleResponse(resp *http.Response) (PoliciesClientUpdateCustomerResponse, error) { - result := PoliciesClientUpdateCustomerResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.CustomerPolicy); err != nil { - return PoliciesClientUpdateCustomerResponse{}, err +// getBySubscriptionHandleResponse handles the GetBySubscription response. +func (client *PoliciesClient) getBySubscriptionHandleResponse(resp *http.Response) (PoliciesClientGetBySubscriptionResponse, error) { + result := PoliciesClientGetBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionPolicy); err != nil { + return PoliciesClientGetBySubscriptionResponse{}, err } return result, nil } diff --git a/sdk/resourcemanager/billing/armbilling/policies_client_example_test.go b/sdk/resourcemanager/billing/armbilling/policies_client_example_test.go index c45bcf7668ed..fe36109b6ff0 100644 --- a/sdk/resourcemanager/billing/armbilling/policies_client_example_test.go +++ b/sdk/resourcemanager/billing/armbilling/policies_client_example_test.go @@ -18,7 +18,71 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/Policy.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/policiesGetByCustomer.json +func ExamplePoliciesClient_GetByCustomer() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPoliciesClient().GetByCustomer(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "11111111-1111-1111-1111-111111111111", armbilling.ServiceDefinedResourceNameDefault, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CustomerPolicy = armbilling.CustomerPolicy{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/customers/policies"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/customers/11111111-1111-1111-1111-111111111111/policies/default"), + // Properties: &armbilling.CustomerPolicyProperties{ + // ViewCharges: to.Ptr(armbilling.ViewChargesPolicyAllowed), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/policiesPutByCustomer.json +func ExamplePoliciesClient_BeginCreateOrUpdateByCustomer() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewPoliciesClient().BeginCreateOrUpdateByCustomer(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "11111111-1111-1111-1111-111111111111", armbilling.CustomerPolicy{ + Properties: &armbilling.CustomerPolicyProperties{ + ViewCharges: to.Ptr(armbilling.ViewChargesPolicyAllowed), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CustomerPolicy = armbilling.CustomerPolicy{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/customers/policies"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/customers/11111111-1111-1111-1111-111111111111/policies/default"), + // Properties: &armbilling.CustomerPolicyProperties{ + // ViewCharges: to.Ptr(armbilling.ViewChargesPolicyAllowed), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/policiesGetByBillingProfile.json func ExamplePoliciesClient_GetByBillingProfile() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -29,27 +93,28 @@ func ExamplePoliciesClient_GetByBillingProfile() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewPoliciesClient().GetByBillingProfile(ctx, "{billingAccountName}", "{billingProfileName}", nil) + res, err := clientFactory.NewPoliciesClient().GetByBillingProfile(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Policy = armbilling.Policy{ + // res.ProfilePolicy = armbilling.ProfilePolicy{ // Name: to.Ptr("default"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/policies"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default"), - // Properties: &armbilling.PolicyProperties{ + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx/policies/default"), + // Properties: &armbilling.ProfilePolicyProperties{ + // InvoiceSectionLabelManagement: to.Ptr(armbilling.InvoiceSectionLabelManagementPolicyAllowed), // MarketplacePurchases: to.Ptr(armbilling.MarketplacePurchasesPolicyAllAllowed), // ReservationPurchases: to.Ptr(armbilling.ReservationPurchasesPolicyAllowed), - // ViewCharges: to.Ptr(armbilling.ViewChargesPolicyAllowed), + // SavingsPlanPurchases: to.Ptr(armbilling.SavingsPlanPurchasesPolicyAllowed), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/UpdatePolicy.json -func ExamplePoliciesClient_Update() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/policiesPutByBillingProfile.json +func ExamplePoliciesClient_BeginCreateOrUpdateByBillingProfile() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -59,33 +124,39 @@ func ExamplePoliciesClient_Update() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewPoliciesClient().Update(ctx, "{billingAccountName}", "{billingProfileName}", armbilling.Policy{ - Properties: &armbilling.PolicyProperties{ - MarketplacePurchases: to.Ptr(armbilling.MarketplacePurchasesPolicyOnlyFreeAllowed), - ReservationPurchases: to.Ptr(armbilling.ReservationPurchasesPolicyNotAllowed), - ViewCharges: to.Ptr(armbilling.ViewChargesPolicyAllowed), + poller, err := clientFactory.NewPoliciesClient().BeginCreateOrUpdateByBillingProfile(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", armbilling.ProfilePolicy{ + Properties: &armbilling.ProfilePolicyProperties{ + InvoiceSectionLabelManagement: to.Ptr(armbilling.InvoiceSectionLabelManagementPolicyAllowed), + MarketplacePurchases: to.Ptr(armbilling.MarketplacePurchasesPolicyAllAllowed), + ReservationPurchases: to.Ptr(armbilling.ReservationPurchasesPolicyAllowed), + SavingsPlanPurchases: to.Ptr(armbilling.SavingsPlanPurchasesPolicyAllowed), }, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Policy = armbilling.Policy{ + // res.ProfilePolicy = armbilling.ProfilePolicy{ // Name: to.Ptr("default"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/policies"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default"), - // Properties: &armbilling.PolicyProperties{ - // MarketplacePurchases: to.Ptr(armbilling.MarketplacePurchasesPolicyOnlyFreeAllowed), - // ReservationPurchases: to.Ptr(armbilling.ReservationPurchasesPolicyNotAllowed), - // ViewCharges: to.Ptr(armbilling.ViewChargesPolicyAllowed), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx/policies/default"), + // Properties: &armbilling.ProfilePolicyProperties{ + // InvoiceSectionLabelManagement: to.Ptr(armbilling.InvoiceSectionLabelManagementPolicyAllowed), + // MarketplacePurchases: to.Ptr(armbilling.MarketplacePurchasesPolicyAllAllowed), + // ReservationPurchases: to.Ptr(armbilling.ReservationPurchasesPolicyAllowed), + // SavingsPlanPurchases: to.Ptr(armbilling.SavingsPlanPurchasesPolicyAllowed), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/CustomerPolicy.json -func ExamplePoliciesClient_GetByCustomer() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/policiesGetByCustomerAtBillingAccount.json +func ExamplePoliciesClient_GetByCustomerAtBillingAccount() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -95,7 +166,7 @@ func ExamplePoliciesClient_GetByCustomer() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewPoliciesClient().GetByCustomer(ctx, "{billingAccountName}", "{customerName}", nil) + res, err := clientFactory.NewPoliciesClient().GetByCustomerAtBillingAccount(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "11111111-1111-1111-1111-111111111111", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -104,16 +175,16 @@ func ExamplePoliciesClient_GetByCustomer() { // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.CustomerPolicy = armbilling.CustomerPolicy{ // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/customers/policies"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/customers/policies"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/customers/11111111-1111-1111-1111-111111111111/policies/default"), // Properties: &armbilling.CustomerPolicyProperties{ - // ViewCharges: to.Ptr(armbilling.ViewChargesAllowed), + // ViewCharges: to.Ptr(armbilling.ViewChargesPolicyAllowed), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/UpdateCustomerPolicy.json -func ExamplePoliciesClient_UpdateCustomer() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/policiesPutByCustomerAtBillingAccount.json +func ExamplePoliciesClient_BeginCreateOrUpdateByCustomerAtBillingAccount() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -123,23 +194,140 @@ func ExamplePoliciesClient_UpdateCustomer() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewPoliciesClient().UpdateCustomer(ctx, "{billingAccountName}", "{customerName}", armbilling.CustomerPolicy{ + poller, err := clientFactory.NewPoliciesClient().BeginCreateOrUpdateByCustomerAtBillingAccount(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "11111111-1111-1111-1111-111111111111", armbilling.CustomerPolicy{ Properties: &armbilling.CustomerPolicyProperties{ - ViewCharges: to.Ptr(armbilling.ViewChargesNotAllowed), + ViewCharges: to.Ptr(armbilling.ViewChargesPolicyAllowed), }, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.CustomerPolicy = armbilling.CustomerPolicy{ // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/customers/policies"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/customers/policies"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/customers/11111111-1111-1111-1111-111111111111/policies/default"), // Properties: &armbilling.CustomerPolicyProperties{ - // ViewCharges: to.Ptr(armbilling.ViewChargesNotAllowed), + // ViewCharges: to.Ptr(armbilling.ViewChargesPolicyAllowed), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/policiesGetByBillingAccount.json +func ExamplePoliciesClient_GetByBillingAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPoliciesClient().GetByBillingAccount(ctx, "1234567", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AccountPolicy = armbilling.AccountPolicy{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/policies"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234567/policies/default"), + // Properties: &armbilling.AccountPolicyProperties{ + // EnterpriseAgreementPolicies: &armbilling.AccountPolicyPropertiesEnterpriseAgreementPolicies{ + // AuthenticationType: to.Ptr(armbilling.EnrollmentAuthLevelStateOrganizationalAccountOnly), + // }, + // MarketplacePurchases: to.Ptr(armbilling.MarketplacePurchasesPolicyAllAllowed), + // ReservationPurchases: to.Ptr(armbilling.ReservationPurchasesPolicyAllowed), + // SavingsPlanPurchases: to.Ptr(armbilling.SavingsPlanPurchasesPolicyNotAllowed), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/policiesPutByBillingAccount.json +func ExamplePoliciesClient_BeginCreateOrUpdateByBillingAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewPoliciesClient().BeginCreateOrUpdateByBillingAccount(ctx, "1234567", armbilling.AccountPolicy{ + Properties: &armbilling.AccountPolicyProperties{ + EnterpriseAgreementPolicies: &armbilling.AccountPolicyPropertiesEnterpriseAgreementPolicies{ + AuthenticationType: to.Ptr(armbilling.EnrollmentAuthLevelStateOrganizationalAccountOnly), + }, + MarketplacePurchases: to.Ptr(armbilling.MarketplacePurchasesPolicyAllAllowed), + ReservationPurchases: to.Ptr(armbilling.ReservationPurchasesPolicyAllowed), + SavingsPlanPurchases: to.Ptr(armbilling.SavingsPlanPurchasesPolicyNotAllowed), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AccountPolicy = armbilling.AccountPolicy{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/policies"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234567/policies/default"), + // Properties: &armbilling.AccountPolicyProperties{ + // EnterpriseAgreementPolicies: &armbilling.AccountPolicyPropertiesEnterpriseAgreementPolicies{ + // AuthenticationType: to.Ptr(armbilling.EnrollmentAuthLevelStateOrganizationalAccountOnly), + // }, + // MarketplacePurchases: to.Ptr(armbilling.MarketplacePurchasesPolicyAllAllowed), + // ReservationPurchases: to.Ptr(armbilling.ReservationPurchasesPolicyAllowed), + // SavingsPlanPurchases: to.Ptr(armbilling.SavingsPlanPurchasesPolicyNotAllowed), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/policiesGetBySubscription.json +func ExamplePoliciesClient_GetBySubscription() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPoliciesClient().GetBySubscription(ctx, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SubscriptionPolicy = armbilling.SubscriptionPolicy{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Billing/policies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/policies/default"), + // Properties: &armbilling.SubscriptionPolicyProperties{ + // Policies: []*armbilling.PolicySummary{ + // { + // Name: to.Ptr("ViewCharges"), + // PolicyType: to.Ptr(armbilling.PolicyTypeSystemControlled), + // Scope: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000"), + // Value: to.Ptr("Allowed"), + // }}, // }, // } } diff --git a/sdk/resourcemanager/billing/armbilling/products_client.go b/sdk/resourcemanager/billing/armbilling/products_client.go index cb1e3b8c96ed..0f8c8ed0590e 100644 --- a/sdk/resourcemanager/billing/armbilling/products_client.go +++ b/sdk/resourcemanager/billing/armbilling/products_client.go @@ -11,14 +11,15 @@ package armbilling import ( "context" "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "net/url" "strconv" "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" ) // ProductsClient contains the methods for the Products group. @@ -45,7 +46,7 @@ func NewProductsClient(credential azcore.TokenCredential, options *arm.ClientOpt // Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - productName - The ID that uniquely identifies a product. // - options - ProductsClientGetOptions contains the optional parameters for the ProductsClient.Get method. @@ -87,7 +88,7 @@ func (client *ProductsClient) getCreateRequest(ctx context.Context, billingAccou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -106,7 +107,7 @@ func (client *ProductsClient) getHandleResponse(resp *http.Response) (ProductsCl // The operation is supported for billing accounts with agreement type Microsoft Customer Agreement or // Microsoft Partner Agreement. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - options - ProductsClientListByBillingAccountOptions contains the optional parameters for the ProductsClient.NewListByBillingAccountPager // method. @@ -145,9 +146,24 @@ func (client *ProductsClient) listByBillingAccountCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } if options != nil && options.Filter != nil { - reqQP.Set("$filter", *options.Filter) + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} @@ -157,7 +173,7 @@ func (client *ProductsClient) listByBillingAccountCreateRequest(ctx context.Cont // listByBillingAccountHandleResponse handles the ListByBillingAccount response. func (client *ProductsClient) listByBillingAccountHandleResponse(resp *http.Response) (ProductsClientListByBillingAccountResponse, error) { result := ProductsClientListByBillingAccountResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ProductsListResult); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.ProductListResult); err != nil { return ProductsClientListByBillingAccountResponse{}, err } return result, nil @@ -167,7 +183,7 @@ func (client *ProductsClient) listByBillingAccountHandleResponse(resp *http.Resp // The operation is supported for billing accounts with agreement type Microsoft Customer Agreement or // Microsoft Partner Agreement. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingProfileName - The ID that uniquely identifies a billing profile. // - options - ProductsClientListByBillingProfileOptions contains the optional parameters for the ProductsClient.NewListByBillingProfilePager @@ -211,9 +227,24 @@ func (client *ProductsClient) listByBillingProfileCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } if options != nil && options.Filter != nil { - reqQP.Set("$filter", *options.Filter) + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} @@ -223,7 +254,7 @@ func (client *ProductsClient) listByBillingProfileCreateRequest(ctx context.Cont // listByBillingProfileHandleResponse handles the ListByBillingProfile response. func (client *ProductsClient) listByBillingProfileHandleResponse(resp *http.Response) (ProductsClientListByBillingProfileResponse, error) { result := ProductsClientListByBillingProfileResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ProductsListResult); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.ProductListResult); err != nil { return ProductsClientListByBillingProfileResponse{}, err } return result, nil @@ -232,7 +263,7 @@ func (client *ProductsClient) listByBillingProfileHandleResponse(resp *http.Resp // NewListByCustomerPager - Lists the products for a customer. These don't include products billed based on usage.The operation // is supported only for billing accounts with agreement type Microsoft Partner Agreement. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - customerName - The ID that uniquely identifies a customer. // - options - ProductsClientListByCustomerOptions contains the optional parameters for the ProductsClient.NewListByCustomerPager @@ -276,7 +307,25 @@ func (client *ProductsClient) listByCustomerCreateRequest(ctx context.Context, b return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -285,7 +334,7 @@ func (client *ProductsClient) listByCustomerCreateRequest(ctx context.Context, b // listByCustomerHandleResponse handles the ListByCustomer response. func (client *ProductsClient) listByCustomerHandleResponse(resp *http.Response) (ProductsClientListByCustomerResponse, error) { result := ProductsClientListByCustomerResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ProductsListResult); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.ProductListResult); err != nil { return ProductsClientListByCustomerResponse{}, err } return result, nil @@ -294,7 +343,7 @@ func (client *ProductsClient) listByCustomerHandleResponse(resp *http.Response) // NewListByInvoiceSectionPager - Lists the products for an invoice section. These don't include products billed based on // usage. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingProfileName - The ID that uniquely identifies a billing profile. // - invoiceSectionName - The ID that uniquely identifies an invoice section. @@ -343,9 +392,24 @@ func (client *ProductsClient) listByInvoiceSectionCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } if options != nil && options.Filter != nil { - reqQP.Set("$filter", *options.Filter) + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} @@ -355,46 +419,69 @@ func (client *ProductsClient) listByInvoiceSectionCreateRequest(ctx context.Cont // listByInvoiceSectionHandleResponse handles the ListByInvoiceSection response. func (client *ProductsClient) listByInvoiceSectionHandleResponse(resp *http.Response) (ProductsClientListByInvoiceSectionResponse, error) { result := ProductsClientListByInvoiceSectionResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ProductsListResult); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.ProductListResult); err != nil { return ProductsClientListByInvoiceSectionResponse{}, err } return result, nil } -// Move - Moves a product's charges to a new invoice section. The new invoice section must belong to the same billing profile -// as the existing invoice section. This operation is supported only for products that +// BeginMove - Moves a product's charges to a new invoice section. The new invoice section must belong to the same billing +// profile as the existing invoice section. This operation is supported only for products that // are purchased with a recurring charge and for billing accounts with agreement type Microsoft Customer Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - productName - The ID that uniquely identifies a product. -// - parameters - Request parameters that are provided to the move product operation. -// - options - ProductsClientMoveOptions contains the optional parameters for the ProductsClient.Move method. -func (client *ProductsClient) Move(ctx context.Context, billingAccountName string, productName string, parameters TransferProductRequestProperties, options *ProductsClientMoveOptions) (ProductsClientMoveResponse, error) { +// - parameters - The properties of the product to initiate a transfer. +// - options - ProductsClientBeginMoveOptions contains the optional parameters for the ProductsClient.BeginMove method. +func (client *ProductsClient) BeginMove(ctx context.Context, billingAccountName string, productName string, parameters MoveProductRequest, options *ProductsClientBeginMoveOptions) (*runtime.Poller[ProductsClientMoveResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.move(ctx, billingAccountName, productName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ProductsClientMoveResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ProductsClientMoveResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Move - Moves a product's charges to a new invoice section. The new invoice section must belong to the same billing profile +// as the existing invoice section. This operation is supported only for products that +// are purchased with a recurring charge and for billing accounts with agreement type Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *ProductsClient) move(ctx context.Context, billingAccountName string, productName string, parameters MoveProductRequest, options *ProductsClientBeginMoveOptions) (*http.Response, error) { var err error - const operationName = "ProductsClient.Move" + const operationName = "ProductsClient.BeginMove" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.moveCreateRequest(ctx, billingAccountName, productName, parameters, options) if err != nil { - return ProductsClientMoveResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return ProductsClientMoveResponse{}, err + return nil, err } if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) - return ProductsClientMoveResponse{}, err + return nil, err } - resp, err := client.moveHandleResponse(httpResp) - return resp, err + return httpResp, nil } // moveCreateRequest creates the Move request. -func (client *ProductsClient) moveCreateRequest(ctx context.Context, billingAccountName string, productName string, parameters TransferProductRequestProperties, options *ProductsClientMoveOptions) (*policy.Request, error) { +func (client *ProductsClient) moveCreateRequest(ctx context.Context, billingAccountName string, productName string, parameters MoveProductRequest, options *ProductsClientBeginMoveOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}/move" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") @@ -409,7 +496,7 @@ func (client *ProductsClient) moveCreateRequest(ctx context.Context, billingAcco return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -418,36 +505,16 @@ func (client *ProductsClient) moveCreateRequest(ctx context.Context, billingAcco return req, nil } -// moveHandleResponse handles the Move response. -func (client *ProductsClient) moveHandleResponse(resp *http.Response) (ProductsClientMoveResponse, error) { - result := ProductsClientMoveResponse{} - if val := resp.Header.Get("Location"); val != "" { - result.Location = &val - } - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return ProductsClientMoveResponse{}, err - } - result.RetryAfter = &retryAfter - } - if err := runtime.UnmarshalAsJSON(resp, &result.Product); err != nil { - return ProductsClientMoveResponse{}, err - } - return result, nil -} - // Update - Updates the properties of a Product. Currently, auto renew can be updated. The operation is supported only for // billing accounts with agreement type Microsoft Customer Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - productName - The ID that uniquely identifies a product. -// - parameters - Request parameters that are provided to the update product operation. +// - parameters - A product. // - options - ProductsClientUpdateOptions contains the optional parameters for the ProductsClient.Update method. -func (client *ProductsClient) Update(ctx context.Context, billingAccountName string, productName string, parameters Product, options *ProductsClientUpdateOptions) (ProductsClientUpdateResponse, error) { +func (client *ProductsClient) Update(ctx context.Context, billingAccountName string, productName string, parameters ProductPatch, options *ProductsClientUpdateOptions) (ProductsClientUpdateResponse, error) { var err error const operationName = "ProductsClient.Update" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) @@ -470,7 +537,7 @@ func (client *ProductsClient) Update(ctx context.Context, billingAccountName str } // updateCreateRequest creates the Update request. -func (client *ProductsClient) updateCreateRequest(ctx context.Context, billingAccountName string, productName string, parameters Product, options *ProductsClientUpdateOptions) (*policy.Request, error) { +func (client *ProductsClient) updateCreateRequest(ctx context.Context, billingAccountName string, productName string, parameters ProductPatch, options *ProductsClientUpdateOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") @@ -485,7 +552,7 @@ func (client *ProductsClient) updateCreateRequest(ctx context.Context, billingAc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -503,40 +570,41 @@ func (client *ProductsClient) updateHandleResponse(resp *http.Response) (Product return result, nil } -// ValidateMove - Validates if a product's charges can be moved to a new invoice section. This operation is supported only -// for products that are purchased with a recurring charge and for billing accounts with agreement +// ValidateMoveEligibility - Validates if a product's charges can be moved to a new invoice section. This operation is supported +// only for products that are purchased with a recurring charge and for billing accounts with agreement // type Microsoft Customer Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - productName - The ID that uniquely identifies a product. -// - parameters - Request parameters that are provided to the validate move eligibility operation. -// - options - ProductsClientValidateMoveOptions contains the optional parameters for the ProductsClient.ValidateMove method. -func (client *ProductsClient) ValidateMove(ctx context.Context, billingAccountName string, productName string, parameters TransferProductRequestProperties, options *ProductsClientValidateMoveOptions) (ProductsClientValidateMoveResponse, error) { +// - parameters - The properties of the product to initiate a transfer. +// - options - ProductsClientValidateMoveEligibilityOptions contains the optional parameters for the ProductsClient.ValidateMoveEligibility +// method. +func (client *ProductsClient) ValidateMoveEligibility(ctx context.Context, billingAccountName string, productName string, parameters MoveProductRequest, options *ProductsClientValidateMoveEligibilityOptions) (ProductsClientValidateMoveEligibilityResponse, error) { var err error - const operationName = "ProductsClient.ValidateMove" + const operationName = "ProductsClient.ValidateMoveEligibility" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.validateMoveCreateRequest(ctx, billingAccountName, productName, parameters, options) + req, err := client.validateMoveEligibilityCreateRequest(ctx, billingAccountName, productName, parameters, options) if err != nil { - return ProductsClientValidateMoveResponse{}, err + return ProductsClientValidateMoveEligibilityResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return ProductsClientValidateMoveResponse{}, err + return ProductsClientValidateMoveEligibilityResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return ProductsClientValidateMoveResponse{}, err + return ProductsClientValidateMoveEligibilityResponse{}, err } - resp, err := client.validateMoveHandleResponse(httpResp) + resp, err := client.validateMoveEligibilityHandleResponse(httpResp) return resp, err } -// validateMoveCreateRequest creates the ValidateMove request. -func (client *ProductsClient) validateMoveCreateRequest(ctx context.Context, billingAccountName string, productName string, parameters TransferProductRequestProperties, options *ProductsClientValidateMoveOptions) (*policy.Request, error) { +// validateMoveEligibilityCreateRequest creates the ValidateMoveEligibility request. +func (client *ProductsClient) validateMoveEligibilityCreateRequest(ctx context.Context, billingAccountName string, productName string, parameters MoveProductRequest, options *ProductsClientValidateMoveEligibilityOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}/validateMoveEligibility" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") @@ -551,7 +619,7 @@ func (client *ProductsClient) validateMoveCreateRequest(ctx context.Context, bil return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -560,11 +628,11 @@ func (client *ProductsClient) validateMoveCreateRequest(ctx context.Context, bil return req, nil } -// validateMoveHandleResponse handles the ValidateMove response. -func (client *ProductsClient) validateMoveHandleResponse(resp *http.Response) (ProductsClientValidateMoveResponse, error) { - result := ProductsClientValidateMoveResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ValidateProductTransferEligibilityResult); err != nil { - return ProductsClientValidateMoveResponse{}, err +// validateMoveEligibilityHandleResponse handles the ValidateMoveEligibility response. +func (client *ProductsClient) validateMoveEligibilityHandleResponse(resp *http.Response) (ProductsClientValidateMoveEligibilityResponse, error) { + result := ProductsClientValidateMoveEligibilityResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.MoveProductEligibilityResult); err != nil { + return ProductsClientValidateMoveEligibilityResponse{}, err } return result, nil } diff --git a/sdk/resourcemanager/billing/armbilling/products_client_example_test.go b/sdk/resourcemanager/billing/armbilling/products_client_example_test.go index 1fdc30ca2599..0d4c88066f64 100644 --- a/sdk/resourcemanager/billing/armbilling/products_client_example_test.go +++ b/sdk/resourcemanager/billing/armbilling/products_client_example_test.go @@ -18,8 +18,8 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/ProductsListByCustomer.json -func ExampleProductsClient_NewListByCustomerPager() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productsListByInvoiceSection.json +func ExampleProductsClient_NewListByInvoiceSectionPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -29,7 +29,13 @@ func ExampleProductsClient_NewListByCustomerPager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewProductsClient().NewListByCustomerPager("{billingAccountName}", "{customerName}", nil) + pager := clientFactory.NewProductsClient().NewListByInvoiceSectionPager("a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31", "ea36e548-1505-41db-bebc-46fff3d37998", "Q7GV-UUVA-PJA-TGB", &armbilling.ProductsClientListByInvoiceSectionOptions{Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -40,159 +46,73 @@ func ExampleProductsClient_NewListByCustomerPager() { _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ProductsListResult = armbilling.ProductsListResult{ - // TotalCount: to.Ptr[int32](2), + // page.ProductListResult = armbilling.ProductListResult{ // Value: []*armbilling.Product{ // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Name: to.Ptr("6b96d3f2-9008-4a9d-912f-f87744185aa3"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/products"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/products/00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProducts/6b96d3f2-9008-4a9d-912f-f87744185aa3"), // Properties: &armbilling.ProductProperties{ - // AutoRenew: to.Ptr(armbilling.AutoRenewOn), - // AvailabilityID: to.Ptr("AvailabilityId1"), - // BillingFrequency: to.Ptr(armbilling.BillingFrequencyOneTime), // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // CustomerDisplayName: to.Ptr("Customer 1"), - // CustomerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}"), - // DisplayName: to.Ptr("Eng Reservation (1a13s21awe)"), - // LastCharge: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](5000), - // }, - // LastChargeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-15T17:32:28.000Z"); return t}()), - // ProductType: to.Ptr("Reservation"), - // ProductTypeID: to.Ptr("A12345"), - // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T17:32:28.000Z"); return t}()), - // Quantity: to.Ptr[float32](4), - // Reseller: &armbilling.Reseller{ - // Description: to.Ptr("Reseller1"), - // ResellerID: to.Ptr("2c917292-b7bc-42f2-99a2-e498b9087c06"), - // }, - // SKUDescription: to.Ptr("Enterprise Agreement Development"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // DisplayName: to.Ptr("My Product"), + // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB"), + // SKUDescription: to.Ptr("Microsoft Azure Dev/Test"), // SKUID: to.Ptr("0001"), - // Status: to.Ptr(armbilling.ProductStatusTypeActive), - // TenantID: to.Ptr("515a6d36-aaf8-4ca2-a5e8-c45deb0c5cce"), + // Status: to.Ptr(armbilling.ProductStatusActive), // }, // }, // { - // Name: to.Ptr("10000000-0000-0000-0000-000000000001"), + // Name: to.Ptr("CD0BBD7A-461A-4D9A-9C59-EAE51A0D5D12"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/products"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/products/10000000-0000-0000-0000-000000000001"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProducts/CD0BBD7A-461A-4D9A-9C59-EAE51A0D5D12"), // Properties: &armbilling.ProductProperties{ - // AutoRenew: to.Ptr(armbilling.AutoRenewOn), - // AvailabilityID: to.Ptr("AvailabilityId1"), - // BillingFrequency: to.Ptr(armbilling.BillingFrequencyMonthly), // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // CustomerDisplayName: to.Ptr("Customer 1"), - // CustomerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}"), - // DisplayName: to.Ptr("Engineering Email"), - // LastCharge: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](500), - // }, - // LastChargeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-15T17:32:28.000Z"); return t}()), - // ProductType: to.Ptr("Azure subscription"), - // ProductTypeID: to.Ptr("A12345"), - // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-01T17:32:28.000Z"); return t}()), - // Quantity: to.Ptr[float32](4), - // SKUDescription: to.Ptr("Enterprise Agreement Development"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // DisplayName: to.Ptr("Test Product"), + // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB"), + // SKUDescription: to.Ptr("Microsoft Azure Dev/Test"), // SKUID: to.Ptr("0001"), - // Status: to.Ptr(armbilling.ProductStatusTypeActive), - // TenantID: to.Ptr("515a6d36-aaf8-4ca2-a5e8-c45deb0c5cce"), + // Status: to.Ptr(armbilling.ProductStatusActive), // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/ProductsListByBillingAccount.json -func ExampleProductsClient_NewListByBillingAccountPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbilling.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewProductsClient().NewListByBillingAccountPager("{billingAccountName}", &armbilling.ProductsClientListByBillingAccountOptions{Filter: nil}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ProductsListResult = armbilling.ProductsListResult{ - // TotalCount: to.Ptr[int32](2), - // Value: []*armbilling.Product{ + // }, // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Name: to.Ptr("90D31600-D46D-4084-84C6-1235CDAFFB56"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/products"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/products/00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProducts/90D31600-D46D-4084-84C6-1235CDAFFB56"), // Properties: &armbilling.ProductProperties{ - // AutoRenew: to.Ptr(armbilling.AutoRenewOn), - // AvailabilityID: to.Ptr("AvailabilityId1"), - // BillingFrequency: to.Ptr(armbilling.BillingFrequencyOneTime), // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // DisplayName: to.Ptr("Eng Reservation (1a13s21awe)"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // DisplayName: to.Ptr("Dev Product"), // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/22000000-0000-0000-0000-000000000000"), - // LastCharge: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](5000), - // }, - // LastChargeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-15T17:32:28.000Z"); return t}()), - // ProductType: to.Ptr("Reservation"), - // ProductTypeID: to.Ptr("A12345"), - // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T17:32:28.000Z"); return t}()), - // Quantity: to.Ptr[float32](4), - // SKUDescription: to.Ptr("Enterprise Agreement Development"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB"), + // SKUDescription: to.Ptr("Microsoft Azure Dev/Test"), // SKUID: to.Ptr("0001"), - // Status: to.Ptr(armbilling.ProductStatusTypeActive), - // TenantID: to.Ptr("515a6d36-aaf8-4ca2-a5e8-c45deb0c5cce"), + // Status: to.Ptr(armbilling.ProductStatusActive), // }, // }, // { - // Name: to.Ptr("10000000-0000-0000-0000-000000000001"), + // Name: to.Ptr("9e90f86b-22fc-42f3-bfe2-0ac3e7c01d32"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/products"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/products/10000000-0000-0000-0000-000000000001"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProducts/9e90f86b-22fc-42f3-bfe2-0ac3e7c01d32"), // Properties: &armbilling.ProductProperties{ - // AutoRenew: to.Ptr(armbilling.AutoRenewOn), - // AvailabilityID: to.Ptr("AvailabilityId1"), - // BillingFrequency: to.Ptr(armbilling.BillingFrequencyMonthly), // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // DisplayName: to.Ptr("Engineering Email"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // DisplayName: to.Ptr("Dev Test Product"), // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/22000000-0000-0000-0000-000000000000"), - // LastCharge: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](5000), - // }, - // LastChargeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-15T17:32:28.000Z"); return t}()), - // ProductType: to.Ptr("Azure subscription"), - // ProductTypeID: to.Ptr("A12345"), - // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-01T17:32:28.000Z"); return t}()), - // Quantity: to.Ptr[float32](4), - // SKUDescription: to.Ptr("Enterprise Agreement Development"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB"), + // SKUDescription: to.Ptr("Domain Name Registration ORG"), // SKUID: to.Ptr("0001"), - // Status: to.Ptr(armbilling.ProductStatusTypeActive), - // TenantID: to.Ptr("515a6d36-aaf8-4ca2-a5e8-c45deb0c5cce"), + // Status: to.Ptr(armbilling.ProductStatusActive), // }, // }}, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/ProductsListByBillingProfile.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productsListByBillingProfile.json func ExampleProductsClient_NewListByBillingProfilePager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -203,7 +123,13 @@ func ExampleProductsClient_NewListByBillingProfilePager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewProductsClient().NewListByBillingProfilePager("{billingAccountName}", "{billingProfileName}", &armbilling.ProductsClientListByBillingProfileOptions{Filter: nil}) + pager := clientFactory.NewProductsClient().NewListByBillingProfilePager("a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31", "ea36e548-1505-41db-bebc-46fff3d37998", &armbilling.ProductsClientListByBillingProfileOptions{Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -214,71 +140,74 @@ func ExampleProductsClient_NewListByBillingProfilePager() { _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ProductsListResult = armbilling.ProductsListResult{ - // TotalCount: to.Ptr[int32](2), + // page.ProductListResult = armbilling.ProductListResult{ // Value: []*armbilling.Product{ // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Name: to.Ptr("6b96d3f2-9008-4a9d-912f-f87744185aa3"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/products"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/products/00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProducts/6b96d3f2-9008-4a9d-912f-f87744185aa3"), // Properties: &armbilling.ProductProperties{ - // AutoRenew: to.Ptr(armbilling.AutoRenewOn), - // AvailabilityID: to.Ptr("AvailabilityId1"), - // BillingFrequency: to.Ptr(armbilling.BillingFrequencyOneTime), // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // DisplayName: to.Ptr("Eng Reservation (1a13s21awe)"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // DisplayName: to.Ptr("My Product"), // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/22000000-0000-0000-0000-000000000000"), - // LastCharge: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](5000), - // }, - // LastChargeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-15T17:32:28.000Z"); return t}()), - // ProductType: to.Ptr("Reservation"), - // ProductTypeID: to.Ptr("A12345"), - // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T17:32:28.000Z"); return t}()), - // Quantity: to.Ptr[float32](4), - // SKUDescription: to.Ptr("Enterprise Agreement Development"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/22000000-0000-0000-0000-000000000000"), + // SKUDescription: to.Ptr("Microsoft Azure Dev/Test"), // SKUID: to.Ptr("0001"), - // Status: to.Ptr(armbilling.ProductStatusTypeActive), - // TenantID: to.Ptr("515a6d36-aaf8-4ca2-a5e8-c45deb0c5cce"), + // Status: to.Ptr(armbilling.ProductStatusActive), // }, // }, // { - // Name: to.Ptr("10000000-0000-0000-0000-000000000001"), + // Name: to.Ptr("CD0BBD7A-461A-4D9A-9C59-EAE51A0D5D12"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/products"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/products/10000000-0000-0000-0000-000000000001"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProducts/CD0BBD7A-461A-4D9A-9C59-EAE51A0D5D12"), // Properties: &armbilling.ProductProperties{ - // AutoRenew: to.Ptr(armbilling.AutoRenewOn), - // AvailabilityID: to.Ptr("AvailabilityId1"), - // BillingFrequency: to.Ptr(armbilling.BillingFrequencyMonthly), // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // DisplayName: to.Ptr("Engineering Email"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // DisplayName: to.Ptr("Test Product"), // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/22000000-0000-0000-0000-000000000000"), - // LastCharge: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](5000), - // }, - // LastChargeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-15T17:32:28.000Z"); return t}()), - // ProductType: to.Ptr("Azure subscription"), - // ProductTypeID: to.Ptr("A12345"), - // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-01T17:32:28.000Z"); return t}()), - // Quantity: to.Ptr[float32](4), - // SKUDescription: to.Ptr("Enterprise Agreement Development"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/22000000-0000-0000-0000-000000000000"), + // SKUDescription: to.Ptr("Microsoft Azure Dev/Test"), // SKUID: to.Ptr("0001"), - // Status: to.Ptr(armbilling.ProductStatusTypeActive), - // TenantID: to.Ptr("515a6d36-aaf8-4ca2-a5e8-c45deb0c5cce"), + // Status: to.Ptr(armbilling.ProductStatusActive), + // }, + // }, + // { + // Name: to.Ptr("90D31600-D46D-4084-84C6-1235CDAFFB56"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/products"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProducts/90D31600-D46D-4084-84C6-1235CDAFFB56"), + // Properties: &armbilling.ProductProperties{ + // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // DisplayName: to.Ptr("Dev Product"), + // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/22000000-0000-0000-0000-000000000000"), + // SKUDescription: to.Ptr("Microsoft Azure Dev/Test"), + // SKUID: to.Ptr("0001"), + // Status: to.Ptr(armbilling.ProductStatusActive), + // }, + // }, + // { + // Name: to.Ptr("9e90f86b-22fc-42f3-bfe2-0ac3e7c01d32"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/products"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProducts/9e90f86b-22fc-42f3-bfe2-0ac3e7c01d32"), + // Properties: &armbilling.ProductProperties{ + // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // DisplayName: to.Ptr("Dev Test Product"), + // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/22000000-0000-0000-0000-000000000000"), + // SKUDescription: to.Ptr("Domain Name Registration ORG"), + // SKUID: to.Ptr("0001"), + // Status: to.Ptr(armbilling.ProductStatusActive), // }, // }}, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/ProductsListByInvoiceSection.json -func ExampleProductsClient_NewListByInvoiceSectionPager() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productsListByCustomer.json +func ExampleProductsClient_NewListByCustomerPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -288,7 +217,13 @@ func ExampleProductsClient_NewListByInvoiceSectionPager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewProductsClient().NewListByInvoiceSectionPager("{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", &armbilling.ProductsClientListByInvoiceSectionOptions{Filter: nil}) + pager := clientFactory.NewProductsClient().NewListByCustomerPager("a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31", "Q7GV-UUVA-PJA-TGB", &armbilling.ProductsClientListByCustomerOptions{Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -299,70 +234,59 @@ func ExampleProductsClient_NewListByInvoiceSectionPager() { _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ProductsListResult = armbilling.ProductsListResult{ - // TotalCount: to.Ptr[int32](2), + // page.ProductListResult = armbilling.ProductListResult{ // Value: []*armbilling.Product{ // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Name: to.Ptr("6b96d3f2-9008-4a9d-912f-f87744185aa3"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/products"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/products/00000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProducts/6b96d3f2-9008-4a9d-912f-f87744185aa3"), // Properties: &armbilling.ProductProperties{ - // AutoRenew: to.Ptr(armbilling.AutoRenewOn), - // AvailabilityID: to.Ptr("AvailabilityId1"), - // BillingFrequency: to.Ptr(armbilling.BillingFrequencyOneTime), - // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // DisplayName: to.Ptr("Eng Reservation (1a13s21awe)"), - // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}"), - // LastCharge: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](5000), - // }, - // LastChargeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-15T17:32:28.000Z"); return t}()), - // ProductType: to.Ptr("Reservation"), - // ProductTypeID: to.Ptr("A12345"), - // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T17:32:28.000Z"); return t}()), - // Quantity: to.Ptr[float32](4), - // SKUDescription: to.Ptr("Enterprise Agreement Development"), - // SKUID: to.Ptr("0001"), - // Status: to.Ptr(armbilling.ProductStatusTypeActive), - // TenantID: to.Ptr("515a6d36-aaf8-4ca2-a5e8-c45deb0c5cce"), + // BillingProfileDisplayName: to.Ptr("BillingProfile1"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // CustomerDisplayName: to.Ptr("Customer1"), + // CustomerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/customers/Q7GV-UUVA-PJA-TGB"), + // DisplayName: to.Ptr("My Product"), + // SKUDescription: to.Ptr("Microsoft Azure Standard"), + // SKUID: to.Ptr("0002"), + // Status: to.Ptr(armbilling.ProductStatusActive), // }, // }, // { - // Name: to.Ptr("10000000-0000-0000-0000-000000000001"), + // Name: to.Ptr("CD0BBD7A-461A-4D9A-9C59-EAE51A0D5D12"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/products"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/products/10000000-0000-0000-0000-000000000001"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProducts/CD0BBD7A-461A-4D9A-9C59-EAE51A0D5D12"), // Properties: &armbilling.ProductProperties{ - // AutoRenew: to.Ptr(armbilling.AutoRenewOn), - // AvailabilityID: to.Ptr("AvailabilityId1"), - // BillingFrequency: to.Ptr(armbilling.BillingFrequencyMonthly), - // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // DisplayName: to.Ptr("Engineering Email"), - // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}"), - // LastCharge: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](500), - // }, - // LastChargeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-15T17:32:28.000Z"); return t}()), - // ProductType: to.Ptr("Azure subscription"), - // ProductTypeID: to.Ptr("A12345"), - // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-01T17:32:28.000Z"); return t}()), - // Quantity: to.Ptr[float32](4), - // SKUDescription: to.Ptr("Enterprise Agreement Development"), + // BillingProfileDisplayName: to.Ptr("BillingProfile1"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // CustomerDisplayName: to.Ptr("Customer1"), + // CustomerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/customers/Q7GV-UUVA-PJA-TGB"), + // DisplayName: to.Ptr("Test Product"), + // SKUDescription: to.Ptr("Microsoft Azure Standard"), + // SKUID: to.Ptr("0002"), + // Status: to.Ptr(armbilling.ProductStatusActive), + // }, + // }, + // { + // Name: to.Ptr("9e90f86b-22fc-42f3-bfe2-0ac3e7c01d32"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/products"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProducts/9e90f86b-22fc-42f3-bfe2-0ac3e7c01d32"), + // Properties: &armbilling.ProductProperties{ + // BillingProfileDisplayName: to.Ptr("BillingProfile1"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // CustomerDisplayName: to.Ptr("Customer1"), + // CustomerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/customers/Q7GV-UUVA-PJA-TGB"), + // DisplayName: to.Ptr("Dev Test Product"), + // SKUDescription: to.Ptr("Domain Name Registration ORG"), // SKUID: to.Ptr("0001"), - // Status: to.Ptr(armbilling.ProductStatusTypeActive), + // Status: to.Ptr(armbilling.ProductStatusActive), // }, // }}, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/Product.json -func ExampleProductsClient_Get() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productMove.json +func ExampleProductsClient_BeginMove() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -372,45 +296,38 @@ func ExampleProductsClient_Get() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewProductsClient().Get(ctx, "{billingAccountName}", "{productName}", nil) + poller, err := clientFactory.NewProductsClient().BeginMove(ctx, "a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31", "6b96d3f2-9008-4a9d-912f-f87744185aa3", armbilling.MoveProductRequest{ + DestinationInvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB"), + }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Product = armbilling.Product{ - // Name: to.Ptr("{productName}"), + // Name: to.Ptr("6b96d3f2-9008-4a9d-912f-f87744185aa3"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/products"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/products/{productName}"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/products/6b96d3f2-9008-4a9d-912f-f87744185aa3"), // Properties: &armbilling.ProductProperties{ - // AutoRenew: to.Ptr(armbilling.AutoRenewOn), - // AvailabilityID: to.Ptr("AvailabilityId1"), - // BillingFrequency: to.Ptr(armbilling.BillingFrequencyMonthly), // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // DisplayName: to.Ptr("AIP Dev"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // DisplayName: to.Ptr("My Product"), // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}"), - // LastCharge: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](5000), - // }, - // LastChargeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-15T17:32:28.000Z"); return t}()), - // ProductType: to.Ptr("Subscription"), - // ProductTypeID: to.Ptr("A12345"), - // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T17:32:28.000Z"); return t}()), - // Quantity: to.Ptr[float32](4), - // SKUDescription: to.Ptr("Enterprise Agreement Development"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB"), + // SKUDescription: to.Ptr("Microsoft Azure Plan"), // SKUID: to.Ptr("0001"), - // Status: to.Ptr(armbilling.ProductStatusTypeActive), - // TenantID: to.Ptr("515a6d36-aaf8-4ca2-a5e8-c45deb0c5cce"), + // Status: to.Ptr(armbilling.ProductStatusActive), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/UpdateProduct.json -func ExampleProductsClient_Update() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productValidateMoveFailure.json +func ExampleProductsClient_ValidateMoveEligibility_productValidateMoveFailure() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -420,10 +337,8 @@ func ExampleProductsClient_Update() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewProductsClient().Update(ctx, "{billingAccountName}", "{productName}", armbilling.Product{ - Properties: &armbilling.ProductProperties{ - AutoRenew: to.Ptr(armbilling.AutoRenewOff), - }, + res, err := clientFactory.NewProductsClient().ValidateMoveEligibility(ctx, "a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31", "6b96d3f2-9008-4a9d-912f-f87744185aa3", armbilling.MoveProductRequest{ + DestinationInvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB"), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -431,38 +346,16 @@ func ExampleProductsClient_Update() { // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Product = armbilling.Product{ - // Name: to.Ptr("{productName}"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/products"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/products/{productName}"), - // Properties: &armbilling.ProductProperties{ - // AutoRenew: to.Ptr(armbilling.AutoRenewOff), - // AvailabilityID: to.Ptr("AvailabilityId1"), - // BillingFrequency: to.Ptr(armbilling.BillingFrequencyMonthly), - // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // DisplayName: to.Ptr("AIP Dev"), - // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}"), - // LastCharge: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](5000), - // }, - // LastChargeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-15T17:32:28.000Z"); return t}()), - // ProductType: to.Ptr("Subscription"), - // ProductTypeID: to.Ptr("A12345"), - // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T17:32:28.000Z"); return t}()), - // Quantity: to.Ptr[float32](4), - // SKUDescription: to.Ptr("Enterprise Agreement Development"), - // SKUID: to.Ptr("0001"), - // Status: to.Ptr(armbilling.ProductStatusTypeActive), - // TenantID: to.Ptr("515a6d36-aaf8-4ca2-a5e8-c45deb0c5cce"), + // res.MoveProductEligibilityResult = armbilling.MoveProductEligibilityResult{ + // ErrorDetails: &armbilling.MoveProductEligibilityResultErrorDetails{ + // Code: to.Ptr(armbilling.MoveValidationErrorCodeProductInactive), + // Message: to.Ptr("Invoice Sections can only be changed for active products."), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/MoveProduct.json -func ExampleProductsClient_Move() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productValidateMoveSuccess.json +func ExampleProductsClient_ValidateMoveEligibility_productValidateMoveSuccess() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -472,8 +365,8 @@ func ExampleProductsClient_Move() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewProductsClient().Move(ctx, "{billingAccountName}", "{productName}", armbilling.TransferProductRequestProperties{ - DestinationInvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{newInvoiceSectionName}"), + res, err := clientFactory.NewProductsClient().ValidateMoveEligibility(ctx, "a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31", "6b96d3f2-9008-4a9d-912f-f87744185aa3", armbilling.MoveProductRequest{ + DestinationInvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB"), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -481,38 +374,13 @@ func ExampleProductsClient_Move() { // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Product = armbilling.Product{ - // Name: to.Ptr("{productName}"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/products"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{newInvoiceSectionName}/products/{productName}"), - // Properties: &armbilling.ProductProperties{ - // AutoRenew: to.Ptr(armbilling.AutoRenewOn), - // AvailabilityID: to.Ptr("AvailabilityId1"), - // BillingFrequency: to.Ptr(armbilling.BillingFrequencyMonthly), - // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // DisplayName: to.Ptr("Test Product"), - // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{newBillingProfileName}/invoiceSections/{newInvoiceSectionName}"), - // LastCharge: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](5000), - // }, - // LastChargeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-15T17:32:28.000Z"); return t}()), - // ProductType: to.Ptr("Subscription"), - // ProductTypeID: to.Ptr("A12345"), - // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T17:32:28.000Z"); return t}()), - // Quantity: to.Ptr[float32](4), - // SKUDescription: to.Ptr("Enterprise Agreement Development"), - // SKUID: to.Ptr("0001"), - // Status: to.Ptr(armbilling.ProductStatusTypeActive), - // TenantID: to.Ptr("515a6d36-aaf8-4ca2-a5e8-c45deb0c5cce"), - // }, + // res.MoveProductEligibilityResult = armbilling.MoveProductEligibilityResult{ + // IsMoveEligible: to.Ptr(true), // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/ValidateProductMoveFailure.json -func ExampleProductsClient_ValidateMove_subscriptionMoveValidateFailure() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productsGet.json +func ExampleProductsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -522,26 +390,37 @@ func ExampleProductsClient_ValidateMove_subscriptionMoveValidateFailure() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewProductsClient().ValidateMove(ctx, "{billingAccountName}", "{productName}", armbilling.TransferProductRequestProperties{ - DestinationInvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{newInvoiceSectionName}"), - }, nil) + res, err := clientFactory.NewProductsClient().Get(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "11111111-1111-1111-1111-111111111111", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ValidateProductTransferEligibilityResult = armbilling.ValidateProductTransferEligibilityResult{ - // ErrorDetails: &armbilling.ValidateProductTransferEligibilityError{ - // Code: to.Ptr(armbilling.ProductTransferValidationErrorCodeProductTypeNotSupported), - // Message: to.Ptr("Product '{productName}' is not allowed to be transferred."), + // res.Product = armbilling.Product{ + // Name: to.Ptr("90000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/products"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/products/90000000-0000-0000-0000-000000000000"), + // Properties: &armbilling.ProductProperties{ + // AutoRenew: to.Ptr(armbilling.AutoRenewOn), + // BillingProfileDisplayName: to.Ptr("Billing Profile Display Name"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // DisplayName: to.Ptr("My product"), + // InvoiceSectionDisplayName: to.Ptr("Invoice Section Display Name"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy"), + // ProductType: to.Ptr("Seat-Based Product Type"), + // ProductTypeID: to.Ptr("XYZ56789"), + // PurchaseDate: to.Ptr("2023-01-04T22:39:34.2606750Z"), + // Quantity: to.Ptr[int64](1), + // SKUDescription: to.Ptr("SKU Description"), + // SKUID: to.Ptr("0001"), + // Status: to.Ptr(armbilling.ProductStatusActive), // }, - // IsMoveEligible: to.Ptr(false), // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/ValidateProductMoveSuccess.json -func ExampleProductsClient_ValidateMove_subscriptionMoveValidateSuccess() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productsUpdate.json +func ExampleProductsClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -551,8 +430,10 @@ func ExampleProductsClient_ValidateMove_subscriptionMoveValidateSuccess() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewProductsClient().ValidateMove(ctx, "{billingAccountName}", "{productName}", armbilling.TransferProductRequestProperties{ - DestinationInvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{newInvoiceSectionName}"), + res, err := clientFactory.NewProductsClient().Update(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "11111111-1111-1111-1111-111111111111", armbilling.ProductPatch{ + Properties: &armbilling.ProductProperties{ + AutoRenew: to.Ptr(armbilling.AutoRenewOn), + }, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -560,7 +441,118 @@ func ExampleProductsClient_ValidateMove_subscriptionMoveValidateSuccess() { // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ValidateProductTransferEligibilityResult = armbilling.ValidateProductTransferEligibilityResult{ - // IsMoveEligible: to.Ptr(true), + // res.Product = armbilling.Product{ + // Name: to.Ptr("11111111-1111-1111-1111-111111111111"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/products"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/products/11111111-1111-1111-1111-111111111111"), + // Properties: &armbilling.ProductProperties{ + // AutoRenew: to.Ptr(armbilling.AutoRenewOn), + // BillingProfileDisplayName: to.Ptr("Billing Profile Display Name"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // DisplayName: to.Ptr("Product Display Name"), + // InvoiceSectionDisplayName: to.Ptr("Invoice Section Display Name"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy"), + // ProductType: to.Ptr("Seat-Based Product Type"), + // ProductTypeID: to.Ptr("XYZ56789"), + // PurchaseDate: to.Ptr("2023-01-05T22:39:34.2606750Z"), + // Quantity: to.Ptr[int64](1), + // SKUDescription: to.Ptr("SKU Description"), + // SKUID: to.Ptr("0001"), + // Status: to.Ptr(armbilling.ProductStatusActive), + // }, // } } + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productsListByBillingAccount.json +func ExampleProductsClient_NewListByBillingAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewProductsClient().NewListByBillingAccountPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", &armbilling.ProductsClientListByBillingAccountOptions{Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ProductListResult = armbilling.ProductListResult{ + // Value: []*armbilling.Product{ + // { + // Name: to.Ptr("90000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/products"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/products/90000000-0000-0000-0000-000000000000"), + // Properties: &armbilling.ProductProperties{ + // AutoRenew: to.Ptr(armbilling.AutoRenewOn), + // BillingProfileDisplayName: to.Ptr("Billing Profile Display Name"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // DisplayName: to.Ptr("My product"), + // InvoiceSectionDisplayName: to.Ptr("Invoice Section Display Name"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy"), + // ProductType: to.Ptr("Seat-Based Product Type"), + // ProductTypeID: to.Ptr("XYZ56789"), + // PurchaseDate: to.Ptr("2023-01-04T22:39:34.2606750Z"), + // Quantity: to.Ptr[int64](1), + // SKUDescription: to.Ptr("SKU Description"), + // SKUID: to.Ptr("0001"), + // Status: to.Ptr(armbilling.ProductStatusActive), + // }, + // }, + // { + // Name: to.Ptr("90000000-0000-0000-0000-000000000001"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/products"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/products/90000000-0000-0000-0000-000000000001"), + // Properties: &armbilling.ProductProperties{ + // AutoRenew: to.Ptr(armbilling.AutoRenewOn), + // BillingProfileDisplayName: to.Ptr("Billing Profile Display Name"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // DisplayName: to.Ptr("Test product"), + // InvoiceSectionDisplayName: to.Ptr("Invoice Section Display Name"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy"), + // ProductType: to.Ptr("Software Product Type"), + // ProductTypeID: to.Ptr("EFG456"), + // PurchaseDate: to.Ptr("2023-01-06T22:39:34.2606750Z"), + // Quantity: to.Ptr[int64](1), + // SKUDescription: to.Ptr("SKU Description"), + // SKUID: to.Ptr("0001"), + // Status: to.Ptr(armbilling.ProductStatusActive), + // }, + // }, + // { + // Name: to.Ptr("90000000-0000-0000-0000-000000000002"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/products"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/products/90000000-0000-0000-0000-000000000002"), + // Properties: &armbilling.ProductProperties{ + // AutoRenew: to.Ptr(armbilling.AutoRenewOn), + // BillingProfileDisplayName: to.Ptr("Billing Profile Display Name"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // DisplayName: to.Ptr("Dev product"), + // InvoiceSectionDisplayName: to.Ptr("Invoice Section Display Name"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy"), + // ProductType: to.Ptr("Reservation Product Type"), + // ProductTypeID: to.Ptr("JKL789"), + // PurchaseDate: to.Ptr("2023-01-05T22:39:34.2606750Z"), + // Quantity: to.Ptr[int64](1), + // SKUDescription: to.Ptr("SKU Description"), + // SKUID: to.Ptr("0001"), + // Status: to.Ptr(armbilling.ProductStatusSuspended), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/billing/armbilling/profiles_client.go b/sdk/resourcemanager/billing/armbilling/profiles_client.go index cf9ffcab83e0..be75785bb10e 100644 --- a/sdk/resourcemanager/billing/armbilling/profiles_client.go +++ b/sdk/resourcemanager/billing/armbilling/profiles_client.go @@ -11,13 +11,15 @@ package armbilling import ( "context" "errors" + "net/http" + "net/url" + "strconv" + "strings" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" ) // ProfilesClient contains the methods for the BillingProfiles group. @@ -41,13 +43,14 @@ func NewProfilesClient(credential azcore.TokenCredential, options *arm.ClientOpt } // BeginCreateOrUpdate - Creates or updates a billing profile. The operation is supported for billing accounts with agreement -// type Microsoft Customer Agreement or Microsoft Partner Agreement. +// type Microsoft Customer Agreement and Microsoft Partner Agreement. If you are a MCA Individual +// (Pay-as-you-go) customer, then please use the Azure portal experience to create the billing profile. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingProfileName - The ID that uniquely identifies a billing profile. -// - parameters - The new or updated billing profile. +// - parameters - A billing profile. // - options - ProfilesClientBeginCreateOrUpdateOptions contains the optional parameters for the ProfilesClient.BeginCreateOrUpdate // method. func (client *ProfilesClient) BeginCreateOrUpdate(ctx context.Context, billingAccountName string, billingProfileName string, parameters Profile, options *ProfilesClientBeginCreateOrUpdateOptions) (*runtime.Poller[ProfilesClientCreateOrUpdateResponse], error) { @@ -57,7 +60,8 @@ func (client *ProfilesClient) BeginCreateOrUpdate(ctx context.Context, billingAc return nil, err } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ProfilesClientCreateOrUpdateResponse]{ - Tracer: client.internal.Tracer(), + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) return poller, err } else { @@ -68,10 +72,11 @@ func (client *ProfilesClient) BeginCreateOrUpdate(ctx context.Context, billingAc } // CreateOrUpdate - Creates or updates a billing profile. The operation is supported for billing accounts with agreement type -// Microsoft Customer Agreement or Microsoft Partner Agreement. +// Microsoft Customer Agreement and Microsoft Partner Agreement. If you are a MCA Individual +// (Pay-as-you-go) customer, then please use the Azure portal experience to create the billing profile. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 func (client *ProfilesClient) createOrUpdate(ctx context.Context, billingAccountName string, billingProfileName string, parameters Profile, options *ProfilesClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "ProfilesClient.BeginCreateOrUpdate" @@ -86,7 +91,7 @@ func (client *ProfilesClient) createOrUpdate(ctx context.Context, billingAccount if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -109,7 +114,7 @@ func (client *ProfilesClient) createOrUpdateCreateRequest(ctx context.Context, b return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -118,11 +123,85 @@ func (client *ProfilesClient) createOrUpdateCreateRequest(ctx context.Context, b return req, nil } +// BeginDelete - Deletes a billing profile. The operation is supported for billing accounts with agreement type Microsoft +// Customer Agreement and Microsoft Partner Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - options - ProfilesClientBeginDeleteOptions contains the optional parameters for the ProfilesClient.BeginDelete method. +func (client *ProfilesClient) BeginDelete(ctx context.Context, billingAccountName string, billingProfileName string, options *ProfilesClientBeginDeleteOptions) (*runtime.Poller[ProfilesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, billingAccountName, billingProfileName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ProfilesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ProfilesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Deletes a billing profile. The operation is supported for billing accounts with agreement type Microsoft Customer +// Agreement and Microsoft Partner Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *ProfilesClient) deleteOperation(ctx context.Context, billingAccountName string, billingProfileName string, options *ProfilesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "ProfilesClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, billingAccountName, billingProfileName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ProfilesClient) deleteCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, options *ProfilesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + // Get - Gets a billing profile by its ID. The operation is supported for billing accounts with agreement type Microsoft Customer -// Agreement or Microsoft Partner Agreement. +// Agreement and Microsoft Partner Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingProfileName - The ID that uniquely identifies a billing profile. // - options - ProfilesClientGetOptions contains the optional parameters for the ProfilesClient.Get method. @@ -164,10 +243,7 @@ func (client *ProfilesClient) getCreateRequest(ctx context.Context, billingAccou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") - if options != nil && options.Expand != nil { - reqQP.Set("$expand", *options.Expand) - } + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -183,9 +259,9 @@ func (client *ProfilesClient) getHandleResponse(resp *http.Response) (ProfilesCl } // NewListByBillingAccountPager - Lists the billing profiles that a user has access to. The operation is supported for billing -// accounts with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. +// accounts with agreement of type Microsoft Customer Agreement and Microsoft Partner Agreement. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - options - ProfilesClientListByBillingAccountOptions contains the optional parameters for the ProfilesClient.NewListByBillingAccountPager // method. @@ -224,9 +300,27 @@ func (client *ProfilesClient) listByBillingAccountCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") - if options != nil && options.Expand != nil { - reqQP.Set("$expand", *options.Expand) + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.IncludeDeleted != nil { + reqQP.Set("includeDeleted", strconv.FormatBool(*options.IncludeDeleted)) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} @@ -241,3 +335,65 @@ func (client *ProfilesClient) listByBillingAccountHandleResponse(resp *http.Resp } return result, nil } + +// ValidateDeleteEligibility - Validates if the billing profile can be deleted. The operation is supported for billing accounts +// with agreement type Microsoft Customer Agreement and Microsoft Partner Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - options - ProfilesClientValidateDeleteEligibilityOptions contains the optional parameters for the ProfilesClient.ValidateDeleteEligibility +// method. +func (client *ProfilesClient) ValidateDeleteEligibility(ctx context.Context, billingAccountName string, billingProfileName string, options *ProfilesClientValidateDeleteEligibilityOptions) (ProfilesClientValidateDeleteEligibilityResponse, error) { + var err error + const operationName = "ProfilesClient.ValidateDeleteEligibility" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.validateDeleteEligibilityCreateRequest(ctx, billingAccountName, billingProfileName, options) + if err != nil { + return ProfilesClientValidateDeleteEligibilityResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ProfilesClientValidateDeleteEligibilityResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ProfilesClientValidateDeleteEligibilityResponse{}, err + } + resp, err := client.validateDeleteEligibilityHandleResponse(httpResp) + return resp, err +} + +// validateDeleteEligibilityCreateRequest creates the ValidateDeleteEligibility request. +func (client *ProfilesClient) validateDeleteEligibilityCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, options *ProfilesClientValidateDeleteEligibilityOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/validateDeleteEligibility" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// validateDeleteEligibilityHandleResponse handles the ValidateDeleteEligibility response. +func (client *ProfilesClient) validateDeleteEligibilityHandleResponse(resp *http.Response) (ProfilesClientValidateDeleteEligibilityResponse, error) { + result := ProfilesClientValidateDeleteEligibilityResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeleteBillingProfileEligibilityResult); err != nil { + return ProfilesClientValidateDeleteEligibilityResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/profiles_client_example_test.go b/sdk/resourcemanager/billing/armbilling/profiles_client_example_test.go index 1eb8c2600991..ff0180263495 100644 --- a/sdk/resourcemanager/billing/armbilling/profiles_client_example_test.go +++ b/sdk/resourcemanager/billing/armbilling/profiles_client_example_test.go @@ -18,8 +18,8 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingProfilesListByBillingAccount.json -func ExampleProfilesClient_NewListByBillingAccountPager_billingProfilesListByBillingAccount() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesValidateDeleteEligibilityFailure.json +func ExampleProfilesClient_ValidateDeleteEligibility_billingProfilesValidateDeleteEligibilityFailure() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -29,113 +29,41 @@ func ExampleProfilesClient_NewListByBillingAccountPager_billingProfilesListByBil if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewProfilesClient().NewListByBillingAccountPager("{billingAccountName}", &armbilling.ProfilesClientListByBillingAccountOptions{Expand: nil}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ProfileListResult = armbilling.ProfileListResult{ - // Value: []*armbilling.Profile{ - // { - // Name: to.Ptr("11000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // Properties: &armbilling.ProfileProperties{ - // BillTo: &armbilling.AddressDetails{ - // AddressLine1: to.Ptr("Test Address1"), - // AddressLine2: to.Ptr("Test Address2"), - // AddressLine3: to.Ptr("Test Address3"), - // City: to.Ptr("City"), - // CompanyName: to.Ptr("Contoso"), - // Country: to.Ptr("US"), - // Email: to.Ptr("abc@contoso.com"), - // FirstName: to.Ptr("Test"), - // LastName: to.Ptr("User"), - // PhoneNumber: to.Ptr("000-000-0000"), - // PostalCode: to.Ptr("00000"), - // Region: to.Ptr("WA"), - // }, - // BillingRelationshipType: to.Ptr(armbilling.BillingRelationshipTypeDirect), - // Currency: to.Ptr("USD"), - // DisplayName: to.Ptr("BillingProfile1"), - // EnabledAzurePlans: []*armbilling.AzurePlan{ - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan"), - // SKUID: to.Ptr("0001"), - // }, - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), - // SKUID: to.Ptr("0002"), - // }}, - // HasReadAccess: to.Ptr(true), - // InvoiceDay: to.Ptr[int32](5), - // InvoiceEmailOptIn: to.Ptr(true), - // PoNumber: to.Ptr("ABC12345"), - // SpendingLimit: to.Ptr(armbilling.SpendingLimitOn), - // Status: to.Ptr(armbilling.BillingProfileStatusWarned), - // StatusReasonCode: to.Ptr(armbilling.StatusReasonCodePastDue), - // SystemID: to.Ptr("1XXX-11XX-XX1-XXXX-XXX"), - // }, - // }, - // { - // Name: to.Ptr("11000000-0000-0000-0000-000000000001"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000001"), - // Properties: &armbilling.ProfileProperties{ - // BillTo: &armbilling.AddressDetails{ - // AddressLine1: to.Ptr("Test Address1"), - // AddressLine2: to.Ptr("Test Address2"), - // AddressLine3: to.Ptr("Test Address3"), - // City: to.Ptr("City"), - // CompanyName: to.Ptr("Contoso"), - // Country: to.Ptr("US"), - // Email: to.Ptr("abc@contoso.com"), - // FirstName: to.Ptr("Test"), - // LastName: to.Ptr("User"), - // PhoneNumber: to.Ptr("000-000-0000"), - // PostalCode: to.Ptr("00000"), - // Region: to.Ptr("WA"), - // }, - // BillingRelationshipType: to.Ptr(armbilling.BillingRelationshipTypeIndirectCustomer), - // Currency: to.Ptr("USD"), - // DisplayName: to.Ptr("BillingProfile2"), - // EnabledAzurePlans: []*armbilling.AzurePlan{ - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan"), - // SKUID: to.Ptr("0001"), - // }, - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), - // SKUID: to.Ptr("0002"), - // }}, - // HasReadAccess: to.Ptr(true), - // IndirectRelationshipInfo: &armbilling.IndirectRelationshipInfo{ - // BillingAccountName: to.Ptr("30000000-0000-0000-0000-000000000001_00000000-0000-0000-0000-000000000000"), - // BillingProfileName: to.Ptr("33000000-0000-0000-0000-000000000001"), - // DisplayName: to.Ptr("Partner1"), - // }, - // InvoiceDay: to.Ptr[int32](5), - // InvoiceEmailOptIn: to.Ptr(true), - // PoNumber: to.Ptr("ABC12345"), - // SpendingLimit: to.Ptr(armbilling.SpendingLimitOff), - // Status: to.Ptr(armbilling.BillingProfileStatusActive), - // SystemID: to.Ptr("2XXX-22XX-XX1-XXXX-XXX"), - // TargetClouds: []*armbilling.TargetCloud{ - // }, - // }, - // }}, - // } + res, err := clientFactory.NewProfilesClient().ValidateDeleteEligibility(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DeleteBillingProfileEligibilityResult = armbilling.DeleteBillingProfileEligibilityResult{ + // EligibilityDetails: []*armbilling.DeleteBillingProfileEligibilityDetail{ + // { + // Code: to.Ptr(armbilling.DeleteBillingProfileEligibilityCodeActiveBillingSubscriptions), + // Message: to.Ptr("There are active or disabled subscriptions assigned to the invoice section. Either move the subscription to another invoice section or delete the subscriptions and then try deleting the invoice section."), + // }, + // { + // Code: to.Ptr(armbilling.DeleteBillingProfileEligibilityCodeLastBillingProfile), + // Message: to.Ptr("Billing profile cannot be deleted as this is the only billing profile in this billing account."), + // }, + // { + // Code: to.Ptr(armbilling.DeleteBillingProfileEligibilityCodeOutstandingCharges), + // Message: to.Ptr("Billing Profile cannot be deleted as there are outstanding charges on this billing profile."), + // }, + // { + // Code: to.Ptr(armbilling.DeleteBillingProfileEligibilityCodePendingCharges), + // Message: to.Ptr("Billing Profile cannot be deleted as there are pending charges accumulating on this billing profile."), + // }, + // { + // Code: to.Ptr(armbilling.DeleteBillingProfileEligibilityCodeReservedInstances), + // Message: to.Ptr("Billing Profile cannot be deleted as there are reserved assets with a billing plan."), + // }}, + // EligibilityStatus: to.Ptr(armbilling.DeleteBillingProfileEligibilityStatusNotAllowed), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingProfilesListWithExpand.json -func ExampleProfilesClient_NewListByBillingAccountPager_billingProfilesListWithExpand() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesValidateDeleteEligibilitySuccess.json +func ExampleProfilesClient_ValidateDeleteEligibility_billingProfilesValidateDeleteEligibilitySuccess() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -145,152 +73,19 @@ func ExampleProfilesClient_NewListByBillingAccountPager_billingProfilesListWithE if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewProfilesClient().NewListByBillingAccountPager("{billingAccountName}", &armbilling.ProfilesClientListByBillingAccountOptions{Expand: to.Ptr("invoiceSections")}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ProfileListResult = armbilling.ProfileListResult{ - // Value: []*armbilling.Profile{ - // { - // Name: to.Ptr("11000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // Properties: &armbilling.ProfileProperties{ - // BillTo: &armbilling.AddressDetails{ - // AddressLine1: to.Ptr("Test Address1"), - // AddressLine2: to.Ptr("Test Address2"), - // AddressLine3: to.Ptr("Test Address3"), - // City: to.Ptr("City"), - // CompanyName: to.Ptr("Contoso"), - // Country: to.Ptr("US"), - // Email: to.Ptr("abc@contoso.com"), - // FirstName: to.Ptr("Test"), - // LastName: to.Ptr("User"), - // PhoneNumber: to.Ptr("000-000-0000"), - // PostalCode: to.Ptr("00000"), - // Region: to.Ptr("WA"), - // }, - // BillingRelationshipType: to.Ptr(armbilling.BillingRelationshipTypeDirect), - // Currency: to.Ptr("USD"), - // DisplayName: to.Ptr("BillingProfile1"), - // EnabledAzurePlans: []*armbilling.AzurePlan{ - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan"), - // SKUID: to.Ptr("0001"), - // }, - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), - // SKUID: to.Ptr("0002"), - // }}, - // HasReadAccess: to.Ptr(true), - // InvoiceDay: to.Ptr[int32](5), - // InvoiceEmailOptIn: to.Ptr(true), - // InvoiceSections: &armbilling.InvoiceSectionsOnExpand{ - // HasMoreResults: to.Ptr(false), - // Value: []*armbilling.InvoiceSection{ - // { - // Name: to.Ptr("invoiceSectionId1"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000/invoiceSections/invoiceSectionId1"), - // Properties: &armbilling.InvoiceSectionProperties{ - // DisplayName: to.Ptr("invoiceSectionName1"), - // Labels: map[string]*string{ - // "costCategory": to.Ptr("Support"), - // "pcCode": to.Ptr("A123456"), - // }, - // State: to.Ptr(armbilling.InvoiceSectionStateActive), - // SystemID: to.Ptr("9XXX-11XX-XX1-XXXX-XXX"), - // }, - // }}, - // }, - // PoNumber: to.Ptr("ABC12345"), - // SpendingLimit: to.Ptr(armbilling.SpendingLimitOn), - // Status: to.Ptr(armbilling.BillingProfileStatusWarned), - // StatusReasonCode: to.Ptr(armbilling.StatusReasonCodePastDue), - // SystemID: to.Ptr("1XXX-11XX-XX1-XXXX-XXX"), - // TargetClouds: []*armbilling.TargetCloud{ - // }, - // }, - // }, - // { - // Name: to.Ptr("11000000-0000-0000-0000-000000000001"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000001"), - // Properties: &armbilling.ProfileProperties{ - // BillTo: &armbilling.AddressDetails{ - // AddressLine1: to.Ptr("Test Address1"), - // AddressLine2: to.Ptr("Test Address2"), - // AddressLine3: to.Ptr("Test Address3"), - // City: to.Ptr("City"), - // CompanyName: to.Ptr("Contoso"), - // Country: to.Ptr("US"), - // Email: to.Ptr("abc@contoso.com"), - // FirstName: to.Ptr("Test"), - // LastName: to.Ptr("User"), - // PhoneNumber: to.Ptr("000-000-0000"), - // PostalCode: to.Ptr("00000"), - // Region: to.Ptr("WA"), - // }, - // BillingRelationshipType: to.Ptr(armbilling.BillingRelationshipTypeIndirectCustomer), - // Currency: to.Ptr("USD"), - // DisplayName: to.Ptr("BillingProfile2"), - // EnabledAzurePlans: []*armbilling.AzurePlan{ - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan"), - // SKUID: to.Ptr("0001"), - // }, - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), - // SKUID: to.Ptr("0002"), - // }}, - // HasReadAccess: to.Ptr(true), - // IndirectRelationshipInfo: &armbilling.IndirectRelationshipInfo{ - // BillingAccountName: to.Ptr("30000000-0000-0000-0000-000000000001_00000000-0000-0000-0000-000000000000"), - // BillingProfileName: to.Ptr("33000000-0000-0000-0000-000000000001"), - // DisplayName: to.Ptr("Partner1"), - // }, - // InvoiceDay: to.Ptr[int32](5), - // InvoiceEmailOptIn: to.Ptr(true), - // InvoiceSections: &armbilling.InvoiceSectionsOnExpand{ - // HasMoreResults: to.Ptr(false), - // Value: []*armbilling.InvoiceSection{ - // { - // Name: to.Ptr("invoiceSectionId2"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000001/invoiceSections/invoiceSectionId2"), - // Properties: &armbilling.InvoiceSectionProperties{ - // DisplayName: to.Ptr("invoiceSectionName2"), - // Labels: map[string]*string{ - // "costCategory": to.Ptr("Marketing"), - // "pcCode": to.Ptr("Z223456"), - // }, - // State: to.Ptr(armbilling.InvoiceSectionStateActive), - // SystemID: to.Ptr("9XXX-22XX-XX1-XXXX-XXX"), - // }, - // }}, - // }, - // PoNumber: to.Ptr("ABC12345"), - // SpendingLimit: to.Ptr(armbilling.SpendingLimitOn), - // Status: to.Ptr(armbilling.BillingProfileStatusWarned), - // StatusReasonCode: to.Ptr(armbilling.StatusReasonCodePastDue), - // SystemID: to.Ptr("2XXX-22XX-XX1-XXXX-XXX"), - // TargetClouds: []*armbilling.TargetCloud{ - // }, - // }, - // }}, - // } + res, err := clientFactory.NewProfilesClient().ValidateDeleteEligibility(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DeleteBillingProfileEligibilityResult = armbilling.DeleteBillingProfileEligibilityResult{ + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingProfile.json -func ExampleProfilesClient_Get_billingProfile() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesDelete.json +func ExampleProfilesClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -300,58 +95,18 @@ func ExampleProfilesClient_Get_billingProfile() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewProfilesClient().Get(ctx, "{billingAccountName}", "{billingProfileName}", &armbilling.ProfilesClientGetOptions{Expand: nil}) + poller, err := clientFactory.NewProfilesClient().BeginDelete(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Profile = armbilling.Profile{ - // Name: to.Ptr("{billingProfileName}"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"), - // Properties: &armbilling.ProfileProperties{ - // BillTo: &armbilling.AddressDetails{ - // AddressLine1: to.Ptr("Test Address1"), - // AddressLine2: to.Ptr("Test Address2"), - // AddressLine3: to.Ptr("Test Address3"), - // City: to.Ptr("City"), - // CompanyName: to.Ptr("Contoso"), - // Country: to.Ptr("US"), - // Email: to.Ptr("abc@contoso.com"), - // FirstName: to.Ptr("Test"), - // LastName: to.Ptr("User"), - // PhoneNumber: to.Ptr("000-000-0000"), - // PostalCode: to.Ptr("00000"), - // Region: to.Ptr("WA"), - // }, - // BillingRelationshipType: to.Ptr(armbilling.BillingRelationshipTypeDirect), - // Currency: to.Ptr("USD"), - // DisplayName: to.Ptr("Billing Profile1"), - // EnabledAzurePlans: []*armbilling.AzurePlan{ - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan"), - // SKUID: to.Ptr("0001"), - // }, - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), - // SKUID: to.Ptr("0002"), - // }}, - // HasReadAccess: to.Ptr(true), - // InvoiceDay: to.Ptr[int32](5), - // InvoiceEmailOptIn: to.Ptr(true), - // PoNumber: to.Ptr("ABC12345"), - // SpendingLimit: to.Ptr(armbilling.SpendingLimitOn), - // Status: to.Ptr(armbilling.BillingProfileStatusWarned), - // StatusReasonCode: to.Ptr(armbilling.StatusReasonCodePastDue), - // SystemID: to.Ptr("1XXX-11XX-XX1-XXXX-XXX"), - // }, - // } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingProfileWithExpand.json -func ExampleProfilesClient_Get_billingProfileWithExpand() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesGet.json +func ExampleProfilesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -361,7 +116,7 @@ func ExampleProfilesClient_Get_billingProfileWithExpand() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewProfilesClient().Get(ctx, "{billingAccountName}", "{billingProfileName}", &armbilling.ProfilesClientGetOptions{Expand: to.Ptr("invoiceSections")}) + res, err := clientFactory.NewProfilesClient().Get(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -369,11 +124,11 @@ func ExampleProfilesClient_Get_billingProfileWithExpand() { _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Profile = armbilling.Profile{ - // Name: to.Ptr("{billingProfileName}"), + // Name: to.Ptr("xxxx-xxxx-xxx-xxx"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), // Properties: &armbilling.ProfileProperties{ - // BillTo: &armbilling.AddressDetails{ + // BillTo: &armbilling.ProfilePropertiesBillTo{ // AddressLine1: to.Ptr("Test Address1"), // AddressLine2: to.Ptr("Test Address2"), // AddressLine3: to.Ptr("Test Address3"), @@ -382,54 +137,69 @@ func ExampleProfilesClient_Get_billingProfileWithExpand() { // Country: to.Ptr("US"), // Email: to.Ptr("abc@contoso.com"), // FirstName: to.Ptr("Test"), + // IsValidAddress: to.Ptr(true), // LastName: to.Ptr("User"), // PhoneNumber: to.Ptr("000-000-0000"), // PostalCode: to.Ptr("00000"), // Region: to.Ptr("WA"), // }, - // BillingRelationshipType: to.Ptr(armbilling.BillingRelationshipTypeDirect), // Currency: to.Ptr("USD"), - // DisplayName: to.Ptr("Billing Profile1"), - // EnabledAzurePlans: []*armbilling.AzurePlan{ - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan"), - // SKUID: to.Ptr("0001"), - // }, - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), - // SKUID: to.Ptr("0002"), - // }}, + // DisplayName: to.Ptr("Billing Profile 1"), // HasReadAccess: to.Ptr(true), // InvoiceDay: to.Ptr[int32](5), // InvoiceEmailOptIn: to.Ptr(true), - // InvoiceSections: &armbilling.InvoiceSectionsOnExpand{ - // HasMoreResults: to.Ptr(false), - // Value: []*armbilling.InvoiceSection{ + // InvoiceRecipients: []*string{ + // to.Ptr("abc@contoso.com"), + // to.Ptr("xyz@contoso.com")}, + // PoNumber: to.Ptr("ABC12345"), + // ShipTo: &armbilling.ProfilePropertiesShipTo{ + // AddressLine1: to.Ptr("Test Address1"), + // AddressLine2: to.Ptr("Test Address2"), + // AddressLine3: to.Ptr("Test Address3"), + // City: to.Ptr("City"), + // CompanyName: to.Ptr("Contoso"), + // Country: to.Ptr("US"), + // Email: to.Ptr("abc@contoso.com"), + // FirstName: to.Ptr("Test"), + // IsValidAddress: to.Ptr(true), + // LastName: to.Ptr("User"), + // PhoneNumber: to.Ptr("000-000-0000"), + // PostalCode: to.Ptr("00000"), + // Region: to.Ptr("WA"), + // }, + // SoldTo: &armbilling.ProfilePropertiesSoldTo{ + // AddressLine1: to.Ptr("Test Address1"), + // AddressLine2: to.Ptr("Test Address2"), + // AddressLine3: to.Ptr("Test Address3"), + // City: to.Ptr("City"), + // CompanyName: to.Ptr("Contoso"), + // Country: to.Ptr("US"), + // Email: to.Ptr("abc@contoso.com"), + // FirstName: to.Ptr("Test"), + // IsValidAddress: to.Ptr(true), + // LastName: to.Ptr("User"), + // PhoneNumber: to.Ptr("000-000-0000"), + // PostalCode: to.Ptr("00000"), + // Region: to.Ptr("WA"), + // }, + // SpendingLimit: to.Ptr(armbilling.SpendingLimitOn), + // SpendingLimitDetails: []*armbilling.SpendingLimitDetails{ // { - // Name: to.Ptr("invoiceSectionId1"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/invoiceSectionId1"), - // Properties: &armbilling.InvoiceSectionProperties{ - // DisplayName: to.Ptr("invoiceSectionName1"), - // Labels: map[string]*string{ - // "costCategory": to.Ptr("Support"), - // "pcCode": to.Ptr("A123456"), - // }, - // State: to.Ptr(armbilling.InvoiceSectionStateActive), - // SystemID: to.Ptr("9XXX-11XX-XX1-XXXX-XXX"), - // }, + // Type: to.Ptr(armbilling.SpendingLimitTypeFreeAccount), + // Amount: to.Ptr[float32](200), + // Currency: to.Ptr("USD"), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-01-01T00:00:00.000Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.000Z"); return t}()), + // Status: to.Ptr(armbilling.SpendingLimitStatusActive), // }}, + // Status: to.Ptr(armbilling.BillingProfileStatusWarned), + // StatusReasonCode: to.Ptr(armbilling.BillingProfileStatusReasonCodePastDue), + // SystemID: to.Ptr("11111111-1111-1111-1111-111111111111"), // }, - // PoNumber: to.Ptr("ABC12345"), - // SpendingLimit: to.Ptr(armbilling.SpendingLimitOn), - // Status: to.Ptr(armbilling.BillingProfileStatusWarned), - // StatusReasonCode: to.Ptr(armbilling.StatusReasonCodePastDue), - // SystemID: to.Ptr("1XXX-11XX-XX1-XXXX-XXX"), - // }, - // } + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/PutBillingProfile.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesCreateOrUpdate.json func ExampleProfilesClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -440,18 +210,24 @@ func ExampleProfilesClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := clientFactory.NewProfilesClient().BeginCreateOrUpdate(ctx, "{billingAccountName}", "{billingProfileName}", armbilling.Profile{ + poller, err := clientFactory.NewProfilesClient().BeginCreateOrUpdate(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", armbilling.Profile{ Properties: &armbilling.ProfileProperties{ - BillTo: &armbilling.AddressDetails{ - AddressLine1: to.Ptr("Test Address 1"), - City: to.Ptr("Redmond"), - Country: to.Ptr("US"), - FirstName: to.Ptr("Test"), - LastName: to.Ptr("User"), - PostalCode: to.Ptr("12345"), - Region: to.Ptr("WA"), + BillTo: &armbilling.ProfilePropertiesBillTo{ + AddressLine1: to.Ptr("Test Address1"), + AddressLine2: to.Ptr("Test Address2"), + AddressLine3: to.Ptr("Test Address3"), + City: to.Ptr("City"), + CompanyName: to.Ptr("Contoso"), + Country: to.Ptr("US"), + Email: to.Ptr("abc@contoso.com"), + FirstName: to.Ptr("Test"), + IsValidAddress: to.Ptr(true), + LastName: to.Ptr("User"), + PhoneNumber: to.Ptr("000-000-0000"), + PostalCode: to.Ptr("00000"), + Region: to.Ptr("WA"), }, - DisplayName: to.Ptr("Finance"), + DisplayName: to.Ptr("Billing Profile 1"), EnabledAzurePlans: []*armbilling.AzurePlan{ { SKUID: to.Ptr("0001"), @@ -461,6 +237,21 @@ func ExampleProfilesClient_BeginCreateOrUpdate() { }}, InvoiceEmailOptIn: to.Ptr(true), PoNumber: to.Ptr("ABC12345"), + ShipTo: &armbilling.ProfilePropertiesShipTo{ + AddressLine1: to.Ptr("Test Address1"), + AddressLine2: to.Ptr("Test Address2"), + AddressLine3: to.Ptr("Test Address3"), + City: to.Ptr("City"), + CompanyName: to.Ptr("Contoso"), + Country: to.Ptr("US"), + Email: to.Ptr("abc@contoso.com"), + FirstName: to.Ptr("Test"), + IsValidAddress: to.Ptr(true), + LastName: to.Ptr("User"), + PhoneNumber: to.Ptr("000-000-0000"), + PostalCode: to.Ptr("00000"), + Region: to.Ptr("WA"), + }, }, }, nil) if err != nil { @@ -474,37 +265,284 @@ func ExampleProfilesClient_BeginCreateOrUpdate() { _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Profile = armbilling.Profile{ - // Name: to.Ptr("billingProfileId1"), + // Name: to.Ptr("xxxx-xxxx-xxx-xxx"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/billingProfileId1"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), // Properties: &armbilling.ProfileProperties{ - // BillTo: &armbilling.AddressDetails{ - // AddressLine1: to.Ptr("Test Address 1"), - // City: to.Ptr("Redmond"), + // BillTo: &armbilling.ProfilePropertiesBillTo{ + // AddressLine1: to.Ptr("Test Address1"), + // AddressLine2: to.Ptr("Test Address2"), + // AddressLine3: to.Ptr("Test Address3"), + // City: to.Ptr("City"), + // CompanyName: to.Ptr("Contoso"), // Country: to.Ptr("US"), + // Email: to.Ptr("abc@contoso.com"), // FirstName: to.Ptr("Test"), + // IsValidAddress: to.Ptr(true), // LastName: to.Ptr("User"), - // PostalCode: to.Ptr("12345"), + // PhoneNumber: to.Ptr("000-000-0000"), + // PostalCode: to.Ptr("00000"), // Region: to.Ptr("WA"), // }, // Currency: to.Ptr("USD"), - // DisplayName: to.Ptr("Finance"), - // EnabledAzurePlans: []*armbilling.AzurePlan{ - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan"), - // SKUID: to.Ptr("0001"), - // }, - // { - // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), - // SKUID: to.Ptr("0002"), - // }}, + // DisplayName: to.Ptr("Billing Profile 1"), // HasReadAccess: to.Ptr(true), // InvoiceDay: to.Ptr[int32](5), // InvoiceEmailOptIn: to.Ptr(true), // PoNumber: to.Ptr("ABC12345"), - // SpendingLimit: to.Ptr(armbilling.SpendingLimitOff), + // ShipTo: &armbilling.ProfilePropertiesShipTo{ + // AddressLine1: to.Ptr("Test Address1"), + // AddressLine2: to.Ptr("Test Address2"), + // AddressLine3: to.Ptr("Test Address3"), + // City: to.Ptr("City"), + // CompanyName: to.Ptr("Contoso"), + // Country: to.Ptr("US"), + // Email: to.Ptr("abc@contoso.com"), + // FirstName: to.Ptr("Test"), + // IsValidAddress: to.Ptr(true), + // LastName: to.Ptr("User"), + // PhoneNumber: to.Ptr("000-000-0000"), + // PostalCode: to.Ptr("00000"), + // Region: to.Ptr("WA"), + // }, // Status: to.Ptr(armbilling.BillingProfileStatusActive), - // SystemID: to.Ptr("1XXX-11XX-XX1-XXXX-XXX"), + // SystemID: to.Ptr("11111111-1111-1111-1111-111111111111"), // }, // } } + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesListByBillingAccount.json +func ExampleProfilesClient_NewListByBillingAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewProfilesClient().NewListByBillingAccountPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", &armbilling.ProfilesClientListByBillingAccountOptions{IncludeDeleted: nil, + Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ProfileListResult = armbilling.ProfileListResult{ + // Value: []*armbilling.Profile{ + // { + // Name: to.Ptr("xxxx-xxxx-xxx-xxx"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // Properties: &armbilling.ProfileProperties{ + // BillTo: &armbilling.ProfilePropertiesBillTo{ + // AddressLine1: to.Ptr("Test Address1"), + // AddressLine2: to.Ptr("Test Address2"), + // AddressLine3: to.Ptr("Test Address3"), + // City: to.Ptr("City"), + // CompanyName: to.Ptr("Contoso"), + // Country: to.Ptr("US"), + // Email: to.Ptr("abc@contoso.com"), + // FirstName: to.Ptr("Test"), + // IsValidAddress: to.Ptr(true), + // LastName: to.Ptr("User"), + // PhoneNumber: to.Ptr("000-000-0000"), + // PostalCode: to.Ptr("00000"), + // Region: to.Ptr("WA"), + // }, + // Currency: to.Ptr("USD"), + // DisplayName: to.Ptr("Billing Profile 1"), + // HasReadAccess: to.Ptr(true), + // InvoiceDay: to.Ptr[int32](5), + // InvoiceEmailOptIn: to.Ptr(true), + // InvoiceRecipients: []*string{ + // to.Ptr("abc@contoso.com"), + // to.Ptr("xyz@contoso.com")}, + // PoNumber: to.Ptr("ABC12345"), + // ShipTo: &armbilling.ProfilePropertiesShipTo{ + // AddressLine1: to.Ptr("Test Address1"), + // AddressLine2: to.Ptr("Test Address2"), + // AddressLine3: to.Ptr("Test Address3"), + // City: to.Ptr("City"), + // CompanyName: to.Ptr("Contoso"), + // Country: to.Ptr("US"), + // Email: to.Ptr("abc@contoso.com"), + // FirstName: to.Ptr("Test"), + // IsValidAddress: to.Ptr(true), + // LastName: to.Ptr("User"), + // PhoneNumber: to.Ptr("000-000-0000"), + // PostalCode: to.Ptr("00000"), + // Region: to.Ptr("WA"), + // }, + // SoldTo: &armbilling.ProfilePropertiesSoldTo{ + // AddressLine1: to.Ptr("Test Address1"), + // AddressLine2: to.Ptr("Test Address2"), + // AddressLine3: to.Ptr("Test Address3"), + // City: to.Ptr("City"), + // CompanyName: to.Ptr("Contoso"), + // Country: to.Ptr("US"), + // Email: to.Ptr("abc@contoso.com"), + // FirstName: to.Ptr("Test"), + // IsValidAddress: to.Ptr(true), + // LastName: to.Ptr("User"), + // PhoneNumber: to.Ptr("000-000-0000"), + // PostalCode: to.Ptr("00000"), + // Region: to.Ptr("WA"), + // }, + // SpendingLimit: to.Ptr(armbilling.SpendingLimitOn), + // SpendingLimitDetails: []*armbilling.SpendingLimitDetails{ + // { + // Type: to.Ptr(armbilling.SpendingLimitTypeFreeAccount), + // Amount: to.Ptr[float32](200), + // Currency: to.Ptr("USD"), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-01-01T00:00:00.000Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.000Z"); return t}()), + // Status: to.Ptr(armbilling.SpendingLimitStatusActive), + // }}, + // Status: to.Ptr(armbilling.BillingProfileStatusWarned), + // StatusReasonCode: to.Ptr(armbilling.BillingProfileStatusReasonCodePastDue), + // SystemID: to.Ptr("11111111-1111-1111-1111-111111111111"), + // }, + // }, + // { + // Name: to.Ptr("yyyy-yyyy-yyy-yyy"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/yyyy-yyyy-yyy-yyy"), + // Properties: &armbilling.ProfileProperties{ + // BillTo: &armbilling.ProfilePropertiesBillTo{ + // AddressLine1: to.Ptr("Test Address1"), + // AddressLine2: to.Ptr("Test Address2"), + // AddressLine3: to.Ptr("Test Address3"), + // City: to.Ptr("City"), + // CompanyName: to.Ptr("Contoso"), + // Country: to.Ptr("US"), + // Email: to.Ptr("abc@contoso.com"), + // FirstName: to.Ptr("Test"), + // IsValidAddress: to.Ptr(true), + // LastName: to.Ptr("User"), + // PhoneNumber: to.Ptr("000-000-0000"), + // PostalCode: to.Ptr("00000"), + // Region: to.Ptr("WA"), + // }, + // Currency: to.Ptr("USD"), + // DisplayName: to.Ptr("Billing Profile 2"), + // HasReadAccess: to.Ptr(true), + // InvoiceDay: to.Ptr[int32](5), + // InvoiceEmailOptIn: to.Ptr(true), + // InvoiceRecipients: []*string{ + // to.Ptr("abc@contoso.com"), + // to.Ptr("xyz@contoso.com")}, + // PoNumber: to.Ptr("ABC12345"), + // ShipTo: &armbilling.ProfilePropertiesShipTo{ + // AddressLine1: to.Ptr("Test Address1"), + // AddressLine2: to.Ptr("Test Address2"), + // AddressLine3: to.Ptr("Test Address3"), + // City: to.Ptr("City"), + // CompanyName: to.Ptr("Contoso"), + // Country: to.Ptr("US"), + // Email: to.Ptr("abc@contoso.com"), + // FirstName: to.Ptr("Test"), + // IsValidAddress: to.Ptr(true), + // LastName: to.Ptr("User"), + // PhoneNumber: to.Ptr("000-000-0000"), + // PostalCode: to.Ptr("00000"), + // Region: to.Ptr("WA"), + // }, + // SoldTo: &armbilling.ProfilePropertiesSoldTo{ + // AddressLine1: to.Ptr("Test Address1"), + // AddressLine2: to.Ptr("Test Address2"), + // AddressLine3: to.Ptr("Test Address3"), + // City: to.Ptr("City"), + // CompanyName: to.Ptr("Contoso"), + // Country: to.Ptr("US"), + // Email: to.Ptr("abc@contoso.com"), + // FirstName: to.Ptr("Test"), + // IsValidAddress: to.Ptr(true), + // LastName: to.Ptr("User"), + // PhoneNumber: to.Ptr("000-000-0000"), + // PostalCode: to.Ptr("00000"), + // Region: to.Ptr("WA"), + // }, + // Status: to.Ptr(armbilling.BillingProfileStatusUnderReview), + // StatusReasonCode: to.Ptr(armbilling.BillingProfileStatusReasonCodeUnusualActivity), + // SystemID: to.Ptr("22222222-2222-2222-2222-222222222222"), + // }, + // }, + // { + // Name: to.Ptr("zzzz-zzzz-zzz-zzz"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/zzzz-zzzz-zzz-zzz"), + // Properties: &armbilling.ProfileProperties{ + // BillTo: &armbilling.ProfilePropertiesBillTo{ + // AddressLine1: to.Ptr("Test Address1"), + // AddressLine2: to.Ptr("Test Address2"), + // AddressLine3: to.Ptr("Test Address3"), + // City: to.Ptr("City"), + // CompanyName: to.Ptr("Contoso"), + // Country: to.Ptr("US"), + // Email: to.Ptr("abc@contoso.com"), + // FirstName: to.Ptr("Test"), + // IsValidAddress: to.Ptr(true), + // LastName: to.Ptr("User"), + // PhoneNumber: to.Ptr("000-000-0000"), + // PostalCode: to.Ptr("00000"), + // Region: to.Ptr("WA"), + // }, + // Currency: to.Ptr("USD"), + // DisplayName: to.Ptr("Billing Profile 1"), + // HasReadAccess: to.Ptr(true), + // InvoiceDay: to.Ptr[int32](5), + // InvoiceEmailOptIn: to.Ptr(true), + // InvoiceRecipients: []*string{ + // to.Ptr("abc@contoso.com"), + // to.Ptr("xyz@contoso.com")}, + // PoNumber: to.Ptr("ABC12345"), + // ShipTo: &armbilling.ProfilePropertiesShipTo{ + // AddressLine1: to.Ptr("Test Address1"), + // AddressLine2: to.Ptr("Test Address2"), + // AddressLine3: to.Ptr("Test Address3"), + // City: to.Ptr("City"), + // CompanyName: to.Ptr("Contoso"), + // Country: to.Ptr("US"), + // Email: to.Ptr("abc@contoso.com"), + // FirstName: to.Ptr("Test"), + // IsValidAddress: to.Ptr(true), + // LastName: to.Ptr("User"), + // PhoneNumber: to.Ptr("000-000-0000"), + // PostalCode: to.Ptr("00000"), + // Region: to.Ptr("WA"), + // }, + // SoldTo: &armbilling.ProfilePropertiesSoldTo{ + // AddressLine1: to.Ptr("Test Address1"), + // AddressLine2: to.Ptr("Test Address2"), + // AddressLine3: to.Ptr("Test Address3"), + // City: to.Ptr("City"), + // CompanyName: to.Ptr("Contoso"), + // Country: to.Ptr("US"), + // Email: to.Ptr("abc@contoso.com"), + // FirstName: to.Ptr("Test"), + // IsValidAddress: to.Ptr(true), + // LastName: to.Ptr("User"), + // PhoneNumber: to.Ptr("000-000-0000"), + // PostalCode: to.Ptr("00000"), + // Region: to.Ptr("WA"), + // }, + // Status: to.Ptr(armbilling.BillingProfileStatusActive), + // SystemID: to.Ptr("33333333-3333-3333-3333-333333333333"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/billing/armbilling/property_client.go b/sdk/resourcemanager/billing/armbilling/property_client.go index a9e0a2fc6677..e0d87ac2ab57 100644 --- a/sdk/resourcemanager/billing/armbilling/property_client.go +++ b/sdk/resourcemanager/billing/armbilling/property_client.go @@ -11,13 +11,15 @@ package armbilling import ( "context" "errors" + "net/http" + "net/url" + "strconv" + "strings" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" ) // PropertyClient contains the methods for the BillingProperty group. @@ -28,7 +30,7 @@ type PropertyClient struct { } // NewPropertyClient creates a new instance of PropertyClient with the specified values. -// - subscriptionID - The ID that uniquely identifies an Azure subscription. +// - subscriptionID - The ID that uniquely identifies a billing subscription. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewPropertyClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PropertyClient, error) { @@ -43,11 +45,10 @@ func NewPropertyClient(subscriptionID string, credential azcore.TokenCredential, return client, nil } -// Get - Get the billing properties for a subscription. This operation is not supported for billing accounts with agreement -// type Enterprise Agreement. +// Get - Gets the billing properties for a subscription // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - options - PropertyClientGetOptions contains the optional parameters for the PropertyClient.Get method. func (client *PropertyClient) Get(ctx context.Context, options *PropertyClientGetOptions) (PropertyClientGetResponse, error) { var err error @@ -83,7 +84,13 @@ func (client *PropertyClient) getCreateRequest(ctx context.Context, options *Pro return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.IncludeBillingCountry != nil { + reqQP.Set("includeBillingCountry", strconv.FormatBool(*options.IncludeBillingCountry)) + } + if options != nil && options.IncludeTransitionStatus != nil { + reqQP.Set("includeTransitionStatus", strconv.FormatBool(*options.IncludeTransitionStatus)) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -98,12 +105,13 @@ func (client *PropertyClient) getHandleResponse(resp *http.Response) (PropertyCl return result, nil } -// Update - Updates the billing property of a subscription. Currently, cost center can be updated. The operation is supported -// only for billing accounts with agreement type Microsoft Customer Agreement. +// Update - Updates the billing property of a subscription. Currently, cost center can be updated for billing accounts with +// agreement type Microsoft Customer Agreement and subscription service usage address can +// be updated for billing accounts with agreement type Microsoft Online Service Program. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 -// - parameters - Request parameters that are provided to the update billing property operation. +// Generated from API version 2024-04-01 +// - parameters - A billing property. // - options - PropertyClientUpdateOptions contains the optional parameters for the PropertyClient.Update method. func (client *PropertyClient) Update(ctx context.Context, parameters Property, options *PropertyClientUpdateOptions) (PropertyClientUpdateResponse, error) { var err error @@ -139,7 +147,7 @@ func (client *PropertyClient) updateCreateRequest(ctx context.Context, parameter return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/sdk/resourcemanager/billing/armbilling/property_client_example_test.go b/sdk/resourcemanager/billing/armbilling/property_client_example_test.go index d0d394fb090c..4ab5a267ad2f 100644 --- a/sdk/resourcemanager/billing/armbilling/property_client_example_test.go +++ b/sdk/resourcemanager/billing/armbilling/property_client_example_test.go @@ -18,8 +18,8 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingProperty.json -func ExamplePropertyClient_Get() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingPropertyGetMCA.json +func ExamplePropertyClient_Get_billingPropertyGetMca() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -29,7 +29,9 @@ func ExamplePropertyClient_Get() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewPropertyClient().Get(ctx, nil) + res, err := clientFactory.NewPropertyClient().Get(ctx, &armbilling.PropertyClientGetOptions{IncludeBillingCountry: nil, + IncludeTransitionStatus: nil, + }) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -39,31 +41,134 @@ func ExamplePropertyClient_Get() { // res.Property = armbilling.Property{ // Name: to.Ptr("default"), // Type: to.Ptr("Microsoft.Billing/billingProperty"), - // ID: to.Ptr("/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingProperty/default"), + // ID: to.Ptr("/subscriptions/11111111-1111-1111-1111-111111111111/providers/Microsoft.Billing/billingProperty/default"), // Properties: &armbilling.PropertyProperties{ - // AccountAdminNotificationEmailAddress: to.Ptr("test@contoso.com"), + // BillingAccountAgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftCustomerAgreement), // BillingAccountDisplayName: to.Ptr("My Account"), - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000"), - // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000/billingProfiles/11000000-0000-0000-0000-000000000000"), - // BillingProfileSpendingLimit: to.Ptr(armbilling.BillingProfileSpendingLimitOn), - // BillingProfileStatus: to.Ptr(armbilling.BillingProfileStatusWarned), - // BillingProfileStatusReasonCode: to.Ptr(armbilling.BillingProfileStatusReasonCodePastDue), - // BillingTenantID: to.Ptr("90000000-0000-0000-0000-000000000011"), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000"), + // BillingAccountSoldToCountry: to.Ptr("US"), + // BillingAccountType: to.Ptr(armbilling.AccountTypeBusiness), + // BillingProfileDisplayName: to.Ptr("Contoso"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000/billingProfiles/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileSpendingLimit: to.Ptr(armbilling.SpendingLimitOff), + // BillingProfileStatus: to.Ptr(armbilling.BillingProfileStatusActive), // CostCenter: to.Ptr("1010"), - // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoice section"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000/invoiceSections/22000000-0000-0000-0000-000000000000"), - // IsAccountAdmin: to.Ptr(true), - // ProductID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000/invoiceSections/22000000-0000-0000-0000-000000000000/products/44000000-0000-0000-0000-000000000000"), - // ProductName: to.Ptr("Standard Dev"), - // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), + // InvoiceSectionDisplayName: to.Ptr("Operations"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000/billingProfiles/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy"), + // SKUDescription: to.Ptr("Microsoft Azure Plan"), // SKUID: to.Ptr("0001"), + // SubscriptionBillingStatus: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SubscriptionBillingStatusDetails: []*armbilling.SubscriptionStatusDetails{ + // { + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-01T17:32:28.000Z"); return t}()), + // Reason: to.Ptr(armbilling.SubscriptionStatusReasonCancelled), + // }}, + // SubscriptionBillingType: to.Ptr(armbilling.SubscriptionBillingTypeFree), + // SubscriptionWorkloadType: to.Ptr(armbilling.SubscriptionWorkloadTypeProduction), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/UpdateBillingProperty.json -func ExamplePropertyClient_Update() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingPropertyGetMOSP.json +func ExamplePropertyClient_Get_billingPropertyGetMosp() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPropertyClient().Get(ctx, &armbilling.PropertyClientGetOptions{IncludeBillingCountry: nil, + IncludeTransitionStatus: nil, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Property = armbilling.Property{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Billing/billingProperty"), + // ID: to.Ptr("/subscriptions/11111111-1111-1111-1111-111111111111/providers/Microsoft.Billing/billingProperty/default"), + // Properties: &armbilling.PropertyProperties{ + // BillingAccountAgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftOnlineServicesProgram), + // BillingAccountDisplayName: to.Ptr("My Account"), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000"), + // BillingAccountSoldToCountry: to.Ptr("US"), + // BillingAccountType: to.Ptr(armbilling.AccountTypeIndividual), + // SubscriptionBillingType: to.Ptr(armbilling.SubscriptionBillingTypeFree), + // SubscriptionServiceUsageAddress: &armbilling.PropertyPropertiesSubscriptionServiceUsageAddress{ + // AddressLine1: to.Ptr("Address line 1"), + // AddressLine2: to.Ptr("Address line 2"), + // City: to.Ptr("City"), + // Country: to.Ptr("US"), + // FirstName: to.Ptr("Jenny"), + // LastName: to.Ptr("Doe"), + // MiddleName: to.Ptr("Ann"), + // PostalCode: to.Ptr("12345"), + // Region: to.Ptr("State"), + // }, + // SubscriptionWorkloadType: to.Ptr(armbilling.SubscriptionWorkloadTypeProduction), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingPropertyGetMPA.json +func ExamplePropertyClient_Get_billingPropertyGetMpa() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPropertyClient().Get(ctx, &armbilling.PropertyClientGetOptions{IncludeBillingCountry: nil, + IncludeTransitionStatus: nil, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Property = armbilling.Property{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Billing/billingProperty"), + // ID: to.Ptr("/subscriptions/11111111-1111-1111-1111-111111111111/providers/Microsoft.Billing/billingProperty/default"), + // Properties: &armbilling.PropertyProperties{ + // BillingAccountAgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftCustomerAgreement), + // BillingAccountDisplayName: to.Ptr("My Account"), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000"), + // BillingAccountSoldToCountry: to.Ptr("US"), + // BillingAccountType: to.Ptr(armbilling.AccountTypeBusiness), + // BillingProfileDisplayName: to.Ptr("Contoso"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000/billingProfiles/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileSpendingLimit: to.Ptr(armbilling.SpendingLimitOff), + // BillingProfileStatus: to.Ptr(armbilling.BillingProfileStatusActive), + // CostCenter: to.Ptr("1010"), + // CustomerDisplayName: to.Ptr("Operations"), + // CustomerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000/billingProfiles/billingProfiles/xxxx-xxxx-xxx-xxx/customers/yyyy-yyyy-yyy-yyy"), + // SKUDescription: to.Ptr("Microsoft Azure Plan"), + // SKUID: to.Ptr("0001"), + // SubscriptionBillingStatus: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SubscriptionBillingStatusDetails: []*armbilling.SubscriptionStatusDetails{ + // { + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-01T17:32:28.000Z"); return t}()), + // Reason: to.Ptr(armbilling.SubscriptionStatusReasonCancelled), + // }}, + // SubscriptionBillingType: to.Ptr(armbilling.SubscriptionBillingTypeFree), + // SubscriptionWorkloadType: to.Ptr(armbilling.SubscriptionWorkloadTypeProduction), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingPropertyPatchCostCenter.json +func ExamplePropertyClient_Update_billingPropertyPatchCostCenter() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -87,25 +192,89 @@ func ExamplePropertyClient_Update() { // res.Property = armbilling.Property{ // Name: to.Ptr("default"), // Type: to.Ptr("Microsoft.Billing/billingProperty"), - // ID: to.Ptr("/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingProperty/default"), + // ID: to.Ptr("/subscriptions/11111111-1111-1111-1111-111111111111/providers/Microsoft.Billing/billingProperty/default"), // Properties: &armbilling.PropertyProperties{ - // AccountAdminNotificationEmailAddress: to.Ptr("test@contoso.com"), + // BillingAccountAgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftCustomerAgreement), // BillingAccountDisplayName: to.Ptr("My Account"), - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000"), - // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000/billingProfiles/11000000-0000-0000-0000-000000000000"), - // BillingProfileSpendingLimit: to.Ptr(armbilling.BillingProfileSpendingLimitOn), - // BillingProfileStatus: to.Ptr(armbilling.BillingProfileStatusWarned), - // BillingProfileStatusReasonCode: to.Ptr(armbilling.BillingProfileStatusReasonCodePastDue), - // BillingTenantID: to.Ptr("90000000-0000-0000-0000-000000000011"), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000"), + // BillingAccountSoldToCountry: to.Ptr("US"), + // BillingAccountType: to.Ptr(armbilling.AccountTypeBusiness), + // BillingProfileDisplayName: to.Ptr("Contoso"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000/billingProfiles/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileSpendingLimit: to.Ptr(armbilling.SpendingLimitOff), + // BillingProfileStatus: to.Ptr(armbilling.BillingProfileStatusActive), // CostCenter: to.Ptr("1010"), - // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoice section"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000/invoiceSections/22000000-0000-0000-0000-000000000000"), - // IsAccountAdmin: to.Ptr(true), - // ProductID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000/invoiceSections/22000000-0000-0000-0000-000000000000/products/44000000-0000-0000-0000-000000000000"), - // ProductName: to.Ptr("Standard Dev"), - // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), + // InvoiceSectionDisplayName: to.Ptr("Operations"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000/billingProfiles/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy"), + // SKUDescription: to.Ptr("Microsoft Azure Plan"), // SKUID: to.Ptr("0001"), + // SubscriptionBillingStatus: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SubscriptionBillingStatusDetails: []*armbilling.SubscriptionStatusDetails{ + // { + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-01T17:32:28.000Z"); return t}()), + // Reason: to.Ptr(armbilling.SubscriptionStatusReasonCancelled), + // }}, + // SubscriptionBillingType: to.Ptr(armbilling.SubscriptionBillingTypeFree), + // SubscriptionWorkloadType: to.Ptr(armbilling.SubscriptionWorkloadTypeProduction), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingPropertyPatchSubscriptionServiceUsageAddress.json +func ExamplePropertyClient_Update_billingPropertyPatchSubscriptionServiceUsageAddress() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPropertyClient().Update(ctx, armbilling.Property{ + Properties: &armbilling.PropertyProperties{ + SubscriptionServiceUsageAddress: &armbilling.PropertyPropertiesSubscriptionServiceUsageAddress{ + AddressLine1: to.Ptr("Address line 1"), + AddressLine2: to.Ptr("Address line 2"), + City: to.Ptr("City"), + Country: to.Ptr("US"), + FirstName: to.Ptr("Jenny"), + LastName: to.Ptr("Doe"), + MiddleName: to.Ptr("Ann"), + PostalCode: to.Ptr("12345"), + Region: to.Ptr("State"), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Property = armbilling.Property{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Billing/billingProperty"), + // ID: to.Ptr("/subscriptions/11111111-1111-1111-1111-111111111111/providers/Microsoft.Billing/billingProperty/default"), + // Properties: &armbilling.PropertyProperties{ + // BillingAccountAgreementType: to.Ptr(armbilling.AgreementTypeMicrosoftOnlineServicesProgram), + // BillingAccountDisplayName: to.Ptr("My Account"), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000"), + // BillingAccountSoldToCountry: to.Ptr("US"), + // BillingAccountType: to.Ptr(armbilling.AccountTypeIndividual), + // SubscriptionBillingType: to.Ptr(armbilling.SubscriptionBillingTypeFree), + // SubscriptionServiceUsageAddress: &armbilling.PropertyPropertiesSubscriptionServiceUsageAddress{ + // AddressLine1: to.Ptr("Address line 1"), + // AddressLine2: to.Ptr("Address line 2"), + // City: to.Ptr("City"), + // Country: to.Ptr("US"), + // FirstName: to.Ptr("Jenny"), + // LastName: to.Ptr("Doe"), + // MiddleName: to.Ptr("Ann"), + // PostalCode: to.Ptr("12345"), + // Region: to.Ptr("State"), + // }, + // SubscriptionWorkloadType: to.Ptr(armbilling.SubscriptionWorkloadTypeProduction), // }, // } } diff --git a/sdk/resourcemanager/billing/armbilling/recipienttransfers_client.go b/sdk/resourcemanager/billing/armbilling/recipienttransfers_client.go new file mode 100644 index 000000000000..acf6ec6af0e9 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/recipienttransfers_client.go @@ -0,0 +1,325 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armbilling + +import ( + "context" + "errors" + "net/http" + "net/url" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// RecipientTransfersClient contains the methods for the RecipientTransfers group. +// Don't use this type directly, use NewRecipientTransfersClient() instead. +type RecipientTransfersClient struct { + internal *arm.Client +} + +// NewRecipientTransfersClient creates a new instance of RecipientTransfersClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewRecipientTransfersClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*RecipientTransfersClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &RecipientTransfersClient{ + internal: cl, + } + return client, nil +} + +// Accept - Accepts a transfer request. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - transferName - The ID that uniquely identifies a transfer request. +// - parameters - Request parameters that are provided to the accept transfer operation. +// - options - RecipientTransfersClientAcceptOptions contains the optional parameters for the RecipientTransfersClient.Accept +// method. +func (client *RecipientTransfersClient) Accept(ctx context.Context, transferName string, parameters AcceptTransferRequest, options *RecipientTransfersClientAcceptOptions) (RecipientTransfersClientAcceptResponse, error) { + var err error + const operationName = "RecipientTransfersClient.Accept" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.acceptCreateRequest(ctx, transferName, parameters, options) + if err != nil { + return RecipientTransfersClientAcceptResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RecipientTransfersClientAcceptResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RecipientTransfersClientAcceptResponse{}, err + } + resp, err := client.acceptHandleResponse(httpResp) + return resp, err +} + +// acceptCreateRequest creates the Accept request. +func (client *RecipientTransfersClient) acceptCreateRequest(ctx context.Context, transferName string, parameters AcceptTransferRequest, options *RecipientTransfersClientAcceptOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/transfers/{transferName}/accept" + if transferName == "" { + return nil, errors.New("parameter transferName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{transferName}", url.PathEscape(transferName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// acceptHandleResponse handles the Accept response. +func (client *RecipientTransfersClient) acceptHandleResponse(resp *http.Response) (RecipientTransfersClientAcceptResponse, error) { + result := RecipientTransfersClientAcceptResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RecipientTransferDetails); err != nil { + return RecipientTransfersClientAcceptResponse{}, err + } + return result, nil +} + +// Decline - Declines a transfer request. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - transferName - The ID that uniquely identifies a transfer request. +// - options - RecipientTransfersClientDeclineOptions contains the optional parameters for the RecipientTransfersClient.Decline +// method. +func (client *RecipientTransfersClient) Decline(ctx context.Context, transferName string, options *RecipientTransfersClientDeclineOptions) (RecipientTransfersClientDeclineResponse, error) { + var err error + const operationName = "RecipientTransfersClient.Decline" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.declineCreateRequest(ctx, transferName, options) + if err != nil { + return RecipientTransfersClientDeclineResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RecipientTransfersClientDeclineResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RecipientTransfersClientDeclineResponse{}, err + } + resp, err := client.declineHandleResponse(httpResp) + return resp, err +} + +// declineCreateRequest creates the Decline request. +func (client *RecipientTransfersClient) declineCreateRequest(ctx context.Context, transferName string, options *RecipientTransfersClientDeclineOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/transfers/{transferName}/decline" + if transferName == "" { + return nil, errors.New("parameter transferName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{transferName}", url.PathEscape(transferName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// declineHandleResponse handles the Decline response. +func (client *RecipientTransfersClient) declineHandleResponse(resp *http.Response) (RecipientTransfersClientDeclineResponse, error) { + result := RecipientTransfersClientDeclineResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RecipientTransferDetails); err != nil { + return RecipientTransfersClientDeclineResponse{}, err + } + return result, nil +} + +// Get - Gets a transfer request by ID. The caller must be the recipient of the transfer request. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - transferName - The ID that uniquely identifies a transfer request. +// - options - RecipientTransfersClientGetOptions contains the optional parameters for the RecipientTransfersClient.Get method. +func (client *RecipientTransfersClient) Get(ctx context.Context, transferName string, options *RecipientTransfersClientGetOptions) (RecipientTransfersClientGetResponse, error) { + var err error + const operationName = "RecipientTransfersClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, transferName, options) + if err != nil { + return RecipientTransfersClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RecipientTransfersClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RecipientTransfersClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *RecipientTransfersClient) getCreateRequest(ctx context.Context, transferName string, options *RecipientTransfersClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/transfers/{transferName}" + if transferName == "" { + return nil, errors.New("parameter transferName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{transferName}", url.PathEscape(transferName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *RecipientTransfersClient) getHandleResponse(resp *http.Response) (RecipientTransfersClientGetResponse, error) { + result := RecipientTransfersClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RecipientTransferDetails); err != nil { + return RecipientTransfersClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Lists the transfer requests received by the caller. +// +// Generated from API version 2024-04-01 +// - options - RecipientTransfersClientListOptions contains the optional parameters for the RecipientTransfersClient.NewListPager +// method. +func (client *RecipientTransfersClient) NewListPager(options *RecipientTransfersClientListOptions) *runtime.Pager[RecipientTransfersClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[RecipientTransfersClientListResponse]{ + More: func(page RecipientTransfersClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RecipientTransfersClientListResponse) (RecipientTransfersClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RecipientTransfersClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return RecipientTransfersClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *RecipientTransfersClient) listCreateRequest(ctx context.Context, options *RecipientTransfersClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/transfers" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *RecipientTransfersClient) listHandleResponse(resp *http.Response) (RecipientTransfersClientListResponse, error) { + result := RecipientTransfersClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RecipientTransferDetailsListResult); err != nil { + return RecipientTransfersClientListResponse{}, err + } + return result, nil +} + +// Validate - Validates if a subscription or a reservation can be transferred. Use this operation to validate your subscriptions +// or reservation before using the accept transfer operation. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - transferName - The ID that uniquely identifies a transfer request. +// - parameters - Request parameters that are provided to the validate transfer operation. +// - options - RecipientTransfersClientValidateOptions contains the optional parameters for the RecipientTransfersClient.Validate +// method. +func (client *RecipientTransfersClient) Validate(ctx context.Context, transferName string, parameters AcceptTransferRequest, options *RecipientTransfersClientValidateOptions) (RecipientTransfersClientValidateResponse, error) { + var err error + const operationName = "RecipientTransfersClient.Validate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.validateCreateRequest(ctx, transferName, parameters, options) + if err != nil { + return RecipientTransfersClientValidateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RecipientTransfersClientValidateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RecipientTransfersClientValidateResponse{}, err + } + resp, err := client.validateHandleResponse(httpResp) + return resp, err +} + +// validateCreateRequest creates the Validate request. +func (client *RecipientTransfersClient) validateCreateRequest(ctx context.Context, transferName string, parameters AcceptTransferRequest, options *RecipientTransfersClientValidateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/transfers/{transferName}/validate" + if transferName == "" { + return nil, errors.New("parameter transferName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{transferName}", url.PathEscape(transferName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// validateHandleResponse handles the Validate response. +func (client *RecipientTransfersClient) validateHandleResponse(resp *http.Response) (RecipientTransfersClientValidateResponse, error) { + result := RecipientTransfersClientValidateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ValidateTransferListResponse); err != nil { + return RecipientTransfersClientValidateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/recipienttransfers_client_example_test.go b/sdk/resourcemanager/billing/armbilling/recipienttransfers_client_example_test.go new file mode 100644 index 000000000000..460b35bb0cd3 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/recipienttransfers_client_example_test.go @@ -0,0 +1,255 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armbilling_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/recipientTransfersAccept.json +func ExampleRecipientTransfersClient_Accept() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecipientTransfersClient().Accept(ctx, "aabb123", armbilling.AcceptTransferRequest{ + Properties: &armbilling.AcceptTransferProperties{ + ProductDetails: []*armbilling.ProductDetails{ + { + ProductID: to.Ptr("subscriptionId"), + ProductType: to.Ptr(armbilling.ProductTypeAzureSubscription), + }, + { + ProductID: to.Ptr("reservedInstanceId"), + ProductType: to.Ptr(armbilling.ProductTypeAzureReservation), + }}, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RecipientTransferDetails = armbilling.RecipientTransferDetails{ + // Name: to.Ptr("aabb123"), + // Type: to.Ptr("Microsoft.Billing/transfers"), + // ID: to.Ptr("/providers/Microsoft.Billing/transfers/aabb123"), + // Properties: &armbilling.RecipientTransferProperties{ + // DetailedTransferStatus: []*armbilling.DetailedTransferStatus{ + // { + // ProductID: to.Ptr("subscriptionId"), + // ProductName: to.Ptr("Azure subscription 1"), + // ProductType: to.Ptr(armbilling.ProductTypeAzureSubscription), + // SKUDescription: to.Ptr("MS-AZR-0017G"), + // TransferStatus: to.Ptr(armbilling.ProductTransferStatusInProgress), + // }, + // { + // ProductID: to.Ptr("reservedInstanceId"), + // ProductName: to.Ptr("Reservation name"), + // ProductType: to.Ptr(armbilling.ProductTypeAzureReservation), + // SKUDescription: to.Ptr("Standard_D2s_v3;VirtualMachines;P1Y"), + // TransferStatus: to.Ptr(armbilling.ProductTransferStatusInProgress), + // }}, + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-05T17:32:28.000Z"); return t}()), + // InitiatorEmailID: to.Ptr("xyz@contoso.com"), + // RecipientEmailID: to.Ptr("user@contoso.com"), + // TransferStatus: to.Ptr(armbilling.TransferStatusInProgress), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/recipientTransfersValidate.json +func ExampleRecipientTransfersClient_Validate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecipientTransfersClient().Validate(ctx, "aabb123", armbilling.AcceptTransferRequest{ + Properties: &armbilling.AcceptTransferProperties{ + ProductDetails: []*armbilling.ProductDetails{ + { + ProductID: to.Ptr("subscriptionId"), + ProductType: to.Ptr(armbilling.ProductTypeAzureSubscription), + }, + { + ProductID: to.Ptr("reservedInstanceId"), + ProductType: to.Ptr(armbilling.ProductTypeAzureReservation), + }}, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ValidateTransferListResponse = armbilling.ValidateTransferListResponse{ + // Value: []*armbilling.ValidateTransferResponse{ + // { + // Properties: &armbilling.ValidateTransferResponseProperties{ + // ProductID: to.Ptr("subscriptionId"), + // Results: []*armbilling.ValidationResultProperties{ + // { + // Code: to.Ptr("NotIntendedRecipient"), + // Level: to.Ptr("Error"), + // Message: to.Ptr("Intended recipient is different."), + // }}, + // Status: to.Ptr("Failed"), + // }, + // }}, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/recipientTransfersDecline.json +func ExampleRecipientTransfersClient_Decline() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecipientTransfersClient().Decline(ctx, "aabb123", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RecipientTransferDetails = armbilling.RecipientTransferDetails{ + // Name: to.Ptr("aabb123"), + // Type: to.Ptr("Microsoft.Billing/transfers"), + // ID: to.Ptr("/providers/Microsoft.Billing/transfers/aabb123"), + // Properties: &armbilling.RecipientTransferProperties{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-05T17:32:28.000Z"); return t}()), + // InitiatorEmailID: to.Ptr("xyz@contoso.com"), + // RecipientEmailID: to.Ptr("user@contoso.com"), + // TransferStatus: to.Ptr(armbilling.TransferStatusDeclined), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/recipientTransfersGet.json +func ExampleRecipientTransfersClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRecipientTransfersClient().Get(ctx, "aabb123", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RecipientTransferDetails = armbilling.RecipientTransferDetails{ + // Name: to.Ptr("aabb123"), + // Type: to.Ptr("Microsoft.Billing/transfers"), + // ID: to.Ptr("/providers/Microsoft.Billing/transfers/aabb123"), + // Properties: &armbilling.RecipientTransferProperties{ + // DetailedTransferStatus: []*armbilling.DetailedTransferStatus{ + // { + // ProductID: to.Ptr("subscriptionId"), + // ProductName: to.Ptr("Azure subscription 1"), + // ProductType: to.Ptr(armbilling.ProductTypeAzureSubscription), + // SKUDescription: to.Ptr("MS-AZR-0017G"), + // TransferStatus: to.Ptr(armbilling.ProductTransferStatusInProgress), + // }, + // { + // ProductID: to.Ptr("reservedInstanceId"), + // ProductName: to.Ptr("Reservation name"), + // ProductType: to.Ptr(armbilling.ProductTypeAzureReservation), + // SKUDescription: to.Ptr("Standard_D2s_v3;VirtualMachines;P1Y"), + // TransferStatus: to.Ptr(armbilling.ProductTransferStatusInProgress), + // }}, + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-05T17:32:28.000Z"); return t}()), + // InitiatorEmailID: to.Ptr("xyz@contoso.com"), + // RecipientEmailID: to.Ptr("user@contoso.com"), + // TransferStatus: to.Ptr(armbilling.TransferStatusInProgress), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/recipientTransfersList.json +func ExampleRecipientTransfersClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRecipientTransfersClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.RecipientTransferDetailsListResult = armbilling.RecipientTransferDetailsListResult{ + // Value: []*armbilling.RecipientTransferDetails{ + // { + // Name: to.Ptr("aabb123"), + // Type: to.Ptr("Microsoft.Billing/transfers"), + // ID: to.Ptr("/providers/Microsoft.Billing/transfers/aabb123"), + // Properties: &armbilling.RecipientTransferProperties{ + // DetailedTransferStatus: []*armbilling.DetailedTransferStatus{ + // { + // ProductID: to.Ptr("subscriptionId"), + // ProductName: to.Ptr("Azure subscription 1"), + // ProductType: to.Ptr(armbilling.ProductTypeAzureSubscription), + // SKUDescription: to.Ptr("MS-AZR-0017G"), + // TransferStatus: to.Ptr(armbilling.ProductTransferStatusInProgress), + // }, + // { + // ProductID: to.Ptr("reservedInstanceId"), + // ProductName: to.Ptr("Reservation name"), + // ProductType: to.Ptr(armbilling.ProductType("ReservedInstance")), + // SKUDescription: to.Ptr("Standard_D2s_v3;VirtualMachines;P1Y"), + // TransferStatus: to.Ptr(armbilling.ProductTransferStatusInProgress), + // }}, + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-05T17:32:28.000Z"); return t}()), + // InitiatorEmailID: to.Ptr("xyz@contoso.com"), + // RecipientEmailID: to.Ptr("user@contoso.com"), + // TransferStatus: to.Ptr(armbilling.TransferStatusInProgress), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/billing/armbilling/requests_client.go b/sdk/resourcemanager/billing/armbilling/requests_client.go new file mode 100644 index 000000000000..497428b43343 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/requests_client.go @@ -0,0 +1,560 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armbilling + +import ( + "context" + "errors" + "net/http" + "net/url" + "strconv" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// RequestsClient contains the methods for the BillingRequests group. +// Don't use this type directly, use NewRequestsClient() instead. +type RequestsClient struct { + internal *arm.Client +} + +// NewRequestsClient creates a new instance of RequestsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewRequestsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*RequestsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &RequestsClient{ + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create or update a billing request. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingRequestName - The ID that uniquely identifies a billing request. +// - parameters - A request submitted by a user to manage billing. Users with an owner role on the scope can approve or decline +// these requests. +// - options - RequestsClientBeginCreateOrUpdateOptions contains the optional parameters for the RequestsClient.BeginCreateOrUpdate +// method. +func (client *RequestsClient) BeginCreateOrUpdate(ctx context.Context, billingRequestName string, parameters Request, options *RequestsClientBeginCreateOrUpdateOptions) (*runtime.Poller[RequestsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, billingRequestName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RequestsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RequestsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create or update a billing request. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *RequestsClient) createOrUpdate(ctx context.Context, billingRequestName string, parameters Request, options *RequestsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "RequestsClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, billingRequestName, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *RequestsClient) createOrUpdateCreateRequest(ctx context.Context, billingRequestName string, parameters Request, options *RequestsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingRequests/{billingRequestName}" + if billingRequestName == "" { + return nil, errors.New("parameter billingRequestName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingRequestName}", url.PathEscape(billingRequestName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// Get - Gets a billing request by its ID. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingRequestName - The ID that uniquely identifies a billing request. +// - options - RequestsClientGetOptions contains the optional parameters for the RequestsClient.Get method. +func (client *RequestsClient) Get(ctx context.Context, billingRequestName string, options *RequestsClientGetOptions) (RequestsClientGetResponse, error) { + var err error + const operationName = "RequestsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, billingRequestName, options) + if err != nil { + return RequestsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RequestsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RequestsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *RequestsClient) getCreateRequest(ctx context.Context, billingRequestName string, options *RequestsClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingRequests/{billingRequestName}" + if billingRequestName == "" { + return nil, errors.New("parameter billingRequestName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingRequestName}", url.PathEscape(billingRequestName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *RequestsClient) getHandleResponse(resp *http.Response) (RequestsClientGetResponse, error) { + result := RequestsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Request); err != nil { + return RequestsClientGetResponse{}, err + } + return result, nil +} + +// NewListByBillingAccountPager - The list of billing requests submitted for the billing account. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - options - RequestsClientListByBillingAccountOptions contains the optional parameters for the RequestsClient.NewListByBillingAccountPager +// method. +func (client *RequestsClient) NewListByBillingAccountPager(billingAccountName string, options *RequestsClientListByBillingAccountOptions) *runtime.Pager[RequestsClientListByBillingAccountResponse] { + return runtime.NewPager(runtime.PagingHandler[RequestsClientListByBillingAccountResponse]{ + More: func(page RequestsClientListByBillingAccountResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RequestsClientListByBillingAccountResponse) (RequestsClientListByBillingAccountResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RequestsClient.NewListByBillingAccountPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByBillingAccountCreateRequest(ctx, billingAccountName, options) + }, nil) + if err != nil { + return RequestsClientListByBillingAccountResponse{}, err + } + return client.listByBillingAccountHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByBillingAccountCreateRequest creates the ListByBillingAccount request. +func (client *RequestsClient) listByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, options *RequestsClientListByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRequests" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByBillingAccountHandleResponse handles the ListByBillingAccount response. +func (client *RequestsClient) listByBillingAccountHandleResponse(resp *http.Response) (RequestsClientListByBillingAccountResponse, error) { + result := RequestsClientListByBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RequestListResult); err != nil { + return RequestsClientListByBillingAccountResponse{}, err + } + return result, nil +} + +// NewListByBillingProfilePager - The list of billing requests submitted for the billing profile. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - options - RequestsClientListByBillingProfileOptions contains the optional parameters for the RequestsClient.NewListByBillingProfilePager +// method. +func (client *RequestsClient) NewListByBillingProfilePager(billingAccountName string, billingProfileName string, options *RequestsClientListByBillingProfileOptions) *runtime.Pager[RequestsClientListByBillingProfileResponse] { + return runtime.NewPager(runtime.PagingHandler[RequestsClientListByBillingProfileResponse]{ + More: func(page RequestsClientListByBillingProfileResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RequestsClientListByBillingProfileResponse) (RequestsClientListByBillingProfileResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RequestsClient.NewListByBillingProfilePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, options) + }, nil) + if err != nil { + return RequestsClientListByBillingProfileResponse{}, err + } + return client.listByBillingProfileHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByBillingProfileCreateRequest creates the ListByBillingProfile request. +func (client *RequestsClient) listByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, options *RequestsClientListByBillingProfileOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRequests" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByBillingProfileHandleResponse handles the ListByBillingProfile response. +func (client *RequestsClient) listByBillingProfileHandleResponse(resp *http.Response) (RequestsClientListByBillingProfileResponse, error) { + result := RequestsClientListByBillingProfileResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RequestListResult); err != nil { + return RequestsClientListByBillingProfileResponse{}, err + } + return result, nil +} + +// NewListByCustomerPager - The list of billing requests submitted for the customer. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - customerName - The ID that uniquely identifies a customer. +// - options - RequestsClientListByCustomerOptions contains the optional parameters for the RequestsClient.NewListByCustomerPager +// method. +func (client *RequestsClient) NewListByCustomerPager(billingAccountName string, billingProfileName string, customerName string, options *RequestsClientListByCustomerOptions) *runtime.Pager[RequestsClientListByCustomerResponse] { + return runtime.NewPager(runtime.PagingHandler[RequestsClientListByCustomerResponse]{ + More: func(page RequestsClientListByCustomerResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RequestsClientListByCustomerResponse) (RequestsClientListByCustomerResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RequestsClient.NewListByCustomerPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByCustomerCreateRequest(ctx, billingAccountName, billingProfileName, customerName, options) + }, nil) + if err != nil { + return RequestsClientListByCustomerResponse{}, err + } + return client.listByCustomerHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByCustomerCreateRequest creates the ListByCustomer request. +func (client *RequestsClient) listByCustomerCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, options *RequestsClientListByCustomerOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/billingRequests" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if customerName == "" { + return nil, errors.New("parameter customerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{customerName}", url.PathEscape(customerName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByCustomerHandleResponse handles the ListByCustomer response. +func (client *RequestsClient) listByCustomerHandleResponse(resp *http.Response) (RequestsClientListByCustomerResponse, error) { + result := RequestsClientListByCustomerResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RequestListResult); err != nil { + return RequestsClientListByCustomerResponse{}, err + } + return result, nil +} + +// NewListByInvoiceSectionPager - The list of billing requests submitted for the invoice section. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - invoiceSectionName - The ID that uniquely identifies an invoice section. +// - options - RequestsClientListByInvoiceSectionOptions contains the optional parameters for the RequestsClient.NewListByInvoiceSectionPager +// method. +func (client *RequestsClient) NewListByInvoiceSectionPager(billingAccountName string, billingProfileName string, invoiceSectionName string, options *RequestsClientListByInvoiceSectionOptions) *runtime.Pager[RequestsClientListByInvoiceSectionResponse] { + return runtime.NewPager(runtime.PagingHandler[RequestsClientListByInvoiceSectionResponse]{ + More: func(page RequestsClientListByInvoiceSectionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RequestsClientListByInvoiceSectionResponse) (RequestsClientListByInvoiceSectionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RequestsClient.NewListByInvoiceSectionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByInvoiceSectionCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, options) + }, nil) + if err != nil { + return RequestsClientListByInvoiceSectionResponse{}, err + } + return client.listByInvoiceSectionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByInvoiceSectionCreateRequest creates the ListByInvoiceSection request. +func (client *RequestsClient) listByInvoiceSectionCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, options *RequestsClientListByInvoiceSectionOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRequests" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if invoiceSectionName == "" { + return nil, errors.New("parameter invoiceSectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByInvoiceSectionHandleResponse handles the ListByInvoiceSection response. +func (client *RequestsClient) listByInvoiceSectionHandleResponse(resp *http.Response) (RequestsClientListByInvoiceSectionResponse, error) { + result := RequestsClientListByInvoiceSectionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RequestListResult); err != nil { + return RequestsClientListByInvoiceSectionResponse{}, err + } + return result, nil +} + +// NewListByUserPager - The list of billing requests submitted by a user. +// +// Generated from API version 2024-04-01 +// - options - RequestsClientListByUserOptions contains the optional parameters for the RequestsClient.NewListByUserPager method. +func (client *RequestsClient) NewListByUserPager(options *RequestsClientListByUserOptions) *runtime.Pager[RequestsClientListByUserResponse] { + return runtime.NewPager(runtime.PagingHandler[RequestsClientListByUserResponse]{ + More: func(page RequestsClientListByUserResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RequestsClientListByUserResponse) (RequestsClientListByUserResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RequestsClient.NewListByUserPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByUserCreateRequest(ctx, options) + }, nil) + if err != nil { + return RequestsClientListByUserResponse{}, err + } + return client.listByUserHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByUserCreateRequest creates the ListByUser request. +func (client *RequestsClient) listByUserCreateRequest(ctx context.Context, options *RequestsClientListByUserOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingRequests" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByUserHandleResponse handles the ListByUser response. +func (client *RequestsClient) listByUserHandleResponse(resp *http.Response) (RequestsClientListByUserResponse, error) { + result := RequestsClientListByUserResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RequestListResult); err != nil { + return RequestsClientListByUserResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/requests_client_example_test.go b/sdk/resourcemanager/billing/armbilling/requests_client_example_test.go new file mode 100644 index 000000000000..b4d28813da25 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/requests_client_example_test.go @@ -0,0 +1,557 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armbilling_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRequestsListByBillingProfile.json +func ExampleRequestsClient_NewListByBillingProfilePager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRequestsClient().NewListByBillingProfilePager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", &armbilling.RequestsClientListByBillingProfileOptions{Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.RequestListResult = armbilling.RequestListResult{ + // Value: []*armbilling.Request{ + // { + // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingRequests"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingRequests/00000000-0000-0000-0000-000000000000"), + // Properties: &armbilling.RequestProperties{ + // Type: to.Ptr(armbilling.BillingRequestTypeRoleAssignment), + // AdditionalInformation: map[string]*string{ + // "RoleId": to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), + // }, + // BillingAccountDisplayName: to.Ptr("Contoso"), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingAccountName: to.Ptr("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileName: to.Ptr("xxxx-xxxx-xxx-xxx"), + // CreatedBy: &armbilling.RequestPropertiesCreatedBy{ + // Upn: to.Ptr("foo@contoso.com"), + // }, + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-01T17:32:28.000Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-15T17:32:28.000Z"); return t}()), + // LastUpdatedBy: &armbilling.RequestPropertiesLastUpdatedBy{ + // Upn: to.Ptr("foo@contoso.com"), + // }, + // LastUpdatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-01T17:32:28.000Z"); return t}()), + // RequestScope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // Status: to.Ptr(armbilling.BillingRequestStatusPending), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRequestsListByCustomer.json +func ExampleRequestsClient_NewListByCustomerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRequestsClient().NewListByCustomerPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "11111111-1111-1111-1111-111111111111", &armbilling.RequestsClientListByCustomerOptions{Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.RequestListResult = armbilling.RequestListResult{ + // Value: []*armbilling.Request{ + // { + // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingRequests"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingRequests/00000000-0000-0000-0000-000000000000"), + // Properties: &armbilling.RequestProperties{ + // Type: to.Ptr(armbilling.BillingRequestTypeRoleAssignment), + // AdditionalInformation: map[string]*string{ + // "RoleId": to.Ptr("30000000-aaaa-bbbb-cccc-200000000003"), + // }, + // BillingAccountDisplayName: to.Ptr("Contoso"), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingAccountName: to.Ptr("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileName: to.Ptr("xxxx-xxxx-xxx-xxx"), + // CreatedBy: &armbilling.RequestPropertiesCreatedBy{ + // Upn: to.Ptr("foo@contoso.com"), + // }, + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-01T17:32:28.000Z"); return t}()), + // CustomerDisplayName: to.Ptr("Customer 1"), + // CustomerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/customers/11111111-1111-1111-1111-111111111111"), + // CustomerName: to.Ptr("11111111-1111-1111-1111-111111111111"), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-15T17:32:28.000Z"); return t}()), + // LastUpdatedBy: &armbilling.RequestPropertiesLastUpdatedBy{ + // Upn: to.Ptr("foo@contoso.com"), + // }, + // LastUpdatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-01T17:32:28.000Z"); return t}()), + // RequestScope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/customers/11111111-1111-1111-1111-111111111111"), + // Status: to.Ptr(armbilling.BillingRequestStatusPending), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRequestsListByInvoiceSection.json +func ExampleRequestsClient_NewListByInvoiceSectionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRequestsClient().NewListByInvoiceSectionPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "yyyy-yyyy-yyy-yyy", &armbilling.RequestsClientListByInvoiceSectionOptions{Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.RequestListResult = armbilling.RequestListResult{ + // Value: []*armbilling.Request{ + // { + // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingRequests"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingRequests/00000000-0000-0000-0000-000000000000"), + // Properties: &armbilling.RequestProperties{ + // Type: to.Ptr(armbilling.BillingRequestTypeRoleAssignment), + // AdditionalInformation: map[string]*string{ + // "RoleId": to.Ptr("30000000-aaaa-bbbb-cccc-200000000003"), + // }, + // BillingAccountDisplayName: to.Ptr("Contoso"), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingAccountName: to.Ptr("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileName: to.Ptr("xxxx-xxxx-xxx-xxx"), + // CreatedBy: &armbilling.RequestPropertiesCreatedBy{ + // Upn: to.Ptr("foo@contoso.com"), + // }, + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-01T17:32:28.000Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-15T17:32:28.000Z"); return t}()), + // InvoiceSectionDisplayName: to.Ptr("Department 1"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy"), + // InvoiceSectionName: to.Ptr("yyyy-yyyy-yyy-yyy"), + // LastUpdatedBy: &armbilling.RequestPropertiesLastUpdatedBy{ + // Upn: to.Ptr("foo@contoso.com"), + // }, + // LastUpdatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-01T17:32:28.000Z"); return t}()), + // RequestScope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy"), + // Status: to.Ptr(armbilling.BillingRequestStatusPending), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRequestsListByBillingAccount.json +func ExampleRequestsClient_NewListByBillingAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRequestsClient().NewListByBillingAccountPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", &armbilling.RequestsClientListByBillingAccountOptions{Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.RequestListResult = armbilling.RequestListResult{ + // Value: []*armbilling.Request{ + // { + // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingRequests"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingRequests/00000000-0000-0000-0000-000000000000"), + // Properties: &armbilling.RequestProperties{ + // Type: to.Ptr(armbilling.BillingRequestTypeRoleAssignment), + // AdditionalInformation: map[string]*string{ + // "RoleId": to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), + // }, + // BillingAccountDisplayName: to.Ptr("Contoso"), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingAccountName: to.Ptr("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileName: to.Ptr("xxxx-xxxx-xxx-xxx"), + // CreatedBy: &armbilling.RequestPropertiesCreatedBy{ + // Upn: to.Ptr("foo@contoso.com"), + // }, + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-01T17:32:28.000Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-15T17:32:28.000Z"); return t}()), + // LastUpdatedBy: &armbilling.RequestPropertiesLastUpdatedBy{ + // Upn: to.Ptr("foo@contoso.com"), + // }, + // LastUpdatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-01T17:32:28.000Z"); return t}()), + // RequestScope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // Status: to.Ptr(armbilling.BillingRequestStatusPending), + // }, + // }, + // { + // Name: to.Ptr("11111111-1111-1111-1111-111111111111"), + // Type: to.Ptr("Microsoft.Billing/billingRequests"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingRequests/11111111-1111-1111-1111-111111111111"), + // Properties: &armbilling.RequestProperties{ + // Type: to.Ptr(armbilling.BillingRequestTypeProvisioningAccess), + // BillingAccountDisplayName: to.Ptr("Contoso"), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingAccountName: to.Ptr("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // CreatedBy: &armbilling.RequestPropertiesCreatedBy{ + // Upn: to.Ptr("foo@contoso.com"), + // }, + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T17:32:28.000Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-15T17:32:28.000Z"); return t}()), + // LastUpdatedBy: &armbilling.RequestPropertiesLastUpdatedBy{ + // Upn: to.Ptr("admin@contosofinance.com"), + // }, + // LastUpdatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-02T17:32:28.000Z"); return t}()), + // RequestScope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/associatedTenants/100000000-0000-0000-0000-00000000"), + // ReviewalDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-02T17:32:28.000Z"); return t}()), + // ReviewedBy: &armbilling.RequestPropertiesReviewedBy{ + // Upn: to.Ptr("admin@contosofinance.com"), + // }, + // Status: to.Ptr(armbilling.BillingRequestStatusApproved), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRequestsGet.json +func ExampleRequestsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRequestsClient().Get(ctx, "00000000-0000-0000-0000-000000000000", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Request = armbilling.Request{ + // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingRequests"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingRequests/00000000-0000-0000-0000-000000000000"), + // Properties: &armbilling.RequestProperties{ + // Type: to.Ptr(armbilling.BillingRequestTypeRoleAssignment), + // AdditionalInformation: map[string]*string{ + // "RoleId": to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), + // }, + // BillingAccountDisplayName: to.Ptr("Contoso"), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingAccountName: to.Ptr("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileName: to.Ptr("xxxx-xxxx-xxx-xxx"), + // CreatedBy: &armbilling.RequestPropertiesCreatedBy{ + // Upn: to.Ptr("foo@contoso.com"), + // }, + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-01T17:32:28.000Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-15T17:32:28.000Z"); return t}()), + // LastUpdatedBy: &armbilling.RequestPropertiesLastUpdatedBy{ + // Upn: to.Ptr("admin@contoso.com"), + // }, + // LastUpdatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-01T17:32:28.000Z"); return t}()), + // RequestScope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // Status: to.Ptr(armbilling.BillingRequestStatusPending), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRequestsCreateOrUpdate.json +func ExampleRequestsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewRequestsClient().BeginCreateOrUpdate(ctx, "00000000-0000-0000-0000-000000000000", armbilling.Request{ + Properties: &armbilling.RequestProperties{ + Type: to.Ptr(armbilling.BillingRequestTypeRoleAssignment), + AdditionalInformation: map[string]*string{ + "RoleId": to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), + }, + DecisionReason: to.Ptr("New team member"), + RequestScope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + Status: to.Ptr(armbilling.BillingRequestStatusPending), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Request = armbilling.Request{ + // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingRequests"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingRequests/00000000-0000-0000-0000-000000000000"), + // Properties: &armbilling.RequestProperties{ + // Type: to.Ptr(armbilling.BillingRequestTypeRoleAssignment), + // AdditionalInformation: map[string]*string{ + // "RoleId": to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), + // }, + // BillingAccountDisplayName: to.Ptr("Contoso"), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingAccountName: to.Ptr("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileName: to.Ptr("xxxx-xxxx-xxx-xxx"), + // CreatedBy: &armbilling.RequestPropertiesCreatedBy{ + // Upn: to.Ptr("foo@contoso.com"), + // }, + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-01T17:32:28.000Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-15T17:32:28.000Z"); return t}()), + // LastUpdatedBy: &armbilling.RequestPropertiesLastUpdatedBy{ + // Upn: to.Ptr("admin@contoso.com"), + // }, + // LastUpdatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-01T17:32:28.000Z"); return t}()), + // RequestScope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // Status: to.Ptr(armbilling.BillingRequestStatusPending), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRequestsListByUser.json +func ExampleRequestsClient_NewListByUserPager_billingRequestsListByUser() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRequestsClient().NewListByUserPager(&armbilling.RequestsClientListByUserOptions{Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.RequestListResult = armbilling.RequestListResult{ + // Value: []*armbilling.Request{ + // { + // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingRequests"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingRequests/00000000-0000-0000-0000-000000000000"), + // Properties: &armbilling.RequestProperties{ + // Type: to.Ptr(armbilling.BillingRequestTypeRoleAssignment), + // AdditionalInformation: map[string]*string{ + // "RoleId": to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), + // }, + // BillingAccountDisplayName: to.Ptr("Contoso"), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingAccountName: to.Ptr("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileName: to.Ptr("xxxx-xxxx-xxx-xxx"), + // CreatedBy: &armbilling.RequestPropertiesCreatedBy{ + // Upn: to.Ptr("foo@contoso.com"), + // }, + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-01T17:32:28.000Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-15T17:32:28.000Z"); return t}()), + // LastUpdatedBy: &armbilling.RequestPropertiesLastUpdatedBy{ + // Upn: to.Ptr("foo@contoso.com"), + // }, + // LastUpdatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-01T17:32:28.000Z"); return t}()), + // RequestScope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // Status: to.Ptr(armbilling.BillingRequestStatusPending), + // }, + // }, + // { + // Name: to.Ptr("11111111-1111-1111-1111-111111111111"), + // Type: to.Ptr("Microsoft.Billing/billingRequests"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingRequests/11111111-1111-1111-1111-111111111111"), + // Properties: &armbilling.RequestProperties{ + // Type: to.Ptr(armbilling.BillingRequestTypeProvisioningAccess), + // BillingAccountDisplayName: to.Ptr("Contoso"), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingAccountName: to.Ptr("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // CreatedBy: &armbilling.RequestPropertiesCreatedBy{ + // Upn: to.Ptr("foo@contoso.com"), + // }, + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T17:32:28.000Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-15T17:32:28.000Z"); return t}()), + // LastUpdatedBy: &armbilling.RequestPropertiesLastUpdatedBy{ + // Upn: to.Ptr("admin@contosofinance.com"), + // }, + // LastUpdatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-02T17:32:28.000Z"); return t}()), + // RequestScope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/associatedTenants/100000000-0000-0000-0000-00000000"), + // ReviewalDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-02T17:32:28.000Z"); return t}()), + // ReviewedBy: &armbilling.RequestPropertiesReviewedBy{ + // Upn: to.Ptr("admin@contosofinance.com"), + // }, + // Status: to.Ptr(armbilling.BillingRequestStatusApproved), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRequestsListByUserWithFilter.json +func ExampleRequestsClient_NewListByUserPager_billingRequestsListByUserWithFilter() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRequestsClient().NewListByUserPager(&armbilling.RequestsClientListByUserOptions{Filter: to.Ptr("properties/status eq 'Approved'"), + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.RequestListResult = armbilling.RequestListResult{ + // Value: []*armbilling.Request{ + // { + // Name: to.Ptr("11111111-1111-1111-1111-111111111111"), + // Type: to.Ptr("Microsoft.Billing/billingRequests"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingRequests/11111111-1111-1111-1111-111111111111"), + // Properties: &armbilling.RequestProperties{ + // Type: to.Ptr(armbilling.BillingRequestTypeProvisioningAccess), + // BillingAccountDisplayName: to.Ptr("Contoso"), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingAccountName: to.Ptr("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // CreatedBy: &armbilling.RequestPropertiesCreatedBy{ + // Upn: to.Ptr("foo@contoso.com"), + // }, + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T17:32:28.000Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-15T17:32:28.000Z"); return t}()), + // LastUpdatedBy: &armbilling.RequestPropertiesLastUpdatedBy{ + // Upn: to.Ptr("admin@contosofinance.com"), + // }, + // LastUpdatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-02T17:32:28.000Z"); return t}()), + // RequestScope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/associatedTenants/100000000-0000-0000-0000-00000000"), + // ReviewalDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-02T17:32:28.000Z"); return t}()), + // ReviewedBy: &armbilling.RequestPropertiesReviewedBy{ + // Upn: to.Ptr("admin@contosofinance.com"), + // }, + // Status: to.Ptr(armbilling.BillingRequestStatusApproved), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/billing/armbilling/reservationorders_client.go b/sdk/resourcemanager/billing/armbilling/reservationorders_client.go new file mode 100644 index 000000000000..e153906e067e --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/reservationorders_client.go @@ -0,0 +1,172 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armbilling + +import ( + "context" + "errors" + "net/http" + "net/url" + "strconv" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// ReservationOrdersClient contains the methods for the ReservationOrders group. +// Don't use this type directly, use NewReservationOrdersClient() instead. +type ReservationOrdersClient struct { + internal *arm.Client +} + +// NewReservationOrdersClient creates a new instance of ReservationOrdersClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewReservationOrdersClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ReservationOrdersClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ReservationOrdersClient{ + internal: cl, + } + return client, nil +} + +// GetByBillingAccount - Get the details of the ReservationOrder in the billing account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - reservationOrderID - Order Id of the reservation +// - options - ReservationOrdersClientGetByBillingAccountOptions contains the optional parameters for the ReservationOrdersClient.GetByBillingAccount +// method. +func (client *ReservationOrdersClient) GetByBillingAccount(ctx context.Context, billingAccountName string, reservationOrderID string, options *ReservationOrdersClientGetByBillingAccountOptions) (ReservationOrdersClientGetByBillingAccountResponse, error) { + var err error + const operationName = "ReservationOrdersClient.GetByBillingAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByBillingAccountCreateRequest(ctx, billingAccountName, reservationOrderID, options) + if err != nil { + return ReservationOrdersClientGetByBillingAccountResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ReservationOrdersClientGetByBillingAccountResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ReservationOrdersClientGetByBillingAccountResponse{}, err + } + resp, err := client.getByBillingAccountHandleResponse(httpResp) + return resp, err +} + +// getByBillingAccountCreateRequest creates the GetByBillingAccount request. +func (client *ReservationOrdersClient) getByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, reservationOrderID string, options *ReservationOrdersClientGetByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/reservationOrders/{reservationOrderId}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if reservationOrderID == "" { + return nil, errors.New("parameter reservationOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationOrderId}", url.PathEscape(reservationOrderID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Expand != nil { + reqQP.Set("expand", *options.Expand) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByBillingAccountHandleResponse handles the GetByBillingAccount response. +func (client *ReservationOrdersClient) getByBillingAccountHandleResponse(resp *http.Response) (ReservationOrdersClientGetByBillingAccountResponse, error) { + result := ReservationOrdersClientGetByBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ReservationOrder); err != nil { + return ReservationOrdersClientGetByBillingAccountResponse{}, err + } + return result, nil +} + +// NewListByBillingAccountPager - List all the `ReservationOrders in the billing account. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - options - ReservationOrdersClientListByBillingAccountOptions contains the optional parameters for the ReservationOrdersClient.NewListByBillingAccountPager +// method. +func (client *ReservationOrdersClient) NewListByBillingAccountPager(billingAccountName string, options *ReservationOrdersClientListByBillingAccountOptions) *runtime.Pager[ReservationOrdersClientListByBillingAccountResponse] { + return runtime.NewPager(runtime.PagingHandler[ReservationOrdersClientListByBillingAccountResponse]{ + More: func(page ReservationOrdersClientListByBillingAccountResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ReservationOrdersClientListByBillingAccountResponse) (ReservationOrdersClientListByBillingAccountResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ReservationOrdersClient.NewListByBillingAccountPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByBillingAccountCreateRequest(ctx, billingAccountName, options) + }, nil) + if err != nil { + return ReservationOrdersClientListByBillingAccountResponse{}, err + } + return client.listByBillingAccountHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByBillingAccountCreateRequest creates the ListByBillingAccount request. +func (client *ReservationOrdersClient) listByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, options *ReservationOrdersClientListByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/reservationOrders" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Skiptoken != nil { + reqQP.Set("skiptoken", strconv.FormatFloat(float64(*options.Skiptoken), 'f', -1, 32)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByBillingAccountHandleResponse handles the ListByBillingAccount response. +func (client *ReservationOrdersClient) listByBillingAccountHandleResponse(resp *http.Response) (ReservationOrdersClientListByBillingAccountResponse, error) { + result := ReservationOrdersClientListByBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ReservationOrderList); err != nil { + return ReservationOrdersClientListByBillingAccountResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/reservationorders_client_example_test.go b/sdk/resourcemanager/billing/armbilling/reservationorders_client_example_test.go new file mode 100644 index 000000000000..bbf1d3ee6f51 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/reservationorders_client_example_test.go @@ -0,0 +1,540 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armbilling_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationOrderGetByBillingAccount.json +func ExampleReservationOrdersClient_GetByBillingAccount_reservationOrderGetByBillingAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewReservationOrdersClient().GetByBillingAccount(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "20000000-0000-0000-0000-000000000000", &armbilling.ReservationOrdersClientGetByBillingAccountOptions{Expand: nil}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ReservationOrder = armbilling.ReservationOrder{ + // Name: to.Ptr("20000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("microsoft.billing/billingAccounts/reservationOrders"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/reservationOrders/20000000-0000-0000-0000-000000000000"), + // Etag: to.Ptr[int32](27), + // Properties: &armbilling.ReservationOrderProperty{ + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-25T06:34:12.926Z"); return t}()), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingPlan: to.Ptr(armbilling.ReservationBillingPlanMonthly), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/AAAA-AAAA-AAA-AAA"), + // CreatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-25T06:34:13.973Z"); return t}()), + // DisplayName: to.Ptr("VM_RI_11-24-2021_22-30"), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-25T06:34:12.926Z"); return t}()), + // OriginalQuantity: to.Ptr[int32](1), + // ProductCode: to.Ptr("20000000-0000-0000-0000-000000000005"), + // ProvisioningState: to.Ptr("Succeeded"), + // RequestDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-25T06:31:18.392Z"); return t}()), + // Reservations: []*armbilling.Reservation{ + // { + // ID: to.Ptr("/providers/Microsoft.Capacity/reservationOrders/20000000-0000-0000-0000-000000000000/reservations/20000000-0000-0000-0000-000000000001"), + // }}, + // Term: to.Ptr("P3Y"), + // }, + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationOrderGetByBillingAccountWithExpandPlanInformation.json +func ExampleReservationOrdersClient_GetByBillingAccount_reservationOrderGetByBillingAccountWithExpandPlanInformation() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewReservationOrdersClient().GetByBillingAccount(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "20000000-0000-0000-0000-000000000000", &armbilling.ReservationOrdersClientGetByBillingAccountOptions{Expand: nil}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ReservationOrder = armbilling.ReservationOrder{ + // Name: to.Ptr("20000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("microsoft.billing/billingAccounts/reservationOrders"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/reservationOrders/20000000-0000-0000-0000-000000000000"), + // Etag: to.Ptr[int32](26), + // Properties: &armbilling.ReservationOrderProperty{ + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-25T06:34:12.926Z"); return t}()), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingPlan: to.Ptr(armbilling.ReservationBillingPlanMonthly), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/AAAA-AAAA-AAA-AAA"), + // CreatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-25T06:34:13.973Z"); return t}()), + // DisplayName: to.Ptr("VM_RI_11-24-2021_22-30"), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-25T06:34:12.926Z"); return t}()), + // OriginalQuantity: to.Ptr[int32](1), + // PlanInformation: &armbilling.ReservationOrderBillingPlanInformation{ + // NextPaymentDueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-01-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](715.68), + // CurrencyCode: to.Ptr("USD"), + // }, + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2021-11-25"); return t}()), + // Transactions: []*armbilling.ReservationPaymentDetail{ + // { + // BillingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2021-11-25"); return t}()), + // PaymentDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2021-11-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusCompleted), + // }, + // { + // BillingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2021-12-25"); return t}()), + // PaymentDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2021-12-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusCompleted), + // }, + // { + // BillingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-01-25"); return t}()), + // PaymentDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-01-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusCompleted), + // }, + // { + // BillingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-02-25"); return t}()), + // PaymentDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-02-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusCompleted), + // }, + // { + // BillingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-03-25"); return t}()), + // PaymentDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-03-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusCompleted), + // }, + // { + // BillingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-04-25"); return t}()), + // PaymentDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-04-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusCompleted), + // }, + // { + // BillingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-05-25"); return t}()), + // PaymentDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-05-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusCompleted), + // }, + // { + // BillingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-06-25"); return t}()), + // PaymentDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-06-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusCompleted), + // }, + // { + // BillingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-07-25"); return t}()), + // PaymentDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-07-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusCompleted), + // }, + // { + // BillingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-08-25"); return t}()), + // PaymentDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-08-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusCompleted), + // }, + // { + // BillingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-09-25"); return t}()), + // PaymentDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-09-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusCompleted), + // }, + // { + // BillingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-10-25"); return t}()), + // PaymentDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-10-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusCompleted), + // }, + // { + // BillingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-11-25"); return t}()), + // PaymentDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-11-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusCompleted), + // }, + // { + // BillingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-12-25"); return t}()), + // PaymentDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-12-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusCompleted), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-01-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-02-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-03-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-04-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-05-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-06-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-07-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-08-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-09-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-10-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-11-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-12-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-01-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-02-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-03-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-04-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-05-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-06-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-07-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-08-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-09-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-10-25"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](19.88), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }}, + // }, + // ProductCode: to.Ptr("20000000-0000-0000-0000-000000000005"), + // ProvisioningState: to.Ptr("Succeeded"), + // RequestDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-25T06:31:18.392Z"); return t}()), + // Reservations: []*armbilling.Reservation{ + // { + // ID: to.Ptr("/providers/Microsoft.Capacity/reservationOrders/20000000-0000-0000-0000-000000000000/reservations/20000000-0000-0000-0000-000000000001"), + // }}, + // Term: to.Ptr("P3Y"), + // }, + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationOrdersListByBillingAccount.json +func ExampleReservationOrdersClient_NewListByBillingAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewReservationOrdersClient().NewListByBillingAccountPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", &armbilling.ReservationOrdersClientListByBillingAccountOptions{Filter: nil, + OrderBy: nil, + Skiptoken: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ReservationOrderList = armbilling.ReservationOrderList{ + // Value: []*armbilling.ReservationOrder{ + // { + // Name: to.Ptr("20000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("microsoft.billing/billingAccounts/reservationOrders"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/400000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/reservationOrders/20000000-0000-0000-0000-000000000000"), + // Etag: to.Ptr[int32](10), + // Properties: &armbilling.ReservationOrderProperty{ + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-03T21:26:48.512Z"); return t}()), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/400000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingPlan: to.Ptr(armbilling.ReservationBillingPlanUpfront), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/400000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/AAAA-AAAA-AAA-AAA"), + // CreatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-03T21:26:50.778Z"); return t}()), + // DisplayName: to.Ptr("SUSE_Plan_08-03-2021_14-22"), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-08-03T21:26:48.512Z"); return t}()), + // OriginalQuantity: to.Ptr[int32](1), + // ProductCode: to.Ptr("20000000-0000-0000-0000-000000000005"), + // ProvisioningState: to.Ptr("Succeeded"), + // RequestDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-03T21:23:47.909Z"); return t}()), + // Reservations: []*armbilling.Reservation{ + // { + // ID: to.Ptr("/providers/Microsoft.Capacity/reservationOrders/20000000-0000-0000-0000-000000000000/reservations/20000000-0000-0000-0000-000000000001"), + // }}, + // Term: to.Ptr("P3Y"), + // }, + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/billing/armbilling/reservations_client.go b/sdk/resourcemanager/billing/armbilling/reservations_client.go index 8139ccffe74c..1c8737ebf63f 100644 --- a/sdk/resourcemanager/billing/armbilling/reservations_client.go +++ b/sdk/resourcemanager/billing/armbilling/reservations_client.go @@ -11,13 +11,15 @@ package armbilling import ( "context" "errors" + "net/http" + "net/url" + "strconv" + "strings" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" ) // ReservationsClient contains the methods for the Reservations group. @@ -40,10 +42,79 @@ func NewReservationsClient(credential azcore.TokenCredential, options *arm.Clien return client, nil } -// NewListByBillingAccountPager - Lists the reservations for a billing account and the roll up counts of reservations group +// GetByReservationOrder - Get specific Reservation details in the billing account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - reservationOrderID - Order Id of the reservation +// - reservationID - Id of the reservation item +// - options - ReservationsClientGetByReservationOrderOptions contains the optional parameters for the ReservationsClient.GetByReservationOrder +// method. +func (client *ReservationsClient) GetByReservationOrder(ctx context.Context, billingAccountName string, reservationOrderID string, reservationID string, options *ReservationsClientGetByReservationOrderOptions) (ReservationsClientGetByReservationOrderResponse, error) { + var err error + const operationName = "ReservationsClient.GetByReservationOrder" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByReservationOrderCreateRequest(ctx, billingAccountName, reservationOrderID, reservationID, options) + if err != nil { + return ReservationsClientGetByReservationOrderResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ReservationsClientGetByReservationOrderResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ReservationsClientGetByReservationOrderResponse{}, err + } + resp, err := client.getByReservationOrderHandleResponse(httpResp) + return resp, err +} + +// getByReservationOrderCreateRequest creates the GetByReservationOrder request. +func (client *ReservationsClient) getByReservationOrderCreateRequest(ctx context.Context, billingAccountName string, reservationOrderID string, reservationID string, options *ReservationsClientGetByReservationOrderOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/reservationOrders/{reservationOrderId}/reservations/{reservationId}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if reservationOrderID == "" { + return nil, errors.New("parameter reservationOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationOrderId}", url.PathEscape(reservationOrderID)) + if reservationID == "" { + return nil, errors.New("parameter reservationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationId}", url.PathEscape(reservationID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Expand != nil { + reqQP.Set("expand", *options.Expand) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByReservationOrderHandleResponse handles the GetByReservationOrder response. +func (client *ReservationsClient) getByReservationOrderHandleResponse(resp *http.Response) (ReservationsClientGetByReservationOrderResponse, error) { + result := ReservationsClientGetByReservationOrderResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Reservation); err != nil { + return ReservationsClientGetByReservationOrderResponse{}, err + } + return result, nil +} + +// NewListByBillingAccountPager - Lists the reservations in the billing account and the roll up counts of reservations group // by provisioning states. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - options - ReservationsClientListByBillingAccountOptions contains the optional parameters for the ReservationsClient.NewListByBillingAccountPager // method. @@ -82,12 +153,12 @@ func (client *ReservationsClient) listByBillingAccountCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") if options != nil && options.Filter != nil { - reqQP.Set("$filter", *options.Filter) + reqQP.Set("filter", *options.Filter) } - if options != nil && options.Orderby != nil { - reqQP.Set("$orderby", *options.Orderby) + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) } if options != nil && options.RefreshSummary != nil { reqQP.Set("refreshSummary", *options.RefreshSummary) @@ -95,6 +166,12 @@ func (client *ReservationsClient) listByBillingAccountCreateRequest(ctx context. if options != nil && options.SelectedState != nil { reqQP.Set("selectedState", *options.SelectedState) } + if options != nil && options.Skiptoken != nil { + reqQP.Set("skiptoken", strconv.FormatFloat(float64(*options.Skiptoken), 'f', -1, 32)) + } + if options != nil && options.Take != nil { + reqQP.Set("take", strconv.FormatFloat(float64(*options.Take), 'f', -1, 32)) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -112,7 +189,7 @@ func (client *ReservationsClient) listByBillingAccountHandleResponse(resp *http. // NewListByBillingProfilePager - Lists the reservations for a billing profile and the roll up counts of reservations group // by provisioning state. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingProfileName - The ID that uniquely identifies a billing profile. // - options - ReservationsClientListByBillingProfileOptions contains the optional parameters for the ReservationsClient.NewListByBillingProfilePager @@ -156,12 +233,12 @@ func (client *ReservationsClient) listByBillingProfileCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") if options != nil && options.Filter != nil { - reqQP.Set("$filter", *options.Filter) + reqQP.Set("filter", *options.Filter) } - if options != nil && options.Orderby != nil { - reqQP.Set("$orderby", *options.Orderby) + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) } if options != nil && options.RefreshSummary != nil { reqQP.Set("refreshSummary", *options.RefreshSummary) @@ -169,6 +246,12 @@ func (client *ReservationsClient) listByBillingProfileCreateRequest(ctx context. if options != nil && options.SelectedState != nil { reqQP.Set("selectedState", *options.SelectedState) } + if options != nil && options.Skiptoken != nil { + reqQP.Set("skiptoken", strconv.FormatFloat(float64(*options.Skiptoken), 'f', -1, 32)) + } + if options != nil && options.Take != nil { + reqQP.Set("take", strconv.FormatFloat(float64(*options.Take), 'f', -1, 32)) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -182,3 +265,146 @@ func (client *ReservationsClient) listByBillingProfileHandleResponse(resp *http. } return result, nil } + +// NewListByReservationOrderPager - List Reservations within a single ReservationOrder in the billing account. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - reservationOrderID - Order Id of the reservation +// - options - ReservationsClientListByReservationOrderOptions contains the optional parameters for the ReservationsClient.NewListByReservationOrderPager +// method. +func (client *ReservationsClient) NewListByReservationOrderPager(billingAccountName string, reservationOrderID string, options *ReservationsClientListByReservationOrderOptions) *runtime.Pager[ReservationsClientListByReservationOrderResponse] { + return runtime.NewPager(runtime.PagingHandler[ReservationsClientListByReservationOrderResponse]{ + More: func(page ReservationsClientListByReservationOrderResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ReservationsClientListByReservationOrderResponse) (ReservationsClientListByReservationOrderResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ReservationsClient.NewListByReservationOrderPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByReservationOrderCreateRequest(ctx, billingAccountName, reservationOrderID, options) + }, nil) + if err != nil { + return ReservationsClientListByReservationOrderResponse{}, err + } + return client.listByReservationOrderHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByReservationOrderCreateRequest creates the ListByReservationOrder request. +func (client *ReservationsClient) listByReservationOrderCreateRequest(ctx context.Context, billingAccountName string, reservationOrderID string, options *ReservationsClientListByReservationOrderOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/reservationOrders/{reservationOrderId}/reservations" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if reservationOrderID == "" { + return nil, errors.New("parameter reservationOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationOrderId}", url.PathEscape(reservationOrderID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByReservationOrderHandleResponse handles the ListByReservationOrder response. +func (client *ReservationsClient) listByReservationOrderHandleResponse(resp *http.Response) (ReservationsClientListByReservationOrderResponse, error) { + result := ReservationsClientListByReservationOrderResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ReservationList); err != nil { + return ReservationsClientListByReservationOrderResponse{}, err + } + return result, nil +} + +// BeginUpdateByBillingAccount - Update reservation by billing account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - reservationOrderID - Order Id of the reservation +// - reservationID - Id of the reservation item +// - body - Request body for patching a reservation +// - options - ReservationsClientBeginUpdateByBillingAccountOptions contains the optional parameters for the ReservationsClient.BeginUpdateByBillingAccount +// method. +func (client *ReservationsClient) BeginUpdateByBillingAccount(ctx context.Context, billingAccountName string, reservationOrderID string, reservationID string, body Patch, options *ReservationsClientBeginUpdateByBillingAccountOptions) (*runtime.Poller[ReservationsClientUpdateByBillingAccountResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.updateByBillingAccount(ctx, billingAccountName, reservationOrderID, reservationID, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReservationsClientUpdateByBillingAccountResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReservationsClientUpdateByBillingAccountResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// UpdateByBillingAccount - Update reservation by billing account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *ReservationsClient) updateByBillingAccount(ctx context.Context, billingAccountName string, reservationOrderID string, reservationID string, body Patch, options *ReservationsClientBeginUpdateByBillingAccountOptions) (*http.Response, error) { + var err error + const operationName = "ReservationsClient.BeginUpdateByBillingAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateByBillingAccountCreateRequest(ctx, billingAccountName, reservationOrderID, reservationID, body, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateByBillingAccountCreateRequest creates the UpdateByBillingAccount request. +func (client *ReservationsClient) updateByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, reservationOrderID string, reservationID string, body Patch, options *ReservationsClientBeginUpdateByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/reservationOrders/{reservationOrderId}/reservations/{reservationId}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if reservationOrderID == "" { + return nil, errors.New("parameter reservationOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationOrderId}", url.PathEscape(reservationOrderID)) + if reservationID == "" { + return nil, errors.New("parameter reservationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationId}", url.PathEscape(reservationID)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/reservations_client_example_test.go b/sdk/resourcemanager/billing/armbilling/reservations_client_example_test.go index 342cec012724..b5a194603143 100644 --- a/sdk/resourcemanager/billing/armbilling/reservations_client_example_test.go +++ b/sdk/resourcemanager/billing/armbilling/reservations_client_example_test.go @@ -18,7 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/ReservationsListByBillingAccount.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationsListByBillingAccount.json func ExampleReservationsClient_NewListByBillingAccountPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -29,10 +29,12 @@ func ExampleReservationsClient_NewListByBillingAccountPager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewReservationsClient().NewListByBillingAccountPager("{billingAccountName}", &armbilling.ReservationsClientListByBillingAccountOptions{Filter: to.Ptr("properties/reservedResourceType eq 'VirtualMachines'"), - Orderby: to.Ptr("properties/userFriendlyAppliedScopeType asc"), + pager := clientFactory.NewReservationsClient().NewListByBillingAccountPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", &armbilling.ReservationsClientListByBillingAccountOptions{Filter: nil, + OrderBy: nil, + Skiptoken: nil, RefreshSummary: nil, SelectedState: to.Ptr("Succeeded"), + Take: nil, }) for pager.More() { page, err := pager.NextPage(ctx) @@ -50,25 +52,40 @@ func ExampleReservationsClient_NewListByBillingAccountPager() { // ExpiredCount: to.Ptr[float32](0), // ExpiringCount: to.Ptr[float32](0), // FailedCount: to.Ptr[float32](0), + // NoBenefitCount: to.Ptr[float32](0), // PendingCount: to.Ptr[float32](0), + // ProcessingCount: to.Ptr[float32](0), // SucceededCount: to.Ptr[float32](1), + // WarningCount: to.Ptr[float32](0), // }, // Value: []*armbilling.Reservation{ // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000001/00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders/reservations"), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/00000000-0000-0000-0000-000000000001/reservations/00000000-0000-0000-0000-000000000000"), - // Location: to.Ptr("westus"), + // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("microsoft.billing/billingAccounts/reservationOrders/reservations"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/reservationOrders/00000000-0000-0000-0000-000000000001/reservations/00000000-0000-0000-0000-000000000000"), + // Location: to.Ptr("global"), // Properties: &armbilling.ReservationProperty{ // AppliedScopeType: to.Ptr("Shared"), - // DisplayName: to.Ptr("VM_RI_07-21-2020_12-06"), + // Archived: to.Ptr(false), + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-18T21:54:31.074Z"); return t}()), + // BillingPlan: to.Ptr(armbilling.ReservationBillingPlanMonthly), + // BillingScopeID: to.Ptr("/subscriptions/eef82110-c91b-4395-9420-fcfcbefc5a47"), + // DisplayName: to.Ptr("VirtualMachineSoftware_01-18-2022_13-51"), // DisplayProvisioningState: to.Ptr("Succeeded"), - // EffectiveDateTime: to.Ptr("0001-01-01T00:00:00"), - // ExpiryDate: to.Ptr("2023-07-21"), + // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "1-01-01T00:00:00.000Z"); return t}()), + // ExpiryDate: to.Ptr("2025-01-18"), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-01-18T21:54:31.074Z"); return t}()), + // InstanceFlexibility: to.Ptr(armbilling.InstanceFlexibilityOn), + // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0-12-31T15:54:17.000Z"); return t}()), + // ProductCode: to.Ptr("20000000-0000-0000-0000-000000000005"), // ProvisioningState: to.Ptr("Succeeded"), - // Quantity: to.Ptr[float32](2), + // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-01-18"); return t}()), + // PurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-18T21:51:29.906Z"); return t}()), + // Quantity: to.Ptr[float32](1), // Renew: to.Ptr(false), - // ReservedResourceType: to.Ptr("VirtualMachines"), + // ReservedResourceType: to.Ptr("VirtualMachineSoftware"), + // SKUDescription: to.Ptr("Sku description"), + // Term: to.Ptr("P3Y"), // UserFriendlyAppliedScopeType: to.Ptr("Shared"), // UserFriendlyRenewState: to.Ptr("Off"), // Utilization: &armbilling.ReservationPropertyUtilization{ @@ -76,33 +93,37 @@ func ExampleReservationsClient_NewListByBillingAccountPager() { // { // Grain: to.Ptr[float32](1), // GrainUnit: to.Ptr("days"), - // Value: to.Ptr[float32](0.05), + // Value: to.Ptr[float32](0), // ValueUnit: to.Ptr("percentage"), // }, // { // Grain: to.Ptr[float32](7), // GrainUnit: to.Ptr("days"), - // Value: to.Ptr[float32](0.05), + // Value: to.Ptr[float32](0), // ValueUnit: to.Ptr("percentage"), // }, // { // Grain: to.Ptr[float32](30), // GrainUnit: to.Ptr("days"), - // Value: to.Ptr[float32](0.05), + // Value: to.Ptr[float32](0), // ValueUnit: to.Ptr("percentage"), // }}, - // Trend: to.Ptr("UP"), + // Trend: to.Ptr("SAME"), // }, // }, // SKU: &armbilling.ReservationSKUProperty{ - // Name: to.Ptr("Standard_D1"), + // Name: to.Ptr("mock_sku"), + // }, + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), // }, // }}, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/ReservationsListByBillingProfile.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationsListByBillingProfile.json func ExampleReservationsClient_NewListByBillingProfilePager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -113,10 +134,12 @@ func ExampleReservationsClient_NewListByBillingProfilePager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewReservationsClient().NewListByBillingProfilePager("{billingAccountName}", "{billingProfileName}", &armbilling.ReservationsClientListByBillingProfileOptions{Filter: to.Ptr("properties/reservedResourceType eq 'VirtualMachines'"), - Orderby: to.Ptr("properties/userFriendlyAppliedScopeType asc"), + pager := clientFactory.NewReservationsClient().NewListByBillingProfilePager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "AAAA-AAAA-AAA-AAA", &armbilling.ReservationsClientListByBillingProfileOptions{Filter: nil, + OrderBy: nil, + Skiptoken: nil, RefreshSummary: nil, SelectedState: to.Ptr("Succeeded"), + Take: nil, }) for pager.More() { page, err := pager.NextPage(ctx) @@ -134,26 +157,40 @@ func ExampleReservationsClient_NewListByBillingProfilePager() { // ExpiredCount: to.Ptr[float32](0), // ExpiringCount: to.Ptr[float32](0), // FailedCount: to.Ptr[float32](0), + // NoBenefitCount: to.Ptr[float32](0), // PendingCount: to.Ptr[float32](0), + // ProcessingCount: to.Ptr[float32](0), // SucceededCount: to.Ptr[float32](1), + // WarningCount: to.Ptr[float32](0), // }, // Value: []*armbilling.Reservation{ // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000001/00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders/reservations"), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/00000000-0000-0000-0000-000000000001/reservations/00000000-0000-0000-0000-000000000000"), - // Location: to.Ptr("westus"), + // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("microsoft.billing/billingAccounts/reservationOrders/reservations"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/reservationOrders/00000000-0000-0000-0000-000000000001/reservations/00000000-0000-0000-0000-000000000000"), + // Location: to.Ptr("global"), // Properties: &armbilling.ReservationProperty{ // AppliedScopeType: to.Ptr("Shared"), - // DisplayName: to.Ptr("VM_RI_07-21-2020_12-06"), + // Archived: to.Ptr(false), + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-18T21:54:31.074Z"); return t}()), + // BillingPlan: to.Ptr(armbilling.ReservationBillingPlanMonthly), + // BillingScopeID: to.Ptr("/subscriptions/eef82110-c91b-4395-9420-fcfcbefc5a47"), + // DisplayName: to.Ptr("VirtualMachineSoftware_01-18-2022_13-51"), // DisplayProvisioningState: to.Ptr("Succeeded"), - // EffectiveDateTime: to.Ptr("0001-01-01T00:00:00"), - // ExpiryDate: to.Ptr("2023-07-21"), + // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "1-01-01T00:00:00.000Z"); return t}()), + // ExpiryDate: to.Ptr("2025-01-18"), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-01-18T21:54:31.074Z"); return t}()), + // InstanceFlexibility: to.Ptr(armbilling.InstanceFlexibilityOn), + // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0-12-31T15:54:17.000Z"); return t}()), + // ProductCode: to.Ptr("20000000-0000-0000-0000-000000000005"), // ProvisioningState: to.Ptr("Succeeded"), - // Quantity: to.Ptr[float32](2), + // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-01-18"); return t}()), + // PurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-18T21:51:29.906Z"); return t}()), + // Quantity: to.Ptr[float32](1), // Renew: to.Ptr(false), - // RenewSource: to.Ptr("/providers/Microsoft.Capacity/reservationorders/00000000-0000-0000-0000-000000000002/reservations/00000000-0000-0000-0000-000000000003"), - // ReservedResourceType: to.Ptr("VirtualMachines"), + // ReservedResourceType: to.Ptr("VirtualMachineSoftware"), + // SKUDescription: to.Ptr("Sku description"), + // Term: to.Ptr("P3Y"), // UserFriendlyAppliedScopeType: to.Ptr("Shared"), // UserFriendlyRenewState: to.Ptr("Off"), // Utilization: &armbilling.ReservationPropertyUtilization{ @@ -161,26 +198,707 @@ func ExampleReservationsClient_NewListByBillingProfilePager() { // { // Grain: to.Ptr[float32](1), // GrainUnit: to.Ptr("days"), - // Value: to.Ptr[float32](0.05), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](7), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](30), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }}, + // Trend: to.Ptr("SAME"), + // }, + // }, + // SKU: &armbilling.ReservationSKUProperty{ + // Name: to.Ptr("mock_sku"), + // }, + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccount.json +func ExampleReservationsClient_GetByReservationOrder_reservationGetByBillingAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewReservationsClient().GetByReservationOrder(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "20000000-0000-0000-0000-000000000000", "30000000-0000-0000-0000-000000000000", &armbilling.ReservationsClientGetByReservationOrderOptions{Expand: nil}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Reservation = armbilling.Reservation{ + // Name: to.Ptr("30000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("microsoft.billing/billingAccounts/reservationOrders/reservations"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/reservationOrders/20000000-0000-0000-0000-000000000000/reservations/30000000-0000-0000-0000-000000000000"), + // Etag: to.Ptr[int32](15), + // Location: to.Ptr("westus"), + // Properties: &armbilling.ReservationProperty{ + // AppliedScopeType: to.Ptr("Shared"), + // Archived: to.Ptr(false), + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-25T06:34:12.926Z"); return t}()), + // BillingPlan: to.Ptr(armbilling.ReservationBillingPlanMonthly), + // BillingScopeID: to.Ptr("/subscriptions/30000000-0000-0000-0000-000000000009"), + // DisplayName: to.Ptr("VM_RI_11-24-2021_22-30"), + // DisplayProvisioningState: to.Ptr("Succeeded"), + // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-24T01:46:05.425Z"); return t}()), + // ExpiryDate: to.Ptr("2024-11-25"), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-25T06:34:12.926Z"); return t}()), + // InstanceFlexibility: to.Ptr(armbilling.InstanceFlexibilityOn), + // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-24T01:46:05.534Z"); return t}()), + // ProductCode: to.Ptr("20000000-0000-0000-0000-000000000005"), + // ProvisioningState: to.Ptr("Succeeded"), + // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2021-11-25"); return t}()), + // PurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-25T06:31:18.392Z"); return t}()), + // Quantity: to.Ptr[float32](1), + // Renew: to.Ptr(true), + // RenewProperties: &armbilling.RenewPropertiesResponse{ + // BillingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](715.68), + // CurrencyCode: to.Ptr("USD"), + // }, + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](715.68), + // CurrencyCode: to.Ptr("USD"), + // }, + // PurchaseProperties: &armbilling.ReservationPurchaseRequest{ + // Location: to.Ptr("westus"), + // Properties: &armbilling.ReservationPurchaseRequestProperties{ + // AppliedScopeType: to.Ptr(armbilling.AppliedScopeTypeShared), + // BillingPlan: to.Ptr(armbilling.ReservationBillingPlanMonthly), + // BillingScopeID: to.Ptr("/subscriptions/30000000-0000-0000-0000-000000000009"), + // DisplayName: to.Ptr("VM_RI_11-24-2021_22-30_renewed"), + // InstanceFlexibility: to.Ptr(armbilling.InstanceFlexibilityOn), + // Quantity: to.Ptr[int32](1), + // Renew: to.Ptr(false), + // ReservedResourceProperties: &armbilling.ReservationPurchaseRequestPropertiesReservedResourceProperties{ + // InstanceFlexibility: to.Ptr(armbilling.InstanceFlexibilityOn), + // }, + // ReservedResourceType: to.Ptr("VirtualMachines"), + // Term: to.Ptr("P3Y"), + // }, + // SKU: &armbilling.SKUName{ + // Name: to.Ptr("Standard_DS1_v2"), + // }, + // }, + // }, + // ReservedResourceType: to.Ptr("VirtualMachines"), + // SKUDescription: to.Ptr("Reserved VM Instance, Standard_DS1_v2, US West, 3 Years"), + // Term: to.Ptr("P3Y"), + // UserFriendlyAppliedScopeType: to.Ptr("Shared"), + // UserFriendlyRenewState: to.Ptr("On"), + // Utilization: &armbilling.ReservationPropertyUtilization{ + // Aggregates: []*armbilling.ReservationUtilizationAggregates{ + // { + // Grain: to.Ptr[float32](1), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](7), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](30), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }}, + // Trend: to.Ptr("SAME"), + // }, + // }, + // SKU: &armbilling.ReservationSKUProperty{ + // Name: to.Ptr("Standard_DS1_v2"), + // }, + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccountManagementGroup.json +func ExampleReservationsClient_GetByReservationOrder_reservationGetByBillingAccountManagementGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewReservationsClient().GetByReservationOrder(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "20000000-0000-0000-0000-000000000000", "30000000-0000-0000-0000-000000000000", &armbilling.ReservationsClientGetByReservationOrderOptions{Expand: nil}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Reservation = armbilling.Reservation{ + // Name: to.Ptr("30000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("microsoft.billing/billingAccounts/reservationOrders/reservations"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/reservationOrders/20000000-0000-0000-0000-000000000000/reservations/30000000-0000-0000-0000-000000000000"), + // Etag: to.Ptr[int32](21), + // Location: to.Ptr("westus"), + // Properties: &armbilling.ReservationProperty{ + // AppliedScopeProperties: &armbilling.ReservationAppliedScopeProperties{ + // DisplayName: to.Ptr("TestRg"), + // ManagementGroupID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestRg"), + // TenantID: to.Ptr("50000000-0000-0000-0000-000000000009"), + // }, + // AppliedScopeType: to.Ptr("ManagementGroup"), + // Archived: to.Ptr(false), + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-25T06:34:12.926Z"); return t}()), + // BillingPlan: to.Ptr(armbilling.ReservationBillingPlanMonthly), + // BillingScopeID: to.Ptr("/subscriptions/30000000-0000-0000-0000-000000000009"), + // DisplayName: to.Ptr("VM_RI_11-24-2021_22-30"), + // DisplayProvisioningState: to.Ptr("NoBenefit"), + // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-26T01:19:31.991Z"); return t}()), + // ExpiryDate: to.Ptr("2024-11-25"), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-25T06:34:12.926Z"); return t}()), + // ExtendedStatusInfo: &armbilling.ReservationExtendedStatusInfo{ + // Message: to.Ptr("The subscriptions utilizing the reservation were removed or transferred from this account and no longer receive the reservation benefit. You can cancel the reservation or transfer to the right account or create resources and subscriptions to map it to this reservation."), + // StatusCode: to.Ptr(armbilling.ReservationStatusCodeNoBenefit), + // }, + // InstanceFlexibility: to.Ptr(armbilling.InstanceFlexibilityOn), + // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-26T01:19:32.069Z"); return t}()), + // ProductCode: to.Ptr("20000000-0000-0000-0000-000000000005"), + // ProvisioningState: to.Ptr("Succeeded"), + // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2021-11-25"); return t}()), + // PurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-25T06:31:18.392Z"); return t}()), + // Quantity: to.Ptr[float32](1), + // Renew: to.Ptr(true), + // RenewProperties: &armbilling.RenewPropertiesResponse{ + // BillingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](715.68), + // CurrencyCode: to.Ptr("USD"), + // }, + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](715.68), + // CurrencyCode: to.Ptr("USD"), + // }, + // PurchaseProperties: &armbilling.ReservationPurchaseRequest{ + // Location: to.Ptr("westus"), + // Properties: &armbilling.ReservationPurchaseRequestProperties{ + // AppliedScopeProperties: &armbilling.ReservationAppliedScopeProperties{ + // ManagementGroupID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestRg"), + // TenantID: to.Ptr("50000000-0000-0000-0000-000000000009"), + // }, + // AppliedScopeType: to.Ptr(armbilling.AppliedScopeTypeManagementGroup), + // BillingPlan: to.Ptr(armbilling.ReservationBillingPlanMonthly), + // BillingScopeID: to.Ptr("/subscriptions/30000000-0000-0000-0000-000000000009"), + // DisplayName: to.Ptr("VM_RI_11-24-2021_22-30_renewed"), + // InstanceFlexibility: to.Ptr(armbilling.InstanceFlexibilityOn), + // Quantity: to.Ptr[int32](1), + // Renew: to.Ptr(false), + // ReservedResourceProperties: &armbilling.ReservationPurchaseRequestPropertiesReservedResourceProperties{ + // InstanceFlexibility: to.Ptr(armbilling.InstanceFlexibilityOn), + // }, + // ReservedResourceType: to.Ptr("VirtualMachines"), + // Term: to.Ptr("P3Y"), + // }, + // SKU: &armbilling.SKUName{ + // Name: to.Ptr("Standard_DS1_v2"), + // }, + // }, + // }, + // ReservedResourceType: to.Ptr("VirtualMachines"), + // SKUDescription: to.Ptr("Reserved VM Instance, Standard_DS1_v2, US West, 3 Years"), + // Term: to.Ptr("P3Y"), + // UserFriendlyAppliedScopeType: to.Ptr("ManagementGroup"), + // UserFriendlyRenewState: to.Ptr("On"), + // Utilization: &armbilling.ReservationPropertyUtilization{ + // Aggregates: []*armbilling.ReservationUtilizationAggregates{ + // { + // Grain: to.Ptr[float32](1), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](7), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](30), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }}, + // Trend: to.Ptr("SAME"), + // }, + // }, + // SKU: &armbilling.ReservationSKUProperty{ + // Name: to.Ptr("Standard_DS1_v2"), + // }, + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccountSingleResourceGroup.json +func ExampleReservationsClient_GetByReservationOrder_reservationGetByBillingAccountSingleResourceGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewReservationsClient().GetByReservationOrder(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "20000000-0000-0000-0000-000000000000", "30000000-0000-0000-0000-000000000000", &armbilling.ReservationsClientGetByReservationOrderOptions{Expand: nil}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Reservation = armbilling.Reservation{ + // Name: to.Ptr("30000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("microsoft.billing/billingAccounts/reservationOrders/reservations"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/reservationOrders/20000000-0000-0000-0000-000000000000/reservations/30000000-0000-0000-0000-000000000000"), + // Etag: to.Ptr[int32](23), + // Location: to.Ptr("westus"), + // Properties: &armbilling.ReservationProperty{ + // AppliedScopeProperties: &armbilling.ReservationAppliedScopeProperties{ + // DisplayName: to.Ptr("fastpathtesting_20210915"), + // ResourceGroupID: to.Ptr("/subscriptions/30000000-0000-0000-0000-000000000009/resourcegroups/fastpathtesting_20210915"), + // }, + // AppliedScopeType: to.Ptr("Single"), + // Archived: to.Ptr(false), + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-25T06:34:12.926Z"); return t}()), + // BillingPlan: to.Ptr(armbilling.ReservationBillingPlanMonthly), + // BillingScopeID: to.Ptr("/subscriptions/30000000-0000-0000-0000-000000000009"), + // DisplayName: to.Ptr("VM_RI_11-24-2021_22-30"), + // DisplayProvisioningState: to.Ptr("Succeeded"), + // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-26T01:21:47.293Z"); return t}()), + // ExpiryDate: to.Ptr("2024-11-25"), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-25T06:34:12.926Z"); return t}()), + // InstanceFlexibility: to.Ptr(armbilling.InstanceFlexibilityOn), + // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-26T01:21:47.356Z"); return t}()), + // ProductCode: to.Ptr("20000000-0000-0000-0000-000000000005"), + // ProvisioningState: to.Ptr("Succeeded"), + // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2021-11-25"); return t}()), + // PurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-25T06:31:18.392Z"); return t}()), + // Quantity: to.Ptr[float32](1), + // Renew: to.Ptr(true), + // RenewProperties: &armbilling.RenewPropertiesResponse{ + // BillingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](715.68), + // CurrencyCode: to.Ptr("USD"), + // }, + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](715.68), + // CurrencyCode: to.Ptr("USD"), + // }, + // PurchaseProperties: &armbilling.ReservationPurchaseRequest{ + // Location: to.Ptr("westus"), + // Properties: &armbilling.ReservationPurchaseRequestProperties{ + // AppliedScopeType: to.Ptr(armbilling.AppliedScopeTypeSingle), + // AppliedScopes: []*string{ + // to.Ptr("/subscriptions/30000000-0000-0000-0000-000000000009/resourcegroups/fastpathtesting_20210915")}, + // BillingPlan: to.Ptr(armbilling.ReservationBillingPlanMonthly), + // BillingScopeID: to.Ptr("/subscriptions/30000000-0000-0000-0000-000000000009"), + // DisplayName: to.Ptr("VM_RI_11-24-2021_22-30_renewed"), + // InstanceFlexibility: to.Ptr(armbilling.InstanceFlexibilityOn), + // Quantity: to.Ptr[int32](1), + // Renew: to.Ptr(false), + // ReservedResourceProperties: &armbilling.ReservationPurchaseRequestPropertiesReservedResourceProperties{ + // InstanceFlexibility: to.Ptr(armbilling.InstanceFlexibilityOn), + // }, + // ReservedResourceType: to.Ptr("VirtualMachines"), + // Term: to.Ptr("P3Y"), + // }, + // SKU: &armbilling.SKUName{ + // Name: to.Ptr("Standard_DS1_v2"), + // }, + // }, + // }, + // ReservedResourceType: to.Ptr("VirtualMachines"), + // SKUDescription: to.Ptr("Reserved VM Instance, Standard_DS1_v2, US West, 3 Years"), + // Term: to.Ptr("P3Y"), + // UserFriendlyAppliedScopeType: to.Ptr("ResourceGroup"), + // UserFriendlyRenewState: to.Ptr("On"), + // Utilization: &armbilling.ReservationPropertyUtilization{ + // Aggregates: []*armbilling.ReservationUtilizationAggregates{ + // { + // Grain: to.Ptr[float32](1), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](7), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](30), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }}, + // Trend: to.Ptr("SAME"), + // }, + // }, + // SKU: &armbilling.ReservationSKUProperty{ + // Name: to.Ptr("Standard_DS1_v2"), + // }, + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccountSingleScope.json +func ExampleReservationsClient_GetByReservationOrder_reservationGetByBillingAccountSingleScope() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewReservationsClient().GetByReservationOrder(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "20000000-0000-0000-0000-000000000000", "30000000-0000-0000-0000-000000000000", &armbilling.ReservationsClientGetByReservationOrderOptions{Expand: nil}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Reservation = armbilling.Reservation{ + // Name: to.Ptr("30000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("microsoft.billing/billingAccounts/reservationOrders/reservations"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/reservationOrders/20000000-0000-0000-0000-000000000000/reservations/30000000-0000-0000-0000-000000000000"), + // Etag: to.Ptr[int32](19), + // Location: to.Ptr("westus"), + // Properties: &armbilling.ReservationProperty{ + // AppliedScopeProperties: &armbilling.ReservationAppliedScopeProperties{ + // DisplayName: to.Ptr("Azure subscription 1"), + // SubscriptionID: to.Ptr("/subscriptions/30000000-0000-0000-0000-000000000009"), + // }, + // AppliedScopeType: to.Ptr("Single"), + // Archived: to.Ptr(false), + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-25T06:34:12.926Z"); return t}()), + // BillingPlan: to.Ptr(armbilling.ReservationBillingPlanMonthly), + // BillingScopeID: to.Ptr("/subscriptions/30000000-0000-0000-0000-000000000009"), + // DisplayName: to.Ptr("VM_RI_11-24-2021_22-30"), + // DisplayProvisioningState: to.Ptr("Succeeded"), + // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-26T01:14:18.558Z"); return t}()), + // ExpiryDate: to.Ptr("2024-11-25"), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-25T06:34:12.926Z"); return t}()), + // InstanceFlexibility: to.Ptr(armbilling.InstanceFlexibilityOff), + // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-26T01:14:18.605Z"); return t}()), + // ProductCode: to.Ptr("20000000-0000-0000-0000-000000000005"), + // ProvisioningState: to.Ptr("Succeeded"), + // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2021-11-25"); return t}()), + // PurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-25T06:31:18.392Z"); return t}()), + // Quantity: to.Ptr[float32](1), + // Renew: to.Ptr(true), + // RenewProperties: &armbilling.RenewPropertiesResponse{ + // BillingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](715.68), + // CurrencyCode: to.Ptr("USD"), + // }, + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](715.68), + // CurrencyCode: to.Ptr("USD"), + // }, + // PurchaseProperties: &armbilling.ReservationPurchaseRequest{ + // Location: to.Ptr("westus"), + // Properties: &armbilling.ReservationPurchaseRequestProperties{ + // AppliedScopeType: to.Ptr(armbilling.AppliedScopeTypeSingle), + // AppliedScopes: []*string{ + // to.Ptr("/subscriptions/30000000-0000-0000-0000-000000000009")}, + // BillingPlan: to.Ptr(armbilling.ReservationBillingPlanMonthly), + // BillingScopeID: to.Ptr("/subscriptions/30000000-0000-0000-0000-000000000009"), + // DisplayName: to.Ptr("VM_RI_11-24-2021_22-30_renewed"), + // InstanceFlexibility: to.Ptr(armbilling.InstanceFlexibilityOff), + // Quantity: to.Ptr[int32](1), + // Renew: to.Ptr(false), + // ReservedResourceProperties: &armbilling.ReservationPurchaseRequestPropertiesReservedResourceProperties{ + // InstanceFlexibility: to.Ptr(armbilling.InstanceFlexibilityOff), + // }, + // ReservedResourceType: to.Ptr("VirtualMachines"), + // Term: to.Ptr("P3Y"), + // }, + // SKU: &armbilling.SKUName{ + // Name: to.Ptr("Standard_DS1_v2"), + // }, + // }, + // }, + // ReservedResourceType: to.Ptr("VirtualMachines"), + // SKUDescription: to.Ptr("Reserved VM Instance, Standard_DS1_v2, US West, 3 Years"), + // Term: to.Ptr("P3Y"), + // UserFriendlyAppliedScopeType: to.Ptr("Single"), + // UserFriendlyRenewState: to.Ptr("On"), + // Utilization: &armbilling.ReservationPropertyUtilization{ + // Aggregates: []*armbilling.ReservationUtilizationAggregates{ + // { + // Grain: to.Ptr[float32](1), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](7), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](30), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }}, + // Trend: to.Ptr("SAME"), + // }, + // }, + // SKU: &armbilling.ReservationSKUProperty{ + // Name: to.Ptr("Standard_DS1_v2"), + // }, + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationUpdateByBillingAccount.json +func ExampleReservationsClient_BeginUpdateByBillingAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewReservationsClient().BeginUpdateByBillingAccount(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "20000000-0000-0000-0000-000000000000", "30000000-0000-0000-0000-000000000000", armbilling.Patch{ + Properties: &armbilling.PatchProperties{ + DisplayName: to.Ptr("NewName"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Reservation = armbilling.Reservation{ + // Name: to.Ptr("30000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("microsoft.billing/billingAccounts/reservationOrders/reservations"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/reservationOrders/20000000-0000-0000-0000-000000000000/reservations/30000000-0000-0000-0000-000000000000"), + // Etag: to.Ptr[int32](15), + // Location: to.Ptr("westus"), + // Properties: &armbilling.ReservationProperty{ + // AppliedScopeType: to.Ptr("Shared"), + // Archived: to.Ptr(false), + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-25T06:34:12.926Z"); return t}()), + // BillingPlan: to.Ptr(armbilling.ReservationBillingPlanMonthly), + // BillingScopeID: to.Ptr("/subscriptions/30000000-0000-0000-0000-000000000009"), + // DisplayName: to.Ptr("NewName"), + // DisplayProvisioningState: to.Ptr("Succeeded"), + // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-24T01:46:05.425Z"); return t}()), + // ExpiryDate: to.Ptr("2024-11-25"), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-25T06:34:12.926Z"); return t}()), + // InstanceFlexibility: to.Ptr(armbilling.InstanceFlexibilityOn), + // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-24T01:46:05.534Z"); return t}()), + // ProductCode: to.Ptr("20000000-0000-0000-0000-000000000005"), + // ProvisioningState: to.Ptr("Succeeded"), + // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2021-11-25"); return t}()), + // PurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-25T06:31:18.392Z"); return t}()), + // Quantity: to.Ptr[float32](1), + // Renew: to.Ptr(true), + // RenewProperties: &armbilling.RenewPropertiesResponse{ + // BillingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](715.68), + // CurrencyCode: to.Ptr("USD"), + // }, + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](715.68), + // CurrencyCode: to.Ptr("USD"), + // }, + // PurchaseProperties: &armbilling.ReservationPurchaseRequest{ + // Location: to.Ptr("westus"), + // Properties: &armbilling.ReservationPurchaseRequestProperties{ + // AppliedScopeType: to.Ptr(armbilling.AppliedScopeTypeShared), + // BillingPlan: to.Ptr(armbilling.ReservationBillingPlanMonthly), + // BillingScopeID: to.Ptr("/subscriptions/30000000-0000-0000-0000-000000000009"), + // DisplayName: to.Ptr("VM_RI_11-24-2021_22-30_renewed"), + // InstanceFlexibility: to.Ptr(armbilling.InstanceFlexibilityOn), + // Quantity: to.Ptr[int32](1), + // Renew: to.Ptr(false), + // ReservedResourceProperties: &armbilling.ReservationPurchaseRequestPropertiesReservedResourceProperties{ + // InstanceFlexibility: to.Ptr(armbilling.InstanceFlexibilityOn), + // }, + // ReservedResourceType: to.Ptr("VirtualMachines"), + // Term: to.Ptr("P3Y"), + // }, + // SKU: &armbilling.SKUName{ + // Name: to.Ptr("Standard_DS1_v2"), + // }, + // }, + // }, + // ReservedResourceType: to.Ptr("VirtualMachines"), + // SKUDescription: to.Ptr("Reserved VM Instance, Standard_DS1_v2, US West, 3 Years"), + // Term: to.Ptr("P3Y"), + // UserFriendlyAppliedScopeType: to.Ptr("Shared"), + // UserFriendlyRenewState: to.Ptr("On"), + // Utilization: &armbilling.ReservationPropertyUtilization{ + // Aggregates: []*armbilling.ReservationUtilizationAggregates{ + // { + // Grain: to.Ptr[float32](1), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](7), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](30), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }}, + // Trend: to.Ptr("SAME"), + // }, + // }, + // SKU: &armbilling.ReservationSKUProperty{ + // Name: to.Ptr("Standard_DS1_v2"), + // }, + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationsGetFromOrderByBillingAccount.json +func ExampleReservationsClient_NewListByReservationOrderPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewReservationsClient().NewListByReservationOrderPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "20000000-0000-0000-0000-000000000000", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ReservationList = armbilling.ReservationList{ + // Value: []*armbilling.Reservation{ + // { + // Name: to.Ptr("a7d70646-b848-4498-8093-5938128b225c"), + // Type: to.Ptr("microsoft.billing/billingAccounts/reservationOrders/reservations"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/4973e1de-a829-5c64-4fef-0a692e2b3108:1970c5da-0aa4-46fd-a917-4772f9a17978_2019-05-31/reservationOrders/99f340d1-6db4-41b4-b469-cfc499716973/reservations/a7d70646-b848-4498-8093-5938128b225c"), + // Etag: to.Ptr[int32](15), + // Location: to.Ptr("westus"), + // Properties: &armbilling.ReservationProperty{ + // AppliedScopeType: to.Ptr("Shared"), + // Archived: to.Ptr(false), + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-25T06:34:12.926Z"); return t}()), + // BillingPlan: to.Ptr(armbilling.ReservationBillingPlanMonthly), + // BillingScopeID: to.Ptr("/subscriptions/eef82110-c91b-4395-9420-fcfcbefc5a47"), + // DisplayName: to.Ptr("VM_RI_11-24-2021_22-30"), + // DisplayProvisioningState: to.Ptr("Succeeded"), + // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-24T01:46:05.425Z"); return t}()), + // ExpiryDate: to.Ptr("2024-11-25"), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-25T06:34:12.926Z"); return t}()), + // InstanceFlexibility: to.Ptr(armbilling.InstanceFlexibilityOn), + // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-24T01:46:05.534Z"); return t}()), + // ProductCode: to.Ptr("20000000-0000-0000-0000-000000000005"), + // ProvisioningState: to.Ptr("Succeeded"), + // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2021-11-25"); return t}()), + // PurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-25T06:31:18.392Z"); return t}()), + // Quantity: to.Ptr[float32](1), + // Renew: to.Ptr(true), + // ReservedResourceType: to.Ptr("VirtualMachines"), + // SKUDescription: to.Ptr("Reserved VM Instance, Standard_DS1_v2, US West, 3 Years"), + // Term: to.Ptr("P3Y"), + // UserFriendlyAppliedScopeType: to.Ptr("Shared"), + // UserFriendlyRenewState: to.Ptr("On"), + // Utilization: &armbilling.ReservationPropertyUtilization{ + // Aggregates: []*armbilling.ReservationUtilizationAggregates{ + // { + // Grain: to.Ptr[float32](1), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), // ValueUnit: to.Ptr("percentage"), // }, // { // Grain: to.Ptr[float32](7), // GrainUnit: to.Ptr("days"), - // Value: to.Ptr[float32](0.05), + // Value: to.Ptr[float32](0), // ValueUnit: to.Ptr("percentage"), // }, // { // Grain: to.Ptr[float32](30), // GrainUnit: to.Ptr("days"), - // Value: to.Ptr[float32](0.05), + // Value: to.Ptr[float32](0), // ValueUnit: to.Ptr("percentage"), // }}, - // Trend: to.Ptr("UP"), + // Trend: to.Ptr("SAME"), // }, // }, // SKU: &armbilling.ReservationSKUProperty{ - // Name: to.Ptr("Standard_D1"), + // Name: to.Ptr("Standard_DS1_v2"), + // }, + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), // }, // }}, // } diff --git a/sdk/resourcemanager/billing/armbilling/response_types.go b/sdk/resourcemanager/billing/armbilling/response_types.go deleted file mode 100644 index 6656f68bcfe8..000000000000 --- a/sdk/resourcemanager/billing/armbilling/response_types.go +++ /dev/null @@ -1,489 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armbilling - -// AccountsClientGetResponse contains the response from method AccountsClient.Get. -type AccountsClientGetResponse struct { - // A billing account. - Account -} - -// AccountsClientListInvoiceSectionsByCreateSubscriptionPermissionResponse contains the response from method AccountsClient.NewListInvoiceSectionsByCreateSubscriptionPermissionPager. -type AccountsClientListInvoiceSectionsByCreateSubscriptionPermissionResponse struct { - // The list of invoice section properties with create subscription permission. - InvoiceSectionListWithCreateSubPermissionResult -} - -// AccountsClientListResponse contains the response from method AccountsClient.NewListPager. -type AccountsClientListResponse struct { - // The list of billing accounts. - AccountListResult -} - -// AccountsClientUpdateResponse contains the response from method AccountsClient.BeginUpdate. -type AccountsClientUpdateResponse struct { - // A billing account. - Account -} - -// AddressClientValidateResponse contains the response from method AddressClient.Validate. -type AddressClientValidateResponse struct { - // Result of the address validation - ValidateAddressResponse -} - -// AgreementsClientGetResponse contains the response from method AgreementsClient.Get. -type AgreementsClientGetResponse struct { - // An agreement. - Agreement -} - -// AgreementsClientListByBillingAccountResponse contains the response from method AgreementsClient.NewListByBillingAccountPager. -type AgreementsClientListByBillingAccountResponse struct { - // Result of listing agreements. - AgreementListResult -} - -// AvailableBalancesClientGetResponse contains the response from method AvailableBalancesClient.Get. -type AvailableBalancesClientGetResponse struct { - // The latest Azure credit balance. This is the balance available for pay now. - AvailableBalance -} - -// CustomersClientGetResponse contains the response from method CustomersClient.Get. -type CustomersClientGetResponse struct { - // A partner's customer. - Customer -} - -// CustomersClientListByBillingAccountResponse contains the response from method CustomersClient.NewListByBillingAccountPager. -type CustomersClientListByBillingAccountResponse struct { - // The list of customers. - CustomerListResult -} - -// CustomersClientListByBillingProfileResponse contains the response from method CustomersClient.NewListByBillingProfilePager. -type CustomersClientListByBillingProfileResponse struct { - // The list of customers. - CustomerListResult -} - -// EnrollmentAccountsClientGetResponse contains the response from method EnrollmentAccountsClient.Get. -type EnrollmentAccountsClientGetResponse struct { - // An enrollment account resource. - EnrollmentAccountSummary -} - -// EnrollmentAccountsClientListResponse contains the response from method EnrollmentAccountsClient.NewListPager. -type EnrollmentAccountsClientListResponse struct { - // Result of listing enrollment accounts. - EnrollmentAccountListResult -} - -// InstructionsClientGetResponse contains the response from method InstructionsClient.Get. -type InstructionsClientGetResponse struct { - // An instruction. - Instruction -} - -// InstructionsClientListByBillingProfileResponse contains the response from method InstructionsClient.NewListByBillingProfilePager. -type InstructionsClientListByBillingProfileResponse struct { - // The list of billing instructions used during invoice generation. - InstructionListResult -} - -// InstructionsClientPutResponse contains the response from method InstructionsClient.Put. -type InstructionsClientPutResponse struct { - // An instruction. - Instruction -} - -// InvoiceSectionsClientCreateOrUpdateResponse contains the response from method InvoiceSectionsClient.BeginCreateOrUpdate. -type InvoiceSectionsClientCreateOrUpdateResponse struct { - // An invoice section. - InvoiceSection -} - -// InvoiceSectionsClientGetResponse contains the response from method InvoiceSectionsClient.Get. -type InvoiceSectionsClientGetResponse struct { - // An invoice section. - InvoiceSection -} - -// InvoiceSectionsClientListByBillingProfileResponse contains the response from method InvoiceSectionsClient.NewListByBillingProfilePager. -type InvoiceSectionsClientListByBillingProfileResponse struct { - // The list of invoice sections. - InvoiceSectionListResult -} - -// InvoicesClientDownloadBillingSubscriptionInvoiceResponse contains the response from method InvoicesClient.BeginDownloadBillingSubscriptionInvoice. -type InvoicesClientDownloadBillingSubscriptionInvoiceResponse struct { - // A secure URL that can be used to download a an entity until the URL expires. - DownloadURL -} - -// InvoicesClientDownloadInvoiceResponse contains the response from method InvoicesClient.BeginDownloadInvoice. -type InvoicesClientDownloadInvoiceResponse struct { - // A secure URL that can be used to download a an entity until the URL expires. - DownloadURL -} - -// InvoicesClientDownloadMultipleBillingProfileInvoicesResponse contains the response from method InvoicesClient.BeginDownloadMultipleBillingProfileInvoices. -type InvoicesClientDownloadMultipleBillingProfileInvoicesResponse struct { - // A secure URL that can be used to download a an entity until the URL expires. - DownloadURL -} - -// InvoicesClientDownloadMultipleBillingSubscriptionInvoicesResponse contains the response from method InvoicesClient.BeginDownloadMultipleBillingSubscriptionInvoices. -type InvoicesClientDownloadMultipleBillingSubscriptionInvoicesResponse struct { - // A secure URL that can be used to download a an entity until the URL expires. - DownloadURL -} - -// InvoicesClientGetByIDResponse contains the response from method InvoicesClient.GetByID. -type InvoicesClientGetByIDResponse struct { - // An invoice. - Invoice -} - -// InvoicesClientGetBySubscriptionAndInvoiceIDResponse contains the response from method InvoicesClient.GetBySubscriptionAndInvoiceID. -type InvoicesClientGetBySubscriptionAndInvoiceIDResponse struct { - // An invoice. - Invoice -} - -// InvoicesClientGetResponse contains the response from method InvoicesClient.Get. -type InvoicesClientGetResponse struct { - // An invoice. - Invoice -} - -// InvoicesClientListByBillingAccountResponse contains the response from method InvoicesClient.NewListByBillingAccountPager. -type InvoicesClientListByBillingAccountResponse struct { - // The list of invoices. - InvoiceListResult -} - -// InvoicesClientListByBillingProfileResponse contains the response from method InvoicesClient.NewListByBillingProfilePager. -type InvoicesClientListByBillingProfileResponse struct { - // The list of invoices. - InvoiceListResult -} - -// InvoicesClientListByBillingSubscriptionResponse contains the response from method InvoicesClient.NewListByBillingSubscriptionPager. -type InvoicesClientListByBillingSubscriptionResponse struct { - // The list of invoices. - InvoiceListResult -} - -// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. -type OperationsClientListResponse struct { - // The list of billing operations and a URL link to get the next set of results. - OperationListResult -} - -// PeriodsClientGetResponse contains the response from method PeriodsClient.Get. -type PeriodsClientGetResponse struct { - // A billing period resource. - Period -} - -// PeriodsClientListResponse contains the response from method PeriodsClient.NewListPager. -type PeriodsClientListResponse struct { - // Result of listing billing periods. It contains a list of available billing periods in reverse chronological order. - PeriodsListResult -} - -// PermissionsClientListByBillingAccountResponse contains the response from method PermissionsClient.NewListByBillingAccountPager. -type PermissionsClientListByBillingAccountResponse struct { - // Result of list billingPermissions a caller has on a billing account. - PermissionsListResult -} - -// PermissionsClientListByBillingProfileResponse contains the response from method PermissionsClient.NewListByBillingProfilePager. -type PermissionsClientListByBillingProfileResponse struct { - // Result of list billingPermissions a caller has on a billing account. - PermissionsListResult -} - -// PermissionsClientListByCustomerResponse contains the response from method PermissionsClient.NewListByCustomerPager. -type PermissionsClientListByCustomerResponse struct { - // Result of list billingPermissions a caller has on a billing account. - PermissionsListResult -} - -// PermissionsClientListByInvoiceSectionsResponse contains the response from method PermissionsClient.NewListByInvoiceSectionsPager. -type PermissionsClientListByInvoiceSectionsResponse struct { - // Result of list billingPermissions a caller has on a billing account. - PermissionsListResult -} - -// PoliciesClientGetByBillingProfileResponse contains the response from method PoliciesClient.GetByBillingProfile. -type PoliciesClientGetByBillingProfileResponse struct { - // A policy. - Policy -} - -// PoliciesClientGetByCustomerResponse contains the response from method PoliciesClient.GetByCustomer. -type PoliciesClientGetByCustomerResponse struct { - // The customer's Policy. - CustomerPolicy -} - -// PoliciesClientUpdateCustomerResponse contains the response from method PoliciesClient.UpdateCustomer. -type PoliciesClientUpdateCustomerResponse struct { - // The customer's Policy. - CustomerPolicy -} - -// PoliciesClientUpdateResponse contains the response from method PoliciesClient.Update. -type PoliciesClientUpdateResponse struct { - // A policy. - Policy -} - -// ProductsClientGetResponse contains the response from method ProductsClient.Get. -type ProductsClientGetResponse struct { - // A product. - Product -} - -// ProductsClientListByBillingAccountResponse contains the response from method ProductsClient.NewListByBillingAccountPager. -type ProductsClientListByBillingAccountResponse struct { - // The list of products. It contains a list of available product summaries in reverse chronological order by purchase date. - ProductsListResult -} - -// ProductsClientListByBillingProfileResponse contains the response from method ProductsClient.NewListByBillingProfilePager. -type ProductsClientListByBillingProfileResponse struct { - // The list of products. It contains a list of available product summaries in reverse chronological order by purchase date. - ProductsListResult -} - -// ProductsClientListByCustomerResponse contains the response from method ProductsClient.NewListByCustomerPager. -type ProductsClientListByCustomerResponse struct { - // The list of products. It contains a list of available product summaries in reverse chronological order by purchase date. - ProductsListResult -} - -// ProductsClientListByInvoiceSectionResponse contains the response from method ProductsClient.NewListByInvoiceSectionPager. -type ProductsClientListByInvoiceSectionResponse struct { - // The list of products. It contains a list of available product summaries in reverse chronological order by purchase date. - ProductsListResult -} - -// ProductsClientMoveResponse contains the response from method ProductsClient.Move. -type ProductsClientMoveResponse struct { - // A product. - Product - - // Location contains the information returned from the Location header response. - Location *string - - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 -} - -// ProductsClientUpdateResponse contains the response from method ProductsClient.Update. -type ProductsClientUpdateResponse struct { - // A product. - Product -} - -// ProductsClientValidateMoveResponse contains the response from method ProductsClient.ValidateMove. -type ProductsClientValidateMoveResponse struct { - // Result of the product transfer eligibility validation. - ValidateProductTransferEligibilityResult -} - -// ProfilesClientCreateOrUpdateResponse contains the response from method ProfilesClient.BeginCreateOrUpdate. -type ProfilesClientCreateOrUpdateResponse struct { - // A billing profile. - Profile -} - -// ProfilesClientGetResponse contains the response from method ProfilesClient.Get. -type ProfilesClientGetResponse struct { - // A billing profile. - Profile -} - -// ProfilesClientListByBillingAccountResponse contains the response from method ProfilesClient.NewListByBillingAccountPager. -type ProfilesClientListByBillingAccountResponse struct { - // The list of billing profiles. - ProfileListResult -} - -// PropertyClientGetResponse contains the response from method PropertyClient.Get. -type PropertyClientGetResponse struct { - // A billing property. - Property -} - -// PropertyClientUpdateResponse contains the response from method PropertyClient.Update. -type PropertyClientUpdateResponse struct { - // A billing property. - Property -} - -// ReservationsClientListByBillingAccountResponse contains the response from method ReservationsClient.NewListByBillingAccountPager. -type ReservationsClientListByBillingAccountResponse struct { - // The list of reservations and summary of roll out count of reservations in each state. - ReservationsListResult -} - -// ReservationsClientListByBillingProfileResponse contains the response from method ReservationsClient.NewListByBillingProfilePager. -type ReservationsClientListByBillingProfileResponse struct { - // The list of reservations and summary of roll out count of reservations in each state. - ReservationsListResult -} - -// RoleAssignmentsClientDeleteByBillingAccountResponse contains the response from method RoleAssignmentsClient.DeleteByBillingAccount. -type RoleAssignmentsClientDeleteByBillingAccountResponse struct { - // The role assignment - RoleAssignment -} - -// RoleAssignmentsClientDeleteByBillingProfileResponse contains the response from method RoleAssignmentsClient.DeleteByBillingProfile. -type RoleAssignmentsClientDeleteByBillingProfileResponse struct { - // The role assignment - RoleAssignment -} - -// RoleAssignmentsClientDeleteByInvoiceSectionResponse contains the response from method RoleAssignmentsClient.DeleteByInvoiceSection. -type RoleAssignmentsClientDeleteByInvoiceSectionResponse struct { - // The role assignment - RoleAssignment -} - -// RoleAssignmentsClientGetByBillingAccountResponse contains the response from method RoleAssignmentsClient.GetByBillingAccount. -type RoleAssignmentsClientGetByBillingAccountResponse struct { - // The role assignment - RoleAssignment -} - -// RoleAssignmentsClientGetByBillingProfileResponse contains the response from method RoleAssignmentsClient.GetByBillingProfile. -type RoleAssignmentsClientGetByBillingProfileResponse struct { - // The role assignment - RoleAssignment -} - -// RoleAssignmentsClientGetByInvoiceSectionResponse contains the response from method RoleAssignmentsClient.GetByInvoiceSection. -type RoleAssignmentsClientGetByInvoiceSectionResponse struct { - // The role assignment - RoleAssignment -} - -// RoleAssignmentsClientListByBillingAccountResponse contains the response from method RoleAssignmentsClient.NewListByBillingAccountPager. -type RoleAssignmentsClientListByBillingAccountResponse struct { - // The list of role assignments. - RoleAssignmentListResult -} - -// RoleAssignmentsClientListByBillingProfileResponse contains the response from method RoleAssignmentsClient.NewListByBillingProfilePager. -type RoleAssignmentsClientListByBillingProfileResponse struct { - // The list of role assignments. - RoleAssignmentListResult -} - -// RoleAssignmentsClientListByInvoiceSectionResponse contains the response from method RoleAssignmentsClient.NewListByInvoiceSectionPager. -type RoleAssignmentsClientListByInvoiceSectionResponse struct { - // The list of role assignments. - RoleAssignmentListResult -} - -// RoleDefinitionsClientGetByBillingAccountResponse contains the response from method RoleDefinitionsClient.GetByBillingAccount. -type RoleDefinitionsClientGetByBillingAccountResponse struct { - // The properties of a role definition. - RoleDefinition -} - -// RoleDefinitionsClientGetByBillingProfileResponse contains the response from method RoleDefinitionsClient.GetByBillingProfile. -type RoleDefinitionsClientGetByBillingProfileResponse struct { - // The properties of a role definition. - RoleDefinition -} - -// RoleDefinitionsClientGetByInvoiceSectionResponse contains the response from method RoleDefinitionsClient.GetByInvoiceSection. -type RoleDefinitionsClientGetByInvoiceSectionResponse struct { - // The properties of a role definition. - RoleDefinition -} - -// RoleDefinitionsClientListByBillingAccountResponse contains the response from method RoleDefinitionsClient.NewListByBillingAccountPager. -type RoleDefinitionsClientListByBillingAccountResponse struct { - // The list of role definitions. - RoleDefinitionListResult -} - -// RoleDefinitionsClientListByBillingProfileResponse contains the response from method RoleDefinitionsClient.NewListByBillingProfilePager. -type RoleDefinitionsClientListByBillingProfileResponse struct { - // The list of role definitions. - RoleDefinitionListResult -} - -// RoleDefinitionsClientListByInvoiceSectionResponse contains the response from method RoleDefinitionsClient.NewListByInvoiceSectionPager. -type RoleDefinitionsClientListByInvoiceSectionResponse struct { - // The list of role definitions. - RoleDefinitionListResult -} - -// SubscriptionsClientGetResponse contains the response from method SubscriptionsClient.Get. -type SubscriptionsClientGetResponse struct { - // A billing subscription. - Subscription -} - -// SubscriptionsClientListByBillingAccountResponse contains the response from method SubscriptionsClient.NewListByBillingAccountPager. -type SubscriptionsClientListByBillingAccountResponse struct { - // The list of billing subscriptions. - SubscriptionsListResult -} - -// SubscriptionsClientListByBillingProfileResponse contains the response from method SubscriptionsClient.NewListByBillingProfilePager. -type SubscriptionsClientListByBillingProfileResponse struct { - // The list of billing subscriptions. - SubscriptionsListResult -} - -// SubscriptionsClientListByCustomerResponse contains the response from method SubscriptionsClient.NewListByCustomerPager. -type SubscriptionsClientListByCustomerResponse struct { - // The list of billing subscriptions. - SubscriptionsListResult -} - -// SubscriptionsClientListByInvoiceSectionResponse contains the response from method SubscriptionsClient.NewListByInvoiceSectionPager. -type SubscriptionsClientListByInvoiceSectionResponse struct { - // The list of billing subscriptions. - SubscriptionsListResult -} - -// SubscriptionsClientMoveResponse contains the response from method SubscriptionsClient.BeginMove. -type SubscriptionsClientMoveResponse struct { - // A billing subscription. - Subscription -} - -// SubscriptionsClientUpdateResponse contains the response from method SubscriptionsClient.Update. -type SubscriptionsClientUpdateResponse struct { - // A billing subscription. - Subscription -} - -// SubscriptionsClientValidateMoveResponse contains the response from method SubscriptionsClient.ValidateMove. -type SubscriptionsClientValidateMoveResponse struct { - // Result of the transfer eligibility validation. - ValidateSubscriptionTransferEligibilityResult -} - -// TransactionsClientListByInvoiceResponse contains the response from method TransactionsClient.NewListByInvoicePager. -type TransactionsClientListByInvoiceResponse struct { - // The list of transactions. - TransactionListResult -} diff --git a/sdk/resourcemanager/billing/armbilling/responses.go b/sdk/resourcemanager/billing/armbilling/responses.go new file mode 100644 index 000000000000..adef3cbcfee4 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/responses.go @@ -0,0 +1,1125 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armbilling + +// AccountsClientAddPaymentTermsResponse contains the response from method AccountsClient.BeginAddPaymentTerms. +type AccountsClientAddPaymentTermsResponse struct { + // A billing account. + Account +} + +// AccountsClientCancelPaymentTermsResponse contains the response from method AccountsClient.BeginCancelPaymentTerms. +type AccountsClientCancelPaymentTermsResponse struct { + // A billing account. + Account +} + +// AccountsClientConfirmTransitionResponse contains the response from method AccountsClient.ConfirmTransition. +type AccountsClientConfirmTransitionResponse struct { + // The details for a billing account transitioned from agreement type Microsoft Online Services Program to agreement type + // Microsoft Customer Agreement. + TransitionDetails +} + +// AccountsClientGetResponse contains the response from method AccountsClient.Get. +type AccountsClientGetResponse struct { + // A billing account. + Account +} + +// AccountsClientListInvoiceSectionsByCreateSubscriptionPermissionResponse contains the response from method AccountsClient.NewListInvoiceSectionsByCreateSubscriptionPermissionPager. +type AccountsClientListInvoiceSectionsByCreateSubscriptionPermissionResponse struct { + // A container for a list of resources + InvoiceSectionWithCreateSubPermissionListResult +} + +// AccountsClientListResponse contains the response from method AccountsClient.NewListPager. +type AccountsClientListResponse struct { + // A container for a list of resources + AccountListResult +} + +// AccountsClientUpdateResponse contains the response from method AccountsClient.BeginUpdate. +type AccountsClientUpdateResponse struct { + // A billing account. + Account +} + +// AccountsClientValidatePaymentTermsResponse contains the response from method AccountsClient.ValidatePaymentTerms. +type AccountsClientValidatePaymentTermsResponse struct { + // Result of the payment terms eligibility. + PaymentTermsEligibilityResult +} + +// AddressClientValidateResponse contains the response from method AddressClient.Validate. +type AddressClientValidateResponse struct { + // Result of the address validation. + AddressValidationResponse +} + +// AgreementsClientGetResponse contains the response from method AgreementsClient.Get. +type AgreementsClientGetResponse struct { + // An agreement. + Agreement +} + +// AgreementsClientListByBillingAccountResponse contains the response from method AgreementsClient.NewListByBillingAccountPager. +type AgreementsClientListByBillingAccountResponse struct { + // A container for a list of resources + AgreementListResult +} + +// AssociatedTenantsClientCreateOrUpdateResponse contains the response from method AssociatedTenantsClient.BeginCreateOrUpdate. +type AssociatedTenantsClientCreateOrUpdateResponse struct { + // An associated tenant. + AssociatedTenant +} + +// AssociatedTenantsClientDeleteResponse contains the response from method AssociatedTenantsClient.BeginDelete. +type AssociatedTenantsClientDeleteResponse struct { + // placeholder for future response values +} + +// AssociatedTenantsClientGetResponse contains the response from method AssociatedTenantsClient.Get. +type AssociatedTenantsClientGetResponse struct { + // An associated tenant. + AssociatedTenant +} + +// AssociatedTenantsClientListByBillingAccountResponse contains the response from method AssociatedTenantsClient.NewListByBillingAccountPager. +type AssociatedTenantsClientListByBillingAccountResponse struct { + // A container for a list of resources + AssociatedTenantListResult +} + +// AvailableBalancesClientGetByBillingAccountResponse contains the response from method AvailableBalancesClient.GetByBillingAccount. +type AvailableBalancesClientGetByBillingAccountResponse struct { + // The Available Credit or Payment on Account Balance. The credit balance can be used to settle due or past due invoices. + AvailableBalance +} + +// AvailableBalancesClientGetByBillingProfileResponse contains the response from method AvailableBalancesClient.GetByBillingProfile. +type AvailableBalancesClientGetByBillingProfileResponse struct { + // The Available Credit or Payment on Account Balance. The credit balance can be used to settle due or past due invoices. + AvailableBalance +} + +// CustomersClientGetByBillingAccountResponse contains the response from method CustomersClient.GetByBillingAccount. +type CustomersClientGetByBillingAccountResponse struct { + // A partner's customer. + Customer +} + +// CustomersClientGetResponse contains the response from method CustomersClient.Get. +type CustomersClientGetResponse struct { + // A partner's customer. + Customer +} + +// CustomersClientListByBillingAccountResponse contains the response from method CustomersClient.NewListByBillingAccountPager. +type CustomersClientListByBillingAccountResponse struct { + // A container for a list of resources + CustomerListResult +} + +// CustomersClientListByBillingProfileResponse contains the response from method CustomersClient.NewListByBillingProfilePager. +type CustomersClientListByBillingProfileResponse struct { + // A container for a list of resources + CustomerListResult +} + +// DepartmentsClientGetResponse contains the response from method DepartmentsClient.Get. +type DepartmentsClientGetResponse struct { + // Optional grouping of enrollment accounts to segment costs into logical groupings and set budgets. + Department +} + +// DepartmentsClientListByBillingAccountResponse contains the response from method DepartmentsClient.NewListByBillingAccountPager. +type DepartmentsClientListByBillingAccountResponse struct { + // A container for a list of resources + DepartmentListResult +} + +// EnrollmentAccountsClientGetByDepartmentResponse contains the response from method EnrollmentAccountsClient.GetByDepartment. +type EnrollmentAccountsClientGetByDepartmentResponse struct { + // It is an organizational hierarchy within a billing account to administer and manage azure costs. + EnrollmentAccount +} + +// EnrollmentAccountsClientGetResponse contains the response from method EnrollmentAccountsClient.Get. +type EnrollmentAccountsClientGetResponse struct { + // It is an organizational hierarchy within a billing account to administer and manage azure costs. + EnrollmentAccount +} + +// EnrollmentAccountsClientListByBillingAccountResponse contains the response from method EnrollmentAccountsClient.NewListByBillingAccountPager. +type EnrollmentAccountsClientListByBillingAccountResponse struct { + // A container for a list of resources + EnrollmentAccountListResult +} + +// EnrollmentAccountsClientListByDepartmentResponse contains the response from method EnrollmentAccountsClient.NewListByDepartmentPager. +type EnrollmentAccountsClientListByDepartmentResponse struct { + // A container for a list of resources + EnrollmentAccountListResult +} + +// InvoiceSectionsClientCreateOrUpdateResponse contains the response from method InvoiceSectionsClient.BeginCreateOrUpdate. +type InvoiceSectionsClientCreateOrUpdateResponse struct { + // An invoice section. + InvoiceSection +} + +// InvoiceSectionsClientDeleteResponse contains the response from method InvoiceSectionsClient.BeginDelete. +type InvoiceSectionsClientDeleteResponse struct { + // placeholder for future response values +} + +// InvoiceSectionsClientGetResponse contains the response from method InvoiceSectionsClient.Get. +type InvoiceSectionsClientGetResponse struct { + // An invoice section. + InvoiceSection +} + +// InvoiceSectionsClientListByBillingProfileResponse contains the response from method InvoiceSectionsClient.NewListByBillingProfilePager. +type InvoiceSectionsClientListByBillingProfileResponse struct { + // A container for a list of resources + InvoiceSectionListResult +} + +// InvoiceSectionsClientValidateDeleteEligibilityResponse contains the response from method InvoiceSectionsClient.ValidateDeleteEligibility. +type InvoiceSectionsClientValidateDeleteEligibilityResponse struct { + // Eligibility to delete an invoice section result. + DeleteInvoiceSectionEligibilityResult +} + +// InvoicesClientAmendResponse contains the response from method InvoicesClient.BeginAmend. +type InvoicesClientAmendResponse struct { + // placeholder for future response values +} + +// InvoicesClientDownloadByBillingAccountResponse contains the response from method InvoicesClient.BeginDownloadByBillingAccount. +type InvoicesClientDownloadByBillingAccountResponse struct { + // A secure URL that can be used to download a an entity until the URL expires. + DocumentDownloadResult +} + +// InvoicesClientDownloadByBillingSubscriptionResponse contains the response from method InvoicesClient.BeginDownloadByBillingSubscription. +type InvoicesClientDownloadByBillingSubscriptionResponse struct { + // A secure URL that can be used to download a an entity until the URL expires. + DocumentDownloadResult +} + +// InvoicesClientDownloadDocumentsByBillingAccountResponse contains the response from method InvoicesClient.BeginDownloadDocumentsByBillingAccount. +type InvoicesClientDownloadDocumentsByBillingAccountResponse struct { + // A secure URL that can be used to download a an entity until the URL expires. + DocumentDownloadResult +} + +// InvoicesClientDownloadDocumentsByBillingSubscriptionResponse contains the response from method InvoicesClient.BeginDownloadDocumentsByBillingSubscription. +type InvoicesClientDownloadDocumentsByBillingSubscriptionResponse struct { + // A secure URL that can be used to download a an entity until the URL expires. + DocumentDownloadResult +} + +// InvoicesClientDownloadSummaryByBillingAccountResponse contains the response from method InvoicesClient.BeginDownloadSummaryByBillingAccount. +type InvoicesClientDownloadSummaryByBillingAccountResponse struct { + // A secure URL that can be used to download a an entity until the URL expires. + DocumentDownloadResult +} + +// InvoicesClientGetByBillingAccountResponse contains the response from method InvoicesClient.GetByBillingAccount. +type InvoicesClientGetByBillingAccountResponse struct { + // An invoice. + Invoice +} + +// InvoicesClientGetByBillingSubscriptionResponse contains the response from method InvoicesClient.GetByBillingSubscription. +type InvoicesClientGetByBillingSubscriptionResponse struct { + // An invoice. + Invoice +} + +// InvoicesClientGetResponse contains the response from method InvoicesClient.Get. +type InvoicesClientGetResponse struct { + // An invoice. + Invoice +} + +// InvoicesClientListByBillingAccountResponse contains the response from method InvoicesClient.NewListByBillingAccountPager. +type InvoicesClientListByBillingAccountResponse struct { + // A container for a list of resources + InvoiceListResult +} + +// InvoicesClientListByBillingProfileResponse contains the response from method InvoicesClient.NewListByBillingProfilePager. +type InvoicesClientListByBillingProfileResponse struct { + // A container for a list of resources + InvoiceListResult +} + +// InvoicesClientListByBillingSubscriptionResponse contains the response from method InvoicesClient.NewListByBillingSubscriptionPager. +type InvoicesClientListByBillingSubscriptionResponse struct { + // A container for a list of resources + InvoiceListResult +} + +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. +type OperationsClientListResponse struct { + // A container for a list of resources + OperationListResult +} + +// PartnerTransfersClientCancelResponse contains the response from method PartnerTransfersClient.Cancel. +type PartnerTransfersClientCancelResponse struct { + // Details of the transfer. + PartnerTransferDetails +} + +// PartnerTransfersClientGetResponse contains the response from method PartnerTransfersClient.Get. +type PartnerTransfersClientGetResponse struct { + // Details of the transfer. + PartnerTransferDetails +} + +// PartnerTransfersClientInitiateResponse contains the response from method PartnerTransfersClient.Initiate. +type PartnerTransfersClientInitiateResponse struct { + // Details of the transfer. + PartnerTransferDetails +} + +// PartnerTransfersClientListResponse contains the response from method PartnerTransfersClient.NewListPager. +type PartnerTransfersClientListResponse struct { + // The list of transfers initiated by partner. + PartnerTransferDetailsListResult +} + +// PaymentMethodsClientDeleteByUserResponse contains the response from method PaymentMethodsClient.DeleteByUser. +type PaymentMethodsClientDeleteByUserResponse struct { + // placeholder for future response values +} + +// PaymentMethodsClientGetByBillingAccountResponse contains the response from method PaymentMethodsClient.GetByBillingAccount. +type PaymentMethodsClientGetByBillingAccountResponse struct { + // A payment method. + PaymentMethod +} + +// PaymentMethodsClientGetByBillingProfileResponse contains the response from method PaymentMethodsClient.GetByBillingProfile. +type PaymentMethodsClientGetByBillingProfileResponse struct { + // A payment method link. + PaymentMethodLink +} + +// PaymentMethodsClientGetByUserResponse contains the response from method PaymentMethodsClient.GetByUser. +type PaymentMethodsClientGetByUserResponse struct { + // A payment method. + PaymentMethod +} + +// PaymentMethodsClientListByBillingAccountResponse contains the response from method PaymentMethodsClient.NewListByBillingAccountPager. +type PaymentMethodsClientListByBillingAccountResponse struct { + // The list of payment methods. + PaymentMethodsListResult +} + +// PaymentMethodsClientListByBillingProfileResponse contains the response from method PaymentMethodsClient.NewListByBillingProfilePager. +type PaymentMethodsClientListByBillingProfileResponse struct { + // The list of payment method links. + PaymentMethodLinksListResult +} + +// PaymentMethodsClientListByUserResponse contains the response from method PaymentMethodsClient.NewListByUserPager. +type PaymentMethodsClientListByUserResponse struct { + // The list of payment methods. + PaymentMethodsListResult +} + +// PermissionsClientCheckAccessByBillingAccountResponse contains the response from method PermissionsClient.CheckAccessByBillingAccount. +type PermissionsClientCheckAccessByBillingAccountResponse struct { + // Array of CheckAccessResponse + CheckAccessResponseArray []*CheckAccessResponse +} + +// PermissionsClientCheckAccessByBillingProfileResponse contains the response from method PermissionsClient.CheckAccessByBillingProfile. +type PermissionsClientCheckAccessByBillingProfileResponse struct { + // Array of CheckAccessResponse + CheckAccessResponseArray []*CheckAccessResponse +} + +// PermissionsClientCheckAccessByCustomerResponse contains the response from method PermissionsClient.CheckAccessByCustomer. +type PermissionsClientCheckAccessByCustomerResponse struct { + // Array of CheckAccessResponse + CheckAccessResponseArray []*CheckAccessResponse +} + +// PermissionsClientCheckAccessByDepartmentResponse contains the response from method PermissionsClient.CheckAccessByDepartment. +type PermissionsClientCheckAccessByDepartmentResponse struct { + // Array of CheckAccessResponse + CheckAccessResponseArray []*CheckAccessResponse +} + +// PermissionsClientCheckAccessByEnrollmentAccountResponse contains the response from method PermissionsClient.CheckAccessByEnrollmentAccount. +type PermissionsClientCheckAccessByEnrollmentAccountResponse struct { + // Array of CheckAccessResponse + CheckAccessResponseArray []*CheckAccessResponse +} + +// PermissionsClientCheckAccessByInvoiceSectionResponse contains the response from method PermissionsClient.CheckAccessByInvoiceSection. +type PermissionsClientCheckAccessByInvoiceSectionResponse struct { + // Array of CheckAccessResponse + CheckAccessResponseArray []*CheckAccessResponse +} + +// PermissionsClientListByBillingAccountResponse contains the response from method PermissionsClient.NewListByBillingAccountPager. +type PermissionsClientListByBillingAccountResponse struct { + // A container for a list of resources + PermissionListResult +} + +// PermissionsClientListByBillingProfileResponse contains the response from method PermissionsClient.NewListByBillingProfilePager. +type PermissionsClientListByBillingProfileResponse struct { + // A container for a list of resources + PermissionListResult +} + +// PermissionsClientListByCustomerAtBillingAccountResponse contains the response from method PermissionsClient.NewListByCustomerAtBillingAccountPager. +type PermissionsClientListByCustomerAtBillingAccountResponse struct { + // A container for a list of resources + PermissionListResult +} + +// PermissionsClientListByCustomerResponse contains the response from method PermissionsClient.NewListByCustomerPager. +type PermissionsClientListByCustomerResponse struct { + // A container for a list of resources + PermissionListResult +} + +// PermissionsClientListByDepartmentResponse contains the response from method PermissionsClient.NewListByDepartmentPager. +type PermissionsClientListByDepartmentResponse struct { + // A container for a list of resources + PermissionListResult +} + +// PermissionsClientListByEnrollmentAccountResponse contains the response from method PermissionsClient.NewListByEnrollmentAccountPager. +type PermissionsClientListByEnrollmentAccountResponse struct { + // A container for a list of resources + PermissionListResult +} + +// PermissionsClientListByInvoiceSectionResponse contains the response from method PermissionsClient.NewListByInvoiceSectionPager. +type PermissionsClientListByInvoiceSectionResponse struct { + // A container for a list of resources + PermissionListResult +} + +// PoliciesClientCreateOrUpdateByBillingAccountResponse contains the response from method PoliciesClient.BeginCreateOrUpdateByBillingAccount. +type PoliciesClientCreateOrUpdateByBillingAccountResponse struct { + // A policy at billing account scope. + AccountPolicy +} + +// PoliciesClientCreateOrUpdateByBillingProfileResponse contains the response from method PoliciesClient.BeginCreateOrUpdateByBillingProfile. +type PoliciesClientCreateOrUpdateByBillingProfileResponse struct { + // A policy at billing profile scope. + ProfilePolicy +} + +// PoliciesClientCreateOrUpdateByCustomerAtBillingAccountResponse contains the response from method PoliciesClient.BeginCreateOrUpdateByCustomerAtBillingAccount. +type PoliciesClientCreateOrUpdateByCustomerAtBillingAccountResponse struct { + // A policy at customer scope. + CustomerPolicy +} + +// PoliciesClientCreateOrUpdateByCustomerResponse contains the response from method PoliciesClient.BeginCreateOrUpdateByCustomer. +type PoliciesClientCreateOrUpdateByCustomerResponse struct { + // A policy at customer scope. + CustomerPolicy +} + +// PoliciesClientGetByBillingAccountResponse contains the response from method PoliciesClient.GetByBillingAccount. +type PoliciesClientGetByBillingAccountResponse struct { + // A policy at billing account scope. + AccountPolicy +} + +// PoliciesClientGetByBillingProfileResponse contains the response from method PoliciesClient.GetByBillingProfile. +type PoliciesClientGetByBillingProfileResponse struct { + // A policy at billing profile scope. + ProfilePolicy +} + +// PoliciesClientGetByCustomerAtBillingAccountResponse contains the response from method PoliciesClient.GetByCustomerAtBillingAccount. +type PoliciesClientGetByCustomerAtBillingAccountResponse struct { + // A policy at customer scope. + CustomerPolicy +} + +// PoliciesClientGetByCustomerResponse contains the response from method PoliciesClient.GetByCustomer. +type PoliciesClientGetByCustomerResponse struct { + // A policy at customer scope. + CustomerPolicy +} + +// PoliciesClientGetBySubscriptionResponse contains the response from method PoliciesClient.GetBySubscription. +type PoliciesClientGetBySubscriptionResponse struct { + // A policy at subscription scope. + SubscriptionPolicy +} + +// ProductsClientGetResponse contains the response from method ProductsClient.Get. +type ProductsClientGetResponse struct { + // A product. + Product +} + +// ProductsClientListByBillingAccountResponse contains the response from method ProductsClient.NewListByBillingAccountPager. +type ProductsClientListByBillingAccountResponse struct { + // A container for a list of resources + ProductListResult +} + +// ProductsClientListByBillingProfileResponse contains the response from method ProductsClient.NewListByBillingProfilePager. +type ProductsClientListByBillingProfileResponse struct { + // A container for a list of resources + ProductListResult +} + +// ProductsClientListByCustomerResponse contains the response from method ProductsClient.NewListByCustomerPager. +type ProductsClientListByCustomerResponse struct { + // A container for a list of resources + ProductListResult +} + +// ProductsClientListByInvoiceSectionResponse contains the response from method ProductsClient.NewListByInvoiceSectionPager. +type ProductsClientListByInvoiceSectionResponse struct { + // A container for a list of resources + ProductListResult +} + +// ProductsClientMoveResponse contains the response from method ProductsClient.BeginMove. +type ProductsClientMoveResponse struct { + // A product. + Product +} + +// ProductsClientUpdateResponse contains the response from method ProductsClient.Update. +type ProductsClientUpdateResponse struct { + // A product. + Product +} + +// ProductsClientValidateMoveEligibilityResponse contains the response from method ProductsClient.ValidateMoveEligibility. +type ProductsClientValidateMoveEligibilityResponse struct { + // Result of the transfer eligibility validation. + MoveProductEligibilityResult +} + +// ProfilesClientCreateOrUpdateResponse contains the response from method ProfilesClient.BeginCreateOrUpdate. +type ProfilesClientCreateOrUpdateResponse struct { + // A billing profile. + Profile +} + +// ProfilesClientDeleteResponse contains the response from method ProfilesClient.BeginDelete. +type ProfilesClientDeleteResponse struct { + // placeholder for future response values +} + +// ProfilesClientGetResponse contains the response from method ProfilesClient.Get. +type ProfilesClientGetResponse struct { + // A billing profile. + Profile +} + +// ProfilesClientListByBillingAccountResponse contains the response from method ProfilesClient.NewListByBillingAccountPager. +type ProfilesClientListByBillingAccountResponse struct { + // A container for a list of resources + ProfileListResult +} + +// ProfilesClientValidateDeleteEligibilityResponse contains the response from method ProfilesClient.ValidateDeleteEligibility. +type ProfilesClientValidateDeleteEligibilityResponse struct { + // Eligibility to delete a billing profile result. + DeleteBillingProfileEligibilityResult +} + +// PropertyClientGetResponse contains the response from method PropertyClient.Get. +type PropertyClientGetResponse struct { + // A billing property. + Property +} + +// PropertyClientUpdateResponse contains the response from method PropertyClient.Update. +type PropertyClientUpdateResponse struct { + // A billing property. + Property +} + +// RecipientTransfersClientAcceptResponse contains the response from method RecipientTransfersClient.Accept. +type RecipientTransfersClientAcceptResponse struct { + // Details of the transfer. + RecipientTransferDetails +} + +// RecipientTransfersClientDeclineResponse contains the response from method RecipientTransfersClient.Decline. +type RecipientTransfersClientDeclineResponse struct { + // Details of the transfer. + RecipientTransferDetails +} + +// RecipientTransfersClientGetResponse contains the response from method RecipientTransfersClient.Get. +type RecipientTransfersClientGetResponse struct { + // Details of the transfer. + RecipientTransferDetails +} + +// RecipientTransfersClientListResponse contains the response from method RecipientTransfersClient.NewListPager. +type RecipientTransfersClientListResponse struct { + // The list of transfers received by caller. + RecipientTransferDetailsListResult +} + +// RecipientTransfersClientValidateResponse contains the response from method RecipientTransfersClient.Validate. +type RecipientTransfersClientValidateResponse struct { + // Result of transfer validation. + ValidateTransferListResponse +} + +// RequestsClientCreateOrUpdateResponse contains the response from method RequestsClient.BeginCreateOrUpdate. +type RequestsClientCreateOrUpdateResponse struct { + // A request submitted by a user to manage billing. Users with an owner role on the scope can approve or decline these requests. + Request +} + +// RequestsClientGetResponse contains the response from method RequestsClient.Get. +type RequestsClientGetResponse struct { + // A request submitted by a user to manage billing. Users with an owner role on the scope can approve or decline these requests. + Request +} + +// RequestsClientListByBillingAccountResponse contains the response from method RequestsClient.NewListByBillingAccountPager. +type RequestsClientListByBillingAccountResponse struct { + // A container for a list of resources + RequestListResult +} + +// RequestsClientListByBillingProfileResponse contains the response from method RequestsClient.NewListByBillingProfilePager. +type RequestsClientListByBillingProfileResponse struct { + // A container for a list of resources + RequestListResult +} + +// RequestsClientListByCustomerResponse contains the response from method RequestsClient.NewListByCustomerPager. +type RequestsClientListByCustomerResponse struct { + // A container for a list of resources + RequestListResult +} + +// RequestsClientListByInvoiceSectionResponse contains the response from method RequestsClient.NewListByInvoiceSectionPager. +type RequestsClientListByInvoiceSectionResponse struct { + // A container for a list of resources + RequestListResult +} + +// RequestsClientListByUserResponse contains the response from method RequestsClient.NewListByUserPager. +type RequestsClientListByUserResponse struct { + // A container for a list of resources + RequestListResult +} + +// ReservationOrdersClientGetByBillingAccountResponse contains the response from method ReservationOrdersClient.GetByBillingAccount. +type ReservationOrdersClientGetByBillingAccountResponse struct { + // Details of a reservation order being returned. + ReservationOrder +} + +// ReservationOrdersClientListByBillingAccountResponse contains the response from method ReservationOrdersClient.NewListByBillingAccountPager. +type ReservationOrdersClientListByBillingAccountResponse struct { + // List of ReservationOrders + ReservationOrderList +} + +// ReservationsClientGetByReservationOrderResponse contains the response from method ReservationsClient.GetByReservationOrder. +type ReservationsClientGetByReservationOrderResponse struct { + // The definition of the reservation. + Reservation +} + +// ReservationsClientListByBillingAccountResponse contains the response from method ReservationsClient.NewListByBillingAccountPager. +type ReservationsClientListByBillingAccountResponse struct { + // The list of reservations and summary of roll out count of reservations in each state. + ReservationsListResult +} + +// ReservationsClientListByBillingProfileResponse contains the response from method ReservationsClient.NewListByBillingProfilePager. +type ReservationsClientListByBillingProfileResponse struct { + // The list of reservations and summary of roll out count of reservations in each state. + ReservationsListResult +} + +// ReservationsClientListByReservationOrderResponse contains the response from method ReservationsClient.NewListByReservationOrderPager. +type ReservationsClientListByReservationOrderResponse struct { + // List of `Reservations + ReservationList +} + +// ReservationsClientUpdateByBillingAccountResponse contains the response from method ReservationsClient.BeginUpdateByBillingAccount. +type ReservationsClientUpdateByBillingAccountResponse struct { + // The definition of the reservation. + Reservation +} + +// RoleAssignmentsClientCreateByBillingAccountResponse contains the response from method RoleAssignmentsClient.BeginCreateByBillingAccount. +type RoleAssignmentsClientCreateByBillingAccountResponse struct { + // The properties of the billing role assignment. + RoleAssignment +} + +// RoleAssignmentsClientCreateByBillingProfileResponse contains the response from method RoleAssignmentsClient.BeginCreateByBillingProfile. +type RoleAssignmentsClientCreateByBillingProfileResponse struct { + // The properties of the billing role assignment. + RoleAssignment +} + +// RoleAssignmentsClientCreateByCustomerResponse contains the response from method RoleAssignmentsClient.BeginCreateByCustomer. +type RoleAssignmentsClientCreateByCustomerResponse struct { + // The properties of the billing role assignment. + RoleAssignment +} + +// RoleAssignmentsClientCreateByInvoiceSectionResponse contains the response from method RoleAssignmentsClient.BeginCreateByInvoiceSection. +type RoleAssignmentsClientCreateByInvoiceSectionResponse struct { + // The properties of the billing role assignment. + RoleAssignment +} + +// RoleAssignmentsClientCreateOrUpdateByBillingAccountResponse contains the response from method RoleAssignmentsClient.BeginCreateOrUpdateByBillingAccount. +type RoleAssignmentsClientCreateOrUpdateByBillingAccountResponse struct { + // The properties of the billing role assignment. + RoleAssignment +} + +// RoleAssignmentsClientCreateOrUpdateByDepartmentResponse contains the response from method RoleAssignmentsClient.BeginCreateOrUpdateByDepartment. +type RoleAssignmentsClientCreateOrUpdateByDepartmentResponse struct { + // The properties of the billing role assignment. + RoleAssignment +} + +// RoleAssignmentsClientCreateOrUpdateByEnrollmentAccountResponse contains the response from method RoleAssignmentsClient.BeginCreateOrUpdateByEnrollmentAccount. +type RoleAssignmentsClientCreateOrUpdateByEnrollmentAccountResponse struct { + // The properties of the billing role assignment. + RoleAssignment +} + +// RoleAssignmentsClientDeleteByBillingAccountResponse contains the response from method RoleAssignmentsClient.DeleteByBillingAccount. +type RoleAssignmentsClientDeleteByBillingAccountResponse struct { + // placeholder for future response values +} + +// RoleAssignmentsClientDeleteByBillingProfileResponse contains the response from method RoleAssignmentsClient.DeleteByBillingProfile. +type RoleAssignmentsClientDeleteByBillingProfileResponse struct { + // placeholder for future response values +} + +// RoleAssignmentsClientDeleteByCustomerResponse contains the response from method RoleAssignmentsClient.DeleteByCustomer. +type RoleAssignmentsClientDeleteByCustomerResponse struct { + // placeholder for future response values +} + +// RoleAssignmentsClientDeleteByDepartmentResponse contains the response from method RoleAssignmentsClient.DeleteByDepartment. +type RoleAssignmentsClientDeleteByDepartmentResponse struct { + // placeholder for future response values +} + +// RoleAssignmentsClientDeleteByEnrollmentAccountResponse contains the response from method RoleAssignmentsClient.DeleteByEnrollmentAccount. +type RoleAssignmentsClientDeleteByEnrollmentAccountResponse struct { + // placeholder for future response values +} + +// RoleAssignmentsClientDeleteByInvoiceSectionResponse contains the response from method RoleAssignmentsClient.DeleteByInvoiceSection. +type RoleAssignmentsClientDeleteByInvoiceSectionResponse struct { + // placeholder for future response values +} + +// RoleAssignmentsClientGetByBillingAccountResponse contains the response from method RoleAssignmentsClient.GetByBillingAccount. +type RoleAssignmentsClientGetByBillingAccountResponse struct { + // The properties of the billing role assignment. + RoleAssignment +} + +// RoleAssignmentsClientGetByBillingProfileResponse contains the response from method RoleAssignmentsClient.GetByBillingProfile. +type RoleAssignmentsClientGetByBillingProfileResponse struct { + // The properties of the billing role assignment. + RoleAssignment +} + +// RoleAssignmentsClientGetByCustomerResponse contains the response from method RoleAssignmentsClient.GetByCustomer. +type RoleAssignmentsClientGetByCustomerResponse struct { + // The properties of the billing role assignment. + RoleAssignment +} + +// RoleAssignmentsClientGetByDepartmentResponse contains the response from method RoleAssignmentsClient.GetByDepartment. +type RoleAssignmentsClientGetByDepartmentResponse struct { + // The properties of the billing role assignment. + RoleAssignment +} + +// RoleAssignmentsClientGetByEnrollmentAccountResponse contains the response from method RoleAssignmentsClient.GetByEnrollmentAccount. +type RoleAssignmentsClientGetByEnrollmentAccountResponse struct { + // The properties of the billing role assignment. + RoleAssignment +} + +// RoleAssignmentsClientGetByInvoiceSectionResponse contains the response from method RoleAssignmentsClient.GetByInvoiceSection. +type RoleAssignmentsClientGetByInvoiceSectionResponse struct { + // The properties of the billing role assignment. + RoleAssignment +} + +// RoleAssignmentsClientListByBillingAccountResponse contains the response from method RoleAssignmentsClient.NewListByBillingAccountPager. +type RoleAssignmentsClientListByBillingAccountResponse struct { + // A container for a list of resources + RoleAssignmentListResult +} + +// RoleAssignmentsClientListByBillingProfileResponse contains the response from method RoleAssignmentsClient.NewListByBillingProfilePager. +type RoleAssignmentsClientListByBillingProfileResponse struct { + // A container for a list of resources + RoleAssignmentListResult +} + +// RoleAssignmentsClientListByCustomerResponse contains the response from method RoleAssignmentsClient.NewListByCustomerPager. +type RoleAssignmentsClientListByCustomerResponse struct { + // A container for a list of resources + RoleAssignmentListResult +} + +// RoleAssignmentsClientListByDepartmentResponse contains the response from method RoleAssignmentsClient.NewListByDepartmentPager. +type RoleAssignmentsClientListByDepartmentResponse struct { + // A container for a list of resources + RoleAssignmentListResult +} + +// RoleAssignmentsClientListByEnrollmentAccountResponse contains the response from method RoleAssignmentsClient.NewListByEnrollmentAccountPager. +type RoleAssignmentsClientListByEnrollmentAccountResponse struct { + // A container for a list of resources + RoleAssignmentListResult +} + +// RoleAssignmentsClientListByInvoiceSectionResponse contains the response from method RoleAssignmentsClient.NewListByInvoiceSectionPager. +type RoleAssignmentsClientListByInvoiceSectionResponse struct { + // A container for a list of resources + RoleAssignmentListResult +} + +// RoleAssignmentsClientResolveByBillingAccountResponse contains the response from method RoleAssignmentsClient.BeginResolveByBillingAccount. +type RoleAssignmentsClientResolveByBillingAccountResponse struct { + // A container for a list of resources + RoleAssignmentListResult +} + +// RoleAssignmentsClientResolveByBillingProfileResponse contains the response from method RoleAssignmentsClient.BeginResolveByBillingProfile. +type RoleAssignmentsClientResolveByBillingProfileResponse struct { + // A container for a list of resources + RoleAssignmentListResult +} + +// RoleAssignmentsClientResolveByCustomerResponse contains the response from method RoleAssignmentsClient.BeginResolveByCustomer. +type RoleAssignmentsClientResolveByCustomerResponse struct { + // A container for a list of resources + RoleAssignmentListResult +} + +// RoleAssignmentsClientResolveByInvoiceSectionResponse contains the response from method RoleAssignmentsClient.BeginResolveByInvoiceSection. +type RoleAssignmentsClientResolveByInvoiceSectionResponse struct { + // A container for a list of resources + RoleAssignmentListResult +} + +// RoleDefinitionClientGetByBillingAccountResponse contains the response from method RoleDefinitionClient.GetByBillingAccount. +type RoleDefinitionClientGetByBillingAccountResponse struct { + // The properties of a role definition. + RoleDefinition +} + +// RoleDefinitionClientGetByBillingProfileResponse contains the response from method RoleDefinitionClient.GetByBillingProfile. +type RoleDefinitionClientGetByBillingProfileResponse struct { + // The properties of a role definition. + RoleDefinition +} + +// RoleDefinitionClientGetByCustomerResponse contains the response from method RoleDefinitionClient.GetByCustomer. +type RoleDefinitionClientGetByCustomerResponse struct { + // The properties of a role definition. + RoleDefinition +} + +// RoleDefinitionClientGetByDepartmentResponse contains the response from method RoleDefinitionClient.GetByDepartment. +type RoleDefinitionClientGetByDepartmentResponse struct { + // The properties of a role definition. + RoleDefinition +} + +// RoleDefinitionClientGetByEnrollmentAccountResponse contains the response from method RoleDefinitionClient.GetByEnrollmentAccount. +type RoleDefinitionClientGetByEnrollmentAccountResponse struct { + // The properties of a role definition. + RoleDefinition +} + +// RoleDefinitionClientGetByInvoiceSectionResponse contains the response from method RoleDefinitionClient.GetByInvoiceSection. +type RoleDefinitionClientGetByInvoiceSectionResponse struct { + // The properties of a role definition. + RoleDefinition +} + +// RoleDefinitionClientListByBillingAccountResponse contains the response from method RoleDefinitionClient.NewListByBillingAccountPager. +type RoleDefinitionClientListByBillingAccountResponse struct { + // A container for a list of resources + RoleDefinitionListResult +} + +// RoleDefinitionClientListByBillingProfileResponse contains the response from method RoleDefinitionClient.NewListByBillingProfilePager. +type RoleDefinitionClientListByBillingProfileResponse struct { + // A container for a list of resources + RoleDefinitionListResult +} + +// RoleDefinitionClientListByCustomerResponse contains the response from method RoleDefinitionClient.NewListByCustomerPager. +type RoleDefinitionClientListByCustomerResponse struct { + // A container for a list of resources + RoleDefinitionListResult +} + +// RoleDefinitionClientListByDepartmentResponse contains the response from method RoleDefinitionClient.NewListByDepartmentPager. +type RoleDefinitionClientListByDepartmentResponse struct { + // A container for a list of resources + RoleDefinitionListResult +} + +// RoleDefinitionClientListByEnrollmentAccountResponse contains the response from method RoleDefinitionClient.NewListByEnrollmentAccountPager. +type RoleDefinitionClientListByEnrollmentAccountResponse struct { + // A container for a list of resources + RoleDefinitionListResult +} + +// RoleDefinitionClientListByInvoiceSectionResponse contains the response from method RoleDefinitionClient.NewListByInvoiceSectionPager. +type RoleDefinitionClientListByInvoiceSectionResponse struct { + // A container for a list of resources + RoleDefinitionListResult +} + +// SavingsPlanOrdersClientGetByBillingAccountResponse contains the response from method SavingsPlanOrdersClient.GetByBillingAccount. +type SavingsPlanOrdersClientGetByBillingAccountResponse struct { + // Savings plan order + SavingsPlanOrderModel +} + +// SavingsPlanOrdersClientListByBillingAccountResponse contains the response from method SavingsPlanOrdersClient.NewListByBillingAccountPager. +type SavingsPlanOrdersClientListByBillingAccountResponse struct { + // List of savings plan orders + SavingsPlanOrderModelList +} + +// SavingsPlansClientGetByBillingAccountResponse contains the response from method SavingsPlansClient.GetByBillingAccount. +type SavingsPlansClientGetByBillingAccountResponse struct { + // Savings plan + SavingsPlanModel +} + +// SavingsPlansClientListByBillingAccountResponse contains the response from method SavingsPlansClient.NewListByBillingAccountPager. +type SavingsPlansClientListByBillingAccountResponse struct { + // List of savings plans + SavingsPlanModelListResult +} + +// SavingsPlansClientListBySavingsPlanOrderResponse contains the response from method SavingsPlansClient.NewListBySavingsPlanOrderPager. +type SavingsPlansClientListBySavingsPlanOrderResponse struct { + // List of savings plans + SavingsPlanModelList +} + +// SavingsPlansClientUpdateByBillingAccountResponse contains the response from method SavingsPlansClient.BeginUpdateByBillingAccount. +type SavingsPlansClientUpdateByBillingAccountResponse struct { + // Savings plan + SavingsPlanModel +} + +// SavingsPlansClientValidateUpdateByBillingAccountResponse contains the response from method SavingsPlansClient.ValidateUpdateByBillingAccount. +type SavingsPlansClientValidateUpdateByBillingAccountResponse struct { + // Savings plan update validate response. + SavingsPlanValidateResponse +} + +// SubscriptionsAliasesClientCreateOrUpdateResponse contains the response from method SubscriptionsAliasesClient.BeginCreateOrUpdate. +type SubscriptionsAliasesClientCreateOrUpdateResponse struct { + // A billing subscription alias. + SubscriptionAlias +} + +// SubscriptionsAliasesClientGetResponse contains the response from method SubscriptionsAliasesClient.Get. +type SubscriptionsAliasesClientGetResponse struct { + // A billing subscription alias. + SubscriptionAlias +} + +// SubscriptionsAliasesClientListByBillingAccountResponse contains the response from method SubscriptionsAliasesClient.NewListByBillingAccountPager. +type SubscriptionsAliasesClientListByBillingAccountResponse struct { + // A container for a list of resources + SubscriptionAliasListResult +} + +// SubscriptionsClientCancelResponse contains the response from method SubscriptionsClient.BeginCancel. +type SubscriptionsClientCancelResponse struct { + // placeholder for future response values +} + +// SubscriptionsClientDeleteResponse contains the response from method SubscriptionsClient.BeginDelete. +type SubscriptionsClientDeleteResponse struct { + // placeholder for future response values +} + +// SubscriptionsClientGetByBillingProfileResponse contains the response from method SubscriptionsClient.GetByBillingProfile. +type SubscriptionsClientGetByBillingProfileResponse struct { + // The billing properties of a subscription. + Subscription +} + +// SubscriptionsClientGetResponse contains the response from method SubscriptionsClient.Get. +type SubscriptionsClientGetResponse struct { + // The billing properties of a subscription. + Subscription +} + +// SubscriptionsClientListByBillingAccountResponse contains the response from method SubscriptionsClient.NewListByBillingAccountPager. +type SubscriptionsClientListByBillingAccountResponse struct { + // A container for a list of resources + SubscriptionListResult +} + +// SubscriptionsClientListByBillingProfileResponse contains the response from method SubscriptionsClient.NewListByBillingProfilePager. +type SubscriptionsClientListByBillingProfileResponse struct { + // A container for a list of resources + SubscriptionListResult +} + +// SubscriptionsClientListByCustomerAtBillingAccountResponse contains the response from method SubscriptionsClient.NewListByCustomerAtBillingAccountPager. +type SubscriptionsClientListByCustomerAtBillingAccountResponse struct { + // A container for a list of resources + SubscriptionListResult +} + +// SubscriptionsClientListByCustomerResponse contains the response from method SubscriptionsClient.NewListByCustomerPager. +type SubscriptionsClientListByCustomerResponse struct { + // A container for a list of resources + SubscriptionListResult +} + +// SubscriptionsClientListByEnrollmentAccountResponse contains the response from method SubscriptionsClient.NewListByEnrollmentAccountPager. +type SubscriptionsClientListByEnrollmentAccountResponse struct { + // A container for a list of resources + SubscriptionListResult +} + +// SubscriptionsClientListByInvoiceSectionResponse contains the response from method SubscriptionsClient.NewListByInvoiceSectionPager. +type SubscriptionsClientListByInvoiceSectionResponse struct { + // A container for a list of resources + SubscriptionListResult +} + +// SubscriptionsClientMergeResponse contains the response from method SubscriptionsClient.BeginMerge. +type SubscriptionsClientMergeResponse struct { + // The billing properties of a subscription. + Subscription +} + +// SubscriptionsClientMoveResponse contains the response from method SubscriptionsClient.BeginMove. +type SubscriptionsClientMoveResponse struct { + // The billing properties of a subscription. + Subscription +} + +// SubscriptionsClientSplitResponse contains the response from method SubscriptionsClient.BeginSplit. +type SubscriptionsClientSplitResponse struct { + // The billing properties of a subscription. + Subscription +} + +// SubscriptionsClientUpdateResponse contains the response from method SubscriptionsClient.BeginUpdate. +type SubscriptionsClientUpdateResponse struct { + // The billing properties of a subscription. + Subscription +} + +// SubscriptionsClientValidateMoveEligibilityResponse contains the response from method SubscriptionsClient.ValidateMoveEligibility. +type SubscriptionsClientValidateMoveEligibilityResponse struct { + // Result of the transfer eligibility validation. + MoveBillingSubscriptionEligibilityResult +} + +// TransactionsClientGetTransactionSummaryByInvoiceResponse contains the response from method TransactionsClient.GetTransactionSummaryByInvoice. +type TransactionsClientGetTransactionSummaryByInvoiceResponse struct { + // A transaction summary. + TransactionSummary +} + +// TransactionsClientListByBillingProfileResponse contains the response from method TransactionsClient.NewListByBillingProfilePager. +type TransactionsClientListByBillingProfileResponse struct { + // A container for a list of resources + TransactionListResult +} + +// TransactionsClientListByCustomerResponse contains the response from method TransactionsClient.NewListByCustomerPager. +type TransactionsClientListByCustomerResponse struct { + // A container for a list of resources + TransactionListResult +} + +// TransactionsClientListByInvoiceResponse contains the response from method TransactionsClient.NewListByInvoicePager. +type TransactionsClientListByInvoiceResponse struct { + // A container for a list of resources + TransactionListResult +} + +// TransactionsClientListByInvoiceSectionResponse contains the response from method TransactionsClient.NewListByInvoiceSectionPager. +type TransactionsClientListByInvoiceSectionResponse struct { + // A container for a list of resources + TransactionListResult +} + +// TransactionsClientTransactionsDownloadByInvoiceResponse contains the response from method TransactionsClient.BeginTransactionsDownloadByInvoice. +type TransactionsClientTransactionsDownloadByInvoiceResponse struct { + // A secure URL that can be used to download a an entity until the URL expires. + DocumentDownloadResult +} + +// TransfersClientCancelResponse contains the response from method TransfersClient.Cancel. +type TransfersClientCancelResponse struct { + // Details of the transfer. + TransferDetails +} + +// TransfersClientGetResponse contains the response from method TransfersClient.Get. +type TransfersClientGetResponse struct { + // Details of the transfer. + TransferDetails +} + +// TransfersClientInitiateResponse contains the response from method TransfersClient.Initiate. +type TransfersClientInitiateResponse struct { + // Details of the transfer. + TransferDetails +} + +// TransfersClientListResponse contains the response from method TransfersClient.NewListPager. +type TransfersClientListResponse struct { + // The list of transfers initiated by caller. + TransferDetailsListResult +} diff --git a/sdk/resourcemanager/billing/armbilling/roleassignments_client.go b/sdk/resourcemanager/billing/armbilling/roleassignments_client.go index 457c95657752..721ca6a6f522 100644 --- a/sdk/resourcemanager/billing/armbilling/roleassignments_client.go +++ b/sdk/resourcemanager/billing/armbilling/roleassignments_client.go @@ -11,13 +11,15 @@ package armbilling import ( "context" "errors" + "net/http" + "net/url" + "strconv" + "strings" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" ) // RoleAssignmentsClient contains the methods for the BillingRoleAssignments group. @@ -40,103 +42,217 @@ func NewRoleAssignmentsClient(credential azcore.TokenCredential, options *arm.Cl return client, nil } -// DeleteByBillingAccount - Deletes a role assignment for the caller on a billing account. The operation is supported for -// billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// BeginCreateByBillingAccount - Adds a role assignment on a billing account. The operation is supported for billing accounts +// with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. -// - billingRoleAssignmentName - The ID that uniquely identifies a role assignment. -// - options - RoleAssignmentsClientDeleteByBillingAccountOptions contains the optional parameters for the RoleAssignmentsClient.DeleteByBillingAccount +// - parameters - The properties of the billing role assignment. +// - options - RoleAssignmentsClientBeginCreateByBillingAccountOptions contains the optional parameters for the RoleAssignmentsClient.BeginCreateByBillingAccount // method. -func (client *RoleAssignmentsClient) DeleteByBillingAccount(ctx context.Context, billingAccountName string, billingRoleAssignmentName string, options *RoleAssignmentsClientDeleteByBillingAccountOptions) (RoleAssignmentsClientDeleteByBillingAccountResponse, error) { +func (client *RoleAssignmentsClient) BeginCreateByBillingAccount(ctx context.Context, billingAccountName string, parameters RoleAssignmentProperties, options *RoleAssignmentsClientBeginCreateByBillingAccountOptions) (*runtime.Poller[RoleAssignmentsClientCreateByBillingAccountResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createByBillingAccount(ctx, billingAccountName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RoleAssignmentsClientCreateByBillingAccountResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RoleAssignmentsClientCreateByBillingAccountResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateByBillingAccount - Adds a role assignment on a billing account. The operation is supported for billing accounts with +// agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *RoleAssignmentsClient) createByBillingAccount(ctx context.Context, billingAccountName string, parameters RoleAssignmentProperties, options *RoleAssignmentsClientBeginCreateByBillingAccountOptions) (*http.Response, error) { var err error - const operationName = "RoleAssignmentsClient.DeleteByBillingAccount" + const operationName = "RoleAssignmentsClient.BeginCreateByBillingAccount" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.deleteByBillingAccountCreateRequest(ctx, billingAccountName, billingRoleAssignmentName, options) + req, err := client.createByBillingAccountCreateRequest(ctx, billingAccountName, parameters, options) if err != nil { - return RoleAssignmentsClientDeleteByBillingAccountResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return RoleAssignmentsClientDeleteByBillingAccountResponse{}, err + return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) - return RoleAssignmentsClientDeleteByBillingAccountResponse{}, err + return nil, err } - resp, err := client.deleteByBillingAccountHandleResponse(httpResp) - return resp, err + return httpResp, nil } -// deleteByBillingAccountCreateRequest creates the DeleteByBillingAccount request. -func (client *RoleAssignmentsClient) deleteByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, billingRoleAssignmentName string, options *RoleAssignmentsClientDeleteByBillingAccountOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/{billingRoleAssignmentName}" +// createByBillingAccountCreateRequest creates the CreateByBillingAccount request. +func (client *RoleAssignmentsClient) createByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, parameters RoleAssignmentProperties, options *RoleAssignmentsClientBeginCreateByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/createBillingRoleAssignment" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) - if billingRoleAssignmentName == "" { - return nil, errors.New("parameter billingRoleAssignmentName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingRoleAssignmentName}", url.PathEscape(billingRoleAssignmentName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } return req, nil } -// deleteByBillingAccountHandleResponse handles the DeleteByBillingAccount response. -func (client *RoleAssignmentsClient) deleteByBillingAccountHandleResponse(resp *http.Response) (RoleAssignmentsClientDeleteByBillingAccountResponse, error) { - result := RoleAssignmentsClientDeleteByBillingAccountResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignment); err != nil { - return RoleAssignmentsClientDeleteByBillingAccountResponse{}, err +// BeginCreateByBillingProfile - Adds a role assignment on a billing profile. The operation is supported for billing accounts +// with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - parameters - The properties of the billing role assignment. +// - options - RoleAssignmentsClientBeginCreateByBillingProfileOptions contains the optional parameters for the RoleAssignmentsClient.BeginCreateByBillingProfile +// method. +func (client *RoleAssignmentsClient) BeginCreateByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, parameters RoleAssignmentProperties, options *RoleAssignmentsClientBeginCreateByBillingProfileOptions) (*runtime.Poller[RoleAssignmentsClientCreateByBillingProfileResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createByBillingProfile(ctx, billingAccountName, billingProfileName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RoleAssignmentsClientCreateByBillingProfileResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RoleAssignmentsClientCreateByBillingProfileResponse]{ + Tracer: client.internal.Tracer(), + }) } - return result, nil } -// DeleteByBillingProfile - Deletes a role assignment for the caller on a billing profile. The operation is supported for -// billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// CreateByBillingProfile - Adds a role assignment on a billing profile. The operation is supported for billing accounts with +// agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *RoleAssignmentsClient) createByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, parameters RoleAssignmentProperties, options *RoleAssignmentsClientBeginCreateByBillingProfileOptions) (*http.Response, error) { + var err error + const operationName = "RoleAssignmentsClient.BeginCreateByBillingProfile" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createByBillingProfileCreateRequest creates the CreateByBillingProfile request. +func (client *RoleAssignmentsClient) createByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, parameters RoleAssignmentProperties, options *RoleAssignmentsClientBeginCreateByBillingProfileOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/createBillingRoleAssignment" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// BeginCreateByCustomer - Adds a role assignment on a customer. The operation is supported for billing accounts with agreement +// type Microsoft Partner Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingProfileName - The ID that uniquely identifies a billing profile. -// - billingRoleAssignmentName - The ID that uniquely identifies a role assignment. -// - options - RoleAssignmentsClientDeleteByBillingProfileOptions contains the optional parameters for the RoleAssignmentsClient.DeleteByBillingProfile +// - customerName - The ID that uniquely identifies a customer. +// - parameters - The properties of the billing role assignment. +// - options - RoleAssignmentsClientBeginCreateByCustomerOptions contains the optional parameters for the RoleAssignmentsClient.BeginCreateByCustomer // method. -func (client *RoleAssignmentsClient) DeleteByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleAssignmentName string, options *RoleAssignmentsClientDeleteByBillingProfileOptions) (RoleAssignmentsClientDeleteByBillingProfileResponse, error) { +func (client *RoleAssignmentsClient) BeginCreateByCustomer(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, parameters RoleAssignmentProperties, options *RoleAssignmentsClientBeginCreateByCustomerOptions) (*runtime.Poller[RoleAssignmentsClientCreateByCustomerResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createByCustomer(ctx, billingAccountName, billingProfileName, customerName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RoleAssignmentsClientCreateByCustomerResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RoleAssignmentsClientCreateByCustomerResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateByCustomer - Adds a role assignment on a customer. The operation is supported for billing accounts with agreement +// type Microsoft Partner Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *RoleAssignmentsClient) createByCustomer(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, parameters RoleAssignmentProperties, options *RoleAssignmentsClientBeginCreateByCustomerOptions) (*http.Response, error) { var err error - const operationName = "RoleAssignmentsClient.DeleteByBillingProfile" + const operationName = "RoleAssignmentsClient.BeginCreateByCustomer" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.deleteByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, billingRoleAssignmentName, options) + req, err := client.createByCustomerCreateRequest(ctx, billingAccountName, billingProfileName, customerName, parameters, options) if err != nil { - return RoleAssignmentsClientDeleteByBillingProfileResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return RoleAssignmentsClientDeleteByBillingProfileResponse{}, err + return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) - return RoleAssignmentsClientDeleteByBillingProfileResponse{}, err + return nil, err } - resp, err := client.deleteByBillingProfileHandleResponse(httpResp) - return resp, err + return httpResp, nil } -// deleteByBillingProfileCreateRequest creates the DeleteByBillingProfile request. -func (client *RoleAssignmentsClient) deleteByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleAssignmentName string, options *RoleAssignmentsClientDeleteByBillingProfileOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments/{billingRoleAssignmentName}" +// createByCustomerCreateRequest creates the CreateByCustomer request. +func (client *RoleAssignmentsClient) createByCustomerCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, parameters RoleAssignmentProperties, options *RoleAssignmentsClientBeginCreateByCustomerOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/createBillingRoleAssignment" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") } @@ -145,66 +261,82 @@ func (client *RoleAssignmentsClient) deleteByBillingProfileCreateRequest(ctx con return nil, errors.New("parameter billingProfileName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) - if billingRoleAssignmentName == "" { - return nil, errors.New("parameter billingRoleAssignmentName cannot be empty") + if customerName == "" { + return nil, errors.New("parameter customerName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{billingRoleAssignmentName}", url.PathEscape(billingRoleAssignmentName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + urlPath = strings.ReplaceAll(urlPath, "{customerName}", url.PathEscape(customerName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// deleteByBillingProfileHandleResponse handles the DeleteByBillingProfile response. -func (client *RoleAssignmentsClient) deleteByBillingProfileHandleResponse(resp *http.Response) (RoleAssignmentsClientDeleteByBillingProfileResponse, error) { - result := RoleAssignmentsClientDeleteByBillingProfileResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignment); err != nil { - return RoleAssignmentsClientDeleteByBillingProfileResponse{}, err + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err } - return result, nil + return req, nil } -// DeleteByInvoiceSection - Deletes a role assignment for the caller on an invoice section. The operation is supported for -// billing accounts with agreement type Microsoft Customer Agreement. +// BeginCreateByInvoiceSection - Adds a role assignment on an invoice section. The operation is supported for billing accounts +// with agreement type Microsoft Customer Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingProfileName - The ID that uniquely identifies a billing profile. // - invoiceSectionName - The ID that uniquely identifies an invoice section. -// - billingRoleAssignmentName - The ID that uniquely identifies a role assignment. -// - options - RoleAssignmentsClientDeleteByInvoiceSectionOptions contains the optional parameters for the RoleAssignmentsClient.DeleteByInvoiceSection +// - parameters - The properties of the billing role assignment. +// - options - RoleAssignmentsClientBeginCreateByInvoiceSectionOptions contains the optional parameters for the RoleAssignmentsClient.BeginCreateByInvoiceSection // method. -func (client *RoleAssignmentsClient) DeleteByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, billingRoleAssignmentName string, options *RoleAssignmentsClientDeleteByInvoiceSectionOptions) (RoleAssignmentsClientDeleteByInvoiceSectionResponse, error) { +func (client *RoleAssignmentsClient) BeginCreateByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, parameters RoleAssignmentProperties, options *RoleAssignmentsClientBeginCreateByInvoiceSectionOptions) (*runtime.Poller[RoleAssignmentsClientCreateByInvoiceSectionResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createByInvoiceSection(ctx, billingAccountName, billingProfileName, invoiceSectionName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RoleAssignmentsClientCreateByInvoiceSectionResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RoleAssignmentsClientCreateByInvoiceSectionResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateByInvoiceSection - Adds a role assignment on an invoice section. The operation is supported for billing accounts +// with agreement type Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *RoleAssignmentsClient) createByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, parameters RoleAssignmentProperties, options *RoleAssignmentsClientBeginCreateByInvoiceSectionOptions) (*http.Response, error) { var err error - const operationName = "RoleAssignmentsClient.DeleteByInvoiceSection" + const operationName = "RoleAssignmentsClient.BeginCreateByInvoiceSection" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.deleteByInvoiceSectionCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, billingRoleAssignmentName, options) + req, err := client.createByInvoiceSectionCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, parameters, options) if err != nil { - return RoleAssignmentsClientDeleteByInvoiceSectionResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return RoleAssignmentsClientDeleteByInvoiceSectionResponse{}, err + return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) - return RoleAssignmentsClientDeleteByInvoiceSectionResponse{}, err + return nil, err } - resp, err := client.deleteByInvoiceSectionHandleResponse(httpResp) - return resp, err + return httpResp, nil } -// deleteByInvoiceSectionCreateRequest creates the DeleteByInvoiceSection request. -func (client *RoleAssignmentsClient) deleteByInvoiceSectionCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, billingRoleAssignmentName string, options *RoleAssignmentsClientDeleteByInvoiceSectionOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments/{billingRoleAssignmentName}" +// createByInvoiceSectionCreateRequest creates the CreateByInvoiceSection request. +func (client *RoleAssignmentsClient) createByInvoiceSectionCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, parameters RoleAssignmentProperties, options *RoleAssignmentsClientBeginCreateByInvoiceSectionOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/createBillingRoleAssignment" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") } @@ -217,63 +349,75 @@ func (client *RoleAssignmentsClient) deleteByInvoiceSectionCreateRequest(ctx con return nil, errors.New("parameter invoiceSectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) - if billingRoleAssignmentName == "" { - return nil, errors.New("parameter billingRoleAssignmentName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingRoleAssignmentName}", url.PathEscape(billingRoleAssignmentName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// deleteByInvoiceSectionHandleResponse handles the DeleteByInvoiceSection response. -func (client *RoleAssignmentsClient) deleteByInvoiceSectionHandleResponse(resp *http.Response) (RoleAssignmentsClientDeleteByInvoiceSectionResponse, error) { - result := RoleAssignmentsClientDeleteByInvoiceSectionResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignment); err != nil { - return RoleAssignmentsClientDeleteByInvoiceSectionResponse{}, err + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err } - return result, nil + return req, nil } -// GetByBillingAccount - Gets a role assignment for the caller on a billing account. The operation is supported for billing -// accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// BeginCreateOrUpdateByBillingAccount - Create or update a billing role assignment. The operation is supported only for billing +// accounts with agreement type Enterprise Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingRoleAssignmentName - The ID that uniquely identifies a role assignment. -// - options - RoleAssignmentsClientGetByBillingAccountOptions contains the optional parameters for the RoleAssignmentsClient.GetByBillingAccount +// - parameters - The properties of the billing role assignment. +// - options - RoleAssignmentsClientBeginCreateOrUpdateByBillingAccountOptions contains the optional parameters for the RoleAssignmentsClient.BeginCreateOrUpdateByBillingAccount // method. -func (client *RoleAssignmentsClient) GetByBillingAccount(ctx context.Context, billingAccountName string, billingRoleAssignmentName string, options *RoleAssignmentsClientGetByBillingAccountOptions) (RoleAssignmentsClientGetByBillingAccountResponse, error) { +func (client *RoleAssignmentsClient) BeginCreateOrUpdateByBillingAccount(ctx context.Context, billingAccountName string, billingRoleAssignmentName string, parameters RoleAssignment, options *RoleAssignmentsClientBeginCreateOrUpdateByBillingAccountOptions) (*runtime.Poller[RoleAssignmentsClientCreateOrUpdateByBillingAccountResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdateByBillingAccount(ctx, billingAccountName, billingRoleAssignmentName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RoleAssignmentsClientCreateOrUpdateByBillingAccountResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RoleAssignmentsClientCreateOrUpdateByBillingAccountResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdateByBillingAccount - Create or update a billing role assignment. The operation is supported only for billing +// accounts with agreement type Enterprise Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *RoleAssignmentsClient) createOrUpdateByBillingAccount(ctx context.Context, billingAccountName string, billingRoleAssignmentName string, parameters RoleAssignment, options *RoleAssignmentsClientBeginCreateOrUpdateByBillingAccountOptions) (*http.Response, error) { var err error - const operationName = "RoleAssignmentsClient.GetByBillingAccount" + const operationName = "RoleAssignmentsClient.BeginCreateOrUpdateByBillingAccount" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getByBillingAccountCreateRequest(ctx, billingAccountName, billingRoleAssignmentName, options) + req, err := client.createOrUpdateByBillingAccountCreateRequest(ctx, billingAccountName, billingRoleAssignmentName, parameters, options) if err != nil { - return RoleAssignmentsClientGetByBillingAccountResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return RoleAssignmentsClientGetByBillingAccountResponse{}, err + return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) - return RoleAssignmentsClientGetByBillingAccountResponse{}, err + return nil, err } - resp, err := client.getByBillingAccountHandleResponse(httpResp) - return resp, err + return httpResp, nil } -// getByBillingAccountCreateRequest creates the GetByBillingAccount request. -func (client *RoleAssignmentsClient) getByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, billingRoleAssignmentName string, options *RoleAssignmentsClientGetByBillingAccountOptions) (*policy.Request, error) { +// createOrUpdateByBillingAccountCreateRequest creates the CreateOrUpdateByBillingAccount request. +func (client *RoleAssignmentsClient) createOrUpdateByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, billingRoleAssignmentName string, parameters RoleAssignment, options *RoleAssignmentsClientBeginCreateOrUpdateByBillingAccountOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/{billingRoleAssignmentName}" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") @@ -283,157 +427,933 @@ func (client *RoleAssignmentsClient) getByBillingAccountCreateRequest(ctx contex return nil, errors.New("parameter billingRoleAssignmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{billingRoleAssignmentName}", url.PathEscape(billingRoleAssignmentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getByBillingAccountHandleResponse handles the GetByBillingAccount response. -func (client *RoleAssignmentsClient) getByBillingAccountHandleResponse(resp *http.Response) (RoleAssignmentsClientGetByBillingAccountResponse, error) { - result := RoleAssignmentsClientGetByBillingAccountResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignment); err != nil { - return RoleAssignmentsClientGetByBillingAccountResponse{}, err + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err } - return result, nil + return req, nil } -// GetByBillingProfile - Gets a role assignment for the caller on a billing profile. The operation is supported for billing -// accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// BeginCreateOrUpdateByDepartment - Create or update a billing role assignment. The operation is supported only for billing +// accounts with agreement type Enterprise Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. -// - billingProfileName - The ID that uniquely identifies a billing profile. +// - departmentName - The name of the department. // - billingRoleAssignmentName - The ID that uniquely identifies a role assignment. -// - options - RoleAssignmentsClientGetByBillingProfileOptions contains the optional parameters for the RoleAssignmentsClient.GetByBillingProfile +// - parameters - The properties of the billing role assignment. +// - options - RoleAssignmentsClientBeginCreateOrUpdateByDepartmentOptions contains the optional parameters for the RoleAssignmentsClient.BeginCreateOrUpdateByDepartment // method. -func (client *RoleAssignmentsClient) GetByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleAssignmentName string, options *RoleAssignmentsClientGetByBillingProfileOptions) (RoleAssignmentsClientGetByBillingProfileResponse, error) { +func (client *RoleAssignmentsClient) BeginCreateOrUpdateByDepartment(ctx context.Context, billingAccountName string, departmentName string, billingRoleAssignmentName string, parameters RoleAssignment, options *RoleAssignmentsClientBeginCreateOrUpdateByDepartmentOptions) (*runtime.Poller[RoleAssignmentsClientCreateOrUpdateByDepartmentResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdateByDepartment(ctx, billingAccountName, departmentName, billingRoleAssignmentName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RoleAssignmentsClientCreateOrUpdateByDepartmentResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RoleAssignmentsClientCreateOrUpdateByDepartmentResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdateByDepartment - Create or update a billing role assignment. The operation is supported only for billing accounts +// with agreement type Enterprise Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *RoleAssignmentsClient) createOrUpdateByDepartment(ctx context.Context, billingAccountName string, departmentName string, billingRoleAssignmentName string, parameters RoleAssignment, options *RoleAssignmentsClientBeginCreateOrUpdateByDepartmentOptions) (*http.Response, error) { var err error - const operationName = "RoleAssignmentsClient.GetByBillingProfile" + const operationName = "RoleAssignmentsClient.BeginCreateOrUpdateByDepartment" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, billingRoleAssignmentName, options) + req, err := client.createOrUpdateByDepartmentCreateRequest(ctx, billingAccountName, departmentName, billingRoleAssignmentName, parameters, options) if err != nil { - return RoleAssignmentsClientGetByBillingProfileResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return RoleAssignmentsClientGetByBillingProfileResponse{}, err + return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) - return RoleAssignmentsClientGetByBillingProfileResponse{}, err + return nil, err } - resp, err := client.getByBillingProfileHandleResponse(httpResp) - return resp, err + return httpResp, nil } -// getByBillingProfileCreateRequest creates the GetByBillingProfile request. -func (client *RoleAssignmentsClient) getByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleAssignmentName string, options *RoleAssignmentsClientGetByBillingProfileOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments/{billingRoleAssignmentName}" +// createOrUpdateByDepartmentCreateRequest creates the CreateOrUpdateByDepartment request. +func (client *RoleAssignmentsClient) createOrUpdateByDepartmentCreateRequest(ctx context.Context, billingAccountName string, departmentName string, billingRoleAssignmentName string, parameters RoleAssignment, options *RoleAssignmentsClientBeginCreateOrUpdateByDepartmentOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}/billingRoleAssignments/{billingRoleAssignmentName}" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) - if billingProfileName == "" { - return nil, errors.New("parameter billingProfileName cannot be empty") + if departmentName == "" { + return nil, errors.New("parameter departmentName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + urlPath = strings.ReplaceAll(urlPath, "{departmentName}", url.PathEscape(departmentName)) if billingRoleAssignmentName == "" { return nil, errors.New("parameter billingRoleAssignmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{billingRoleAssignmentName}", url.PathEscape(billingRoleAssignmentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getByBillingProfileHandleResponse handles the GetByBillingProfile response. -func (client *RoleAssignmentsClient) getByBillingProfileHandleResponse(resp *http.Response) (RoleAssignmentsClientGetByBillingProfileResponse, error) { - result := RoleAssignmentsClientGetByBillingProfileResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignment); err != nil { - return RoleAssignmentsClientGetByBillingProfileResponse{}, err + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err } - return result, nil + return req, nil } -// GetByInvoiceSection - Gets a role assignment for the caller on an invoice section. The operation is supported for billing -// accounts with agreement type Microsoft Customer Agreement. +// BeginCreateOrUpdateByEnrollmentAccount - Create or update a billing role assignment. The operation is supported only for +// billing accounts with agreement type Enterprise Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. -// - billingProfileName - The ID that uniquely identifies a billing profile. -// - invoiceSectionName - The ID that uniquely identifies an invoice section. +// - enrollmentAccountName - The name of the enrollment account. // - billingRoleAssignmentName - The ID that uniquely identifies a role assignment. -// - options - RoleAssignmentsClientGetByInvoiceSectionOptions contains the optional parameters for the RoleAssignmentsClient.GetByInvoiceSection +// - parameters - The properties of the billing role assignment. +// - options - RoleAssignmentsClientBeginCreateOrUpdateByEnrollmentAccountOptions contains the optional parameters for the RoleAssignmentsClient.BeginCreateOrUpdateByEnrollmentAccount // method. -func (client *RoleAssignmentsClient) GetByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, billingRoleAssignmentName string, options *RoleAssignmentsClientGetByInvoiceSectionOptions) (RoleAssignmentsClientGetByInvoiceSectionResponse, error) { +func (client *RoleAssignmentsClient) BeginCreateOrUpdateByEnrollmentAccount(ctx context.Context, billingAccountName string, enrollmentAccountName string, billingRoleAssignmentName string, parameters RoleAssignment, options *RoleAssignmentsClientBeginCreateOrUpdateByEnrollmentAccountOptions) (*runtime.Poller[RoleAssignmentsClientCreateOrUpdateByEnrollmentAccountResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdateByEnrollmentAccount(ctx, billingAccountName, enrollmentAccountName, billingRoleAssignmentName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RoleAssignmentsClientCreateOrUpdateByEnrollmentAccountResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RoleAssignmentsClientCreateOrUpdateByEnrollmentAccountResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdateByEnrollmentAccount - Create or update a billing role assignment. The operation is supported only for billing +// accounts with agreement type Enterprise Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *RoleAssignmentsClient) createOrUpdateByEnrollmentAccount(ctx context.Context, billingAccountName string, enrollmentAccountName string, billingRoleAssignmentName string, parameters RoleAssignment, options *RoleAssignmentsClientBeginCreateOrUpdateByEnrollmentAccountOptions) (*http.Response, error) { var err error - const operationName = "RoleAssignmentsClient.GetByInvoiceSection" + const operationName = "RoleAssignmentsClient.BeginCreateOrUpdateByEnrollmentAccount" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getByInvoiceSectionCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, billingRoleAssignmentName, options) + req, err := client.createOrUpdateByEnrollmentAccountCreateRequest(ctx, billingAccountName, enrollmentAccountName, billingRoleAssignmentName, parameters, options) if err != nil { - return RoleAssignmentsClientGetByInvoiceSectionResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return RoleAssignmentsClientGetByInvoiceSectionResponse{}, err + return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) - return RoleAssignmentsClientGetByInvoiceSectionResponse{}, err + return nil, err } - resp, err := client.getByInvoiceSectionHandleResponse(httpResp) - return resp, err + return httpResp, nil } -// getByInvoiceSectionCreateRequest creates the GetByInvoiceSection request. -func (client *RoleAssignmentsClient) getByInvoiceSectionCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, billingRoleAssignmentName string, options *RoleAssignmentsClientGetByInvoiceSectionOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments/{billingRoleAssignmentName}" +// createOrUpdateByEnrollmentAccountCreateRequest creates the CreateOrUpdateByEnrollmentAccount request. +func (client *RoleAssignmentsClient) createOrUpdateByEnrollmentAccountCreateRequest(ctx context.Context, billingAccountName string, enrollmentAccountName string, billingRoleAssignmentName string, parameters RoleAssignment, options *RoleAssignmentsClientBeginCreateOrUpdateByEnrollmentAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}/billingRoleAssignments/{billingRoleAssignmentName}" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) - if billingProfileName == "" { - return nil, errors.New("parameter billingProfileName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) - if invoiceSectionName == "" { - return nil, errors.New("parameter invoiceSectionName cannot be empty") + if enrollmentAccountName == "" { + return nil, errors.New("parameter enrollmentAccountName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) + urlPath = strings.ReplaceAll(urlPath, "{enrollmentAccountName}", url.PathEscape(enrollmentAccountName)) if billingRoleAssignmentName == "" { return nil, errors.New("parameter billingRoleAssignmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{billingRoleAssignmentName}", url.PathEscape(billingRoleAssignmentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } return req, nil } -// getByInvoiceSectionHandleResponse handles the GetByInvoiceSection response. +// DeleteByBillingAccount - Deletes a role assignment on a billing account. The operation is supported for billing accounts +// with agreement type Microsoft Partner Agreement, Microsoft Customer Agreement or Enterprise Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingRoleAssignmentName - The ID that uniquely identifies a role assignment. +// - options - RoleAssignmentsClientDeleteByBillingAccountOptions contains the optional parameters for the RoleAssignmentsClient.DeleteByBillingAccount +// method. +func (client *RoleAssignmentsClient) DeleteByBillingAccount(ctx context.Context, billingAccountName string, billingRoleAssignmentName string, options *RoleAssignmentsClientDeleteByBillingAccountOptions) (RoleAssignmentsClientDeleteByBillingAccountResponse, error) { + var err error + const operationName = "RoleAssignmentsClient.DeleteByBillingAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteByBillingAccountCreateRequest(ctx, billingAccountName, billingRoleAssignmentName, options) + if err != nil { + return RoleAssignmentsClientDeleteByBillingAccountResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RoleAssignmentsClientDeleteByBillingAccountResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return RoleAssignmentsClientDeleteByBillingAccountResponse{}, err + } + return RoleAssignmentsClientDeleteByBillingAccountResponse{}, nil +} + +// deleteByBillingAccountCreateRequest creates the DeleteByBillingAccount request. +func (client *RoleAssignmentsClient) deleteByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, billingRoleAssignmentName string, options *RoleAssignmentsClientDeleteByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/{billingRoleAssignmentName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingRoleAssignmentName == "" { + return nil, errors.New("parameter billingRoleAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingRoleAssignmentName}", url.PathEscape(billingRoleAssignmentName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// DeleteByBillingProfile - Deletes a role assignment on a billing profile. The operation is supported for billing accounts +// with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - billingRoleAssignmentName - The ID that uniquely identifies a role assignment. +// - options - RoleAssignmentsClientDeleteByBillingProfileOptions contains the optional parameters for the RoleAssignmentsClient.DeleteByBillingProfile +// method. +func (client *RoleAssignmentsClient) DeleteByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleAssignmentName string, options *RoleAssignmentsClientDeleteByBillingProfileOptions) (RoleAssignmentsClientDeleteByBillingProfileResponse, error) { + var err error + const operationName = "RoleAssignmentsClient.DeleteByBillingProfile" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, billingRoleAssignmentName, options) + if err != nil { + return RoleAssignmentsClientDeleteByBillingProfileResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RoleAssignmentsClientDeleteByBillingProfileResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return RoleAssignmentsClientDeleteByBillingProfileResponse{}, err + } + return RoleAssignmentsClientDeleteByBillingProfileResponse{}, nil +} + +// deleteByBillingProfileCreateRequest creates the DeleteByBillingProfile request. +func (client *RoleAssignmentsClient) deleteByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleAssignmentName string, options *RoleAssignmentsClientDeleteByBillingProfileOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments/{billingRoleAssignmentName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if billingRoleAssignmentName == "" { + return nil, errors.New("parameter billingRoleAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingRoleAssignmentName}", url.PathEscape(billingRoleAssignmentName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// DeleteByCustomer - Deletes a role assignment on a customer. The operation is supported for billing accounts with agreement +// type Microsoft Partner Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - customerName - The ID that uniquely identifies a customer. +// - billingRoleAssignmentName - The ID that uniquely identifies a role assignment. +// - options - RoleAssignmentsClientDeleteByCustomerOptions contains the optional parameters for the RoleAssignmentsClient.DeleteByCustomer +// method. +func (client *RoleAssignmentsClient) DeleteByCustomer(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, billingRoleAssignmentName string, options *RoleAssignmentsClientDeleteByCustomerOptions) (RoleAssignmentsClientDeleteByCustomerResponse, error) { + var err error + const operationName = "RoleAssignmentsClient.DeleteByCustomer" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteByCustomerCreateRequest(ctx, billingAccountName, billingProfileName, customerName, billingRoleAssignmentName, options) + if err != nil { + return RoleAssignmentsClientDeleteByCustomerResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RoleAssignmentsClientDeleteByCustomerResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return RoleAssignmentsClientDeleteByCustomerResponse{}, err + } + return RoleAssignmentsClientDeleteByCustomerResponse{}, nil +} + +// deleteByCustomerCreateRequest creates the DeleteByCustomer request. +func (client *RoleAssignmentsClient) deleteByCustomerCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, billingRoleAssignmentName string, options *RoleAssignmentsClientDeleteByCustomerOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/billingRoleAssignments/{billingRoleAssignmentName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if customerName == "" { + return nil, errors.New("parameter customerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{customerName}", url.PathEscape(customerName)) + if billingRoleAssignmentName == "" { + return nil, errors.New("parameter billingRoleAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingRoleAssignmentName}", url.PathEscape(billingRoleAssignmentName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// DeleteByDepartment - Deletes a role assignment on a department. The operation is supported only for billing accounts with +// agreement type Enterprise Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - departmentName - The name of the department. +// - billingRoleAssignmentName - The ID that uniquely identifies a role assignment. +// - options - RoleAssignmentsClientDeleteByDepartmentOptions contains the optional parameters for the RoleAssignmentsClient.DeleteByDepartment +// method. +func (client *RoleAssignmentsClient) DeleteByDepartment(ctx context.Context, billingAccountName string, departmentName string, billingRoleAssignmentName string, options *RoleAssignmentsClientDeleteByDepartmentOptions) (RoleAssignmentsClientDeleteByDepartmentResponse, error) { + var err error + const operationName = "RoleAssignmentsClient.DeleteByDepartment" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteByDepartmentCreateRequest(ctx, billingAccountName, departmentName, billingRoleAssignmentName, options) + if err != nil { + return RoleAssignmentsClientDeleteByDepartmentResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RoleAssignmentsClientDeleteByDepartmentResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return RoleAssignmentsClientDeleteByDepartmentResponse{}, err + } + return RoleAssignmentsClientDeleteByDepartmentResponse{}, nil +} + +// deleteByDepartmentCreateRequest creates the DeleteByDepartment request. +func (client *RoleAssignmentsClient) deleteByDepartmentCreateRequest(ctx context.Context, billingAccountName string, departmentName string, billingRoleAssignmentName string, options *RoleAssignmentsClientDeleteByDepartmentOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}/billingRoleAssignments/{billingRoleAssignmentName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if departmentName == "" { + return nil, errors.New("parameter departmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{departmentName}", url.PathEscape(departmentName)) + if billingRoleAssignmentName == "" { + return nil, errors.New("parameter billingRoleAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingRoleAssignmentName}", url.PathEscape(billingRoleAssignmentName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// DeleteByEnrollmentAccount - Deletes a role assignment on a enrollment Account. The operation is supported only for billing +// accounts with agreement type Enterprise Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - enrollmentAccountName - The name of the enrollment account. +// - billingRoleAssignmentName - The ID that uniquely identifies a role assignment. +// - options - RoleAssignmentsClientDeleteByEnrollmentAccountOptions contains the optional parameters for the RoleAssignmentsClient.DeleteByEnrollmentAccount +// method. +func (client *RoleAssignmentsClient) DeleteByEnrollmentAccount(ctx context.Context, billingAccountName string, enrollmentAccountName string, billingRoleAssignmentName string, options *RoleAssignmentsClientDeleteByEnrollmentAccountOptions) (RoleAssignmentsClientDeleteByEnrollmentAccountResponse, error) { + var err error + const operationName = "RoleAssignmentsClient.DeleteByEnrollmentAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteByEnrollmentAccountCreateRequest(ctx, billingAccountName, enrollmentAccountName, billingRoleAssignmentName, options) + if err != nil { + return RoleAssignmentsClientDeleteByEnrollmentAccountResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RoleAssignmentsClientDeleteByEnrollmentAccountResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return RoleAssignmentsClientDeleteByEnrollmentAccountResponse{}, err + } + return RoleAssignmentsClientDeleteByEnrollmentAccountResponse{}, nil +} + +// deleteByEnrollmentAccountCreateRequest creates the DeleteByEnrollmentAccount request. +func (client *RoleAssignmentsClient) deleteByEnrollmentAccountCreateRequest(ctx context.Context, billingAccountName string, enrollmentAccountName string, billingRoleAssignmentName string, options *RoleAssignmentsClientDeleteByEnrollmentAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}/billingRoleAssignments/{billingRoleAssignmentName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if enrollmentAccountName == "" { + return nil, errors.New("parameter enrollmentAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{enrollmentAccountName}", url.PathEscape(enrollmentAccountName)) + if billingRoleAssignmentName == "" { + return nil, errors.New("parameter billingRoleAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingRoleAssignmentName}", url.PathEscape(billingRoleAssignmentName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// DeleteByInvoiceSection - Deletes a role assignment on an invoice section. The operation is supported for billing accounts +// with agreement type Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - invoiceSectionName - The ID that uniquely identifies an invoice section. +// - billingRoleAssignmentName - The ID that uniquely identifies a role assignment. +// - options - RoleAssignmentsClientDeleteByInvoiceSectionOptions contains the optional parameters for the RoleAssignmentsClient.DeleteByInvoiceSection +// method. +func (client *RoleAssignmentsClient) DeleteByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, billingRoleAssignmentName string, options *RoleAssignmentsClientDeleteByInvoiceSectionOptions) (RoleAssignmentsClientDeleteByInvoiceSectionResponse, error) { + var err error + const operationName = "RoleAssignmentsClient.DeleteByInvoiceSection" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteByInvoiceSectionCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, billingRoleAssignmentName, options) + if err != nil { + return RoleAssignmentsClientDeleteByInvoiceSectionResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RoleAssignmentsClientDeleteByInvoiceSectionResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return RoleAssignmentsClientDeleteByInvoiceSectionResponse{}, err + } + return RoleAssignmentsClientDeleteByInvoiceSectionResponse{}, nil +} + +// deleteByInvoiceSectionCreateRequest creates the DeleteByInvoiceSection request. +func (client *RoleAssignmentsClient) deleteByInvoiceSectionCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, billingRoleAssignmentName string, options *RoleAssignmentsClientDeleteByInvoiceSectionOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments/{billingRoleAssignmentName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if invoiceSectionName == "" { + return nil, errors.New("parameter invoiceSectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) + if billingRoleAssignmentName == "" { + return nil, errors.New("parameter billingRoleAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingRoleAssignmentName}", url.PathEscape(billingRoleAssignmentName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// GetByBillingAccount - Gets a role assignment for the caller on a billing account. The operation is supported for billing +// accounts with agreement type Microsoft Partner Agreement, Microsoft Customer Agreement or Enterprise +// Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingRoleAssignmentName - The ID that uniquely identifies a role assignment. +// - options - RoleAssignmentsClientGetByBillingAccountOptions contains the optional parameters for the RoleAssignmentsClient.GetByBillingAccount +// method. +func (client *RoleAssignmentsClient) GetByBillingAccount(ctx context.Context, billingAccountName string, billingRoleAssignmentName string, options *RoleAssignmentsClientGetByBillingAccountOptions) (RoleAssignmentsClientGetByBillingAccountResponse, error) { + var err error + const operationName = "RoleAssignmentsClient.GetByBillingAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByBillingAccountCreateRequest(ctx, billingAccountName, billingRoleAssignmentName, options) + if err != nil { + return RoleAssignmentsClientGetByBillingAccountResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RoleAssignmentsClientGetByBillingAccountResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RoleAssignmentsClientGetByBillingAccountResponse{}, err + } + resp, err := client.getByBillingAccountHandleResponse(httpResp) + return resp, err +} + +// getByBillingAccountCreateRequest creates the GetByBillingAccount request. +func (client *RoleAssignmentsClient) getByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, billingRoleAssignmentName string, options *RoleAssignmentsClientGetByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/{billingRoleAssignmentName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingRoleAssignmentName == "" { + return nil, errors.New("parameter billingRoleAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingRoleAssignmentName}", url.PathEscape(billingRoleAssignmentName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByBillingAccountHandleResponse handles the GetByBillingAccount response. +func (client *RoleAssignmentsClient) getByBillingAccountHandleResponse(resp *http.Response) (RoleAssignmentsClientGetByBillingAccountResponse, error) { + result := RoleAssignmentsClientGetByBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignment); err != nil { + return RoleAssignmentsClientGetByBillingAccountResponse{}, err + } + return result, nil +} + +// GetByBillingProfile - Gets a role assignment for the caller on a billing profile. The operation is supported for billing +// accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - billingRoleAssignmentName - The ID that uniquely identifies a role assignment. +// - options - RoleAssignmentsClientGetByBillingProfileOptions contains the optional parameters for the RoleAssignmentsClient.GetByBillingProfile +// method. +func (client *RoleAssignmentsClient) GetByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleAssignmentName string, options *RoleAssignmentsClientGetByBillingProfileOptions) (RoleAssignmentsClientGetByBillingProfileResponse, error) { + var err error + const operationName = "RoleAssignmentsClient.GetByBillingProfile" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, billingRoleAssignmentName, options) + if err != nil { + return RoleAssignmentsClientGetByBillingProfileResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RoleAssignmentsClientGetByBillingProfileResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RoleAssignmentsClientGetByBillingProfileResponse{}, err + } + resp, err := client.getByBillingProfileHandleResponse(httpResp) + return resp, err +} + +// getByBillingProfileCreateRequest creates the GetByBillingProfile request. +func (client *RoleAssignmentsClient) getByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleAssignmentName string, options *RoleAssignmentsClientGetByBillingProfileOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments/{billingRoleAssignmentName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if billingRoleAssignmentName == "" { + return nil, errors.New("parameter billingRoleAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingRoleAssignmentName}", url.PathEscape(billingRoleAssignmentName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByBillingProfileHandleResponse handles the GetByBillingProfile response. +func (client *RoleAssignmentsClient) getByBillingProfileHandleResponse(resp *http.Response) (RoleAssignmentsClientGetByBillingProfileResponse, error) { + result := RoleAssignmentsClientGetByBillingProfileResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignment); err != nil { + return RoleAssignmentsClientGetByBillingProfileResponse{}, err + } + return result, nil +} + +// GetByCustomer - Gets a role assignment for the caller on a customer. The operation is supported for billing accounts with +// agreement type Microsoft Partner Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - customerName - The ID that uniquely identifies a customer. +// - billingRoleAssignmentName - The ID that uniquely identifies a role assignment. +// - options - RoleAssignmentsClientGetByCustomerOptions contains the optional parameters for the RoleAssignmentsClient.GetByCustomer +// method. +func (client *RoleAssignmentsClient) GetByCustomer(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, billingRoleAssignmentName string, options *RoleAssignmentsClientGetByCustomerOptions) (RoleAssignmentsClientGetByCustomerResponse, error) { + var err error + const operationName = "RoleAssignmentsClient.GetByCustomer" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByCustomerCreateRequest(ctx, billingAccountName, billingProfileName, customerName, billingRoleAssignmentName, options) + if err != nil { + return RoleAssignmentsClientGetByCustomerResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RoleAssignmentsClientGetByCustomerResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RoleAssignmentsClientGetByCustomerResponse{}, err + } + resp, err := client.getByCustomerHandleResponse(httpResp) + return resp, err +} + +// getByCustomerCreateRequest creates the GetByCustomer request. +func (client *RoleAssignmentsClient) getByCustomerCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, billingRoleAssignmentName string, options *RoleAssignmentsClientGetByCustomerOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/billingRoleAssignments/{billingRoleAssignmentName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if customerName == "" { + return nil, errors.New("parameter customerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{customerName}", url.PathEscape(customerName)) + if billingRoleAssignmentName == "" { + return nil, errors.New("parameter billingRoleAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingRoleAssignmentName}", url.PathEscape(billingRoleAssignmentName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByCustomerHandleResponse handles the GetByCustomer response. +func (client *RoleAssignmentsClient) getByCustomerHandleResponse(resp *http.Response) (RoleAssignmentsClientGetByCustomerResponse, error) { + result := RoleAssignmentsClientGetByCustomerResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignment); err != nil { + return RoleAssignmentsClientGetByCustomerResponse{}, err + } + return result, nil +} + +// GetByDepartment - Gets a role assignment for the caller on a department. The operation is supported only for billing accounts +// with agreement type Enterprise Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - departmentName - The name of the department. +// - billingRoleAssignmentName - The ID that uniquely identifies a role assignment. +// - options - RoleAssignmentsClientGetByDepartmentOptions contains the optional parameters for the RoleAssignmentsClient.GetByDepartment +// method. +func (client *RoleAssignmentsClient) GetByDepartment(ctx context.Context, billingAccountName string, departmentName string, billingRoleAssignmentName string, options *RoleAssignmentsClientGetByDepartmentOptions) (RoleAssignmentsClientGetByDepartmentResponse, error) { + var err error + const operationName = "RoleAssignmentsClient.GetByDepartment" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByDepartmentCreateRequest(ctx, billingAccountName, departmentName, billingRoleAssignmentName, options) + if err != nil { + return RoleAssignmentsClientGetByDepartmentResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RoleAssignmentsClientGetByDepartmentResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RoleAssignmentsClientGetByDepartmentResponse{}, err + } + resp, err := client.getByDepartmentHandleResponse(httpResp) + return resp, err +} + +// getByDepartmentCreateRequest creates the GetByDepartment request. +func (client *RoleAssignmentsClient) getByDepartmentCreateRequest(ctx context.Context, billingAccountName string, departmentName string, billingRoleAssignmentName string, options *RoleAssignmentsClientGetByDepartmentOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}/billingRoleAssignments/{billingRoleAssignmentName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if departmentName == "" { + return nil, errors.New("parameter departmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{departmentName}", url.PathEscape(departmentName)) + if billingRoleAssignmentName == "" { + return nil, errors.New("parameter billingRoleAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingRoleAssignmentName}", url.PathEscape(billingRoleAssignmentName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByDepartmentHandleResponse handles the GetByDepartment response. +func (client *RoleAssignmentsClient) getByDepartmentHandleResponse(resp *http.Response) (RoleAssignmentsClientGetByDepartmentResponse, error) { + result := RoleAssignmentsClientGetByDepartmentResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignment); err != nil { + return RoleAssignmentsClientGetByDepartmentResponse{}, err + } + return result, nil +} + +// GetByEnrollmentAccount - Gets a role assignment for the caller on a enrollment Account. The operation is supported only +// for billing accounts with agreement type Enterprise Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - enrollmentAccountName - The name of the enrollment account. +// - billingRoleAssignmentName - The ID that uniquely identifies a role assignment. +// - options - RoleAssignmentsClientGetByEnrollmentAccountOptions contains the optional parameters for the RoleAssignmentsClient.GetByEnrollmentAccount +// method. +func (client *RoleAssignmentsClient) GetByEnrollmentAccount(ctx context.Context, billingAccountName string, enrollmentAccountName string, billingRoleAssignmentName string, options *RoleAssignmentsClientGetByEnrollmentAccountOptions) (RoleAssignmentsClientGetByEnrollmentAccountResponse, error) { + var err error + const operationName = "RoleAssignmentsClient.GetByEnrollmentAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByEnrollmentAccountCreateRequest(ctx, billingAccountName, enrollmentAccountName, billingRoleAssignmentName, options) + if err != nil { + return RoleAssignmentsClientGetByEnrollmentAccountResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RoleAssignmentsClientGetByEnrollmentAccountResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RoleAssignmentsClientGetByEnrollmentAccountResponse{}, err + } + resp, err := client.getByEnrollmentAccountHandleResponse(httpResp) + return resp, err +} + +// getByEnrollmentAccountCreateRequest creates the GetByEnrollmentAccount request. +func (client *RoleAssignmentsClient) getByEnrollmentAccountCreateRequest(ctx context.Context, billingAccountName string, enrollmentAccountName string, billingRoleAssignmentName string, options *RoleAssignmentsClientGetByEnrollmentAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}/billingRoleAssignments/{billingRoleAssignmentName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if enrollmentAccountName == "" { + return nil, errors.New("parameter enrollmentAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{enrollmentAccountName}", url.PathEscape(enrollmentAccountName)) + if billingRoleAssignmentName == "" { + return nil, errors.New("parameter billingRoleAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingRoleAssignmentName}", url.PathEscape(billingRoleAssignmentName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByEnrollmentAccountHandleResponse handles the GetByEnrollmentAccount response. +func (client *RoleAssignmentsClient) getByEnrollmentAccountHandleResponse(resp *http.Response) (RoleAssignmentsClientGetByEnrollmentAccountResponse, error) { + result := RoleAssignmentsClientGetByEnrollmentAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignment); err != nil { + return RoleAssignmentsClientGetByEnrollmentAccountResponse{}, err + } + return result, nil +} + +// GetByInvoiceSection - Gets a role assignment for the caller on an invoice section. The operation is supported for billing +// accounts with agreement type Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - invoiceSectionName - The ID that uniquely identifies an invoice section. +// - billingRoleAssignmentName - The ID that uniquely identifies a role assignment. +// - options - RoleAssignmentsClientGetByInvoiceSectionOptions contains the optional parameters for the RoleAssignmentsClient.GetByInvoiceSection +// method. +func (client *RoleAssignmentsClient) GetByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, billingRoleAssignmentName string, options *RoleAssignmentsClientGetByInvoiceSectionOptions) (RoleAssignmentsClientGetByInvoiceSectionResponse, error) { + var err error + const operationName = "RoleAssignmentsClient.GetByInvoiceSection" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByInvoiceSectionCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, billingRoleAssignmentName, options) + if err != nil { + return RoleAssignmentsClientGetByInvoiceSectionResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RoleAssignmentsClientGetByInvoiceSectionResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RoleAssignmentsClientGetByInvoiceSectionResponse{}, err + } + resp, err := client.getByInvoiceSectionHandleResponse(httpResp) + return resp, err +} + +// getByInvoiceSectionCreateRequest creates the GetByInvoiceSection request. +func (client *RoleAssignmentsClient) getByInvoiceSectionCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, billingRoleAssignmentName string, options *RoleAssignmentsClientGetByInvoiceSectionOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments/{billingRoleAssignmentName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if invoiceSectionName == "" { + return nil, errors.New("parameter invoiceSectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) + if billingRoleAssignmentName == "" { + return nil, errors.New("parameter billingRoleAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingRoleAssignmentName}", url.PathEscape(billingRoleAssignmentName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByInvoiceSectionHandleResponse handles the GetByInvoiceSection response. func (client *RoleAssignmentsClient) getByInvoiceSectionHandleResponse(resp *http.Response) (RoleAssignmentsClientGetByInvoiceSectionResponse, error) { result := RoleAssignmentsClientGetByInvoiceSectionResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignment); err != nil { @@ -442,121 +1362,340 @@ func (client *RoleAssignmentsClient) getByInvoiceSectionHandleResponse(resp *htt return result, nil } -// NewListByBillingAccountPager - Lists the role assignments for the caller on a billing account. The operation is supported -// for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// NewListByBillingAccountPager - Lists the role assignments for the caller on a billing account. The operation is supported +// for billing accounts with agreement type Microsoft Partner Agreement, Microsoft Customer Agreement or +// Enterprise Agreement. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - options - RoleAssignmentsClientListByBillingAccountOptions contains the optional parameters for the RoleAssignmentsClient.NewListByBillingAccountPager +// method. +func (client *RoleAssignmentsClient) NewListByBillingAccountPager(billingAccountName string, options *RoleAssignmentsClientListByBillingAccountOptions) *runtime.Pager[RoleAssignmentsClientListByBillingAccountResponse] { + return runtime.NewPager(runtime.PagingHandler[RoleAssignmentsClientListByBillingAccountResponse]{ + More: func(page RoleAssignmentsClientListByBillingAccountResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RoleAssignmentsClientListByBillingAccountResponse) (RoleAssignmentsClientListByBillingAccountResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RoleAssignmentsClient.NewListByBillingAccountPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByBillingAccountCreateRequest(ctx, billingAccountName, options) + }, nil) + if err != nil { + return RoleAssignmentsClientListByBillingAccountResponse{}, err + } + return client.listByBillingAccountHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByBillingAccountCreateRequest creates the ListByBillingAccount request. +func (client *RoleAssignmentsClient) listByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, options *RoleAssignmentsClientListByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByBillingAccountHandleResponse handles the ListByBillingAccount response. +func (client *RoleAssignmentsClient) listByBillingAccountHandleResponse(resp *http.Response) (RoleAssignmentsClientListByBillingAccountResponse, error) { + result := RoleAssignmentsClientListByBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignmentListResult); err != nil { + return RoleAssignmentsClientListByBillingAccountResponse{}, err + } + return result, nil +} + +// NewListByBillingProfilePager - Lists the role assignments for the caller on a billing profile. The operation is supported +// for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - options - RoleAssignmentsClientListByBillingProfileOptions contains the optional parameters for the RoleAssignmentsClient.NewListByBillingProfilePager +// method. +func (client *RoleAssignmentsClient) NewListByBillingProfilePager(billingAccountName string, billingProfileName string, options *RoleAssignmentsClientListByBillingProfileOptions) *runtime.Pager[RoleAssignmentsClientListByBillingProfileResponse] { + return runtime.NewPager(runtime.PagingHandler[RoleAssignmentsClientListByBillingProfileResponse]{ + More: func(page RoleAssignmentsClientListByBillingProfileResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RoleAssignmentsClientListByBillingProfileResponse) (RoleAssignmentsClientListByBillingProfileResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RoleAssignmentsClient.NewListByBillingProfilePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, options) + }, nil) + if err != nil { + return RoleAssignmentsClientListByBillingProfileResponse{}, err + } + return client.listByBillingProfileHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByBillingProfileCreateRequest creates the ListByBillingProfile request. +func (client *RoleAssignmentsClient) listByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, options *RoleAssignmentsClientListByBillingProfileOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByBillingProfileHandleResponse handles the ListByBillingProfile response. +func (client *RoleAssignmentsClient) listByBillingProfileHandleResponse(resp *http.Response) (RoleAssignmentsClientListByBillingProfileResponse, error) { + result := RoleAssignmentsClientListByBillingProfileResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignmentListResult); err != nil { + return RoleAssignmentsClientListByBillingProfileResponse{}, err + } + return result, nil +} + +// NewListByCustomerPager - Lists the role assignments for the caller on customer. The operation is supported for billing +// accounts with agreement type Microsoft Partner Agreement. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - customerName - The ID that uniquely identifies a customer. +// - options - RoleAssignmentsClientListByCustomerOptions contains the optional parameters for the RoleAssignmentsClient.NewListByCustomerPager +// method. +func (client *RoleAssignmentsClient) NewListByCustomerPager(billingAccountName string, billingProfileName string, customerName string, options *RoleAssignmentsClientListByCustomerOptions) *runtime.Pager[RoleAssignmentsClientListByCustomerResponse] { + return runtime.NewPager(runtime.PagingHandler[RoleAssignmentsClientListByCustomerResponse]{ + More: func(page RoleAssignmentsClientListByCustomerResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RoleAssignmentsClientListByCustomerResponse) (RoleAssignmentsClientListByCustomerResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RoleAssignmentsClient.NewListByCustomerPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByCustomerCreateRequest(ctx, billingAccountName, billingProfileName, customerName, options) + }, nil) + if err != nil { + return RoleAssignmentsClientListByCustomerResponse{}, err + } + return client.listByCustomerHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByCustomerCreateRequest creates the ListByCustomer request. +func (client *RoleAssignmentsClient) listByCustomerCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, options *RoleAssignmentsClientListByCustomerOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/billingRoleAssignments" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if customerName == "" { + return nil, errors.New("parameter customerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{customerName}", url.PathEscape(customerName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByCustomerHandleResponse handles the ListByCustomer response. +func (client *RoleAssignmentsClient) listByCustomerHandleResponse(resp *http.Response) (RoleAssignmentsClientListByCustomerResponse, error) { + result := RoleAssignmentsClientListByCustomerResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignmentListResult); err != nil { + return RoleAssignmentsClientListByCustomerResponse{}, err + } + return result, nil +} + +// NewListByDepartmentPager - Lists the role assignments for the caller on a department. The operation is supported for billing +// accounts of type Enterprise Agreement. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. -// - options - RoleAssignmentsClientListByBillingAccountOptions contains the optional parameters for the RoleAssignmentsClient.NewListByBillingAccountPager +// - departmentName - The name of the department. +// - options - RoleAssignmentsClientListByDepartmentOptions contains the optional parameters for the RoleAssignmentsClient.NewListByDepartmentPager // method. -func (client *RoleAssignmentsClient) NewListByBillingAccountPager(billingAccountName string, options *RoleAssignmentsClientListByBillingAccountOptions) *runtime.Pager[RoleAssignmentsClientListByBillingAccountResponse] { - return runtime.NewPager(runtime.PagingHandler[RoleAssignmentsClientListByBillingAccountResponse]{ - More: func(page RoleAssignmentsClientListByBillingAccountResponse) bool { +func (client *RoleAssignmentsClient) NewListByDepartmentPager(billingAccountName string, departmentName string, options *RoleAssignmentsClientListByDepartmentOptions) *runtime.Pager[RoleAssignmentsClientListByDepartmentResponse] { + return runtime.NewPager(runtime.PagingHandler[RoleAssignmentsClientListByDepartmentResponse]{ + More: func(page RoleAssignmentsClientListByDepartmentResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *RoleAssignmentsClientListByBillingAccountResponse) (RoleAssignmentsClientListByBillingAccountResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RoleAssignmentsClient.NewListByBillingAccountPager") + Fetcher: func(ctx context.Context, page *RoleAssignmentsClientListByDepartmentResponse) (RoleAssignmentsClientListByDepartmentResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RoleAssignmentsClient.NewListByDepartmentPager") nextLink := "" if page != nil { nextLink = *page.NextLink } resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listByBillingAccountCreateRequest(ctx, billingAccountName, options) + return client.listByDepartmentCreateRequest(ctx, billingAccountName, departmentName, options) }, nil) if err != nil { - return RoleAssignmentsClientListByBillingAccountResponse{}, err + return RoleAssignmentsClientListByDepartmentResponse{}, err } - return client.listByBillingAccountHandleResponse(resp) + return client.listByDepartmentHandleResponse(resp) }, Tracer: client.internal.Tracer(), }) } -// listByBillingAccountCreateRequest creates the ListByBillingAccount request. -func (client *RoleAssignmentsClient) listByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, options *RoleAssignmentsClientListByBillingAccountOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments" +// listByDepartmentCreateRequest creates the ListByDepartment request. +func (client *RoleAssignmentsClient) listByDepartmentCreateRequest(ctx context.Context, billingAccountName string, departmentName string, options *RoleAssignmentsClientListByDepartmentOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}/billingRoleAssignments" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if departmentName == "" { + return nil, errors.New("parameter departmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{departmentName}", url.PathEscape(departmentName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } -// listByBillingAccountHandleResponse handles the ListByBillingAccount response. -func (client *RoleAssignmentsClient) listByBillingAccountHandleResponse(resp *http.Response) (RoleAssignmentsClientListByBillingAccountResponse, error) { - result := RoleAssignmentsClientListByBillingAccountResponse{} +// listByDepartmentHandleResponse handles the ListByDepartment response. +func (client *RoleAssignmentsClient) listByDepartmentHandleResponse(resp *http.Response) (RoleAssignmentsClientListByDepartmentResponse, error) { + result := RoleAssignmentsClientListByDepartmentResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignmentListResult); err != nil { - return RoleAssignmentsClientListByBillingAccountResponse{}, err + return RoleAssignmentsClientListByDepartmentResponse{}, err } return result, nil } -// NewListByBillingProfilePager - Lists the role assignments for the caller on a billing profile. The operation is supported -// for billing accounts with agreement type Microsoft Customer Agreement. +// NewListByEnrollmentAccountPager - Lists the role assignments for the caller on a enrollment account. The operation is supported +// for billing accounts of type Enterprise Agreement. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. -// - billingProfileName - The ID that uniquely identifies a billing profile. -// - options - RoleAssignmentsClientListByBillingProfileOptions contains the optional parameters for the RoleAssignmentsClient.NewListByBillingProfilePager +// - enrollmentAccountName - The name of the enrollment account. +// - options - RoleAssignmentsClientListByEnrollmentAccountOptions contains the optional parameters for the RoleAssignmentsClient.NewListByEnrollmentAccountPager // method. -func (client *RoleAssignmentsClient) NewListByBillingProfilePager(billingAccountName string, billingProfileName string, options *RoleAssignmentsClientListByBillingProfileOptions) *runtime.Pager[RoleAssignmentsClientListByBillingProfileResponse] { - return runtime.NewPager(runtime.PagingHandler[RoleAssignmentsClientListByBillingProfileResponse]{ - More: func(page RoleAssignmentsClientListByBillingProfileResponse) bool { +func (client *RoleAssignmentsClient) NewListByEnrollmentAccountPager(billingAccountName string, enrollmentAccountName string, options *RoleAssignmentsClientListByEnrollmentAccountOptions) *runtime.Pager[RoleAssignmentsClientListByEnrollmentAccountResponse] { + return runtime.NewPager(runtime.PagingHandler[RoleAssignmentsClientListByEnrollmentAccountResponse]{ + More: func(page RoleAssignmentsClientListByEnrollmentAccountResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *RoleAssignmentsClientListByBillingProfileResponse) (RoleAssignmentsClientListByBillingProfileResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RoleAssignmentsClient.NewListByBillingProfilePager") + Fetcher: func(ctx context.Context, page *RoleAssignmentsClientListByEnrollmentAccountResponse) (RoleAssignmentsClientListByEnrollmentAccountResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RoleAssignmentsClient.NewListByEnrollmentAccountPager") nextLink := "" if page != nil { nextLink = *page.NextLink } resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, options) + return client.listByEnrollmentAccountCreateRequest(ctx, billingAccountName, enrollmentAccountName, options) }, nil) if err != nil { - return RoleAssignmentsClientListByBillingProfileResponse{}, err + return RoleAssignmentsClientListByEnrollmentAccountResponse{}, err } - return client.listByBillingProfileHandleResponse(resp) + return client.listByEnrollmentAccountHandleResponse(resp) }, Tracer: client.internal.Tracer(), }) } -// listByBillingProfileCreateRequest creates the ListByBillingProfile request. -func (client *RoleAssignmentsClient) listByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, options *RoleAssignmentsClientListByBillingProfileOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments" +// listByEnrollmentAccountCreateRequest creates the ListByEnrollmentAccount request. +func (client *RoleAssignmentsClient) listByEnrollmentAccountCreateRequest(ctx context.Context, billingAccountName string, enrollmentAccountName string, options *RoleAssignmentsClientListByEnrollmentAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}/billingRoleAssignments" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) - if billingProfileName == "" { - return nil, errors.New("parameter billingProfileName cannot be empty") + if enrollmentAccountName == "" { + return nil, errors.New("parameter enrollmentAccountName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + urlPath = strings.ReplaceAll(urlPath, "{enrollmentAccountName}", url.PathEscape(enrollmentAccountName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } -// listByBillingProfileHandleResponse handles the ListByBillingProfile response. -func (client *RoleAssignmentsClient) listByBillingProfileHandleResponse(resp *http.Response) (RoleAssignmentsClientListByBillingProfileResponse, error) { - result := RoleAssignmentsClientListByBillingProfileResponse{} +// listByEnrollmentAccountHandleResponse handles the ListByEnrollmentAccount response. +func (client *RoleAssignmentsClient) listByEnrollmentAccountHandleResponse(resp *http.Response) (RoleAssignmentsClientListByEnrollmentAccountResponse, error) { + result := RoleAssignmentsClientListByEnrollmentAccountResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignmentListResult); err != nil { - return RoleAssignmentsClientListByBillingProfileResponse{}, err + return RoleAssignmentsClientListByEnrollmentAccountResponse{}, err } return result, nil } @@ -564,7 +1703,7 @@ func (client *RoleAssignmentsClient) listByBillingProfileHandleResponse(resp *ht // NewListByInvoiceSectionPager - Lists the role assignments for the caller on an invoice section. The operation is supported // for billing accounts with agreement type Microsoft Customer Agreement. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingProfileName - The ID that uniquely identifies a billing profile. // - invoiceSectionName - The ID that uniquely identifies an invoice section. @@ -613,7 +1752,16 @@ func (client *RoleAssignmentsClient) listByInvoiceSectionCreateRequest(ctx conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -627,3 +1775,340 @@ func (client *RoleAssignmentsClient) listByInvoiceSectionHandleResponse(resp *ht } return result, nil } + +// BeginResolveByBillingAccount - Lists the role assignments for the caller on a billing account while fetching user info +// for each role assignment. The operation is supported for billing accounts with agreement type Microsoft Partner +// Agreement, Microsoft Customer Agreement or Enterprise Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - options - RoleAssignmentsClientBeginResolveByBillingAccountOptions contains the optional parameters for the RoleAssignmentsClient.BeginResolveByBillingAccount +// method. +func (client *RoleAssignmentsClient) BeginResolveByBillingAccount(ctx context.Context, billingAccountName string, options *RoleAssignmentsClientBeginResolveByBillingAccountOptions) (*runtime.Poller[RoleAssignmentsClientResolveByBillingAccountResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.resolveByBillingAccount(ctx, billingAccountName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RoleAssignmentsClientResolveByBillingAccountResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RoleAssignmentsClientResolveByBillingAccountResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// ResolveByBillingAccount - Lists the role assignments for the caller on a billing account while fetching user info for each +// role assignment. The operation is supported for billing accounts with agreement type Microsoft Partner +// Agreement, Microsoft Customer Agreement or Enterprise Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *RoleAssignmentsClient) resolveByBillingAccount(ctx context.Context, billingAccountName string, options *RoleAssignmentsClientBeginResolveByBillingAccountOptions) (*http.Response, error) { + var err error + const operationName = "RoleAssignmentsClient.BeginResolveByBillingAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.resolveByBillingAccountCreateRequest(ctx, billingAccountName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// resolveByBillingAccountCreateRequest creates the ResolveByBillingAccount request. +func (client *RoleAssignmentsClient) resolveByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, options *RoleAssignmentsClientBeginResolveByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/resolveBillingRoleAssignments" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.ResolveScopeDisplayNames != nil { + reqQP.Set("resolveScopeDisplayNames", strconv.FormatBool(*options.ResolveScopeDisplayNames)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginResolveByBillingProfile - Lists the role assignments for the caller on an billing profile while fetching user info +// for each role assignment. The operation is supported for billing accounts with agreement type Microsoft Partner +// Agreement or Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - options - RoleAssignmentsClientBeginResolveByBillingProfileOptions contains the optional parameters for the RoleAssignmentsClient.BeginResolveByBillingProfile +// method. +func (client *RoleAssignmentsClient) BeginResolveByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, options *RoleAssignmentsClientBeginResolveByBillingProfileOptions) (*runtime.Poller[RoleAssignmentsClientResolveByBillingProfileResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.resolveByBillingProfile(ctx, billingAccountName, billingProfileName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RoleAssignmentsClientResolveByBillingProfileResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RoleAssignmentsClientResolveByBillingProfileResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// ResolveByBillingProfile - Lists the role assignments for the caller on an billing profile while fetching user info for +// each role assignment. The operation is supported for billing accounts with agreement type Microsoft Partner +// Agreement or Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *RoleAssignmentsClient) resolveByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, options *RoleAssignmentsClientBeginResolveByBillingProfileOptions) (*http.Response, error) { + var err error + const operationName = "RoleAssignmentsClient.BeginResolveByBillingProfile" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.resolveByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// resolveByBillingProfileCreateRequest creates the ResolveByBillingProfile request. +func (client *RoleAssignmentsClient) resolveByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, options *RoleAssignmentsClientBeginResolveByBillingProfileOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/resolveBillingRoleAssignments" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.ResolveScopeDisplayNames != nil { + reqQP.Set("resolveScopeDisplayNames", strconv.FormatBool(*options.ResolveScopeDisplayNames)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginResolveByCustomer - Lists the role assignments for the caller on a customer while fetching user info for each role +// assignment. The operation is supported for billing accounts with agreement type Microsoft Partner +// Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - customerName - The ID that uniquely identifies a customer. +// - options - RoleAssignmentsClientBeginResolveByCustomerOptions contains the optional parameters for the RoleAssignmentsClient.BeginResolveByCustomer +// method. +func (client *RoleAssignmentsClient) BeginResolveByCustomer(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, options *RoleAssignmentsClientBeginResolveByCustomerOptions) (*runtime.Poller[RoleAssignmentsClientResolveByCustomerResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.resolveByCustomer(ctx, billingAccountName, billingProfileName, customerName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RoleAssignmentsClientResolveByCustomerResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RoleAssignmentsClientResolveByCustomerResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// ResolveByCustomer - Lists the role assignments for the caller on a customer while fetching user info for each role assignment. +// The operation is supported for billing accounts with agreement type Microsoft Partner +// Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *RoleAssignmentsClient) resolveByCustomer(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, options *RoleAssignmentsClientBeginResolveByCustomerOptions) (*http.Response, error) { + var err error + const operationName = "RoleAssignmentsClient.BeginResolveByCustomer" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.resolveByCustomerCreateRequest(ctx, billingAccountName, billingProfileName, customerName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// resolveByCustomerCreateRequest creates the ResolveByCustomer request. +func (client *RoleAssignmentsClient) resolveByCustomerCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, options *RoleAssignmentsClientBeginResolveByCustomerOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/resolveBillingRoleAssignments" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if customerName == "" { + return nil, errors.New("parameter customerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{customerName}", url.PathEscape(customerName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.ResolveScopeDisplayNames != nil { + reqQP.Set("resolveScopeDisplayNames", strconv.FormatBool(*options.ResolveScopeDisplayNames)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginResolveByInvoiceSection - Lists the role assignments for the caller on an invoice section while fetching user info +// for each role assignment. The operation is supported for billing accounts with agreement type Microsoft +// Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - invoiceSectionName - The ID that uniquely identifies an invoice section. +// - options - RoleAssignmentsClientBeginResolveByInvoiceSectionOptions contains the optional parameters for the RoleAssignmentsClient.BeginResolveByInvoiceSection +// method. +func (client *RoleAssignmentsClient) BeginResolveByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, options *RoleAssignmentsClientBeginResolveByInvoiceSectionOptions) (*runtime.Poller[RoleAssignmentsClientResolveByInvoiceSectionResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.resolveByInvoiceSection(ctx, billingAccountName, billingProfileName, invoiceSectionName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RoleAssignmentsClientResolveByInvoiceSectionResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RoleAssignmentsClientResolveByInvoiceSectionResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// ResolveByInvoiceSection - Lists the role assignments for the caller on an invoice section while fetching user info for +// each role assignment. The operation is supported for billing accounts with agreement type Microsoft +// Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *RoleAssignmentsClient) resolveByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, options *RoleAssignmentsClientBeginResolveByInvoiceSectionOptions) (*http.Response, error) { + var err error + const operationName = "RoleAssignmentsClient.BeginResolveByInvoiceSection" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.resolveByInvoiceSectionCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// resolveByInvoiceSectionCreateRequest creates the ResolveByInvoiceSection request. +func (client *RoleAssignmentsClient) resolveByInvoiceSectionCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, options *RoleAssignmentsClientBeginResolveByInvoiceSectionOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/resolveBillingRoleAssignments" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if invoiceSectionName == "" { + return nil, errors.New("parameter invoiceSectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.ResolveScopeDisplayNames != nil { + reqQP.Set("resolveScopeDisplayNames", strconv.FormatBool(*options.ResolveScopeDisplayNames)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/roleassignments_client_example_test.go b/sdk/resourcemanager/billing/armbilling/roleassignments_client_example_test.go index 6e2334be0fbf..6f27be7589c8 100644 --- a/sdk/resourcemanager/billing/armbilling/roleassignments_client_example_test.go +++ b/sdk/resourcemanager/billing/armbilling/roleassignments_client_example_test.go @@ -13,12 +13,13 @@ import ( "context" "log" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingAccountRoleAssignment.json -func ExampleRoleAssignmentsClient_GetByBillingAccount() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentDeleteByBillingProfile.json +func ExampleRoleAssignmentsClient_DeleteByBillingProfile() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -28,7 +29,24 @@ func ExampleRoleAssignmentsClient_GetByBillingAccount() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewRoleAssignmentsClient().GetByBillingAccount(ctx, "{billingAccountName}", "{billingRoleAssignmentId}", nil) + _, err = clientFactory.NewRoleAssignmentsClient().DeleteByBillingProfile(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30", "BKM6-54VH-BG7-PGB", "10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByBillingProfile.json +func ExampleRoleAssignmentsClient_GetByBillingProfile() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRoleAssignmentsClient().GetByBillingProfile(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30", "xxxx-xxxx-xxx-xxx", "10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -37,22 +55,81 @@ func ExampleRoleAssignmentsClient_GetByBillingAccount() { // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.RoleAssignment = armbilling.RoleAssignment{ // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingRoleAssignments"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), // Properties: &armbilling.RoleAssignmentProperties{ - // CreatedByPrincipalID: to.Ptr("10000000-aaaa-bbbb-cccc-3fd5ff9d6aa1"), - // CreatedByPrincipalTenantID: to.Ptr("7ca289b9-c32d-4f01-8566-7ff93261d76f"), - // CreatedOn: to.Ptr("2018-06-21T21:34:12.2363515+00:00"), - // PrincipalID: to.Ptr("6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), - // PrincipalTenantID: to.Ptr("10000000-aaaa-bbbb-cccc-2d7cd011db47"), - // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000002"), - // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}"), + // CreatedByPrincipalID: to.Ptr("46b831ec-42b2-4f1a-8b54-3fd5ff9d6aa1"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx/billingRoleDefinitions/00000000-0000-0000-0000-000000000000"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingAccountRoleAssignmentDelete.json -func ExampleRoleAssignmentsClient_DeleteByBillingAccount() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentListByBillingProfile.json +func ExampleRoleAssignmentsClient_NewListByBillingProfilePager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRoleAssignmentsClient().NewListByBillingProfilePager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30", "xxxx-xxxx-xxx-xxx", &armbilling.RoleAssignmentsClientListByBillingProfileOptions{Filter: nil, + Top: nil, + Skip: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.RoleAssignmentListResult = armbilling.RoleAssignmentListResult{ + // Value: []*armbilling.RoleAssignment{ + // { + // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // Properties: &armbilling.RoleAssignmentProperties{ + // CreatedByPrincipalID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx/billingRoleDefinitions/00000000-0000-0000-0000-000000000000"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx"), + // }, + // }, + // { + // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), + // Properties: &armbilling.RoleAssignmentProperties{ + // CreatedByPrincipalID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx/billingRoleDefinitions/00000000-0000-0000-0000-000000000001"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentCreateByBillingProfile.json +func ExampleRoleAssignmentsClient_BeginCreateByBillingProfile() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -62,30 +139,272 @@ func ExampleRoleAssignmentsClient_DeleteByBillingAccount() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewRoleAssignmentsClient().DeleteByBillingAccount(ctx, "{billingAccountName}", "{billingRoleAssignmentName}", nil) + poller, err := clientFactory.NewRoleAssignmentsClient().BeginCreateByBillingProfile(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30", "BKM6-54VH-BG7-PGB", armbilling.RoleAssignmentProperties{ + PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + PrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/billingRoleDefinitions/10000000-aaaa-bbbb-cccc-100000000000"), + UserEmailAddress: to.Ptr("john@contoso.com"), + }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.RoleAssignment = armbilling.RoleAssignment{ - // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingRoleAssignments"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_00000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_00000000-0000-0000-0000-000000000000"), + // Properties: &armbilling.RoleAssignmentProperties{ + // CreatedByPrincipalID: to.Ptr("47309529-17e6-4104-b9e8-39f62fa1e5ed"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingRoleDefinitions/10000000-aaaa-bbbb-cccc-100000000000"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentDeleteByCustomer.json +func ExampleRoleAssignmentsClient_DeleteByCustomer() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewRoleAssignmentsClient().DeleteByCustomer(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30", "BKM6-54VH-BG7-PGB", "703ab484-dda2-4402-827b-a74513b61e2d", "30000000-aaaa-bbbb-cccc-100000000000_00000000-0000-0000-0000-000000000000", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByCustomer.json +func ExampleRoleAssignmentsClient_GetByCustomer() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRoleAssignmentsClient().GetByCustomer(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30", "xxxx-xxxx-xxx-xxx", "703ab484-dda2-4402-827b-a74513b61e2d", "30000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RoleAssignment = armbilling.RoleAssignment{ + // Name: to.Ptr("30000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/customers/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx/customers/703ab484-dda2-4402-827b-a74513b61e2d/billingRoleAssignments/30000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // Properties: &armbilling.RoleAssignmentProperties{ + // CreatedByPrincipalID: to.Ptr(""), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx/customers/703ab484-dda2-4402-827b-a74513b61e2d/billingRoleDefinitions/30000000-aaaa-bbbb-cccc-100000000000"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx/customers/703ab484-dda2-4402-827b-a74513b61e2d"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentListByCustomer.json +func ExampleRoleAssignmentsClient_NewListByCustomerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRoleAssignmentsClient().NewListByCustomerPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30", "BKM6-54VH-BG7-PGB", "703ab484-dda2-4402-827b-a74513b61e2d", &armbilling.RoleAssignmentsClientListByCustomerOptions{Filter: nil, + Top: nil, + Skip: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.RoleAssignmentListResult = armbilling.RoleAssignmentListResult{ + // Value: []*armbilling.RoleAssignment{ + // { + // Name: to.Ptr("30000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/customers/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/customers/703ab484-dda2-4402-827b-a74513b61e2d/billingRoleAssignments/30000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // Properties: &armbilling.RoleAssignmentProperties{ + // CreatedByPrincipalID: to.Ptr(""), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/customers/703ab484-dda2-4402-827b-a74513b61e2d/billingRoleDefinitions/30000000-aaaa-bbbb-cccc-100000000000"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/customers/703ab484-dda2-4402-827b-a74513b61e2d"), + // }, + // }, + // { + // Name: to.Ptr("30000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/customers/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/customers/703ab484-dda2-4402-827b-a74513b61e2d/billingRoleAssignments/30000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), + // Properties: &armbilling.RoleAssignmentProperties{ + // CreatedByPrincipalID: to.Ptr(""), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/customers/703ab484-dda2-4402-827b-a74513b61e2d/billingRoleDefinitions/30000000-aaaa-bbbb-cccc-100000000000"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/customers/703ab484-dda2-4402-827b-a74513b61e2d"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentCreateByCustomer.json +func ExampleRoleAssignmentsClient_BeginCreateByCustomer() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewRoleAssignmentsClient().BeginCreateByCustomer(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30", "BKM6-54VH-BG7-PGB", "703ab484-dda2-4402-827b-a74513b61e2d", armbilling.RoleAssignmentProperties{ + PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + PrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfileName/BKM6-54VH-BG7-PGB/customers/703ab484-dda2-4402-827b-a74513b61e2d/billingRoleDefinitions/30000000-aaaa-bbbb-cccc-100000000000"), + UserEmailAddress: to.Ptr("john@contoso.com"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RoleAssignment = armbilling.RoleAssignment{ + // Name: to.Ptr("30000000-aaaa-bbbb-cccc-100000000000_00000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/customers/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfileName/BKM6-54VH-BG7-PGB/customers/703ab484-dda2-4402-827b-a74513b61e2d/billingRoleAssignments/30000000-aaaa-bbbb-cccc-100000000000_00000000-0000-0000-0000-000000000000"), // Properties: &armbilling.RoleAssignmentProperties{ - // CreatedByPrincipalID: to.Ptr("10000000-aaaa-bbbb-cccc-3fd5ff9d6aa1"), - // CreatedByPrincipalTenantID: to.Ptr("7ca289b9-c32d-4f01-8566-7ff93261d76f"), - // CreatedOn: to.Ptr("2018-06-21T21:34:12.2363515+00:00"), - // PrincipalID: to.Ptr("6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), - // PrincipalTenantID: to.Ptr("10000000-aaaa-bbbb-cccc-2d7cd011db47"), - // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000002"), - // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}"), + // CreatedByPrincipalID: to.Ptr("47309529-17e6-4104-b9e8-39f62fa1e5ed"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfileName/BKM6-54VH-BG7-PGB/customers/703ab484-dda2-4402-827b-a74513b61e2d/billingRoleDefinitions/30000000-aaaa-bbbb-cccc-100000000000"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfileName/BKM6-54VH-BG7-PGB/customers/703ab484-dda2-4402-827b-a74513b61e2d"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/InvoiceSectionRoleAssignment.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/resolveBillingRoleAssignmentByCustomer.json +func ExampleRoleAssignmentsClient_BeginResolveByCustomer() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewRoleAssignmentsClient().BeginResolveByCustomer(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30", "xxxx-xxxx-xxx-xxx", "703ab484-dda2-4402-827b-a74513b61e2d", &armbilling.RoleAssignmentsClientBeginResolveByCustomerOptions{ResolveScopeDisplayNames: nil, + Filter: nil, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RoleAssignmentListResult = armbilling.RoleAssignmentListResult{ + // Value: []*armbilling.RoleAssignment{ + // { + // Name: to.Ptr("30000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/customers/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx/customers/703ab484-dda2-4402-827b-a74513b61e2d/billingRoleAssignments/30000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // Properties: &armbilling.RoleAssignmentProperties{ + // CreatedByPrincipalID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalTenantID: to.Ptr("c360d6f1-2709-476d-81bb-d075b213d9fc"), + // PrincipalTenantName: to.Ptr("Foo Bar"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx/customers/703ab484-dda2-4402-827b-a74513b61e2d/billingRoleDefinitions/30000000-aaaa-bbbb-cccc-100000000000"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx/customers/703ab484-dda2-4402-827b-a74513b61e2d"), + // UserEmailAddress: to.Ptr("foo@bar.com"), + // }, + // }, + // { + // Name: to.Ptr("30000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/customers/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx/customers/703ab484-dda2-4402-827b-a74513b61e2d/billingRoleAssignments/30000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), + // Properties: &armbilling.RoleAssignmentProperties{ + // CreatedByPrincipalID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalTenantID: to.Ptr("c360d6f1-2709-476d-81bb-d075b213d9fc"), + // PrincipalTenantName: to.Ptr("Foo Bar"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx/customers/703ab484-dda2-4402-827b-a74513b61e2d/billingRoleDefinitions/30000000-aaaa-bbbb-cccc-100000000000"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx/customers/703ab484-dda2-4402-827b-a74513b61e2d"), + // UserEmailAddress: to.Ptr("foo@bar.com"), + // }, + // }}, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentDeleteByInvoiceSection.json +func ExampleRoleAssignmentsClient_DeleteByInvoiceSection() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewRoleAssignmentsClient().DeleteByInvoiceSection(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30", "BKM6-54VH-BG7-PGB", "xxxx-xxxx-xxx-xxx", "10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByInvoiceSection.json func ExampleRoleAssignmentsClient_GetByInvoiceSection() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -96,7 +415,7 @@ func ExampleRoleAssignmentsClient_GetByInvoiceSection() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewRoleAssignmentsClient().GetByInvoiceSection(ctx, "{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", "{billingRoleAssignmentName}", nil) + res, err := clientFactory.NewRoleAssignmentsClient().GetByInvoiceSection(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30", "BKM6-54VH-BG7-PGB", "xxxx-xxxx-xxx-xxx", "10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -106,21 +425,80 @@ func ExampleRoleAssignmentsClient_GetByInvoiceSection() { // res.RoleAssignment = armbilling.RoleAssignment{ // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections/billingRoleAssignments"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/invoiceSections/xxxx-xxxx-xxx-xxx/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), // Properties: &armbilling.RoleAssignmentProperties{ - // CreatedByPrincipalID: to.Ptr("10000000-aaaa-bbbb-cccc-3fd5ff9d6aa1"), - // CreatedByPrincipalTenantID: to.Ptr("7ca289b9-c32d-4f01-8566-7ff93261d76f"), - // CreatedOn: to.Ptr("2018-06-21T21:34:12.2363515+00:00"), - // PrincipalID: to.Ptr("6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), - // PrincipalTenantID: to.Ptr("10000000-aaaa-bbbb-cccc-2d7cd011db47"), - // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000002"), - // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}"), + // CreatedByPrincipalID: to.Ptr("46b831ec-42b2-4f1a-8b54-3fd5ff9d6aa1"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/invoiceSections/xxxx-xxxx-xxx-xxx/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000000"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/invoiceSections/xxxx-xxxx-xxx-xxx"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/InvoiceSectionRoleAssignmentDelete.json -func ExampleRoleAssignmentsClient_DeleteByInvoiceSection() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentListByInvoiceSection.json +func ExampleRoleAssignmentsClient_NewListByInvoiceSectionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRoleAssignmentsClient().NewListByInvoiceSectionPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30", "BKM6-54VH-BG7-PGB", "xxxx-xxxx-xxx-xxx", &armbilling.RoleAssignmentsClientListByInvoiceSectionOptions{Filter: nil, + Top: nil, + Skip: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.RoleAssignmentListResult = armbilling.RoleAssignmentListResult{ + // Value: []*armbilling.RoleAssignment{ + // { + // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/invoiceSections/xxxx-xxxx-xxx-xxx/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // Properties: &armbilling.RoleAssignmentProperties{ + // CreatedByPrincipalID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/invoiceSections/xxxx-xxxx-xxx-xxx/billingRoleDefinitions/30000000-aaaa-bbbb-cccc-100000000002"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/invoiceSections/xxxx-xxxx-xxx-xxx"), + // }, + // }, + // { + // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/invoiceSections/xxxx-xxxx-xxx-xxx/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), + // Properties: &armbilling.RoleAssignmentProperties{ + // CreatedByPrincipalID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/invoiceSections/xxxx-xxxx-xxx-xxx/billingRoleDefinitions/30000000-aaaa-bbbb-cccc-100000000001"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/invoiceSections/xxxx-xxxx-xxx-xxx"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentCreateByInvoiceSection.json +func ExampleRoleAssignmentsClient_BeginCreateByInvoiceSection() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -130,31 +508,40 @@ func ExampleRoleAssignmentsClient_DeleteByInvoiceSection() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewRoleAssignmentsClient().DeleteByInvoiceSection(ctx, "{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", "{billingRoleAssignmentName}", nil) + poller, err := clientFactory.NewRoleAssignmentsClient().BeginCreateByInvoiceSection(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30", "BKM6-54VH-BG7-PGB", "xxxx-xxxx-xxx-xxx", armbilling.RoleAssignmentProperties{ + PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + PrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/invoiceSections/xxxx-xxxx-xxx-xxx/billingRoleDefinitions/10000000-aaaa-bbbb-cccc-100000000000"), + UserEmailAddress: to.Ptr("john@contoso.com"), + }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.RoleAssignment = armbilling.RoleAssignment{ - // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_00000000-0000-0000-0000-000000000000"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections/billingRoleAssignments"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/invoiceSections/xxxx-xxxx-xxx-xxx/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_00000000-0000-0000-0000-000000000000"), // Properties: &armbilling.RoleAssignmentProperties{ - // CreatedByPrincipalID: to.Ptr("10000000-aaaa-bbbb-cccc-3fd5ff9d6aa1"), - // CreatedByPrincipalTenantID: to.Ptr("7ca289b9-c32d-4f01-8566-7ff93261d76f"), - // CreatedOn: to.Ptr("2018-06-21T21:34:12.2363515+00:00"), - // PrincipalID: to.Ptr("6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), - // PrincipalTenantID: to.Ptr("10000000-aaaa-bbbb-cccc-2d7cd011db47"), - // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000002"), - // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}"), + // CreatedByPrincipalID: to.Ptr("47309529-17e6-4104-b9e8-39f62fa1e5ed"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/invoiceSections/xxxx-xxxx-xxx-xxx/billingRoleDefinitions/10000000-aaaa-bbbb-cccc-100000000000"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/invoiceSections/xxxx-xxxx-xxx-xxx"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingProfileRoleAssignment.json -func ExampleRoleAssignmentsClient_GetByBillingProfile() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/resolveBillingRoleAssignmentByInvoiceSection.json +func ExampleRoleAssignmentsClient_BeginResolveByInvoiceSection() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -164,7 +551,138 @@ func ExampleRoleAssignmentsClient_GetByBillingProfile() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewRoleAssignmentsClient().GetByBillingProfile(ctx, "{billingAccountName}", "{billingProfileName}", "{billingRoleAssignmentName}", nil) + poller, err := clientFactory.NewRoleAssignmentsClient().BeginResolveByInvoiceSection(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30", "BKM6-54VH-BG7-PGB", "xxxx-xxxx-xxx-xxx", &armbilling.RoleAssignmentsClientBeginResolveByInvoiceSectionOptions{ResolveScopeDisplayNames: nil, + Filter: nil, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RoleAssignmentListResult = armbilling.RoleAssignmentListResult{ + // Value: []*armbilling.RoleAssignment{ + // { + // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/invoiceSections/xxxx-xxxx-xxx-xxx/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // Properties: &armbilling.RoleAssignmentProperties{ + // CreatedByPrincipalID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/invoiceSections/xxxx-xxxx-xxx-xxx/billingRoleDefinitions/30000000-aaaa-bbbb-cccc-100000000000"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/invoiceSections/xxxx-xxxx-xxx-xxx"), + // }, + // }, + // { + // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/invoiceSections/xxxx-xxxx-xxx-xxx/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), + // Properties: &armbilling.RoleAssignmentProperties{ + // CreatedByPrincipalID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/invoiceSections/xxxx-xxxx-xxx-xxx/billingRoleDefinitions/30000000-aaaa-bbbb-cccc-100000000000"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/invoiceSections/xxxx-xxxx-xxx-xxx"), + // }, + // }}, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/resolveBillingRoleAssignmentByBillingProfile.json +func ExampleRoleAssignmentsClient_BeginResolveByBillingProfile() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewRoleAssignmentsClient().BeginResolveByBillingProfile(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30", "xxxx-xxxx-xxx-xxx", &armbilling.RoleAssignmentsClientBeginResolveByBillingProfileOptions{ResolveScopeDisplayNames: nil, + Filter: nil, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RoleAssignmentListResult = armbilling.RoleAssignmentListResult{ + // Value: []*armbilling.RoleAssignment{ + // { + // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // Properties: &armbilling.RoleAssignmentProperties{ + // CreatedByPrincipalID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx/billingRoleDefinitions/00000000-0000-0000-0000-000000000000"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx"), + // }, + // }, + // { + // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), + // Properties: &armbilling.RoleAssignmentProperties{ + // CreatedByPrincipalID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx/billingRoleDefinitions/00000000-0000-0000-0000-000000000001"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/xxxx-xxxx-xxx-xxx"), + // }, + // }}, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentDeleteByBillingAccount.json +func ExampleRoleAssignmentsClient_DeleteByBillingAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewRoleAssignmentsClient().DeleteByBillingAccount(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30", "10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByBillingAccount.json +func ExampleRoleAssignmentsClient_GetByBillingAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRoleAssignmentsClient().GetByBillingAccount(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30", "10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -172,23 +690,23 @@ func ExampleRoleAssignmentsClient_GetByBillingProfile() { _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.RoleAssignment = armbilling.RoleAssignment{ - // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/billingRoleAssignments"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), + // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), // Properties: &armbilling.RoleAssignmentProperties{ - // CreatedByPrincipalID: to.Ptr("10000000-aaaa-bbbb-cccc-3fd5ff9d6aa1"), - // CreatedByPrincipalTenantID: to.Ptr("7ca289b9-c32d-4f01-8566-7ff93261d76f"), - // CreatedOn: to.Ptr("2018-06-21T21:58:19.9073876+00:00"), - // PrincipalID: to.Ptr("6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), - // PrincipalTenantID: to.Ptr("10000000-aaaa-bbbb-cccc-2d7cd011db47"), - // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000002"), - // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"), + // CreatedByPrincipalID: to.Ptr(""), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingRoleDefinitions/00000000-0000-0000-0000-000000000000"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingProfileRoleAssignmentDelete.json -func ExampleRoleAssignmentsClient_DeleteByBillingProfile() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentCreateOrUpdateByBillingAccount.json +func ExampleRoleAssignmentsClient_BeginCreateOrUpdateByBillingAccount() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -198,30 +716,41 @@ func ExampleRoleAssignmentsClient_DeleteByBillingProfile() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewRoleAssignmentsClient().DeleteByBillingProfile(ctx, "{billingAccountName}", "{billingProfileName}", "{billingRoleAssignmentName}", nil) + poller, err := clientFactory.NewRoleAssignmentsClient().BeginCreateOrUpdateByBillingAccount(ctx, "7898901", "9dfd08c2-62a3-4d47-85bd-1cdba1408402", armbilling.RoleAssignment{ + Properties: &armbilling.RoleAssignmentProperties{ + PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + PrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/7898901/billingRoleDefinitions/9f1983cb-2574-400c-87e9-34cf8e2280db"), + UserEmailAddress: to.Ptr("john@contoso.com"), + }, + }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.RoleAssignment = armbilling.RoleAssignment{ - // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/billingRoleAssignments"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/10000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), + // Name: to.Ptr("9dfd08c2-62a3-4d47-85bd-1cdba1408402"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/7898901/billingRoleAssignments/9dfd08c2-62a3-4d47-85bd-1cdba1408402"), // Properties: &armbilling.RoleAssignmentProperties{ - // CreatedByPrincipalID: to.Ptr("10000000-aaaa-bbbb-cccc-3fd5ff9d6aa1"), - // CreatedByPrincipalTenantID: to.Ptr("7ca289b9-c32d-4f01-8566-7ff93261d76f"), - // CreatedOn: to.Ptr("2018-06-21T21:58:19.9073876+00:00"), - // PrincipalID: to.Ptr("6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), - // PrincipalTenantID: to.Ptr("10000000-aaaa-bbbb-cccc-2d7cd011db47"), - // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000002"), - // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"), + // CreatedByPrincipalID: to.Ptr("60d97094-2be4-46cc-a4fe-3633021a25b9"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalTenantID: to.Ptr("7ca289b9-c32d-4f01-8566-7ff93261d76f"), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/7898901/billingRoleDefinitions/9f1983cb-2574-400c-87e9-34cf8e2280db"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/7898901"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingAccountRoleAssignmentList.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentListByBillingAccount.json func ExampleRoleAssignmentsClient_NewListByBillingAccountPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -232,7 +761,10 @@ func ExampleRoleAssignmentsClient_NewListByBillingAccountPager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewRoleAssignmentsClient().NewListByBillingAccountPager("{billingAccountName}", nil) + pager := clientFactory.NewRoleAssignmentsClient().NewListByBillingAccountPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30", &armbilling.RoleAssignmentsClientListByBillingAccountOptions{Filter: nil, + Top: nil, + Skip: nil, + }) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -248,37 +780,80 @@ func ExampleRoleAssignmentsClient_NewListByBillingAccountPager() { // { // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingRoleAssignments"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), // Properties: &armbilling.RoleAssignmentProperties{ - // CreatedByPrincipalID: to.Ptr("10000000-aaaa-bbbb-cccc-3fd5ff9d6aa1"), - // CreatedByPrincipalTenantID: to.Ptr("7ca289b9-c32d-4f01-8566-7ff93261d76f"), - // CreatedOn: to.Ptr("2018-06-21T21:34:12.2363515+00:00"), - // PrincipalID: to.Ptr("6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), - // PrincipalTenantID: to.Ptr("10000000-aaaa-bbbb-cccc-2d7cd011db47"), - // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000002"), - // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}"), + // CreatedByPrincipalID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingRoleDefinitions/00000000-0000-0000-0000-000000000000"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30"), // }, // }, // { // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingRoleAssignments"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), // Properties: &armbilling.RoleAssignmentProperties{ - // CreatedByPrincipalID: to.Ptr("10000000-aaaa-bbbb-cccc-3fd5ff9d6aa1"), - // CreatedByPrincipalTenantID: to.Ptr("7ca289b9-c32d-4f01-8566-7ff93261d76f"), - // CreatedOn: to.Ptr("2018-06-21T21:58:19.9073876+00:00"), - // PrincipalID: to.Ptr("b1839933-b3ac-42ca-8112-d29c43f3ab47"), - // PrincipalTenantID: to.Ptr("10000000-aaaa-bbbb-cccc-2d7cd011db47"), - // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000002"), - // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}"), + // CreatedByPrincipalID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingRoleDefinitions/00000000-0000-0000-0000-000000000001"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30"), // }, // }}, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/InvoiceSectionRoleAssignmentList.json -func ExampleRoleAssignmentsClient_NewListByInvoiceSectionPager() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentCreateByBillingAccount.json +func ExampleRoleAssignmentsClient_BeginCreateByBillingAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewRoleAssignmentsClient().BeginCreateByBillingAccount(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30", armbilling.RoleAssignmentProperties{ + PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + PrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingRoleDefinitions/10000000-aaaa-bbbb-cccc-100000000000"), + UserEmailAddress: to.Ptr("john@contoso.com"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RoleAssignment = armbilling.RoleAssignment{ + // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_00000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_00000000-0000-0000-0000-000000000000"), + // Properties: &armbilling.RoleAssignmentProperties{ + // CreatedByPrincipalID: to.Ptr("47309529-17e6-4104-b9e8-39f62fa1e5ed"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingRoleDefinitions/10000000-aaaa-bbbb-cccc-100000000000"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentDeleteByDepartment.json +func ExampleRoleAssignmentsClient_DeleteByDepartment() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -288,7 +863,102 @@ func ExampleRoleAssignmentsClient_NewListByInvoiceSectionPager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewRoleAssignmentsClient().NewListByInvoiceSectionPager("{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", nil) + _, err = clientFactory.NewRoleAssignmentsClient().DeleteByDepartment(ctx, "8608480", "123456", "9dfd08c2-62a3-4d47-85bd-1cdba1408402", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByDepartment.json +func ExampleRoleAssignmentsClient_GetByDepartment() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRoleAssignmentsClient().GetByDepartment(ctx, "7898901", "225314", "9dfd08c2-62a3-4d47-85bd-1cdba1408402", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RoleAssignment = armbilling.RoleAssignment{ + // Name: to.Ptr("9dfd08c2-62a3-4d47-85bd-1cdba1408402"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/departments/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/7898901/departments/225314/billingRoleAssignments/9dfd08c2-62a3-4d47-85bd-1cdba1408402"), + // Properties: &armbilling.RoleAssignmentProperties{ + // CreatedByUserEmailAddress: to.Ptr("test@billtest900006.onmicrosoft.com"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/7898901/departments/225314/billingRoleDefinitions/c15c22c0-9faf-424c-9b7e-bd91c06a240b"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/7898901/departments/225314"), + // UserAuthenticationType: to.Ptr("Organization"), + // UserEmailAddress: to.Ptr("a_owner@billtest900006.onmicrosoft.com"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentCreateOrUpdateByDepartment.json +func ExampleRoleAssignmentsClient_BeginCreateOrUpdateByDepartment() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewRoleAssignmentsClient().BeginCreateOrUpdateByDepartment(ctx, "7898901", "12345", "9dfd08c2-62a3-4d47-85bd-1cdba1408402", armbilling.RoleAssignment{ + Properties: &armbilling.RoleAssignmentProperties{ + PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + PrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/7898901/departments/12345/billingRoleDefinitions/9f1983cb-2574-400c-87e9-34cf8e2280db"), + UserEmailAddress: to.Ptr("john@contoso.com"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RoleAssignment = armbilling.RoleAssignment{ + // Name: to.Ptr("9dfd08c2-62a3-4d47-85bd-1cdba1408402"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/departments/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/7898901/departments/12345/billingRoleAssignments/9dfd08c2-62a3-4d47-85bd-1cdba1408402"), + // Properties: &armbilling.RoleAssignmentProperties{ + // CreatedByPrincipalID: to.Ptr("60d97094-2be4-46cc-a4fe-3633021a25b9"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalTenantID: to.Ptr("7ca289b9-c32d-4f01-8566-7ff93261d76f"), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/7898901/departments/12345/billingRoleDefinitions/9f1983cb-2574-400c-87e9-34cf8e2280db"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/7898901/departments/12345"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentListByDepartment.json +func ExampleRoleAssignmentsClient_NewListByDepartmentPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRoleAssignmentsClient().NewListByDepartmentPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30", "12345", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -303,38 +973,38 @@ func ExampleRoleAssignmentsClient_NewListByInvoiceSectionPager() { // Value: []*armbilling.RoleAssignment{ // { // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections/billingRoleAssignments"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/departments/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/departments/12345/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), // Properties: &armbilling.RoleAssignmentProperties{ - // CreatedByPrincipalID: to.Ptr("10000000-aaaa-bbbb-cccc-3fd5ff9d6aa1"), - // CreatedByPrincipalTenantID: to.Ptr("7ca289b9-c32d-4f01-8566-7ff93261d76f"), - // CreatedOn: to.Ptr("2018-06-21T21:34:12.2363515+00:00"), - // PrincipalID: to.Ptr("6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), - // PrincipalTenantID: to.Ptr("10000000-aaaa-bbbb-cccc-2d7cd011db47"), - // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000002"), - // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}"), + // CreatedByPrincipalID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/departments/12345/billingRoleDefinitions/00000000-0000-0000-0000-000000000000"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/departments/12345"), // }, // }, // { // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections/billingRoleAssignments"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/10000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/departments/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/departments/12345/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), // Properties: &armbilling.RoleAssignmentProperties{ - // CreatedByPrincipalID: to.Ptr("10000000-aaaa-bbbb-cccc-3fd5ff9d6aa1"), - // CreatedByPrincipalTenantID: to.Ptr("7ca289b9-c32d-4f01-8566-7ff93261d76f"), - // CreatedOn: to.Ptr("2018-06-21T21:58:19.9073876+00:00"), - // PrincipalID: to.Ptr("6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), - // PrincipalTenantID: to.Ptr("10000000-aaaa-bbbb-cccc-2d7cd011db47"), - // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000002"), - // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}"), + // CreatedByPrincipalID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("\"/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/departments/12345/billingRoleDefinitions/00000000-0000-0000-0000-000000000001"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/departments/12345"), // }, // }}, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingProfileRoleAssignmentList.json -func ExampleRoleAssignmentsClient_NewListByBillingProfilePager() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentDeleteByEnrollmentAccount.json +func ExampleRoleAssignmentsClient_DeleteByEnrollmentAccount() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -344,7 +1014,102 @@ func ExampleRoleAssignmentsClient_NewListByBillingProfilePager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewRoleAssignmentsClient().NewListByBillingProfilePager("{billingAccountName}", "{billingProfileName}", nil) + _, err = clientFactory.NewRoleAssignmentsClient().DeleteByEnrollmentAccount(ctx, "8608480", "123456", "9dfd08c2-62a3-4d47-85bd-1cdba1408402", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByEnrollmentAccount.json +func ExampleRoleAssignmentsClient_GetByEnrollmentAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRoleAssignmentsClient().GetByEnrollmentAccount(ctx, "7898901", "225314", "9dfd08c2-62a3-4d47-85bd-1cdba1408402", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RoleAssignment = armbilling.RoleAssignment{ + // Name: to.Ptr("9dfd08c2-62a3-4d47-85bd-1cdba1408402"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/7898901/enrollmentAccounts/225314/billingRoleAssignments/9dfd08c2-62a3-4d47-85bd-1cdba1408402"), + // Properties: &armbilling.RoleAssignmentProperties{ + // CreatedByUserEmailAddress: to.Ptr("test@billtest900006.onmicrosoft.com"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/7898901/enrollmentAccounts/225314/billingRoleDefinitions/c15c22c0-9faf-424c-9b7e-bd91c06a240b"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/7898901/enrollmentAccounts/225314"), + // UserAuthenticationType: to.Ptr("Organization"), + // UserEmailAddress: to.Ptr("a_owner@billtest900006.onmicrosoft.com"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentCreateOrUpdateByEnrollmentAccount.json +func ExampleRoleAssignmentsClient_BeginCreateOrUpdateByEnrollmentAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewRoleAssignmentsClient().BeginCreateOrUpdateByEnrollmentAccount(ctx, "7898901", "123456", "9dfd08c2-62a3-4d47-85bd-1cdba1408402", armbilling.RoleAssignment{ + Properties: &armbilling.RoleAssignmentProperties{ + PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + PrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/7898901/enrollmentAccounts/123456/billingRoleDefinitions/9f1983cb-2574-400c-87e9-34cf8e2280db"), + UserEmailAddress: to.Ptr("john@contoso.com"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RoleAssignment = armbilling.RoleAssignment{ + // Name: to.Ptr("9dfd08c2-62a3-4d47-85bd-1cdba1408402"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/7898901/enrollmentAccounts/123456/billingRoleAssignments/9dfd08c2-62a3-4d47-85bd-1cdba1408402"), + // Properties: &armbilling.RoleAssignmentProperties{ + // CreatedByPrincipalID: to.Ptr("60d97094-2be4-46cc-a4fe-3633021a25b9"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalTenantID: to.Ptr("7ca289b9-c32d-4f01-8566-7ff93261d76f"), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/7898901/enrollmentAccounts/123456/billingRoleDefinitions/9f1983cb-2574-400c-87e9-34cf8e2280db"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/7898901/enrollmentAccounts/123456"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentListByEnrollmentAccount.json +func ExampleRoleAssignmentsClient_NewListByEnrollmentAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRoleAssignmentsClient().NewListByEnrollmentAccountPager("6100092", "123456", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -359,32 +1124,89 @@ func ExampleRoleAssignmentsClient_NewListByBillingProfilePager() { // Value: []*armbilling.RoleAssignment{ // { // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/billingRoleAssignments"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/6100092/enrollmentAccounts/123456/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), // Properties: &armbilling.RoleAssignmentProperties{ - // CreatedByPrincipalID: to.Ptr("10000000-aaaa-bbbb-cccc-3fd5ff9d6aa1"), - // CreatedByPrincipalTenantID: to.Ptr("7ca289b9-c32d-4f01-8566-7ff93261d76f"), - // CreatedOn: to.Ptr("2018-06-21T21:34:12.2363515+00:00"), - // PrincipalID: to.Ptr("6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), - // PrincipalTenantID: to.Ptr("10000000-aaaa-bbbb-cccc-2d7cd011db47"), - // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000002"), - // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"), + // CreatedByPrincipalID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/6100092/enrollmentAccounts/123456/billingRoleDefinitions/50000000-0000-0000-0000-000000000000"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/6100092/enrollmentAccounts/123456"), // }, // }, // { - // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/billingRoleAssignments"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/10000000-aaaa-bbbb-cccc-100000000000_00000000-0000-0000-0000-000000000000"), + // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/6100092/enrollmentAccounts/123456/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), // Properties: &armbilling.RoleAssignmentProperties{ - // CreatedByPrincipalID: to.Ptr("10000000-aaaa-bbbb-cccc-3fd5ff9d6aa1"), - // CreatedByPrincipalTenantID: to.Ptr("7ca289b9-c32d-4f01-8566-7ff93261d76f"), - // CreatedOn: to.Ptr("2018-06-21T21:58:19.9073876+00:00"), - // PrincipalID: to.Ptr("b1839933-b3ac-42ca-8112-d29c43f3ab47"), - // PrincipalTenantID: to.Ptr("10000000-aaaa-bbbb-cccc-2d7cd011db47"), - // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000002"), - // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"), + // CreatedByPrincipalID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/6100092/enrollmentAccounts/123456/billingRoleDefinitions/50000000-0000-0000-0000-000000000001"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/6100092/enrollmentAccounts/123456"), // }, // }}, // } } } + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/resolveBillingRoleAssignmentByBillingAccount.json +func ExampleRoleAssignmentsClient_BeginResolveByBillingAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewRoleAssignmentsClient().BeginResolveByBillingAccount(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30", &armbilling.RoleAssignmentsClientBeginResolveByBillingAccountOptions{ResolveScopeDisplayNames: nil, + Filter: nil, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RoleAssignmentListResult = armbilling.RoleAssignmentListResult{ + // Value: []*armbilling.RoleAssignment{ + // { + // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"), + // Properties: &armbilling.RoleAssignmentProperties{ + // CreatedByPrincipalID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingRoleDefinitions/00000000-0000-0000-0000-000000000000"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30"), + // }, + // }, + // { + // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingRoleAssignments"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingRoleAssignments/10000000-aaaa-bbbb-cccc-100000000000_b1839933-b3ac-42ca-8112-d29c43f3ab47"), + // Properties: &armbilling.RoleAssignmentProperties{ + // CreatedByPrincipalID: to.Ptr("00000000-0000-0000-0000-000000000001"), + // CreatedByPrincipalTenantID: to.Ptr("076915e7-de10-4323-bb34-a58c904068bb"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T20:10:50.102Z"); return t}()), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalType: to.Ptr(armbilling.PrincipalTypeUser), + // RoleDefinitionID: to.Ptr("providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingRoleDefinitions/00000000-0000-0000-0000-000000000001"), + // Scope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30"), + // }, + // }}, + // } +} diff --git a/sdk/resourcemanager/billing/armbilling/roledefinition_client.go b/sdk/resourcemanager/billing/armbilling/roledefinition_client.go new file mode 100644 index 000000000000..510d96c9ddfb --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/roledefinition_client.go @@ -0,0 +1,827 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armbilling + +import ( + "context" + "errors" + "net/http" + "net/url" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// RoleDefinitionClient contains the methods for the BillingRoleDefinition group. +// Don't use this type directly, use NewRoleDefinitionClient() instead. +type RoleDefinitionClient struct { + internal *arm.Client +} + +// NewRoleDefinitionClient creates a new instance of RoleDefinitionClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewRoleDefinitionClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*RoleDefinitionClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &RoleDefinitionClient{ + internal: cl, + } + return client, nil +} + +// GetByBillingAccount - Gets the definition for a role on a billing account. The operation is supported for billing accounts +// with agreement type Microsoft Partner Agreement, Microsoft Customer Agreement or Enterprise +// Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - roleDefinitionName - The ID that uniquely identifies a role definition. +// - options - RoleDefinitionClientGetByBillingAccountOptions contains the optional parameters for the RoleDefinitionClient.GetByBillingAccount +// method. +func (client *RoleDefinitionClient) GetByBillingAccount(ctx context.Context, billingAccountName string, roleDefinitionName string, options *RoleDefinitionClientGetByBillingAccountOptions) (RoleDefinitionClientGetByBillingAccountResponse, error) { + var err error + const operationName = "RoleDefinitionClient.GetByBillingAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByBillingAccountCreateRequest(ctx, billingAccountName, roleDefinitionName, options) + if err != nil { + return RoleDefinitionClientGetByBillingAccountResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RoleDefinitionClientGetByBillingAccountResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RoleDefinitionClientGetByBillingAccountResponse{}, err + } + resp, err := client.getByBillingAccountHandleResponse(httpResp) + return resp, err +} + +// getByBillingAccountCreateRequest creates the GetByBillingAccount request. +func (client *RoleDefinitionClient) getByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, roleDefinitionName string, options *RoleDefinitionClientGetByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/{roleDefinitionName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if roleDefinitionName == "" { + return nil, errors.New("parameter roleDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{roleDefinitionName}", url.PathEscape(roleDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByBillingAccountHandleResponse handles the GetByBillingAccount response. +func (client *RoleDefinitionClient) getByBillingAccountHandleResponse(resp *http.Response) (RoleDefinitionClientGetByBillingAccountResponse, error) { + result := RoleDefinitionClientGetByBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinition); err != nil { + return RoleDefinitionClientGetByBillingAccountResponse{}, err + } + return result, nil +} + +// GetByBillingProfile - Gets the definition for a role on a billing profile. The operation is supported for billing accounts +// with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - roleDefinitionName - The ID that uniquely identifies a role definition. +// - options - RoleDefinitionClientGetByBillingProfileOptions contains the optional parameters for the RoleDefinitionClient.GetByBillingProfile +// method. +func (client *RoleDefinitionClient) GetByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, roleDefinitionName string, options *RoleDefinitionClientGetByBillingProfileOptions) (RoleDefinitionClientGetByBillingProfileResponse, error) { + var err error + const operationName = "RoleDefinitionClient.GetByBillingProfile" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, roleDefinitionName, options) + if err != nil { + return RoleDefinitionClientGetByBillingProfileResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RoleDefinitionClientGetByBillingProfileResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RoleDefinitionClientGetByBillingProfileResponse{}, err + } + resp, err := client.getByBillingProfileHandleResponse(httpResp) + return resp, err +} + +// getByBillingProfileCreateRequest creates the GetByBillingProfile request. +func (client *RoleDefinitionClient) getByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, roleDefinitionName string, options *RoleDefinitionClientGetByBillingProfileOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleDefinitions/{roleDefinitionName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if roleDefinitionName == "" { + return nil, errors.New("parameter roleDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{roleDefinitionName}", url.PathEscape(roleDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByBillingProfileHandleResponse handles the GetByBillingProfile response. +func (client *RoleDefinitionClient) getByBillingProfileHandleResponse(resp *http.Response) (RoleDefinitionClientGetByBillingProfileResponse, error) { + result := RoleDefinitionClientGetByBillingProfileResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinition); err != nil { + return RoleDefinitionClientGetByBillingProfileResponse{}, err + } + return result, nil +} + +// GetByCustomer - Gets the definition for a role on a customer. The operation is supported only for billing accounts with +// agreement type Microsoft Partner Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - customerName - The ID that uniquely identifies a customer. +// - roleDefinitionName - The ID that uniquely identifies a role definition. +// - options - RoleDefinitionClientGetByCustomerOptions contains the optional parameters for the RoleDefinitionClient.GetByCustomer +// method. +func (client *RoleDefinitionClient) GetByCustomer(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, roleDefinitionName string, options *RoleDefinitionClientGetByCustomerOptions) (RoleDefinitionClientGetByCustomerResponse, error) { + var err error + const operationName = "RoleDefinitionClient.GetByCustomer" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByCustomerCreateRequest(ctx, billingAccountName, billingProfileName, customerName, roleDefinitionName, options) + if err != nil { + return RoleDefinitionClientGetByCustomerResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RoleDefinitionClientGetByCustomerResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RoleDefinitionClientGetByCustomerResponse{}, err + } + resp, err := client.getByCustomerHandleResponse(httpResp) + return resp, err +} + +// getByCustomerCreateRequest creates the GetByCustomer request. +func (client *RoleDefinitionClient) getByCustomerCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, roleDefinitionName string, options *RoleDefinitionClientGetByCustomerOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/billingRoleDefinitions/{roleDefinitionName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if customerName == "" { + return nil, errors.New("parameter customerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{customerName}", url.PathEscape(customerName)) + if roleDefinitionName == "" { + return nil, errors.New("parameter roleDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{roleDefinitionName}", url.PathEscape(roleDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByCustomerHandleResponse handles the GetByCustomer response. +func (client *RoleDefinitionClient) getByCustomerHandleResponse(resp *http.Response) (RoleDefinitionClientGetByCustomerResponse, error) { + result := RoleDefinitionClientGetByCustomerResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinition); err != nil { + return RoleDefinitionClientGetByCustomerResponse{}, err + } + return result, nil +} + +// GetByDepartment - Gets the definition for a role on a department. The operation is supported for billing accounts with +// agreement type Enterprise Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - departmentName - The name of the department. +// - roleDefinitionName - The ID that uniquely identifies a role definition. +// - options - RoleDefinitionClientGetByDepartmentOptions contains the optional parameters for the RoleDefinitionClient.GetByDepartment +// method. +func (client *RoleDefinitionClient) GetByDepartment(ctx context.Context, billingAccountName string, departmentName string, roleDefinitionName string, options *RoleDefinitionClientGetByDepartmentOptions) (RoleDefinitionClientGetByDepartmentResponse, error) { + var err error + const operationName = "RoleDefinitionClient.GetByDepartment" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByDepartmentCreateRequest(ctx, billingAccountName, departmentName, roleDefinitionName, options) + if err != nil { + return RoleDefinitionClientGetByDepartmentResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RoleDefinitionClientGetByDepartmentResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RoleDefinitionClientGetByDepartmentResponse{}, err + } + resp, err := client.getByDepartmentHandleResponse(httpResp) + return resp, err +} + +// getByDepartmentCreateRequest creates the GetByDepartment request. +func (client *RoleDefinitionClient) getByDepartmentCreateRequest(ctx context.Context, billingAccountName string, departmentName string, roleDefinitionName string, options *RoleDefinitionClientGetByDepartmentOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}/billingRoleDefinitions/{roleDefinitionName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if departmentName == "" { + return nil, errors.New("parameter departmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{departmentName}", url.PathEscape(departmentName)) + if roleDefinitionName == "" { + return nil, errors.New("parameter roleDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{roleDefinitionName}", url.PathEscape(roleDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByDepartmentHandleResponse handles the GetByDepartment response. +func (client *RoleDefinitionClient) getByDepartmentHandleResponse(resp *http.Response) (RoleDefinitionClientGetByDepartmentResponse, error) { + result := RoleDefinitionClientGetByDepartmentResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinition); err != nil { + return RoleDefinitionClientGetByDepartmentResponse{}, err + } + return result, nil +} + +// GetByEnrollmentAccount - Gets the definition for a role on an enrollment account. The operation is supported for billing +// accounts with agreement type Enterprise Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - enrollmentAccountName - The name of the enrollment account. +// - roleDefinitionName - The ID that uniquely identifies a role definition. +// - options - RoleDefinitionClientGetByEnrollmentAccountOptions contains the optional parameters for the RoleDefinitionClient.GetByEnrollmentAccount +// method. +func (client *RoleDefinitionClient) GetByEnrollmentAccount(ctx context.Context, billingAccountName string, enrollmentAccountName string, roleDefinitionName string, options *RoleDefinitionClientGetByEnrollmentAccountOptions) (RoleDefinitionClientGetByEnrollmentAccountResponse, error) { + var err error + const operationName = "RoleDefinitionClient.GetByEnrollmentAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByEnrollmentAccountCreateRequest(ctx, billingAccountName, enrollmentAccountName, roleDefinitionName, options) + if err != nil { + return RoleDefinitionClientGetByEnrollmentAccountResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RoleDefinitionClientGetByEnrollmentAccountResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RoleDefinitionClientGetByEnrollmentAccountResponse{}, err + } + resp, err := client.getByEnrollmentAccountHandleResponse(httpResp) + return resp, err +} + +// getByEnrollmentAccountCreateRequest creates the GetByEnrollmentAccount request. +func (client *RoleDefinitionClient) getByEnrollmentAccountCreateRequest(ctx context.Context, billingAccountName string, enrollmentAccountName string, roleDefinitionName string, options *RoleDefinitionClientGetByEnrollmentAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}/billingRoleDefinitions/{roleDefinitionName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if enrollmentAccountName == "" { + return nil, errors.New("parameter enrollmentAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{enrollmentAccountName}", url.PathEscape(enrollmentAccountName)) + if roleDefinitionName == "" { + return nil, errors.New("parameter roleDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{roleDefinitionName}", url.PathEscape(roleDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByEnrollmentAccountHandleResponse handles the GetByEnrollmentAccount response. +func (client *RoleDefinitionClient) getByEnrollmentAccountHandleResponse(resp *http.Response) (RoleDefinitionClientGetByEnrollmentAccountResponse, error) { + result := RoleDefinitionClientGetByEnrollmentAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinition); err != nil { + return RoleDefinitionClientGetByEnrollmentAccountResponse{}, err + } + return result, nil +} + +// GetByInvoiceSection - Gets the definition for a role on an invoice section. The operation is supported only for billing +// accounts with agreement type Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - invoiceSectionName - The ID that uniquely identifies an invoice section. +// - roleDefinitionName - The ID that uniquely identifies a role definition. +// - options - RoleDefinitionClientGetByInvoiceSectionOptions contains the optional parameters for the RoleDefinitionClient.GetByInvoiceSection +// method. +func (client *RoleDefinitionClient) GetByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, roleDefinitionName string, options *RoleDefinitionClientGetByInvoiceSectionOptions) (RoleDefinitionClientGetByInvoiceSectionResponse, error) { + var err error + const operationName = "RoleDefinitionClient.GetByInvoiceSection" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByInvoiceSectionCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, roleDefinitionName, options) + if err != nil { + return RoleDefinitionClientGetByInvoiceSectionResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RoleDefinitionClientGetByInvoiceSectionResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RoleDefinitionClientGetByInvoiceSectionResponse{}, err + } + resp, err := client.getByInvoiceSectionHandleResponse(httpResp) + return resp, err +} + +// getByInvoiceSectionCreateRequest creates the GetByInvoiceSection request. +func (client *RoleDefinitionClient) getByInvoiceSectionCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, roleDefinitionName string, options *RoleDefinitionClientGetByInvoiceSectionOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleDefinitions/{roleDefinitionName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if invoiceSectionName == "" { + return nil, errors.New("parameter invoiceSectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) + if roleDefinitionName == "" { + return nil, errors.New("parameter roleDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{roleDefinitionName}", url.PathEscape(roleDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByInvoiceSectionHandleResponse handles the GetByInvoiceSection response. +func (client *RoleDefinitionClient) getByInvoiceSectionHandleResponse(resp *http.Response) (RoleDefinitionClientGetByInvoiceSectionResponse, error) { + result := RoleDefinitionClientGetByInvoiceSectionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinition); err != nil { + return RoleDefinitionClientGetByInvoiceSectionResponse{}, err + } + return result, nil +} + +// NewListByBillingAccountPager - Lists the role definitions for a billing account. The operation is supported for billing +// accounts with agreement type Microsoft Partner Agreement, Microsoft Customer Agreement or Enterprise Agreement. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - options - RoleDefinitionClientListByBillingAccountOptions contains the optional parameters for the RoleDefinitionClient.NewListByBillingAccountPager +// method. +func (client *RoleDefinitionClient) NewListByBillingAccountPager(billingAccountName string, options *RoleDefinitionClientListByBillingAccountOptions) *runtime.Pager[RoleDefinitionClientListByBillingAccountResponse] { + return runtime.NewPager(runtime.PagingHandler[RoleDefinitionClientListByBillingAccountResponse]{ + More: func(page RoleDefinitionClientListByBillingAccountResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RoleDefinitionClientListByBillingAccountResponse) (RoleDefinitionClientListByBillingAccountResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RoleDefinitionClient.NewListByBillingAccountPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByBillingAccountCreateRequest(ctx, billingAccountName, options) + }, nil) + if err != nil { + return RoleDefinitionClientListByBillingAccountResponse{}, err + } + return client.listByBillingAccountHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByBillingAccountCreateRequest creates the ListByBillingAccount request. +func (client *RoleDefinitionClient) listByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, options *RoleDefinitionClientListByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByBillingAccountHandleResponse handles the ListByBillingAccount response. +func (client *RoleDefinitionClient) listByBillingAccountHandleResponse(resp *http.Response) (RoleDefinitionClientListByBillingAccountResponse, error) { + result := RoleDefinitionClientListByBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinitionListResult); err != nil { + return RoleDefinitionClientListByBillingAccountResponse{}, err + } + return result, nil +} + +// NewListByBillingProfilePager - Lists the role definitions for a billing profile. The operation is supported for billing +// accounts with agreement type Microsoft Partner Agreement, Microsoft Customer Agreement or Enterprise Agreement. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - options - RoleDefinitionClientListByBillingProfileOptions contains the optional parameters for the RoleDefinitionClient.NewListByBillingProfilePager +// method. +func (client *RoleDefinitionClient) NewListByBillingProfilePager(billingAccountName string, billingProfileName string, options *RoleDefinitionClientListByBillingProfileOptions) *runtime.Pager[RoleDefinitionClientListByBillingProfileResponse] { + return runtime.NewPager(runtime.PagingHandler[RoleDefinitionClientListByBillingProfileResponse]{ + More: func(page RoleDefinitionClientListByBillingProfileResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RoleDefinitionClientListByBillingProfileResponse) (RoleDefinitionClientListByBillingProfileResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RoleDefinitionClient.NewListByBillingProfilePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, options) + }, nil) + if err != nil { + return RoleDefinitionClientListByBillingProfileResponse{}, err + } + return client.listByBillingProfileHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByBillingProfileCreateRequest creates the ListByBillingProfile request. +func (client *RoleDefinitionClient) listByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, options *RoleDefinitionClientListByBillingProfileOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleDefinitions" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByBillingProfileHandleResponse handles the ListByBillingProfile response. +func (client *RoleDefinitionClient) listByBillingProfileHandleResponse(resp *http.Response) (RoleDefinitionClientListByBillingProfileResponse, error) { + result := RoleDefinitionClientListByBillingProfileResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinitionListResult); err != nil { + return RoleDefinitionClientListByBillingProfileResponse{}, err + } + return result, nil +} + +// NewListByCustomerPager - Lists the role definitions for a customer. The operation is supported for billing accounts with +// agreement type Microsoft Partner Agreement. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - customerName - The ID that uniquely identifies a customer. +// - options - RoleDefinitionClientListByCustomerOptions contains the optional parameters for the RoleDefinitionClient.NewListByCustomerPager +// method. +func (client *RoleDefinitionClient) NewListByCustomerPager(billingAccountName string, billingProfileName string, customerName string, options *RoleDefinitionClientListByCustomerOptions) *runtime.Pager[RoleDefinitionClientListByCustomerResponse] { + return runtime.NewPager(runtime.PagingHandler[RoleDefinitionClientListByCustomerResponse]{ + More: func(page RoleDefinitionClientListByCustomerResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RoleDefinitionClientListByCustomerResponse) (RoleDefinitionClientListByCustomerResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RoleDefinitionClient.NewListByCustomerPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByCustomerCreateRequest(ctx, billingAccountName, billingProfileName, customerName, options) + }, nil) + if err != nil { + return RoleDefinitionClientListByCustomerResponse{}, err + } + return client.listByCustomerHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByCustomerCreateRequest creates the ListByCustomer request. +func (client *RoleDefinitionClient) listByCustomerCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, options *RoleDefinitionClientListByCustomerOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/billingRoleDefinitions" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if customerName == "" { + return nil, errors.New("parameter customerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{customerName}", url.PathEscape(customerName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByCustomerHandleResponse handles the ListByCustomer response. +func (client *RoleDefinitionClient) listByCustomerHandleResponse(resp *http.Response) (RoleDefinitionClientListByCustomerResponse, error) { + result := RoleDefinitionClientListByCustomerResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinitionListResult); err != nil { + return RoleDefinitionClientListByCustomerResponse{}, err + } + return result, nil +} + +// NewListByDepartmentPager - List the definition for a department. The operation is supported for billing accounts with agreement +// type Enterprise Agreement. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - departmentName - The name of the department. +// - options - RoleDefinitionClientListByDepartmentOptions contains the optional parameters for the RoleDefinitionClient.NewListByDepartmentPager +// method. +func (client *RoleDefinitionClient) NewListByDepartmentPager(billingAccountName string, departmentName string, options *RoleDefinitionClientListByDepartmentOptions) *runtime.Pager[RoleDefinitionClientListByDepartmentResponse] { + return runtime.NewPager(runtime.PagingHandler[RoleDefinitionClientListByDepartmentResponse]{ + More: func(page RoleDefinitionClientListByDepartmentResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RoleDefinitionClientListByDepartmentResponse) (RoleDefinitionClientListByDepartmentResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RoleDefinitionClient.NewListByDepartmentPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByDepartmentCreateRequest(ctx, billingAccountName, departmentName, options) + }, nil) + if err != nil { + return RoleDefinitionClientListByDepartmentResponse{}, err + } + return client.listByDepartmentHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByDepartmentCreateRequest creates the ListByDepartment request. +func (client *RoleDefinitionClient) listByDepartmentCreateRequest(ctx context.Context, billingAccountName string, departmentName string, options *RoleDefinitionClientListByDepartmentOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}/billingRoleDefinitions" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if departmentName == "" { + return nil, errors.New("parameter departmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{departmentName}", url.PathEscape(departmentName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByDepartmentHandleResponse handles the ListByDepartment response. +func (client *RoleDefinitionClient) listByDepartmentHandleResponse(resp *http.Response) (RoleDefinitionClientListByDepartmentResponse, error) { + result := RoleDefinitionClientListByDepartmentResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinitionListResult); err != nil { + return RoleDefinitionClientListByDepartmentResponse{}, err + } + return result, nil +} + +// NewListByEnrollmentAccountPager - List the definition for an enrollment account. The operation is supported for billing +// accounts with agreement type Enterprise Agreement. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - enrollmentAccountName - The name of the enrollment account. +// - options - RoleDefinitionClientListByEnrollmentAccountOptions contains the optional parameters for the RoleDefinitionClient.NewListByEnrollmentAccountPager +// method. +func (client *RoleDefinitionClient) NewListByEnrollmentAccountPager(billingAccountName string, enrollmentAccountName string, options *RoleDefinitionClientListByEnrollmentAccountOptions) *runtime.Pager[RoleDefinitionClientListByEnrollmentAccountResponse] { + return runtime.NewPager(runtime.PagingHandler[RoleDefinitionClientListByEnrollmentAccountResponse]{ + More: func(page RoleDefinitionClientListByEnrollmentAccountResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RoleDefinitionClientListByEnrollmentAccountResponse) (RoleDefinitionClientListByEnrollmentAccountResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RoleDefinitionClient.NewListByEnrollmentAccountPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByEnrollmentAccountCreateRequest(ctx, billingAccountName, enrollmentAccountName, options) + }, nil) + if err != nil { + return RoleDefinitionClientListByEnrollmentAccountResponse{}, err + } + return client.listByEnrollmentAccountHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByEnrollmentAccountCreateRequest creates the ListByEnrollmentAccount request. +func (client *RoleDefinitionClient) listByEnrollmentAccountCreateRequest(ctx context.Context, billingAccountName string, enrollmentAccountName string, options *RoleDefinitionClientListByEnrollmentAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}/billingRoleDefinitions" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if enrollmentAccountName == "" { + return nil, errors.New("parameter enrollmentAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{enrollmentAccountName}", url.PathEscape(enrollmentAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByEnrollmentAccountHandleResponse handles the ListByEnrollmentAccount response. +func (client *RoleDefinitionClient) listByEnrollmentAccountHandleResponse(resp *http.Response) (RoleDefinitionClientListByEnrollmentAccountResponse, error) { + result := RoleDefinitionClientListByEnrollmentAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinitionListResult); err != nil { + return RoleDefinitionClientListByEnrollmentAccountResponse{}, err + } + return result, nil +} + +// NewListByInvoiceSectionPager - Lists the role definitions for an invoice section. The operation is supported for billing +// accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - invoiceSectionName - The ID that uniquely identifies an invoice section. +// - options - RoleDefinitionClientListByInvoiceSectionOptions contains the optional parameters for the RoleDefinitionClient.NewListByInvoiceSectionPager +// method. +func (client *RoleDefinitionClient) NewListByInvoiceSectionPager(billingAccountName string, billingProfileName string, invoiceSectionName string, options *RoleDefinitionClientListByInvoiceSectionOptions) *runtime.Pager[RoleDefinitionClientListByInvoiceSectionResponse] { + return runtime.NewPager(runtime.PagingHandler[RoleDefinitionClientListByInvoiceSectionResponse]{ + More: func(page RoleDefinitionClientListByInvoiceSectionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RoleDefinitionClientListByInvoiceSectionResponse) (RoleDefinitionClientListByInvoiceSectionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RoleDefinitionClient.NewListByInvoiceSectionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByInvoiceSectionCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, options) + }, nil) + if err != nil { + return RoleDefinitionClientListByInvoiceSectionResponse{}, err + } + return client.listByInvoiceSectionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByInvoiceSectionCreateRequest creates the ListByInvoiceSection request. +func (client *RoleDefinitionClient) listByInvoiceSectionCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, options *RoleDefinitionClientListByInvoiceSectionOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleDefinitions" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if invoiceSectionName == "" { + return nil, errors.New("parameter invoiceSectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByInvoiceSectionHandleResponse handles the ListByInvoiceSection response. +func (client *RoleDefinitionClient) listByInvoiceSectionHandleResponse(resp *http.Response) (RoleDefinitionClientListByInvoiceSectionResponse, error) { + result := RoleDefinitionClientListByInvoiceSectionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinitionListResult); err != nil { + return RoleDefinitionClientListByInvoiceSectionResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/roledefinition_client_example_test.go b/sdk/resourcemanager/billing/armbilling/roledefinition_client_example_test.go new file mode 100644 index 000000000000..494e9026f94b --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/roledefinition_client_example_test.go @@ -0,0 +1,986 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armbilling_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByBillingProfile.json +func ExampleRoleDefinitionClient_GetByBillingProfile() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRoleDefinitionClient().GetByBillingProfile(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "40000000-aaaa-bbbb-cccc-100000000000", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RoleDefinition = armbilling.RoleDefinition{ + // Name: to.Ptr("40000000-aaaa-bbbb-cccc-100000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/billingRoleDefinitions/40000000-aaaa-bbbb-cccc-100000000000"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Description: to.Ptr("The Owner role gives the user all permissions including access management rights to the billing profile."), + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000000"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000002"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000005"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000011"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000012"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000013")}, + // }}, + // RoleName: to.Ptr("Billing profile owner"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionListByBillingProfile.json +func ExampleRoleDefinitionClient_NewListByBillingProfilePager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRoleDefinitionClient().NewListByBillingProfilePager("10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.RoleDefinitionListResult = armbilling.RoleDefinitionListResult{ + // Value: []*armbilling.RoleDefinition{ + // { + // Name: to.Ptr("40000000-aaaa-bbbb-cccc-100000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/billingRoleDefinitions/40000000-aaaa-bbbb-cccc-100000000000"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Description: to.Ptr("The Owner role gives the user all permissions including access management rights to the billing profile."), + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000000"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000002"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000005"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000011"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000012"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000013")}, + // }}, + // RoleName: to.Ptr("Billing profile owner"), + // }, + // }, + // { + // Name: to.Ptr("40000000-aaaa-bbbb-cccc-100000000001"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/billingRoleDefinitions/40000000-aaaa-bbbb-cccc-100000000001"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Description: to.Ptr("The Contributor role gives the user all permissions except access management rights to the billing profile."), + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000002"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000005"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000011"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000012"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000013")}, + // }}, + // RoleName: to.Ptr("Billing profile contributor"), + // }, + // }, + // { + // Name: to.Ptr("40000000-aaaa-bbbb-cccc-100000000002"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/billingRoleDefinitions/40000000-aaaa-bbbb-cccc-100000000002"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Description: to.Ptr("The Reader role gives the user read only access to the billing profile."), + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000012")}, + // }}, + // RoleName: to.Ptr("Billing profile reader"), + // }, + // }, + // { + // Name: to.Ptr("40000000-aaaa-bbbb-cccc-100000000004"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/billingRoleDefinitions/40000000-aaaa-bbbb-cccc-100000000004"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Description: to.Ptr("The Invoice Manager role gives the user the ability to view and manage invoices."), + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000011"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000012"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000013")}, + // }}, + // RoleName: to.Ptr("Invoice manager"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByCustomer.json +func ExampleRoleDefinitionClient_GetByCustomer() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRoleDefinitionClient().GetByCustomer(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "11111111-1111-1111-1111-111111111111", "30000000-aaaa-bbbb-cccc-100000000000", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RoleDefinition = armbilling.RoleDefinition{ + // Name: to.Ptr("30000000-aaaa-bbbb-cccc-100000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/customers/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/customers/11111111-1111-1111-1111-111111111111/billingRoleDefinitions/30000000-aaaa-bbbb-cccc-100000000000"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Description: to.Ptr("The Owner role gives the user all permissions including access management rights to the customer."), + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000000"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000005"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000009"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000011"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000012"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000013"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000016"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000017"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000018")}, + // NotActions: []*string{ + // }, + // }}, + // RoleName: to.Ptr("Customer owner"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionListByCustomer.json +func ExampleRoleDefinitionClient_NewListByCustomerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRoleDefinitionClient().NewListByCustomerPager("10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "11111111-1111-1111-1111-111111111111", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.RoleDefinitionListResult = armbilling.RoleDefinitionListResult{ + // Value: []*armbilling.RoleDefinition{ + // { + // Name: to.Ptr("30000000-aaaa-bbbb-cccc-100000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/customers/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/customers/11111111-1111-1111-1111-111111111111/billingRoleDefinitions/30000000-aaaa-bbbb-cccc-100000000000"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Description: to.Ptr("The Owner role gives the user all permissions including access management rights to the customer."), + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000000"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000005"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000009"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000011"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000012"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000013"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000016"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000017"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000018")}, + // NotActions: []*string{ + // }, + // }}, + // RoleName: to.Ptr("Customer owner"), + // }, + // }, + // { + // Name: to.Ptr("30000000-aaaa-bbbb-cccc-100000000001"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/customers/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/customers/11111111-1111-1111-1111-111111111111/billingRoleDefinitions/30000000-aaaa-bbbb-cccc-100000000001"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Description: to.Ptr("The Contributor role gives the user all permissions except access management rights to the customer."), + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000005"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000009"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000011"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000012"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000013"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000016"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000017"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000018")}, + // NotActions: []*string{ + // }, + // }}, + // RoleName: to.Ptr("Customer contributor"), + // }, + // }, + // { + // Name: to.Ptr("30000000-aaaa-bbbb-cccc-100000000002"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/customers/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/customers/11111111-1111-1111-1111-111111111111/billingRoleDefinitions/30000000-aaaa-bbbb-cccc-100000000002"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Description: to.Ptr("The reader role gives the user read only access to the customer."), + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000017")}, + // NotActions: []*string{ + // }, + // }}, + // RoleName: to.Ptr("Customer reader"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByInvoiceSection.json +func ExampleRoleDefinitionClient_GetByInvoiceSection() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRoleDefinitionClient().GetByInvoiceSection(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "yyyy-yyyy-yyy-yyy", "30000000-aaaa-bbbb-cccc-100000000000", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RoleDefinition = armbilling.RoleDefinition{ + // Name: to.Ptr("30000000-aaaa-bbbb-cccc-100000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy/billingRoleDefinitions/30000000-aaaa-bbbb-cccc-100000000000"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Description: to.Ptr("The Owner role gives the user all permissions including access management rights to the invoice section."), + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000000"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000005"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000009"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000011"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000012"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000013"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000016"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000017"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000018")}, + // }}, + // RoleName: to.Ptr("Invoice section owner"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionListByInvoiceSection.json +func ExampleRoleDefinitionClient_NewListByInvoiceSectionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRoleDefinitionClient().NewListByInvoiceSectionPager("10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "yyyy-yyyy-yyy-yyy", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.RoleDefinitionListResult = armbilling.RoleDefinitionListResult{ + // Value: []*armbilling.RoleDefinition{ + // { + // Name: to.Ptr("30000000-aaaa-bbbb-cccc-100000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy/billingRoleDefinitions/30000000-aaaa-bbbb-cccc-100000000000"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Description: to.Ptr("The Owner role gives the user all permissions including access management rights to the invoice section."), + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000000"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000005"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000009"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000011"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000012"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000013"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000016"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000017"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000018")}, + // }}, + // RoleName: to.Ptr("Invoice section owner"), + // }, + // }, + // { + // Name: to.Ptr("30000000-aaaa-bbbb-cccc-100000000001"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy/billingRoleDefinitions/30000000-aaaa-bbbb-cccc-100000000001"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Description: to.Ptr("The Contributor role gives the user all permissions except access management rights to the invoice section."), + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000005"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000009"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000011"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000012"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000013"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000016"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000017"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000018")}, + // }}, + // RoleName: to.Ptr("Invoice section contributor"), + // }, + // }, + // { + // Name: to.Ptr("30000000-aaaa-bbbb-cccc-100000000002"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy/billingRoleDefinitions/30000000-aaaa-bbbb-cccc-100000000002"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Description: to.Ptr("The reader role gives the user read only access to the invoice section."), + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000017")}, + // }}, + // RoleName: to.Ptr("Invoice section reader"), + // }, + // }, + // { + // Name: to.Ptr("30000000-aaaa-bbbb-cccc-100000000006"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy/billingRoleDefinitions/30000000-aaaa-bbbb-cccc-100000000006"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Description: to.Ptr("The Azure subscription creator role gives the user the ability to create an Azure subscription for the invoice section."), + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000013")}, + // }}, + // RoleName: to.Ptr("Azure subscription creator"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByBillingAccount.json +func ExampleRoleDefinitionClient_GetByBillingAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRoleDefinitionClient().GetByBillingAccount(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "50000000-aaaa-bbbb-cccc-100000000000", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RoleDefinition = armbilling.RoleDefinition{ + // Name: to.Ptr("50000000-aaaa-bbbb-cccc-100000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000000"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000000"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000002"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000002"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000005"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000000"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000009"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000017"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000018"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000000"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000012"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000013"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000005"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000002"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000011"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000013"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000011"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000005"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000012"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000016")}, + // }}, + // RoleName: to.Ptr("Billing account owner"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionListByBillingAccount.json +func ExampleRoleDefinitionClient_NewListByBillingAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRoleDefinitionClient().NewListByBillingAccountPager("10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.RoleDefinitionListResult = armbilling.RoleDefinitionListResult{ + // Value: []*armbilling.RoleDefinition{ + // { + // Name: to.Ptr("50000000-aaaa-bbbb-cccc-100000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000000"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000000"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000002"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000002"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000005"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000000"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000009"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000017"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000018"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000000"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000012"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000013"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000005"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000002"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000011"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000013"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000011"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000005"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000012"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000016")}, + // }}, + // RoleName: to.Ptr("Billing account owner"), + // }, + // }, + // { + // Name: to.Ptr("50000000-aaaa-bbbb-cccc-100000000001"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000001"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Description: to.Ptr("The Contributor role gives the user all permissions except access management on the organization."), + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000002"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000002"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000005"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000009"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000017"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000018"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000012"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000013"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000005"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000002"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000011"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000013"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000011"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000005"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000012"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000016")}, + // }}, + // RoleName: to.Ptr("Billing account contributor"), + // }, + // }, + // { + // Name: to.Ptr("50000000-aaaa-bbbb-cccc-100000000002"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000002"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Description: to.Ptr("The Reader role gives the user read permissions to an organization."), + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000005"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000017"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000012")}, + // }}, + // RoleName: to.Ptr("Billing account reader"), + // }, + // }, + // { + // Name: to.Ptr("50000000-aaaa-bbbb-cccc-100000000002"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000002"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Description: to.Ptr("The Reader role gives the user read permissions to an organization."), + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000003"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000005"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), + // to.Ptr("30000000-aaaa-bbbb-cccc-200000000017"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008"), + // to.Ptr("40000000-aaaa-bbbb-cccc-200000000012")}, + // }}, + // RoleName: to.Ptr("Billing account reader"), + // }, + // }, + // { + // Name: to.Ptr("50000000-aaaa-bbbb-cccc-100000000003"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000003"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Description: to.Ptr("The Purchaser role gives the user permissions to make purchases by creating new Projects and Billing Groups in an organization."), + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000006"), + // to.Ptr("10000000-aaaa-bbbb-cccc-200000000007"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000001"), + // to.Ptr("50000000-aaaa-bbbb-cccc-200000000006")}, + // }}, + // RoleName: to.Ptr("Basic Purchaser"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByDepartment.json +func ExampleRoleDefinitionClient_GetByDepartment() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRoleDefinitionClient().GetByDepartment(ctx, "123456", "7368531", "50000000-aaaa-bbbb-cccc-100000000000", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RoleDefinition = armbilling.RoleDefinition{ + // Name: to.Ptr("50000000-aaaa-bbbb-cccc-100000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/departments/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/departments/7368531/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000000"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("Microsoft.Billing/billingAccounts/departments/read"), + // to.Ptr("Microsoft.Billing/billingAccounts/departments/write"), + // to.Ptr("Microsoft.Billing/billingAccounts/departments/action"), + // to.Ptr("Microsoft.Billing/billingAccounts/departments/delete"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/read"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/write"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/action"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/delete")}, + // }}, + // RoleName: to.Ptr("Department Admin"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionListByDepartment.json +func ExampleRoleDefinitionClient_NewListByDepartmentPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRoleDefinitionClient().NewListByDepartmentPager("123456", "7368531", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.RoleDefinitionListResult = armbilling.RoleDefinitionListResult{ + // Value: []*armbilling.RoleDefinition{ + // { + // Name: to.Ptr("50000000-aaaa-bbbb-cccc-100000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/departments/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/departments/7368531/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000000"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("Microsoft.Billing/billingAccounts/departments/read"), + // to.Ptr("Microsoft.Billing/billingAccounts/departments/write"), + // to.Ptr("Microsoft.Billing/billingAccounts/departments/action"), + // to.Ptr("Microsoft.Billing/billingAccounts/departments/delete"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/read"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/write"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/action"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/delete"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/billingSubscriptions/read")}, + // }}, + // RoleName: to.Ptr("Department Admin"), + // }, + // }, + // { + // Name: to.Ptr("50000000-aaaa-bbbb-cccc-100000000001"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/departments/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/departments/7368531/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000001"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("Microsoft.Billing/billingAccounts/departments/read"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/read"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/billingSubscriptions/read")}, + // }}, + // RoleName: to.Ptr("Department Reader"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByEnrollmentAccount.json +func ExampleRoleDefinitionClient_GetByEnrollmentAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRoleDefinitionClient().GetByEnrollmentAccount(ctx, "123456", "4568789", "50000000-aaaa-bbbb-cccc-100000000000", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RoleDefinition = armbilling.RoleDefinition{ + // Name: to.Ptr("50000000-aaaa-bbbb-cccc-100000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/enrollmentAccounts/4568789/billingRoleDefinitions/50000000-aaaa-bbbb-cccc-100000000000"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/read"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/write"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/action"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/delete"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/billingSubscriptions/read"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/billingSubscriptions/write"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/billingSubscriptions/action")}, + // }}, + // RoleName: to.Ptr("Account Owner"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionListByEnrollmentAccount.json +func ExampleRoleDefinitionClient_NewListByEnrollmentAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRoleDefinitionClient().NewListByEnrollmentAccountPager("123456", "4568789", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.RoleDefinitionListResult = armbilling.RoleDefinitionListResult{ + // Value: []*armbilling.RoleDefinition{ + // { + // Name: to.Ptr("30000000-aaaa-bbbb-cccc-100000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/billingRoleDefinitions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/enrollmentAccounts/4568789/billingRoleDefinitions/30000000-aaaa-bbbb-cccc-100000000000"), + // Properties: &armbilling.RoleDefinitionProperties{ + // Description: to.Ptr("The account owner role gives the user all permissions including access management rights to an accounts."), + // Permissions: []*armbilling.Permission{ + // { + // Actions: []*string{ + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/read"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/write"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/action"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/delete"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/billingSubscriptions/read"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/billingSubscriptions/write"), + // to.Ptr("Microsoft.Billing/billingAccounts/enrollmentAccounts/billingSubscriptions/action")}, + // NotActions: []*string{ + // }, + // }}, + // RoleName: to.Ptr("Account Owner"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/billing/armbilling/roledefinitions_client.go b/sdk/resourcemanager/billing/armbilling/roledefinitions_client.go deleted file mode 100644 index ea8e1b5cc70e..000000000000 --- a/sdk/resourcemanager/billing/armbilling/roledefinitions_client.go +++ /dev/null @@ -1,428 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armbilling - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// RoleDefinitionsClient contains the methods for the BillingRoleDefinitions group. -// Don't use this type directly, use NewRoleDefinitionsClient() instead. -type RoleDefinitionsClient struct { - internal *arm.Client -} - -// NewRoleDefinitionsClient creates a new instance of RoleDefinitionsClient with the specified values. -// - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. -func NewRoleDefinitionsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*RoleDefinitionsClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &RoleDefinitionsClient{ - internal: cl, - } - return client, nil -} - -// GetByBillingAccount - Gets the definition for a role on a billing account. The operation is supported for billing accounts -// with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-05-01 -// - billingAccountName - The ID that uniquely identifies a billing account. -// - billingRoleDefinitionName - The ID that uniquely identifies a role definition. -// - options - RoleDefinitionsClientGetByBillingAccountOptions contains the optional parameters for the RoleDefinitionsClient.GetByBillingAccount -// method. -func (client *RoleDefinitionsClient) GetByBillingAccount(ctx context.Context, billingAccountName string, billingRoleDefinitionName string, options *RoleDefinitionsClientGetByBillingAccountOptions) (RoleDefinitionsClientGetByBillingAccountResponse, error) { - var err error - const operationName = "RoleDefinitionsClient.GetByBillingAccount" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getByBillingAccountCreateRequest(ctx, billingAccountName, billingRoleDefinitionName, options) - if err != nil { - return RoleDefinitionsClientGetByBillingAccountResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return RoleDefinitionsClientGetByBillingAccountResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return RoleDefinitionsClientGetByBillingAccountResponse{}, err - } - resp, err := client.getByBillingAccountHandleResponse(httpResp) - return resp, err -} - -// getByBillingAccountCreateRequest creates the GetByBillingAccount request. -func (client *RoleDefinitionsClient) getByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, billingRoleDefinitionName string, options *RoleDefinitionsClientGetByBillingAccountOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/{billingRoleDefinitionName}" - if billingAccountName == "" { - return nil, errors.New("parameter billingAccountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) - if billingRoleDefinitionName == "" { - return nil, errors.New("parameter billingRoleDefinitionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingRoleDefinitionName}", url.PathEscape(billingRoleDefinitionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getByBillingAccountHandleResponse handles the GetByBillingAccount response. -func (client *RoleDefinitionsClient) getByBillingAccountHandleResponse(resp *http.Response) (RoleDefinitionsClientGetByBillingAccountResponse, error) { - result := RoleDefinitionsClientGetByBillingAccountResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinition); err != nil { - return RoleDefinitionsClientGetByBillingAccountResponse{}, err - } - return result, nil -} - -// GetByBillingProfile - Gets the definition for a role on a billing profile. The operation is supported for billing accounts -// with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-05-01 -// - billingAccountName - The ID that uniquely identifies a billing account. -// - billingProfileName - The ID that uniquely identifies a billing profile. -// - billingRoleDefinitionName - The ID that uniquely identifies a role definition. -// - options - RoleDefinitionsClientGetByBillingProfileOptions contains the optional parameters for the RoleDefinitionsClient.GetByBillingProfile -// method. -func (client *RoleDefinitionsClient) GetByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleDefinitionName string, options *RoleDefinitionsClientGetByBillingProfileOptions) (RoleDefinitionsClientGetByBillingProfileResponse, error) { - var err error - const operationName = "RoleDefinitionsClient.GetByBillingProfile" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, billingRoleDefinitionName, options) - if err != nil { - return RoleDefinitionsClientGetByBillingProfileResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return RoleDefinitionsClientGetByBillingProfileResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return RoleDefinitionsClientGetByBillingProfileResponse{}, err - } - resp, err := client.getByBillingProfileHandleResponse(httpResp) - return resp, err -} - -// getByBillingProfileCreateRequest creates the GetByBillingProfile request. -func (client *RoleDefinitionsClient) getByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleDefinitionName string, options *RoleDefinitionsClientGetByBillingProfileOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleDefinitions/{billingRoleDefinitionName}" - if billingAccountName == "" { - return nil, errors.New("parameter billingAccountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) - if billingProfileName == "" { - return nil, errors.New("parameter billingProfileName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) - if billingRoleDefinitionName == "" { - return nil, errors.New("parameter billingRoleDefinitionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingRoleDefinitionName}", url.PathEscape(billingRoleDefinitionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getByBillingProfileHandleResponse handles the GetByBillingProfile response. -func (client *RoleDefinitionsClient) getByBillingProfileHandleResponse(resp *http.Response) (RoleDefinitionsClientGetByBillingProfileResponse, error) { - result := RoleDefinitionsClientGetByBillingProfileResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinition); err != nil { - return RoleDefinitionsClientGetByBillingProfileResponse{}, err - } - return result, nil -} - -// GetByInvoiceSection - Gets the definition for a role on an invoice section. The operation is supported only for billing -// accounts with agreement type Microsoft Customer Agreement. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-05-01 -// - billingAccountName - The ID that uniquely identifies a billing account. -// - billingProfileName - The ID that uniquely identifies a billing profile. -// - invoiceSectionName - The ID that uniquely identifies an invoice section. -// - billingRoleDefinitionName - The ID that uniquely identifies a role definition. -// - options - RoleDefinitionsClientGetByInvoiceSectionOptions contains the optional parameters for the RoleDefinitionsClient.GetByInvoiceSection -// method. -func (client *RoleDefinitionsClient) GetByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, billingRoleDefinitionName string, options *RoleDefinitionsClientGetByInvoiceSectionOptions) (RoleDefinitionsClientGetByInvoiceSectionResponse, error) { - var err error - const operationName = "RoleDefinitionsClient.GetByInvoiceSection" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getByInvoiceSectionCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, billingRoleDefinitionName, options) - if err != nil { - return RoleDefinitionsClientGetByInvoiceSectionResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return RoleDefinitionsClientGetByInvoiceSectionResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return RoleDefinitionsClientGetByInvoiceSectionResponse{}, err - } - resp, err := client.getByInvoiceSectionHandleResponse(httpResp) - return resp, err -} - -// getByInvoiceSectionCreateRequest creates the GetByInvoiceSection request. -func (client *RoleDefinitionsClient) getByInvoiceSectionCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, billingRoleDefinitionName string, options *RoleDefinitionsClientGetByInvoiceSectionOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleDefinitions/{billingRoleDefinitionName}" - if billingAccountName == "" { - return nil, errors.New("parameter billingAccountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) - if billingProfileName == "" { - return nil, errors.New("parameter billingProfileName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) - if invoiceSectionName == "" { - return nil, errors.New("parameter invoiceSectionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) - if billingRoleDefinitionName == "" { - return nil, errors.New("parameter billingRoleDefinitionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingRoleDefinitionName}", url.PathEscape(billingRoleDefinitionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getByInvoiceSectionHandleResponse handles the GetByInvoiceSection response. -func (client *RoleDefinitionsClient) getByInvoiceSectionHandleResponse(resp *http.Response) (RoleDefinitionsClientGetByInvoiceSectionResponse, error) { - result := RoleDefinitionsClientGetByInvoiceSectionResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinition); err != nil { - return RoleDefinitionsClientGetByInvoiceSectionResponse{}, err - } - return result, nil -} - -// NewListByBillingAccountPager - Lists the role definitions for a billing account. The operation is supported for billing -// accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. -// -// Generated from API version 2020-05-01 -// - billingAccountName - The ID that uniquely identifies a billing account. -// - options - RoleDefinitionsClientListByBillingAccountOptions contains the optional parameters for the RoleDefinitionsClient.NewListByBillingAccountPager -// method. -func (client *RoleDefinitionsClient) NewListByBillingAccountPager(billingAccountName string, options *RoleDefinitionsClientListByBillingAccountOptions) *runtime.Pager[RoleDefinitionsClientListByBillingAccountResponse] { - return runtime.NewPager(runtime.PagingHandler[RoleDefinitionsClientListByBillingAccountResponse]{ - More: func(page RoleDefinitionsClientListByBillingAccountResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *RoleDefinitionsClientListByBillingAccountResponse) (RoleDefinitionsClientListByBillingAccountResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RoleDefinitionsClient.NewListByBillingAccountPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listByBillingAccountCreateRequest(ctx, billingAccountName, options) - }, nil) - if err != nil { - return RoleDefinitionsClientListByBillingAccountResponse{}, err - } - return client.listByBillingAccountHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listByBillingAccountCreateRequest creates the ListByBillingAccount request. -func (client *RoleDefinitionsClient) listByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, options *RoleDefinitionsClientListByBillingAccountOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions" - if billingAccountName == "" { - return nil, errors.New("parameter billingAccountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByBillingAccountHandleResponse handles the ListByBillingAccount response. -func (client *RoleDefinitionsClient) listByBillingAccountHandleResponse(resp *http.Response) (RoleDefinitionsClientListByBillingAccountResponse, error) { - result := RoleDefinitionsClientListByBillingAccountResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinitionListResult); err != nil { - return RoleDefinitionsClientListByBillingAccountResponse{}, err - } - return result, nil -} - -// NewListByBillingProfilePager - Lists the role definitions for a billing profile. The operation is supported for billing -// accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. -// -// Generated from API version 2020-05-01 -// - billingAccountName - The ID that uniquely identifies a billing account. -// - billingProfileName - The ID that uniquely identifies a billing profile. -// - options - RoleDefinitionsClientListByBillingProfileOptions contains the optional parameters for the RoleDefinitionsClient.NewListByBillingProfilePager -// method. -func (client *RoleDefinitionsClient) NewListByBillingProfilePager(billingAccountName string, billingProfileName string, options *RoleDefinitionsClientListByBillingProfileOptions) *runtime.Pager[RoleDefinitionsClientListByBillingProfileResponse] { - return runtime.NewPager(runtime.PagingHandler[RoleDefinitionsClientListByBillingProfileResponse]{ - More: func(page RoleDefinitionsClientListByBillingProfileResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *RoleDefinitionsClientListByBillingProfileResponse) (RoleDefinitionsClientListByBillingProfileResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RoleDefinitionsClient.NewListByBillingProfilePager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, options) - }, nil) - if err != nil { - return RoleDefinitionsClientListByBillingProfileResponse{}, err - } - return client.listByBillingProfileHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listByBillingProfileCreateRequest creates the ListByBillingProfile request. -func (client *RoleDefinitionsClient) listByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, options *RoleDefinitionsClientListByBillingProfileOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleDefinitions" - if billingAccountName == "" { - return nil, errors.New("parameter billingAccountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) - if billingProfileName == "" { - return nil, errors.New("parameter billingProfileName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByBillingProfileHandleResponse handles the ListByBillingProfile response. -func (client *RoleDefinitionsClient) listByBillingProfileHandleResponse(resp *http.Response) (RoleDefinitionsClientListByBillingProfileResponse, error) { - result := RoleDefinitionsClientListByBillingProfileResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinitionListResult); err != nil { - return RoleDefinitionsClientListByBillingProfileResponse{}, err - } - return result, nil -} - -// NewListByInvoiceSectionPager - Lists the role definitions for an invoice section. The operation is supported for billing -// accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. -// -// Generated from API version 2020-05-01 -// - billingAccountName - The ID that uniquely identifies a billing account. -// - billingProfileName - The ID that uniquely identifies a billing profile. -// - invoiceSectionName - The ID that uniquely identifies an invoice section. -// - options - RoleDefinitionsClientListByInvoiceSectionOptions contains the optional parameters for the RoleDefinitionsClient.NewListByInvoiceSectionPager -// method. -func (client *RoleDefinitionsClient) NewListByInvoiceSectionPager(billingAccountName string, billingProfileName string, invoiceSectionName string, options *RoleDefinitionsClientListByInvoiceSectionOptions) *runtime.Pager[RoleDefinitionsClientListByInvoiceSectionResponse] { - return runtime.NewPager(runtime.PagingHandler[RoleDefinitionsClientListByInvoiceSectionResponse]{ - More: func(page RoleDefinitionsClientListByInvoiceSectionResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *RoleDefinitionsClientListByInvoiceSectionResponse) (RoleDefinitionsClientListByInvoiceSectionResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RoleDefinitionsClient.NewListByInvoiceSectionPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listByInvoiceSectionCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, options) - }, nil) - if err != nil { - return RoleDefinitionsClientListByInvoiceSectionResponse{}, err - } - return client.listByInvoiceSectionHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listByInvoiceSectionCreateRequest creates the ListByInvoiceSection request. -func (client *RoleDefinitionsClient) listByInvoiceSectionCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, options *RoleDefinitionsClientListByInvoiceSectionOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleDefinitions" - if billingAccountName == "" { - return nil, errors.New("parameter billingAccountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) - if billingProfileName == "" { - return nil, errors.New("parameter billingProfileName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) - if invoiceSectionName == "" { - return nil, errors.New("parameter invoiceSectionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByInvoiceSectionHandleResponse handles the ListByInvoiceSection response. -func (client *RoleDefinitionsClient) listByInvoiceSectionHandleResponse(resp *http.Response) (RoleDefinitionsClientListByInvoiceSectionResponse, error) { - result := RoleDefinitionsClientListByInvoiceSectionResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinitionListResult); err != nil { - return RoleDefinitionsClientListByInvoiceSectionResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/billing/armbilling/roledefinitions_client_example_test.go b/sdk/resourcemanager/billing/armbilling/roledefinitions_client_example_test.go deleted file mode 100644 index 77324dcf0180..000000000000 --- a/sdk/resourcemanager/billing/armbilling/roledefinitions_client_example_test.go +++ /dev/null @@ -1,508 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armbilling_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingAccountRoleDefinition.json -func ExampleRoleDefinitionsClient_GetByBillingAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbilling.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewRoleDefinitionsClient().GetByBillingAccount(ctx, "{billingAccountName}", "{billingRoleDefinitionName}", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.RoleDefinition = armbilling.RoleDefinition{ - // Name: to.Ptr("{billingRoleDefinitionName}"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingRoleDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/{billingRoleDefinitionName}"), - // Properties: &armbilling.RoleDefinitionProperties{ - // Description: to.Ptr("The Owner role gives the user all permissions including access management rights to the billing account."), - // Permissions: []*armbilling.PermissionsProperties{ - // { - // Actions: []*string{ - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000008"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000001"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000002"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000003"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("20000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000009"), - // to.Ptr("20000000-aaaa-bbbb-cccc-200000000002"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008")}, - // NotActions: []*string{ - // }, - // }}, - // RoleName: to.Ptr("Billing acount owner"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/InvoiceSectionRoleDefinition.json -func ExampleRoleDefinitionsClient_GetByInvoiceSection() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbilling.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewRoleDefinitionsClient().GetByInvoiceSection(ctx, "{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", "{billingRoleDefinitionName}", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.RoleDefinition = armbilling.RoleDefinition{ - // Name: to.Ptr("{billingRoleDefinitionName}"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections/billingRoleDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleDefinitions/{billingRoleDefinitionName}"), - // Properties: &armbilling.RoleDefinitionProperties{ - // Description: to.Ptr("The Owner role gives the user all permissions including access management rights to the invoice section."), - // Permissions: []*armbilling.PermissionsProperties{ - // { - // Actions: []*string{ - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000008"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000001"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000002"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000003"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("20000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000009"), - // to.Ptr("20000000-aaaa-bbbb-cccc-200000000002"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008")}, - // NotActions: []*string{ - // }, - // }}, - // RoleName: to.Ptr("Invoice section owner"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingProfileRoleDefinition.json -func ExampleRoleDefinitionsClient_GetByBillingProfile() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbilling.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewRoleDefinitionsClient().GetByBillingProfile(ctx, "{billingAccountName}", "{billingProfileName}", "{billingRoleDefinitionName}", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.RoleDefinition = armbilling.RoleDefinition{ - // Name: to.Ptr("{billingRoleDefinitionName}"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/billingRoleDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleDefinitions/{billingRoleDefinitionName}"), - // Properties: &armbilling.RoleDefinitionProperties{ - // Description: to.Ptr("The Owner role gives the user all permissions including access management rights to the billing profile."), - // Permissions: []*armbilling.PermissionsProperties{ - // { - // Actions: []*string{ - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000008"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000001"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000002"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000003"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("20000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000009"), - // to.Ptr("20000000-aaaa-bbbb-cccc-200000000002"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008")}, - // NotActions: []*string{ - // }, - // }}, - // RoleName: to.Ptr("Billing profile owner"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingAccountRoleDefinitionsList.json -func ExampleRoleDefinitionsClient_NewListByBillingAccountPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbilling.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewRoleDefinitionsClient().NewListByBillingAccountPager("{billingAccountName}", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.RoleDefinitionListResult = armbilling.RoleDefinitionListResult{ - // Value: []*armbilling.RoleDefinition{ - // { - // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingRoleDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/10000000-aaaa-bbbb-cccc-100000000000"), - // Properties: &armbilling.RoleDefinitionProperties{ - // Description: to.Ptr("The Owner role gives the user all permissions including access management rights to the billing account."), - // Permissions: []*armbilling.PermissionsProperties{ - // { - // Actions: []*string{ - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000008"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000001"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000002"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000003"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("20000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000009"), - // to.Ptr("20000000-aaaa-bbbb-cccc-200000000002"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008")}, - // NotActions: []*string{ - // }, - // }}, - // RoleName: to.Ptr("Billing account owner"), - // }, - // }, - // { - // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000001"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingRoleDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/10000000-aaaa-bbbb-cccc-100000000001"), - // Properties: &armbilling.RoleDefinitionProperties{ - // Description: to.Ptr("The Contributor role give the user all permissions except access management rights to the billing account."), - // Permissions: []*armbilling.PermissionsProperties{ - // { - // Actions: []*string{ - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000008"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000001"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000002"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000003"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000009"), - // to.Ptr("20000000-aaaa-bbbb-cccc-200000000002"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008")}, - // NotActions: []*string{ - // }, - // }}, - // RoleName: to.Ptr("Billing account contributor"), - // }, - // }, - // { - // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000002"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingRoleDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/10000000-aaaa-bbbb-cccc-100000000002"), - // Properties: &armbilling.RoleDefinitionProperties{ - // Description: to.Ptr("The Reader role gives the user read only access to the billing account."), - // Permissions: []*armbilling.PermissionsProperties{ - // { - // Actions: []*string{ - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000008"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000003"), - // to.Ptr("20000000-aaaa-bbbb-cccc-200000000002"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008")}, - // NotActions: []*string{ - // }, - // }}, - // RoleName: to.Ptr("Billing account reader"), - // }, - // }, - // { - // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000003"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingRoleDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/10000000-aaaa-bbbb-cccc-100000000003"), - // Properties: &armbilling.RoleDefinitionProperties{ - // Description: to.Ptr("The Signatory role can sign agreements on behalf of the customer."), - // Permissions: []*armbilling.PermissionsProperties{ - // { - // Actions: []*string{ - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000002"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000003")}, - // NotActions: []*string{ - // }, - // }}, - // RoleName: to.Ptr("Signatory"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/InvoiceSectionRoleDefinitionsList.json -func ExampleRoleDefinitionsClient_NewListByInvoiceSectionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbilling.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewRoleDefinitionsClient().NewListByInvoiceSectionPager("{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.RoleDefinitionListResult = armbilling.RoleDefinitionListResult{ - // Value: []*armbilling.RoleDefinition{ - // { - // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections/billingRoleDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleDefinitions/10000000-aaaa-bbbb-cccc-100000000000"), - // Properties: &armbilling.RoleDefinitionProperties{ - // Description: to.Ptr("The Owner role gives the user all permissions including access management rights to the invoice section."), - // Permissions: []*armbilling.PermissionsProperties{ - // { - // Actions: []*string{ - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000008"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000001"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000002"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000003"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("20000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000009"), - // to.Ptr("20000000-aaaa-bbbb-cccc-200000000002"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008")}, - // NotActions: []*string{ - // }, - // }}, - // RoleName: to.Ptr("Invoice section owner"), - // }, - // }, - // { - // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000001"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections/billingRoleDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleDefinitions/10000000-aaaa-bbbb-cccc-100000000001"), - // Properties: &armbilling.RoleDefinitionProperties{ - // Description: to.Ptr("The Contributor role give the user all permissions except access management rights to the invoice section."), - // Permissions: []*armbilling.PermissionsProperties{ - // { - // Actions: []*string{ - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000008"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000001"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000002"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000003"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000009"), - // to.Ptr("20000000-aaaa-bbbb-cccc-200000000002"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008")}, - // NotActions: []*string{ - // }, - // }}, - // RoleName: to.Ptr("Invoice section contributor"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingProfileRoleDefinitionsList.json -func ExampleRoleDefinitionsClient_NewListByBillingProfilePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbilling.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewRoleDefinitionsClient().NewListByBillingProfilePager("{billingAccountName}", "{billingProfileName}", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.RoleDefinitionListResult = armbilling.RoleDefinitionListResult{ - // Value: []*armbilling.RoleDefinition{ - // { - // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000000"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/billingRoleDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleDefinitions/10000000-aaaa-bbbb-cccc-100000000000"), - // Properties: &armbilling.RoleDefinitionProperties{ - // Description: to.Ptr("The Owner role gives the user all permissions including access management rights to the billing profile."), - // Permissions: []*armbilling.PermissionsProperties{ - // { - // Actions: []*string{ - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000008"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000001"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000002"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000003"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("20000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000000"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000009"), - // to.Ptr("20000000-aaaa-bbbb-cccc-200000000002"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008")}, - // NotActions: []*string{ - // }, - // }}, - // RoleName: to.Ptr("Billing profile owner"), - // }, - // }, - // { - // Name: to.Ptr("10000000-aaaa-bbbb-cccc-100000000001"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/billingRoleDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleDefinitions/10000000-aaaa-bbbb-cccc-100000000001"), - // Properties: &armbilling.RoleDefinitionProperties{ - // Description: to.Ptr("The Contributor role give the user all permissions except access management rights to the billing profile."), - // Permissions: []*armbilling.PermissionsProperties{ - // { - // Actions: []*string{ - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000008"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000001"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000002"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000003"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("10000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000009"), - // to.Ptr("20000000-aaaa-bbbb-cccc-200000000002"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000015"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000004"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000001"), - // to.Ptr("30000000-aaaa-bbbb-cccc-200000000010"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000007"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000006"), - // to.Ptr("40000000-aaaa-bbbb-cccc-200000000008")}, - // NotActions: []*string{ - // }, - // }}, - // RoleName: to.Ptr("Billing profile contributor"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/billing/armbilling/savingsplanorders_client.go b/sdk/resourcemanager/billing/armbilling/savingsplanorders_client.go new file mode 100644 index 000000000000..c0595a028a08 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/savingsplanorders_client.go @@ -0,0 +1,172 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armbilling + +import ( + "context" + "errors" + "net/http" + "net/url" + "strconv" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// SavingsPlanOrdersClient contains the methods for the SavingsPlanOrders group. +// Don't use this type directly, use NewSavingsPlanOrdersClient() instead. +type SavingsPlanOrdersClient struct { + internal *arm.Client +} + +// NewSavingsPlanOrdersClient creates a new instance of SavingsPlanOrdersClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewSavingsPlanOrdersClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*SavingsPlanOrdersClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &SavingsPlanOrdersClient{ + internal: cl, + } + return client, nil +} + +// GetByBillingAccount - Get a savings plan order by billing account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - savingsPlanOrderID - Order ID of the savings plan +// - options - SavingsPlanOrdersClientGetByBillingAccountOptions contains the optional parameters for the SavingsPlanOrdersClient.GetByBillingAccount +// method. +func (client *SavingsPlanOrdersClient) GetByBillingAccount(ctx context.Context, billingAccountName string, savingsPlanOrderID string, options *SavingsPlanOrdersClientGetByBillingAccountOptions) (SavingsPlanOrdersClientGetByBillingAccountResponse, error) { + var err error + const operationName = "SavingsPlanOrdersClient.GetByBillingAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByBillingAccountCreateRequest(ctx, billingAccountName, savingsPlanOrderID, options) + if err != nil { + return SavingsPlanOrdersClientGetByBillingAccountResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SavingsPlanOrdersClientGetByBillingAccountResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SavingsPlanOrdersClientGetByBillingAccountResponse{}, err + } + resp, err := client.getByBillingAccountHandleResponse(httpResp) + return resp, err +} + +// getByBillingAccountCreateRequest creates the GetByBillingAccount request. +func (client *SavingsPlanOrdersClient) getByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, savingsPlanOrderID string, options *SavingsPlanOrdersClientGetByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/savingsPlanOrders/{savingsPlanOrderId}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if savingsPlanOrderID == "" { + return nil, errors.New("parameter savingsPlanOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanOrderId}", url.PathEscape(savingsPlanOrderID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Expand != nil { + reqQP.Set("expand", *options.Expand) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByBillingAccountHandleResponse handles the GetByBillingAccount response. +func (client *SavingsPlanOrdersClient) getByBillingAccountHandleResponse(resp *http.Response) (SavingsPlanOrdersClientGetByBillingAccountResponse, error) { + result := SavingsPlanOrdersClientGetByBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SavingsPlanOrderModel); err != nil { + return SavingsPlanOrdersClientGetByBillingAccountResponse{}, err + } + return result, nil +} + +// NewListByBillingAccountPager - List all Savings plan orders by billing account. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - options - SavingsPlanOrdersClientListByBillingAccountOptions contains the optional parameters for the SavingsPlanOrdersClient.NewListByBillingAccountPager +// method. +func (client *SavingsPlanOrdersClient) NewListByBillingAccountPager(billingAccountName string, options *SavingsPlanOrdersClientListByBillingAccountOptions) *runtime.Pager[SavingsPlanOrdersClientListByBillingAccountResponse] { + return runtime.NewPager(runtime.PagingHandler[SavingsPlanOrdersClientListByBillingAccountResponse]{ + More: func(page SavingsPlanOrdersClientListByBillingAccountResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SavingsPlanOrdersClientListByBillingAccountResponse) (SavingsPlanOrdersClientListByBillingAccountResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SavingsPlanOrdersClient.NewListByBillingAccountPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByBillingAccountCreateRequest(ctx, billingAccountName, options) + }, nil) + if err != nil { + return SavingsPlanOrdersClientListByBillingAccountResponse{}, err + } + return client.listByBillingAccountHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByBillingAccountCreateRequest creates the ListByBillingAccount request. +func (client *SavingsPlanOrdersClient) listByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, options *SavingsPlanOrdersClientListByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/savingsPlanOrders" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Skiptoken != nil { + reqQP.Set("skiptoken", strconv.FormatFloat(float64(*options.Skiptoken), 'f', -1, 32)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByBillingAccountHandleResponse handles the ListByBillingAccount response. +func (client *SavingsPlanOrdersClient) listByBillingAccountHandleResponse(resp *http.Response) (SavingsPlanOrdersClientListByBillingAccountResponse, error) { + result := SavingsPlanOrdersClientListByBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SavingsPlanOrderModelList); err != nil { + return SavingsPlanOrdersClientListByBillingAccountResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/savingsplanorders_client_example_test.go b/sdk/resourcemanager/billing/armbilling/savingsplanorders_client_example_test.go new file mode 100644 index 000000000000..da89cd4117be --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/savingsplanorders_client_example_test.go @@ -0,0 +1,495 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armbilling_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanOrderGetByBillingAccount.json +func ExampleSavingsPlanOrdersClient_GetByBillingAccount_savingsPlanOrderGet() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSavingsPlanOrdersClient().GetByBillingAccount(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "20000000-0000-0000-0000-000000000000", &armbilling.SavingsPlanOrdersClientGetByBillingAccountOptions{Expand: nil}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SavingsPlanOrderModel = armbilling.SavingsPlanOrderModel{ + // Name: to.Ptr("20000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("microsoft.billing/billingAccounts/savingsPlanOrders"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/savingsPlanOrders/20000000-0000-0000-0000-000000000000"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armbilling.SavingsPlanOrderModelProperties{ + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-20T02:36:22.339Z"); return t}()), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingPlan: to.Ptr(armbilling.BillingPlanP1M), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/AAAA-BBBB-CCC-DDD"), + // BillingScopeID: to.Ptr("10000000-0000-0000-0000-000000000000"), + // DisplayName: to.Ptr("SP1"), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2026-01-20T02:36:22.339Z"); return t}()), + // ProductCode: to.Ptr("20000000-0000-0000-0000-000000000005"), + // ProvisioningState: to.Ptr("Succeeded"), + // SavingsPlans: []*string{ + // to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/20000000-0000-0000-0000-000000000000/savingsPlans/30000000-0000-0000-0000-000000000000")}, + // Term: to.Ptr(armbilling.SavingsPlanTermP3Y), + // }, + // SKU: &armbilling.SKU{ + // Name: to.Ptr("Compute_Savings_Plan"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanOrderExpandedScheduleGetByBillingAccount.json +func ExampleSavingsPlanOrdersClient_GetByBillingAccount_savingsPlanOrderWithExpandedPaymentsGet() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSavingsPlanOrdersClient().GetByBillingAccount(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "20000000-0000-0000-0000-000000000000", &armbilling.SavingsPlanOrdersClientGetByBillingAccountOptions{Expand: nil}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SavingsPlanOrderModel = armbilling.SavingsPlanOrderModel{ + // Name: to.Ptr("20000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("microsoft.billing/billingAccounts/savingsPlanOrders"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/savingsPlanOrders/20000000-0000-0000-0000-000000000000"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armbilling.SavingsPlanOrderModelProperties{ + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-20T02:36:22.339Z"); return t}()), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingPlan: to.Ptr(armbilling.BillingPlanP1M), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/AAAA-BBBB-CCC-DDD"), + // BillingScopeID: to.Ptr("10000000-0000-0000-0000-000000000000"), + // DisplayName: to.Ptr("SP1"), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2026-01-20T02:36:22.339Z"); return t}()), + // PlanInformation: &armbilling.PlanInformation{ + // NextPaymentDueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-02-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](26.28), + // CurrencyCode: to.Ptr("USD"), + // }, + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-01-20"); return t}()), + // Transactions: []*armbilling.PaymentDetail{ + // { + // BillingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-01-20"); return t}()), + // PaymentDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-01-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusCompleted), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-02-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-03-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-04-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-05-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-06-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-07-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-08-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-09-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-10-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-11-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-12-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-01-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-02-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-03-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-04-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-05-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-06-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-07-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-08-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-09-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-10-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-11-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-12-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2025-01-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2025-02-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2025-03-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2025-04-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2025-05-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2025-06-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2025-07-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2025-08-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2025-09-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2025-10-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2025-11-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }, + // { + // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2025-12-20"); return t}()), + // PricingCurrencyTotal: &armbilling.Price{ + // Amount: to.Ptr[float64](0.73), + // CurrencyCode: to.Ptr("USD"), + // }, + // Status: to.Ptr(armbilling.PaymentStatusScheduled), + // }}, + // }, + // ProductCode: to.Ptr("20000000-0000-0000-0000-000000000005"), + // ProvisioningState: to.Ptr("Succeeded"), + // SavingsPlans: []*string{ + // to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/20000000-0000-0000-0000-000000000000/savingsPlans/30000000-0000-0000-0000-000000000000")}, + // Term: to.Ptr(armbilling.SavingsPlanTermP3Y), + // }, + // SKU: &armbilling.SKU{ + // Name: to.Ptr("Compute_Savings_Plan"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanOrderListByBillingAccount.json +func ExampleSavingsPlanOrdersClient_NewListByBillingAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSavingsPlanOrdersClient().NewListByBillingAccountPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", &armbilling.SavingsPlanOrdersClientListByBillingAccountOptions{Filter: nil, + OrderBy: nil, + Skiptoken: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.SavingsPlanOrderModelList = armbilling.SavingsPlanOrderModelList{ + // Value: []*armbilling.SavingsPlanOrderModel{ + // { + // Name: to.Ptr("20000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("microsoft.billing/billingAccounts/savingsPlanOrders"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/savingsPlanOrders/20000000-0000-0000-0000-000000000000"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armbilling.SavingsPlanOrderModelProperties{ + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-04T03:18:31.307Z"); return t}()), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingPlan: to.Ptr(armbilling.BillingPlanP1M), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/AAAA-BBBB-CCC-DDD"), + // BillingScopeID: to.Ptr("10000000-0000-0000-0000-000000000000"), + // DisplayName: to.Ptr("SP1"), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2026-02-04T03:18:31.307Z"); return t}()), + // ProductCode: to.Ptr("20000000-0000-0000-0000-000000000005"), + // ProvisioningState: to.Ptr("Succeeded"), + // SavingsPlans: []*string{ + // to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/20000000-0000-0000-0000-000000000000/savingsPlans/30000000-0000-0000-0000-000000000000")}, + // Term: to.Ptr(armbilling.SavingsPlanTermP3Y), + // }, + // SKU: &armbilling.SKU{ + // Name: to.Ptr("Compute_Savings_Plan"), + // }, + // }, + // { + // Name: to.Ptr("20000000-0000-0000-0000-000000000001"), + // Type: to.Ptr("microsoft.billing/billingAccounts/savingsPlanOrders"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/savingsPlanOrders/20000000-0000-0000-0000-000000000001"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armbilling.SavingsPlanOrderModelProperties{ + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-04T03:22:19.730Z"); return t}()), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingPlan: to.Ptr(armbilling.BillingPlanP1M), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/AAAA-BBBB-CCC-DDD"), + // BillingScopeID: to.Ptr("10000000-0000-0000-0000-000000000000"), + // DisplayName: to.Ptr("SP2"), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2026-02-04T03:22:19.730Z"); return t}()), + // ProductCode: to.Ptr("20000000-0000-0000-0000-000000000005"), + // ProvisioningState: to.Ptr("Succeeded"), + // SavingsPlans: []*string{ + // to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/20000000-0000-0000-0000-000000000001/savingsPlans/30000000-0000-0000-0000-000000000001")}, + // Term: to.Ptr(armbilling.SavingsPlanTermP3Y), + // }, + // SKU: &armbilling.SKU{ + // Name: to.Ptr("Compute_Savings_Plan"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/billing/armbilling/savingsplans_client.go b/sdk/resourcemanager/billing/armbilling/savingsplans_client.go new file mode 100644 index 000000000000..556a45de9be2 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/savingsplans_client.go @@ -0,0 +1,399 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armbilling + +import ( + "context" + "errors" + "net/http" + "net/url" + "strconv" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// SavingsPlansClient contains the methods for the SavingsPlans group. +// Don't use this type directly, use NewSavingsPlansClient() instead. +type SavingsPlansClient struct { + internal *arm.Client +} + +// NewSavingsPlansClient creates a new instance of SavingsPlansClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewSavingsPlansClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*SavingsPlansClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &SavingsPlansClient{ + internal: cl, + } + return client, nil +} + +// GetByBillingAccount - Get savings plan by billing account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - savingsPlanOrderID - Order ID of the savings plan +// - savingsPlanID - ID of the savings plan +// - options - SavingsPlansClientGetByBillingAccountOptions contains the optional parameters for the SavingsPlansClient.GetByBillingAccount +// method. +func (client *SavingsPlansClient) GetByBillingAccount(ctx context.Context, billingAccountName string, savingsPlanOrderID string, savingsPlanID string, options *SavingsPlansClientGetByBillingAccountOptions) (SavingsPlansClientGetByBillingAccountResponse, error) { + var err error + const operationName = "SavingsPlansClient.GetByBillingAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByBillingAccountCreateRequest(ctx, billingAccountName, savingsPlanOrderID, savingsPlanID, options) + if err != nil { + return SavingsPlansClientGetByBillingAccountResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SavingsPlansClientGetByBillingAccountResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SavingsPlansClientGetByBillingAccountResponse{}, err + } + resp, err := client.getByBillingAccountHandleResponse(httpResp) + return resp, err +} + +// getByBillingAccountCreateRequest creates the GetByBillingAccount request. +func (client *SavingsPlansClient) getByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, savingsPlanOrderID string, savingsPlanID string, options *SavingsPlansClientGetByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans/{savingsPlanId}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if savingsPlanOrderID == "" { + return nil, errors.New("parameter savingsPlanOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanOrderId}", url.PathEscape(savingsPlanOrderID)) + if savingsPlanID == "" { + return nil, errors.New("parameter savingsPlanID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanId}", url.PathEscape(savingsPlanID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Expand != nil { + reqQP.Set("expand", *options.Expand) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByBillingAccountHandleResponse handles the GetByBillingAccount response. +func (client *SavingsPlansClient) getByBillingAccountHandleResponse(resp *http.Response) (SavingsPlansClientGetByBillingAccountResponse, error) { + result := SavingsPlansClientGetByBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SavingsPlanModel); err != nil { + return SavingsPlansClientGetByBillingAccountResponse{}, err + } + return result, nil +} + +// NewListByBillingAccountPager - List savings plans by billing account. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - options - SavingsPlansClientListByBillingAccountOptions contains the optional parameters for the SavingsPlansClient.NewListByBillingAccountPager +// method. +func (client *SavingsPlansClient) NewListByBillingAccountPager(billingAccountName string, options *SavingsPlansClientListByBillingAccountOptions) *runtime.Pager[SavingsPlansClientListByBillingAccountResponse] { + return runtime.NewPager(runtime.PagingHandler[SavingsPlansClientListByBillingAccountResponse]{ + More: func(page SavingsPlansClientListByBillingAccountResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SavingsPlansClientListByBillingAccountResponse) (SavingsPlansClientListByBillingAccountResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SavingsPlansClient.NewListByBillingAccountPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByBillingAccountCreateRequest(ctx, billingAccountName, options) + }, nil) + if err != nil { + return SavingsPlansClientListByBillingAccountResponse{}, err + } + return client.listByBillingAccountHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByBillingAccountCreateRequest creates the ListByBillingAccount request. +func (client *SavingsPlansClient) listByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, options *SavingsPlansClientListByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/savingsPlans" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.RefreshSummary != nil { + reqQP.Set("refreshSummary", *options.RefreshSummary) + } + if options != nil && options.SelectedState != nil { + reqQP.Set("selectedState", *options.SelectedState) + } + if options != nil && options.Skiptoken != nil { + reqQP.Set("skiptoken", strconv.FormatFloat(float64(*options.Skiptoken), 'f', -1, 32)) + } + if options != nil && options.Take != nil { + reqQP.Set("take", strconv.FormatFloat(float64(*options.Take), 'f', -1, 32)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByBillingAccountHandleResponse handles the ListByBillingAccount response. +func (client *SavingsPlansClient) listByBillingAccountHandleResponse(resp *http.Response) (SavingsPlansClientListByBillingAccountResponse, error) { + result := SavingsPlansClientListByBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SavingsPlanModelListResult); err != nil { + return SavingsPlansClientListByBillingAccountResponse{}, err + } + return result, nil +} + +// NewListBySavingsPlanOrderPager - List savings plans in an order by billing account. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - savingsPlanOrderID - Order ID of the savings plan +// - options - SavingsPlansClientListBySavingsPlanOrderOptions contains the optional parameters for the SavingsPlansClient.NewListBySavingsPlanOrderPager +// method. +func (client *SavingsPlansClient) NewListBySavingsPlanOrderPager(billingAccountName string, savingsPlanOrderID string, options *SavingsPlansClientListBySavingsPlanOrderOptions) *runtime.Pager[SavingsPlansClientListBySavingsPlanOrderResponse] { + return runtime.NewPager(runtime.PagingHandler[SavingsPlansClientListBySavingsPlanOrderResponse]{ + More: func(page SavingsPlansClientListBySavingsPlanOrderResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SavingsPlansClientListBySavingsPlanOrderResponse) (SavingsPlansClientListBySavingsPlanOrderResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SavingsPlansClient.NewListBySavingsPlanOrderPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBySavingsPlanOrderCreateRequest(ctx, billingAccountName, savingsPlanOrderID, options) + }, nil) + if err != nil { + return SavingsPlansClientListBySavingsPlanOrderResponse{}, err + } + return client.listBySavingsPlanOrderHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySavingsPlanOrderCreateRequest creates the ListBySavingsPlanOrder request. +func (client *SavingsPlansClient) listBySavingsPlanOrderCreateRequest(ctx context.Context, billingAccountName string, savingsPlanOrderID string, options *SavingsPlansClientListBySavingsPlanOrderOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if savingsPlanOrderID == "" { + return nil, errors.New("parameter savingsPlanOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanOrderId}", url.PathEscape(savingsPlanOrderID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySavingsPlanOrderHandleResponse handles the ListBySavingsPlanOrder response. +func (client *SavingsPlansClient) listBySavingsPlanOrderHandleResponse(resp *http.Response) (SavingsPlansClientListBySavingsPlanOrderResponse, error) { + result := SavingsPlansClientListBySavingsPlanOrderResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SavingsPlanModelList); err != nil { + return SavingsPlansClientListBySavingsPlanOrderResponse{}, err + } + return result, nil +} + +// BeginUpdateByBillingAccount - Update savings plan by billing account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - savingsPlanOrderID - Order ID of the savings plan +// - savingsPlanID - ID of the savings plan +// - body - Request body for patching a savings plan order alias +// - options - SavingsPlansClientBeginUpdateByBillingAccountOptions contains the optional parameters for the SavingsPlansClient.BeginUpdateByBillingAccount +// method. +func (client *SavingsPlansClient) BeginUpdateByBillingAccount(ctx context.Context, billingAccountName string, savingsPlanOrderID string, savingsPlanID string, body SavingsPlanUpdateRequest, options *SavingsPlansClientBeginUpdateByBillingAccountOptions) (*runtime.Poller[SavingsPlansClientUpdateByBillingAccountResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.updateByBillingAccount(ctx, billingAccountName, savingsPlanOrderID, savingsPlanID, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SavingsPlansClientUpdateByBillingAccountResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[SavingsPlansClientUpdateByBillingAccountResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// UpdateByBillingAccount - Update savings plan by billing account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *SavingsPlansClient) updateByBillingAccount(ctx context.Context, billingAccountName string, savingsPlanOrderID string, savingsPlanID string, body SavingsPlanUpdateRequest, options *SavingsPlansClientBeginUpdateByBillingAccountOptions) (*http.Response, error) { + var err error + const operationName = "SavingsPlansClient.BeginUpdateByBillingAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateByBillingAccountCreateRequest(ctx, billingAccountName, savingsPlanOrderID, savingsPlanID, body, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateByBillingAccountCreateRequest creates the UpdateByBillingAccount request. +func (client *SavingsPlansClient) updateByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, savingsPlanOrderID string, savingsPlanID string, body SavingsPlanUpdateRequest, options *SavingsPlansClientBeginUpdateByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans/{savingsPlanId}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if savingsPlanOrderID == "" { + return nil, errors.New("parameter savingsPlanOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanOrderId}", url.PathEscape(savingsPlanOrderID)) + if savingsPlanID == "" { + return nil, errors.New("parameter savingsPlanID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanId}", url.PathEscape(savingsPlanID)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// ValidateUpdateByBillingAccount - Validate savings plan patch by billing account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - savingsPlanOrderID - Order ID of the savings plan +// - savingsPlanID - ID of the savings plan +// - body - Request body for patching a savings plan order alias +// - options - SavingsPlansClientValidateUpdateByBillingAccountOptions contains the optional parameters for the SavingsPlansClient.ValidateUpdateByBillingAccount +// method. +func (client *SavingsPlansClient) ValidateUpdateByBillingAccount(ctx context.Context, billingAccountName string, savingsPlanOrderID string, savingsPlanID string, body SavingsPlanUpdateValidateRequest, options *SavingsPlansClientValidateUpdateByBillingAccountOptions) (SavingsPlansClientValidateUpdateByBillingAccountResponse, error) { + var err error + const operationName = "SavingsPlansClient.ValidateUpdateByBillingAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.validateUpdateByBillingAccountCreateRequest(ctx, billingAccountName, savingsPlanOrderID, savingsPlanID, body, options) + if err != nil { + return SavingsPlansClientValidateUpdateByBillingAccountResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SavingsPlansClientValidateUpdateByBillingAccountResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SavingsPlansClientValidateUpdateByBillingAccountResponse{}, err + } + resp, err := client.validateUpdateByBillingAccountHandleResponse(httpResp) + return resp, err +} + +// validateUpdateByBillingAccountCreateRequest creates the ValidateUpdateByBillingAccount request. +func (client *SavingsPlansClient) validateUpdateByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, savingsPlanOrderID string, savingsPlanID string, body SavingsPlanUpdateValidateRequest, options *SavingsPlansClientValidateUpdateByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans/{savingsPlanId}/validate" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if savingsPlanOrderID == "" { + return nil, errors.New("parameter savingsPlanOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanOrderId}", url.PathEscape(savingsPlanOrderID)) + if savingsPlanID == "" { + return nil, errors.New("parameter savingsPlanID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanId}", url.PathEscape(savingsPlanID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// validateUpdateByBillingAccountHandleResponse handles the ValidateUpdateByBillingAccount response. +func (client *SavingsPlansClient) validateUpdateByBillingAccountHandleResponse(resp *http.Response) (SavingsPlansClientValidateUpdateByBillingAccountResponse, error) { + result := SavingsPlansClientValidateUpdateByBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SavingsPlanValidateResponse); err != nil { + return SavingsPlansClientValidateUpdateByBillingAccountResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/savingsplans_client_example_test.go b/sdk/resourcemanager/billing/armbilling/savingsplans_client_example_test.go new file mode 100644 index 000000000000..8897f7768b5a --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/savingsplans_client_example_test.go @@ -0,0 +1,707 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armbilling_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlansListBySavingsPlanOrders.json +func ExampleSavingsPlansClient_NewListBySavingsPlanOrderPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSavingsPlansClient().NewListBySavingsPlanOrderPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "20000000-0000-0000-0000-000000000000", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.SavingsPlanModelList = armbilling.SavingsPlanModelList{ + // Value: []*armbilling.SavingsPlanModel{ + // { + // Name: to.Ptr("30000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("microsoft.billing/billingAccounts/savingsPlanOrders/savingsPlans"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/savingsPlanOrders/20000000-0000-0000-0000-000000000000/savingsPlans/30000000-0000-0000-0000-000000000000"), + // Properties: &armbilling.SavingsPlanModelProperties{ + // AppliedScopeType: to.Ptr(armbilling.AppliedScopeTypeShared), + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-20T02:36:22.339Z"); return t}()), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingPlan: to.Ptr(armbilling.BillingPlanP1M), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/AAAA-BBBB-CCC-DDD"), + // BillingScopeID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000"), + // Commitment: &armbilling.Commitment{ + // Amount: to.Ptr[float64](0.001), + // CurrencyCode: to.Ptr("USD"), + // Grain: to.Ptr(armbilling.CommitmentGrainHourly), + // }, + // DisplayName: to.Ptr("SP1"), + // DisplayProvisioningState: to.Ptr("Succeeded"), + // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-20T02:36:25.089Z"); return t}()), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2026-01-20T02:36:22.339Z"); return t}()), + // ProvisioningState: to.Ptr(armbilling.ProvisioningStateSucceeded), + // PurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-20T02:34:38.126Z"); return t}()), + // Renew: to.Ptr(false), + // Term: to.Ptr(armbilling.SavingsPlanTermP3Y), + // UserFriendlyAppliedScopeType: to.Ptr("Shared"), + // Utilization: &armbilling.Utilization{ + // Aggregates: []*armbilling.UtilizationAggregates{ + // { + // Grain: to.Ptr[float32](1), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](7), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](30), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }}, + // Trend: to.Ptr("SAME"), + // }, + // }, + // SKU: &armbilling.SKU{ + // Name: to.Ptr("Compute_Savings_Plan"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlansListByBillingAccount.json +func ExampleSavingsPlansClient_NewListByBillingAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSavingsPlansClient().NewListByBillingAccountPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", &armbilling.SavingsPlansClientListByBillingAccountOptions{Filter: nil, + OrderBy: nil, + Skiptoken: nil, + Take: to.Ptr[float32](3), + SelectedState: to.Ptr("Succeeded"), + RefreshSummary: to.Ptr("true"), + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.SavingsPlanModelListResult = armbilling.SavingsPlanModelListResult{ + // Value: []*armbilling.SavingsPlanModel{ + // { + // Name: to.Ptr("30000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("microsoft.billing/billingAccounts/savingsPlanOrders/savingsPlans"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/savingsPlanOrders/20000000-0000-0000-0000-000000000000/savingsPlans/30000000-0000-0000-0000-000000000000"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armbilling.SavingsPlanModelProperties{ + // AppliedScopeType: to.Ptr(armbilling.AppliedScopeTypeShared), + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-12-16T02:17:03.739Z"); return t}()), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingPlan: to.Ptr(armbilling.BillingPlanP1M), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/AAAA-BBBB-CCC-DDD"), + // BillingScopeID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000"), + // Commitment: &armbilling.Commitment{ + // Amount: to.Ptr[float64](10), + // CurrencyCode: to.Ptr("USD"), + // Grain: to.Ptr(armbilling.CommitmentGrainHourly), + // }, + // DisplayName: to.Ptr("SP1"), + // DisplayProvisioningState: to.Ptr("Succeeded"), + // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-12-16T02:17:04.989Z"); return t}()), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-12-16T02:17:03.739Z"); return t}()), + // ProductCode: to.Ptr("20000000-0000-0000-0000-000000000005"), + // ProvisioningState: to.Ptr(armbilling.ProvisioningStateSucceeded), + // PurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-12-16T02:14:58.230Z"); return t}()), + // Renew: to.Ptr(false), + // Term: to.Ptr(armbilling.SavingsPlanTermP1Y), + // UserFriendlyAppliedScopeType: to.Ptr("Shared"), + // Utilization: &armbilling.Utilization{ + // Aggregates: []*armbilling.UtilizationAggregates{ + // { + // Grain: to.Ptr[float32](1), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](7), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](30), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }}, + // Trend: to.Ptr("SAME"), + // }, + // }, + // SKU: &armbilling.SKU{ + // Name: to.Ptr("Compute_Savings_Plan"), + // }, + // }, + // { + // Name: to.Ptr("30000000-0000-0000-0000-000000000001"), + // Type: to.Ptr("microsoft.billing/billingAccounts/savingsPlanOrders/savingsPlans"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/savingsPlanOrders/20000000-0000-0000-0000-000000000001/savingsPlans/30000000-0000-0000-0000-000000000001"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armbilling.SavingsPlanModelProperties{ + // AppliedScopeProperties: &armbilling.AppliedScopeProperties{ + // DisplayName: to.Ptr("TestRg"), + // ManagementGroupID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestRg"), + // TenantID: to.Ptr("50000000-0000-0000-0000-000000000000"), + // }, + // AppliedScopeType: to.Ptr(armbilling.AppliedScopeTypeManagementGroup), + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-12-16T02:22:22.725Z"); return t}()), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingPlan: to.Ptr(armbilling.BillingPlanP1M), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/AAAA-BBBB-CCC-DDD"), + // BillingScopeID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000"), + // Commitment: &armbilling.Commitment{ + // Amount: to.Ptr[float64](10), + // CurrencyCode: to.Ptr("USD"), + // Grain: to.Ptr(armbilling.CommitmentGrainHourly), + // }, + // DisplayName: to.Ptr("SP2"), + // DisplayProvisioningState: to.Ptr("Succeeded"), + // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-12-16T02:22:24.553Z"); return t}()), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-12-16T02:22:22.725Z"); return t}()), + // ProductCode: to.Ptr("20000000-0000-0000-0000-000000000005"), + // ProvisioningState: to.Ptr(armbilling.ProvisioningStateSucceeded), + // PurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-12-16T02:20:23.473Z"); return t}()), + // Renew: to.Ptr(false), + // Term: to.Ptr(armbilling.SavingsPlanTermP1Y), + // UserFriendlyAppliedScopeType: to.Ptr("ManagementGroup"), + // Utilization: &armbilling.Utilization{ + // Aggregates: []*armbilling.UtilizationAggregates{ + // { + // Grain: to.Ptr[float32](1), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](7), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](30), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }}, + // Trend: to.Ptr("SAME"), + // }, + // }, + // SKU: &armbilling.SKU{ + // Name: to.Ptr("Compute_Savings_Plan"), + // }, + // }, + // { + // Name: to.Ptr("30000000-0000-0000-0000-000000000002"), + // Type: to.Ptr("microsoft.billing/billingAccounts/savingsPlanOrders/savingsPlans"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/savingsPlanOrders/20000000-0000-0000-0000-000000000002/savingsPlans/30000000-0000-0000-0000-000000000002"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armbilling.SavingsPlanModelProperties{ + // AppliedScopeProperties: &armbilling.AppliedScopeProperties{ + // DisplayName: to.Ptr("Azure subscription 1"), + // SubscriptionID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000"), + // }, + // AppliedScopeType: to.Ptr(armbilling.AppliedScopeTypeSingle), + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-14T21:18:55.296Z"); return t}()), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingPlan: to.Ptr(armbilling.BillingPlanP1M), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/AAAA-BBBB-CCC-DDD"), + // BillingScopeID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingSubscriptions/10000000-0000-0000-0000-000000000000"), + // Commitment: &armbilling.Commitment{ + // Amount: to.Ptr[float64](0.025), + // CurrencyCode: to.Ptr("USD"), + // Grain: to.Ptr(armbilling.CommitmentGrainHourly), + // }, + // DisplayName: to.Ptr("SP3"), + // DisplayProvisioningState: to.Ptr("Succeeded"), + // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-07T23:54:43.823Z"); return t}()), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-10-14T21:18:55.296Z"); return t}()), + // ProductCode: to.Ptr("20000000-0000-0000-0000-000000000005"), + // ProvisioningState: to.Ptr(armbilling.ProvisioningStateSucceeded), + // PurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-14T21:16:57.234Z"); return t}()), + // Renew: to.Ptr(true), + // Term: to.Ptr(armbilling.SavingsPlanTermP3Y), + // UserFriendlyAppliedScopeType: to.Ptr("Single"), + // Utilization: &armbilling.Utilization{ + // Aggregates: []*armbilling.UtilizationAggregates{ + // { + // Grain: to.Ptr[float32](1), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](66), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](7), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](66), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](30), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](65.52), + // ValueUnit: to.Ptr("percentage"), + // }}, + // Trend: to.Ptr("SAME"), + // }, + // }, + // SKU: &armbilling.SKU{ + // Name: to.Ptr("Compute_Savings_Plan"), + // }, + // }, + // { + // Name: to.Ptr("30000000-0000-0000-0000-000000000003"), + // Type: to.Ptr("microsoft.billing/billingAccounts/savingsPlanOrders/savingsPlans"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/savingsPlanOrders/20000000-0000-0000-0000-000000000003/savingsPlans/30000000-0000-0000-0000-000000000003"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armbilling.SavingsPlanModelProperties{ + // AppliedScopeProperties: &armbilling.AppliedScopeProperties{ + // DisplayName: to.Ptr("testRG"), + // ResourceGroupID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000/resourcegroups/testRG"), + // }, + // AppliedScopeType: to.Ptr(armbilling.AppliedScopeTypeSingle), + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-08T00:00:06.363Z"); return t}()), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingPlan: to.Ptr(armbilling.BillingPlanP1M), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/AAAA-BBBB-CCC-DDD"), + // BillingScopeID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000"), + // Commitment: &armbilling.Commitment{ + // Amount: to.Ptr[float64](0.001), + // CurrencyCode: to.Ptr("USD"), + // Grain: to.Ptr(armbilling.CommitmentGrainHourly), + // }, + // DisplayName: to.Ptr("SP4"), + // DisplayProvisioningState: to.Ptr("Succeeded"), + // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-30T21:18:12.196Z"); return t}()), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-11-08T00:00:06.363Z"); return t}()), + // ProductCode: to.Ptr("20000000-0000-0000-0000-000000000005"), + // ProvisioningState: to.Ptr(armbilling.ProvisioningStateSucceeded), + // PurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-07T23:57:58.242Z"); return t}()), + // Renew: to.Ptr(false), + // Term: to.Ptr(armbilling.SavingsPlanTermP3Y), + // UserFriendlyAppliedScopeType: to.Ptr("ResourceGroup"), + // Utilization: &armbilling.Utilization{ + // Aggregates: []*armbilling.UtilizationAggregates{ + // { + // Grain: to.Ptr[float32](1), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](100), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](7), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](100), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](30), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](100), + // ValueUnit: to.Ptr("percentage"), + // }}, + // Trend: to.Ptr("SAME"), + // }, + // }, + // SKU: &armbilling.SKU{ + // Name: to.Ptr("Compute_Savings_Plan"), + // }, + // }}, + // Summary: &armbilling.SavingsPlanSummaryCount{ + // CancelledCount: to.Ptr[float32](0), + // ExpiredCount: to.Ptr[float32](0), + // ExpiringCount: to.Ptr[float32](0), + // FailedCount: to.Ptr[float32](0), + // NoBenefitCount: to.Ptr[float32](0), + // PendingCount: to.Ptr[float32](0), + // ProcessingCount: to.Ptr[float32](0), + // SucceededCount: to.Ptr[float32](3), + // WarningCount: to.Ptr[float32](0), + // }, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanGetByBillingAccount.json +func ExampleSavingsPlansClient_GetByBillingAccount_savingsPlanGet() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSavingsPlansClient().GetByBillingAccount(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "20000000-0000-0000-0000-000000000000", "30000000-0000-0000-0000-000000000000", &armbilling.SavingsPlansClientGetByBillingAccountOptions{Expand: nil}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SavingsPlanModel = armbilling.SavingsPlanModel{ + // Name: to.Ptr("30000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("microsoft.billing/billingAccounts/savingsPlanOrders/savingsPlans"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/savingsPlanOrders/20000000-0000-0000-0000-000000000000/savingsPlans/30000000-0000-0000-0000-000000000000"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armbilling.SavingsPlanModelProperties{ + // AppliedScopeProperties: &armbilling.AppliedScopeProperties{ + // DisplayName: to.Ptr("TestRg"), + // ManagementGroupID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestRg"), + // TenantID: to.Ptr("70000000-0000-0000-0000-000000000000"), + // }, + // AppliedScopeType: to.Ptr(armbilling.AppliedScopeTypeManagementGroup), + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T02:25:11.718Z"); return t}()), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingPlan: to.Ptr(armbilling.BillingPlanP1M), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/AAAA-BBBB-CCC-DDD"), + // BillingScopeID: to.Ptr("/subscriptions/50000000-0000-0000-0000-000000000000"), + // Commitment: &armbilling.Commitment{ + // Amount: to.Ptr[float64](0.001), + // CurrencyCode: to.Ptr("USD"), + // Grain: to.Ptr(armbilling.CommitmentGrainHourly), + // }, + // DisplayName: to.Ptr("SP1"), + // DisplayProvisioningState: to.Ptr("NoBenefit"), + // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-12-16T01:35:36.290Z"); return t}()), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-11-16T02:25:11.718Z"); return t}()), + // ProductCode: to.Ptr("20000000-0000-0000-0000-000000000005"), + // ProvisioningState: to.Ptr(armbilling.ProvisioningStateSucceeded), + // PurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T02:23:21.386Z"); return t}()), + // Renew: to.Ptr(false), + // Term: to.Ptr(armbilling.SavingsPlanTermP3Y), + // UserFriendlyAppliedScopeType: to.Ptr("ManagementGroup"), + // Utilization: &armbilling.Utilization{ + // Aggregates: []*armbilling.UtilizationAggregates{ + // { + // Grain: to.Ptr[float32](1), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](7), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](30), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }}, + // Trend: to.Ptr("SAME"), + // }, + // }, + // SKU: &armbilling.SKU{ + // Name: to.Ptr("Compute_Savings_Plan"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanGetExpandRenewPropertiesByBillingAccount.json +func ExampleSavingsPlansClient_GetByBillingAccount_savingsPlanGetExpandRenewProperties() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSavingsPlansClient().GetByBillingAccount(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "20000000-0000-0000-0000-000000000000", "30000000-0000-0000-0000-000000000000", &armbilling.SavingsPlansClientGetByBillingAccountOptions{Expand: nil}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SavingsPlanModel = armbilling.SavingsPlanModel{ + // Name: to.Ptr("30000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("microsoft.billing/billingAccounts/savingsPlanOrders/savingsPlans"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/savingsPlanOrders/20000000-0000-0000-0000-000000000000/savingsPlans/30000000-0000-0000-0000-000000000000"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armbilling.SavingsPlanModelProperties{ + // AppliedScopeProperties: &armbilling.AppliedScopeProperties{ + // DisplayName: to.Ptr("TestRg"), + // ManagementGroupID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestRg"), + // TenantID: to.Ptr("70000000-0000-0000-0000-000000000000"), + // }, + // AppliedScopeType: to.Ptr(armbilling.AppliedScopeTypeManagementGroup), + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T02:25:11.718Z"); return t}()), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingPlan: to.Ptr(armbilling.BillingPlanP1M), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/AAAA-BBBB-CCC-DDD"), + // BillingScopeID: to.Ptr("/subscriptions/50000000-0000-0000-0000-000000000000"), + // Commitment: &armbilling.Commitment{ + // Amount: to.Ptr[float64](0.001), + // CurrencyCode: to.Ptr("USD"), + // Grain: to.Ptr(armbilling.CommitmentGrainHourly), + // }, + // DisplayName: to.Ptr("SP1"), + // DisplayProvisioningState: to.Ptr("NoBenefit"), + // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-12-16T01:35:36.290Z"); return t}()), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-11-16T02:25:11.718Z"); return t}()), + // ProductCode: to.Ptr("20000000-0000-0000-0000-000000000005"), + // ProvisioningState: to.Ptr(armbilling.ProvisioningStateSucceeded), + // PurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T02:23:21.386Z"); return t}()), + // Renew: to.Ptr(false), + // RenewProperties: &armbilling.RenewProperties{ + // PurchaseProperties: &armbilling.PurchaseRequest{ + // Properties: &armbilling.PurchaseRequestProperties{ + // AppliedScopeProperties: &armbilling.AppliedScopeProperties{ + // ManagementGroupID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestRg"), + // TenantID: to.Ptr("70000000-0000-0000-0000-000000000000"), + // }, + // AppliedScopeType: to.Ptr(armbilling.AppliedScopeTypeManagementGroup), + // BillingPlan: to.Ptr(armbilling.BillingPlan("Monthly")), + // BillingScopeID: to.Ptr("/subscriptions/50000000-0000-0000-0000-000000000000"), + // Commitment: &armbilling.Commitment{ + // Amount: to.Ptr[float64](0.001), + // CurrencyCode: to.Ptr("USD"), + // Grain: to.Ptr(armbilling.CommitmentGrainHourly), + // }, + // DisplayName: to.Ptr("SP1_renewed"), + // Term: to.Ptr(armbilling.SavingsPlanTermP3Y), + // }, + // SKU: &armbilling.SKU{ + // Name: to.Ptr("Compute_Savings_Plan"), + // }, + // }, + // }, + // Term: to.Ptr(armbilling.SavingsPlanTermP3Y), + // UserFriendlyAppliedScopeType: to.Ptr("ManagementGroup"), + // Utilization: &armbilling.Utilization{ + // Aggregates: []*armbilling.UtilizationAggregates{ + // { + // Grain: to.Ptr[float32](1), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](7), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }, + // { + // Grain: to.Ptr[float32](30), + // GrainUnit: to.Ptr("days"), + // Value: to.Ptr[float32](0), + // ValueUnit: to.Ptr("percentage"), + // }}, + // Trend: to.Ptr("SAME"), + // }, + // }, + // SKU: &armbilling.SKU{ + // Name: to.Ptr("Compute_Savings_Plan"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanUpdateByBillingAccount.json +func ExampleSavingsPlansClient_BeginUpdateByBillingAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewSavingsPlansClient().BeginUpdateByBillingAccount(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "20000000-0000-0000-0000-000000000000", "30000000-0000-0000-0000-000000000000", armbilling.SavingsPlanUpdateRequest{ + Properties: &armbilling.SavingsPlanUpdateRequestProperties{ + AppliedScopeProperties: &armbilling.AppliedScopeProperties{ + ManagementGroupID: to.Ptr("/providers/Microsoft.Management/managementGroups/mg1"), + TenantID: to.Ptr("80000000-0000-0000-0000-000000000000"), + }, + AppliedScopeType: to.Ptr(armbilling.AppliedScopeTypeManagementGroup), + DisplayName: to.Ptr("sp_newName"), + Renew: to.Ptr(true), + RenewProperties: &armbilling.RenewProperties{ + PurchaseProperties: &armbilling.PurchaseRequest{ + Properties: &armbilling.PurchaseRequestProperties{ + AppliedScopeProperties: &armbilling.AppliedScopeProperties{ + ManagementGroupID: to.Ptr("/providers/Microsoft.Management/managementGroups/mg1"), + TenantID: to.Ptr("80000000-0000-0000-0000-000000000000"), + }, + AppliedScopeType: to.Ptr(armbilling.AppliedScopeTypeManagementGroup), + BillingPlan: to.Ptr(armbilling.BillingPlanP1M), + BillingScopeID: to.Ptr("/subscriptions/50000000-0000-0000-0000-000000000000"), + Commitment: &armbilling.Commitment{ + Amount: to.Ptr[float64](0.001), + CurrencyCode: to.Ptr("USD"), + Grain: to.Ptr(armbilling.CommitmentGrainHourly), + }, + DisplayName: to.Ptr("sp_newName_renewed"), + Term: to.Ptr(armbilling.SavingsPlanTermP3Y), + }, + SKU: &armbilling.SKU{ + Name: to.Ptr("Compute_Savings_Plan"), + }, + }, + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SavingsPlanModel = armbilling.SavingsPlanModel{ + // Name: to.Ptr("30000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("microsoft.billing/billingAccounts/savingsPlanOrders/savingsPlans"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/savingsPlanOrders/20000000-0000-0000-0000-000000000000/savingsPlans/30000000-0000-0000-0000-000000000000"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armbilling.SavingsPlanModelProperties{ + // AppliedScopeProperties: &armbilling.AppliedScopeProperties{ + // DisplayName: to.Ptr("mg1"), + // ManagementGroupID: to.Ptr("/providers/Microsoft.Management/managementGroups/mg1"), + // TenantID: to.Ptr("80000000-0000-0000-0000-000000000000"), + // }, + // AppliedScopeType: to.Ptr(armbilling.AppliedScopeTypeManagementGroup), + // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-04T03:18:31.307Z"); return t}()), + // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"), + // BillingPlan: to.Ptr(armbilling.BillingPlanP1M), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/AAAA-BBBB-CCC-DDD"), + // BillingScopeID: to.Ptr("/subscriptions/50000000-0000-0000-0000-000000000000"), + // Commitment: &armbilling.Commitment{ + // Amount: to.Ptr[float64](0.001), + // CurrencyCode: to.Ptr("USD"), + // Grain: to.Ptr(armbilling.CommitmentGrainHourly), + // }, + // DisplayName: to.Ptr("sp_newName"), + // DisplayProvisioningState: to.Ptr("Succeeded"), + // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-04T04:30:49.198Z"); return t}()), + // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2026-02-04T03:18:31.307Z"); return t}()), + // ProductCode: to.Ptr("20000000-0000-0000-0000-000000000005"), + // ProvisioningState: to.Ptr(armbilling.ProvisioningStateSucceeded), + // PurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-04T03:16:38.906Z"); return t}()), + // Renew: to.Ptr(true), + // Term: to.Ptr(armbilling.SavingsPlanTermP3Y), + // UserFriendlyAppliedScopeType: to.Ptr("ManagementGroup"), + // Utilization: &armbilling.Utilization{ + // Aggregates: []*armbilling.UtilizationAggregates{ + // }, + // }, + // }, + // SKU: &armbilling.SKU{ + // Name: to.Ptr("Compute_Savings_Plan"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanValidateUpdateByBillingAccount.json +func ExampleSavingsPlansClient_ValidateUpdateByBillingAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSavingsPlansClient().ValidateUpdateByBillingAccount(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "20000000-0000-0000-0000-000000000000", "30000000-0000-0000-0000-000000000000", armbilling.SavingsPlanUpdateValidateRequest{ + Benefits: []*armbilling.SavingsPlanUpdateRequestProperties{ + { + AppliedScopeProperties: &armbilling.AppliedScopeProperties{ + SubscriptionID: to.Ptr("/subscriptions/50000000-0000-0000-0000-000000000000"), + }, + AppliedScopeType: to.Ptr(armbilling.AppliedScopeTypeSingle), + }}, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SavingsPlanValidateResponse = armbilling.SavingsPlanValidateResponse{ + // Benefits: []*armbilling.SavingsPlanValidResponseProperty{ + // { + // Valid: to.Ptr(true), + // }}, + // } +} diff --git a/sdk/resourcemanager/billing/armbilling/subscriptions_client.go b/sdk/resourcemanager/billing/armbilling/subscriptions_client.go index b77b847de5cd..1672dfb78ded 100644 --- a/sdk/resourcemanager/billing/armbilling/subscriptions_client.go +++ b/sdk/resourcemanager/billing/armbilling/subscriptions_client.go @@ -11,52 +11,206 @@ package armbilling import ( "context" "errors" + "net/http" + "net/url" + "strconv" + "strings" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" ) // SubscriptionsClient contains the methods for the BillingSubscriptions group. // Don't use this type directly, use NewSubscriptionsClient() instead. type SubscriptionsClient struct { - internal *arm.Client - subscriptionID string + internal *arm.Client } // NewSubscriptionsClient creates a new instance of SubscriptionsClient with the specified values. -// - subscriptionID - The ID that uniquely identifies an Azure subscription. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. -func NewSubscriptionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SubscriptionsClient, error) { +func NewSubscriptionsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*SubscriptionsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } client := &SubscriptionsClient{ - subscriptionID: subscriptionID, - internal: cl, + internal: cl, } return client, nil } +// BeginCancel - Cancels a usage-based subscription. This operation is supported only for billing accounts of type Microsoft +// Partner Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingSubscriptionName - The ID that uniquely identifies a subscription. +// - parameters - Request parameters for cancel customer subscription. +// - options - SubscriptionsClientBeginCancelOptions contains the optional parameters for the SubscriptionsClient.BeginCancel +// method. +func (client *SubscriptionsClient) BeginCancel(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters CancelSubscriptionRequest, options *SubscriptionsClientBeginCancelOptions) (*runtime.Poller[SubscriptionsClientCancelResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.cancel(ctx, billingAccountName, billingSubscriptionName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SubscriptionsClientCancelResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[SubscriptionsClientCancelResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Cancel - Cancels a usage-based subscription. This operation is supported only for billing accounts of type Microsoft Partner +// Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *SubscriptionsClient) cancel(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters CancelSubscriptionRequest, options *SubscriptionsClientBeginCancelOptions) (*http.Response, error) { + var err error + const operationName = "SubscriptionsClient.BeginCancel" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.cancelCreateRequest(ctx, billingAccountName, billingSubscriptionName, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// cancelCreateRequest creates the Cancel request. +func (client *SubscriptionsClient) cancelCreateRequest(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters CancelSubscriptionRequest, options *SubscriptionsClientBeginCancelOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{billingSubscriptionName}/cancel" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingSubscriptionName == "" { + return nil, errors.New("parameter billingSubscriptionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingSubscriptionName}", url.PathEscape(billingSubscriptionName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Cancels a billing subscription. This operation is supported only for billing accounts of type Microsoft Partner +// Agreement or Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingSubscriptionName - The ID that uniquely identifies a subscription. +// - options - SubscriptionsClientBeginDeleteOptions contains the optional parameters for the SubscriptionsClient.BeginDelete +// method. +func (client *SubscriptionsClient) BeginDelete(ctx context.Context, billingAccountName string, billingSubscriptionName string, options *SubscriptionsClientBeginDeleteOptions) (*runtime.Poller[SubscriptionsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, billingAccountName, billingSubscriptionName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SubscriptionsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[SubscriptionsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Cancels a billing subscription. This operation is supported only for billing accounts of type Microsoft Partner +// Agreement or Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *SubscriptionsClient) deleteOperation(ctx context.Context, billingAccountName string, billingSubscriptionName string, options *SubscriptionsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "SubscriptionsClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, billingAccountName, billingSubscriptionName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *SubscriptionsClient) deleteCreateRequest(ctx context.Context, billingAccountName string, billingSubscriptionName string, options *SubscriptionsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{billingSubscriptionName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingSubscriptionName == "" { + return nil, errors.New("parameter billingSubscriptionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingSubscriptionName}", url.PathEscape(billingSubscriptionName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + // Get - Gets a subscription by its ID. The operation is supported for billing accounts with agreement type Microsoft Customer -// Agreement and Microsoft Partner Agreement. +// Agreement, Microsoft Partner Agreement, and Enterprise Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. +// - billingSubscriptionName - The ID that uniquely identifies a subscription. // - options - SubscriptionsClientGetOptions contains the optional parameters for the SubscriptionsClient.Get method. -func (client *SubscriptionsClient) Get(ctx context.Context, billingAccountName string, options *SubscriptionsClientGetOptions) (SubscriptionsClientGetResponse, error) { +func (client *SubscriptionsClient) Get(ctx context.Context, billingAccountName string, billingSubscriptionName string, options *SubscriptionsClientGetOptions) (SubscriptionsClientGetResponse, error) { var err error const operationName = "SubscriptionsClient.Get" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, billingAccountName, options) + req, err := client.getCreateRequest(ctx, billingAccountName, billingSubscriptionName, options) if err != nil { return SubscriptionsClientGetResponse{}, err } @@ -73,22 +227,25 @@ func (client *SubscriptionsClient) Get(ctx context.Context, billingAccountName s } // getCreateRequest creates the Get request. -func (client *SubscriptionsClient) getCreateRequest(ctx context.Context, billingAccountName string, options *SubscriptionsClientGetOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}" +func (client *SubscriptionsClient) getCreateRequest(ctx context.Context, billingAccountName string, billingSubscriptionName string, options *SubscriptionsClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{billingSubscriptionName}" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") + if billingSubscriptionName == "" { + return nil, errors.New("parameter billingSubscriptionName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + urlPath = strings.ReplaceAll(urlPath, "{billingSubscriptionName}", url.PathEscape(billingSubscriptionName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Expand != nil { + reqQP.Set("expand", *options.Expand) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -103,10 +260,79 @@ func (client *SubscriptionsClient) getHandleResponse(resp *http.Response) (Subsc return result, nil } -// NewListByBillingAccountPager - Lists the subscriptions for a billing account. The operation is supported for billing accounts -// with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. +// GetByBillingProfile - Gets a subscription by its billing profile and ID. The operation is supported for billing accounts +// with agreement type Enterprise Agreement. +// If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - billingSubscriptionName - The ID that uniquely identifies a subscription. +// - options - SubscriptionsClientGetByBillingProfileOptions contains the optional parameters for the SubscriptionsClient.GetByBillingProfile +// method. +func (client *SubscriptionsClient) GetByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, billingSubscriptionName string, options *SubscriptionsClientGetByBillingProfileOptions) (SubscriptionsClientGetByBillingProfileResponse, error) { + var err error + const operationName = "SubscriptionsClient.GetByBillingProfile" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, billingSubscriptionName, options) + if err != nil { + return SubscriptionsClientGetByBillingProfileResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SubscriptionsClientGetByBillingProfileResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SubscriptionsClientGetByBillingProfileResponse{}, err + } + resp, err := client.getByBillingProfileHandleResponse(httpResp) + return resp, err +} + +// getByBillingProfileCreateRequest creates the GetByBillingProfile request. +func (client *SubscriptionsClient) getByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, billingSubscriptionName string, options *SubscriptionsClientGetByBillingProfileOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingSubscriptions/{billingSubscriptionName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if billingSubscriptionName == "" { + return nil, errors.New("parameter billingSubscriptionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingSubscriptionName}", url.PathEscape(billingSubscriptionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Expand != nil { + reqQP.Set("expand", *options.Expand) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByBillingProfileHandleResponse handles the GetByBillingProfile response. +func (client *SubscriptionsClient) getByBillingProfileHandleResponse(resp *http.Response) (SubscriptionsClientGetByBillingProfileResponse, error) { + result := SubscriptionsClientGetByBillingProfileResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Subscription); err != nil { + return SubscriptionsClientGetByBillingProfileResponse{}, err + } + return result, nil +} + +// NewListByBillingAccountPager - Lists the subscriptions for a billing account. +// +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - options - SubscriptionsClientListByBillingAccountOptions contains the optional parameters for the SubscriptionsClient.NewListByBillingAccountPager // method. @@ -145,7 +371,37 @@ func (client *SubscriptionsClient) listByBillingAccountCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Expand != nil { + reqQP.Set("expand", *options.Expand) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.IncludeDeleted != nil { + reqQP.Set("includeDeleted", strconv.FormatBool(*options.IncludeDeleted)) + } + if options != nil && options.IncludeFailed != nil { + reqQP.Set("includeFailed", strconv.FormatBool(*options.IncludeFailed)) + } + if options != nil && options.IncludeTenantSubscriptions != nil { + reqQP.Set("includeTenantSubscriptions", strconv.FormatBool(*options.IncludeTenantSubscriptions)) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -154,7 +410,7 @@ func (client *SubscriptionsClient) listByBillingAccountCreateRequest(ctx context // listByBillingAccountHandleResponse handles the ListByBillingAccount response. func (client *SubscriptionsClient) listByBillingAccountHandleResponse(resp *http.Response) (SubscriptionsClientListByBillingAccountResponse, error) { result := SubscriptionsClientListByBillingAccountResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionsListResult); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionListResult); err != nil { return SubscriptionsClientListByBillingAccountResponse{}, err } return result, nil @@ -163,7 +419,7 @@ func (client *SubscriptionsClient) listByBillingAccountHandleResponse(resp *http // NewListByBillingProfilePager - Lists the subscriptions that are billed to a billing profile. The operation is supported // for billing accounts with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingProfileName - The ID that uniquely identifies a billing profile. // - options - SubscriptionsClientListByBillingProfileOptions contains the optional parameters for the SubscriptionsClient.NewListByBillingProfilePager @@ -207,7 +463,31 @@ func (client *SubscriptionsClient) listByBillingProfileCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Expand != nil { + reqQP.Set("expand", *options.Expand) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.IncludeDeleted != nil { + reqQP.Set("includeDeleted", strconv.FormatBool(*options.IncludeDeleted)) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -216,7 +496,7 @@ func (client *SubscriptionsClient) listByBillingProfileCreateRequest(ctx context // listByBillingProfileHandleResponse handles the ListByBillingProfile response. func (client *SubscriptionsClient) listByBillingProfileHandleResponse(resp *http.Response) (SubscriptionsClientListByBillingProfileResponse, error) { result := SubscriptionsClientListByBillingProfileResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionsListResult); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionListResult); err != nil { return SubscriptionsClientListByBillingProfileResponse{}, err } return result, nil @@ -225,12 +505,13 @@ func (client *SubscriptionsClient) listByBillingProfileHandleResponse(resp *http // NewListByCustomerPager - Lists the subscriptions for a customer. The operation is supported only for billing accounts with // agreement type Microsoft Partner Agreement. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. // - customerName - The ID that uniquely identifies a customer. // - options - SubscriptionsClientListByCustomerOptions contains the optional parameters for the SubscriptionsClient.NewListByCustomerPager // method. -func (client *SubscriptionsClient) NewListByCustomerPager(billingAccountName string, customerName string, options *SubscriptionsClientListByCustomerOptions) *runtime.Pager[SubscriptionsClientListByCustomerResponse] { +func (client *SubscriptionsClient) NewListByCustomerPager(billingAccountName string, billingProfileName string, customerName string, options *SubscriptionsClientListByCustomerOptions) *runtime.Pager[SubscriptionsClientListByCustomerResponse] { return runtime.NewPager(runtime.PagingHandler[SubscriptionsClientListByCustomerResponse]{ More: func(page SubscriptionsClientListByCustomerResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 @@ -242,7 +523,7 @@ func (client *SubscriptionsClient) NewListByCustomerPager(billingAccountName str nextLink = *page.NextLink } resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listByCustomerCreateRequest(ctx, billingAccountName, customerName, options) + return client.listByCustomerCreateRequest(ctx, billingAccountName, billingProfileName, customerName, options) }, nil) if err != nil { return SubscriptionsClientListByCustomerResponse{}, err @@ -254,12 +535,16 @@ func (client *SubscriptionsClient) NewListByCustomerPager(billingAccountName str } // listByCustomerCreateRequest creates the ListByCustomer request. -func (client *SubscriptionsClient) listByCustomerCreateRequest(ctx context.Context, billingAccountName string, customerName string, options *SubscriptionsClientListByCustomerOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/billingSubscriptions" +func (client *SubscriptionsClient) listByCustomerCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, options *SubscriptionsClientListByCustomerOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/billingSubscriptions" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) if customerName == "" { return nil, errors.New("parameter customerName cannot be empty") } @@ -269,7 +554,31 @@ func (client *SubscriptionsClient) listByCustomerCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Expand != nil { + reqQP.Set("expand", *options.Expand) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.IncludeDeleted != nil { + reqQP.Set("includeDeleted", strconv.FormatBool(*options.IncludeDeleted)) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -278,16 +587,182 @@ func (client *SubscriptionsClient) listByCustomerCreateRequest(ctx context.Conte // listByCustomerHandleResponse handles the ListByCustomer response. func (client *SubscriptionsClient) listByCustomerHandleResponse(resp *http.Response) (SubscriptionsClientListByCustomerResponse, error) { result := SubscriptionsClientListByCustomerResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionsListResult); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionListResult); err != nil { return SubscriptionsClientListByCustomerResponse{}, err } return result, nil } +// NewListByCustomerAtBillingAccountPager - Lists the subscriptions for a customer at billing account level. The operation +// is supported only for billing accounts with agreement type Microsoft Partner Agreement. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - customerName - The ID that uniquely identifies a customer. +// - options - SubscriptionsClientListByCustomerAtBillingAccountOptions contains the optional parameters for the SubscriptionsClient.NewListByCustomerAtBillingAccountPager +// method. +func (client *SubscriptionsClient) NewListByCustomerAtBillingAccountPager(billingAccountName string, customerName string, options *SubscriptionsClientListByCustomerAtBillingAccountOptions) *runtime.Pager[SubscriptionsClientListByCustomerAtBillingAccountResponse] { + return runtime.NewPager(runtime.PagingHandler[SubscriptionsClientListByCustomerAtBillingAccountResponse]{ + More: func(page SubscriptionsClientListByCustomerAtBillingAccountResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SubscriptionsClientListByCustomerAtBillingAccountResponse) (SubscriptionsClientListByCustomerAtBillingAccountResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SubscriptionsClient.NewListByCustomerAtBillingAccountPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByCustomerAtBillingAccountCreateRequest(ctx, billingAccountName, customerName, options) + }, nil) + if err != nil { + return SubscriptionsClientListByCustomerAtBillingAccountResponse{}, err + } + return client.listByCustomerAtBillingAccountHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByCustomerAtBillingAccountCreateRequest creates the ListByCustomerAtBillingAccount request. +func (client *SubscriptionsClient) listByCustomerAtBillingAccountCreateRequest(ctx context.Context, billingAccountName string, customerName string, options *SubscriptionsClientListByCustomerAtBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/billingSubscriptions" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if customerName == "" { + return nil, errors.New("parameter customerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{customerName}", url.PathEscape(customerName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Expand != nil { + reqQP.Set("expand", *options.Expand) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.IncludeDeleted != nil { + reqQP.Set("includeDeleted", strconv.FormatBool(*options.IncludeDeleted)) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByCustomerAtBillingAccountHandleResponse handles the ListByCustomerAtBillingAccount response. +func (client *SubscriptionsClient) listByCustomerAtBillingAccountHandleResponse(resp *http.Response) (SubscriptionsClientListByCustomerAtBillingAccountResponse, error) { + result := SubscriptionsClientListByCustomerAtBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionListResult); err != nil { + return SubscriptionsClientListByCustomerAtBillingAccountResponse{}, err + } + return result, nil +} + +// NewListByEnrollmentAccountPager - Lists the subscriptions for an enrollment account. The operation is supported for billing +// accounts with agreement type Enterprise Agreement. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - enrollmentAccountName - The name of the enrollment account. +// - options - SubscriptionsClientListByEnrollmentAccountOptions contains the optional parameters for the SubscriptionsClient.NewListByEnrollmentAccountPager +// method. +func (client *SubscriptionsClient) NewListByEnrollmentAccountPager(billingAccountName string, enrollmentAccountName string, options *SubscriptionsClientListByEnrollmentAccountOptions) *runtime.Pager[SubscriptionsClientListByEnrollmentAccountResponse] { + return runtime.NewPager(runtime.PagingHandler[SubscriptionsClientListByEnrollmentAccountResponse]{ + More: func(page SubscriptionsClientListByEnrollmentAccountResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SubscriptionsClientListByEnrollmentAccountResponse) (SubscriptionsClientListByEnrollmentAccountResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SubscriptionsClient.NewListByEnrollmentAccountPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByEnrollmentAccountCreateRequest(ctx, billingAccountName, enrollmentAccountName, options) + }, nil) + if err != nil { + return SubscriptionsClientListByEnrollmentAccountResponse{}, err + } + return client.listByEnrollmentAccountHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByEnrollmentAccountCreateRequest creates the ListByEnrollmentAccount request. +func (client *SubscriptionsClient) listByEnrollmentAccountCreateRequest(ctx context.Context, billingAccountName string, enrollmentAccountName string, options *SubscriptionsClientListByEnrollmentAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}/billingSubscriptions" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if enrollmentAccountName == "" { + return nil, errors.New("parameter enrollmentAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{enrollmentAccountName}", url.PathEscape(enrollmentAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByEnrollmentAccountHandleResponse handles the ListByEnrollmentAccount response. +func (client *SubscriptionsClient) listByEnrollmentAccountHandleResponse(resp *http.Response) (SubscriptionsClientListByEnrollmentAccountResponse, error) { + result := SubscriptionsClientListByEnrollmentAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionListResult); err != nil { + return SubscriptionsClientListByEnrollmentAccountResponse{}, err + } + return result, nil +} + // NewListByInvoiceSectionPager - Lists the subscriptions that are billed to an invoice section. The operation is supported // only for billing accounts with agreement type Microsoft Customer Agreement. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingProfileName - The ID that uniquely identifies a billing profile. // - invoiceSectionName - The ID that uniquely identifies an invoice section. @@ -336,7 +811,31 @@ func (client *SubscriptionsClient) listByInvoiceSectionCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Expand != nil { + reqQP.Set("expand", *options.Expand) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.IncludeDeleted != nil { + reqQP.Set("includeDeleted", strconv.FormatBool(*options.IncludeDeleted)) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -345,29 +844,108 @@ func (client *SubscriptionsClient) listByInvoiceSectionCreateRequest(ctx context // listByInvoiceSectionHandleResponse handles the ListByInvoiceSection response. func (client *SubscriptionsClient) listByInvoiceSectionHandleResponse(resp *http.Response) (SubscriptionsClientListByInvoiceSectionResponse, error) { result := SubscriptionsClientListByInvoiceSectionResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionsListResult); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionListResult); err != nil { return SubscriptionsClientListByInvoiceSectionResponse{}, err } return result, nil } -// BeginMove - Moves a subscription's charges to a new invoice section. The new invoice section must belong to the same billing -// profile as the existing invoice section. This operation is supported for billing +// BeginMerge - Merges the billing subscription provided in the request with a target billing subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingSubscriptionName - The ID that uniquely identifies a subscription. +// - parameters - Request parameters that are provided to merge the two billing subscriptions. +// - options - SubscriptionsClientBeginMergeOptions contains the optional parameters for the SubscriptionsClient.BeginMerge +// method. +func (client *SubscriptionsClient) BeginMerge(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters SubscriptionMergeRequest, options *SubscriptionsClientBeginMergeOptions) (*runtime.Poller[SubscriptionsClientMergeResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.merge(ctx, billingAccountName, billingSubscriptionName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SubscriptionsClientMergeResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[SubscriptionsClientMergeResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Merge - Merges the billing subscription provided in the request with a target billing subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *SubscriptionsClient) merge(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters SubscriptionMergeRequest, options *SubscriptionsClientBeginMergeOptions) (*http.Response, error) { + var err error + const operationName = "SubscriptionsClient.BeginMerge" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.mergeCreateRequest(ctx, billingAccountName, billingSubscriptionName, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// mergeCreateRequest creates the Merge request. +func (client *SubscriptionsClient) mergeCreateRequest(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters SubscriptionMergeRequest, options *SubscriptionsClientBeginMergeOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{billingSubscriptionName}/merge" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingSubscriptionName == "" { + return nil, errors.New("parameter billingSubscriptionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingSubscriptionName}", url.PathEscape(billingSubscriptionName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// BeginMove - Moves charges for a subscription to a new invoice section. The new invoice section must belong to the same +// billing profile as the existing invoice section. This operation is supported for billing // accounts with agreement type Microsoft Customer Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. -// - parameters - Request parameters that are provided to the move subscription operation. +// - billingSubscriptionName - The ID that uniquely identifies a subscription. +// - parameters - Request parameters to transfer billing subscription. // - options - SubscriptionsClientBeginMoveOptions contains the optional parameters for the SubscriptionsClient.BeginMove method. -func (client *SubscriptionsClient) BeginMove(ctx context.Context, billingAccountName string, parameters TransferBillingSubscriptionRequestProperties, options *SubscriptionsClientBeginMoveOptions) (*runtime.Poller[SubscriptionsClientMoveResponse], error) { +func (client *SubscriptionsClient) BeginMove(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters MoveBillingSubscriptionRequest, options *SubscriptionsClientBeginMoveOptions) (*runtime.Poller[SubscriptionsClientMoveResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.move(ctx, billingAccountName, parameters, options) + resp, err := client.move(ctx, billingAccountName, billingSubscriptionName, parameters, options) if err != nil { return nil, err } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SubscriptionsClientMoveResponse]{ - Tracer: client.internal.Tracer(), + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) return poller, err } else { @@ -377,19 +955,19 @@ func (client *SubscriptionsClient) BeginMove(ctx context.Context, billingAccount } } -// Move - Moves a subscription's charges to a new invoice section. The new invoice section must belong to the same billing +// Move - Moves charges for a subscription to a new invoice section. The new invoice section must belong to the same billing // profile as the existing invoice section. This operation is supported for billing // accounts with agreement type Microsoft Customer Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 -func (client *SubscriptionsClient) move(ctx context.Context, billingAccountName string, parameters TransferBillingSubscriptionRequestProperties, options *SubscriptionsClientBeginMoveOptions) (*http.Response, error) { +// Generated from API version 2024-04-01 +func (client *SubscriptionsClient) move(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters MoveBillingSubscriptionRequest, options *SubscriptionsClientBeginMoveOptions) (*http.Response, error) { var err error const operationName = "SubscriptionsClient.BeginMove" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.moveCreateRequest(ctx, billingAccountName, parameters, options) + req, err := client.moveCreateRequest(ctx, billingAccountName, billingSubscriptionName, parameters, options) if err != nil { return nil, err } @@ -405,22 +983,22 @@ func (client *SubscriptionsClient) move(ctx context.Context, billingAccountName } // moveCreateRequest creates the Move request. -func (client *SubscriptionsClient) moveCreateRequest(ctx context.Context, billingAccountName string, parameters TransferBillingSubscriptionRequestProperties, options *SubscriptionsClientBeginMoveOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}/move" +func (client *SubscriptionsClient) moveCreateRequest(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters MoveBillingSubscriptionRequest, options *SubscriptionsClientBeginMoveOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{billingSubscriptionName}/move" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") + if billingSubscriptionName == "" { + return nil, errors.New("parameter billingSubscriptionName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + urlPath = strings.ReplaceAll(urlPath, "{billingSubscriptionName}", url.PathEscape(billingSubscriptionName)) req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -429,53 +1007,77 @@ func (client *SubscriptionsClient) moveCreateRequest(ctx context.Context, billin return req, nil } -// Update - Updates the properties of a billing subscription. Currently, cost center can be updated. The operation is supported -// only for billing accounts with agreement type Microsoft Customer Agreement. +// BeginSplit - Splits a subscription into a new subscription with quantity less than current subscription quantity and not +// equal to 0. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. -// - parameters - Request parameters that are provided to the update billing subscription operation. -// - options - SubscriptionsClientUpdateOptions contains the optional parameters for the SubscriptionsClient.Update method. -func (client *SubscriptionsClient) Update(ctx context.Context, billingAccountName string, parameters Subscription, options *SubscriptionsClientUpdateOptions) (SubscriptionsClientUpdateResponse, error) { +// - billingSubscriptionName - The ID that uniquely identifies a subscription. +// - parameters - Request parameters that are provided to split the billing subscription. +// - options - SubscriptionsClientBeginSplitOptions contains the optional parameters for the SubscriptionsClient.BeginSplit +// method. +func (client *SubscriptionsClient) BeginSplit(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters SubscriptionSplitRequest, options *SubscriptionsClientBeginSplitOptions) (*runtime.Poller[SubscriptionsClientSplitResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.split(ctx, billingAccountName, billingSubscriptionName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SubscriptionsClientSplitResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[SubscriptionsClientSplitResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Split - Splits a subscription into a new subscription with quantity less than current subscription quantity and not equal +// to 0. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *SubscriptionsClient) split(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters SubscriptionSplitRequest, options *SubscriptionsClientBeginSplitOptions) (*http.Response, error) { var err error - const operationName = "SubscriptionsClient.Update" + const operationName = "SubscriptionsClient.BeginSplit" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.updateCreateRequest(ctx, billingAccountName, parameters, options) + req, err := client.splitCreateRequest(ctx, billingAccountName, billingSubscriptionName, parameters, options) if err != nil { - return SubscriptionsClientUpdateResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return SubscriptionsClientUpdateResponse{}, err + return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) - return SubscriptionsClientUpdateResponse{}, err + return nil, err } - resp, err := client.updateHandleResponse(httpResp) - return resp, err + return httpResp, nil } -// updateCreateRequest creates the Update request. -func (client *SubscriptionsClient) updateCreateRequest(ctx context.Context, billingAccountName string, parameters Subscription, options *SubscriptionsClientUpdateOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}" +// splitCreateRequest creates the Split request. +func (client *SubscriptionsClient) splitCreateRequest(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters SubscriptionSplitRequest, options *SubscriptionsClientBeginSplitOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{billingSubscriptionName}/split" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") + if billingSubscriptionName == "" { + return nil, errors.New("parameter billingSubscriptionName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + urlPath = strings.ReplaceAll(urlPath, "{billingSubscriptionName}", url.PathEscape(billingSubscriptionName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -484,63 +1086,132 @@ func (client *SubscriptionsClient) updateCreateRequest(ctx context.Context, bill return req, nil } -// updateHandleResponse handles the Update response. -func (client *SubscriptionsClient) updateHandleResponse(resp *http.Response) (SubscriptionsClientUpdateResponse, error) { - result := SubscriptionsClientUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Subscription); err != nil { - return SubscriptionsClientUpdateResponse{}, err +// BeginUpdate - Updates the properties of a billing subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingSubscriptionName - The ID that uniquely identifies a subscription. +// - parameters - The billing properties of a subscription. +// - options - SubscriptionsClientBeginUpdateOptions contains the optional parameters for the SubscriptionsClient.BeginUpdate +// method. +func (client *SubscriptionsClient) BeginUpdate(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters SubscriptionPatch, options *SubscriptionsClientBeginUpdateOptions) (*runtime.Poller[SubscriptionsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, billingAccountName, billingSubscriptionName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SubscriptionsClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[SubscriptionsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } - return result, nil } -// ValidateMove - Validates if a subscription's charges can be moved to a new invoice section. This operation is supported -// for billing accounts with agreement type Microsoft Customer Agreement. +// Update - Updates the properties of a billing subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *SubscriptionsClient) update(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters SubscriptionPatch, options *SubscriptionsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "SubscriptionsClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, billingAccountName, billingSubscriptionName, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *SubscriptionsClient) updateCreateRequest(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters SubscriptionPatch, options *SubscriptionsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{billingSubscriptionName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingSubscriptionName == "" { + return nil, errors.New("parameter billingSubscriptionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingSubscriptionName}", url.PathEscape(billingSubscriptionName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// ValidateMoveEligibility - Validates if charges for a subscription can be moved to a new invoice section. This operation +// is supported for billing accounts with agreement type Microsoft Customer Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. -// - parameters - Request parameters that are provided to the validate move eligibility operation. -// - options - SubscriptionsClientValidateMoveOptions contains the optional parameters for the SubscriptionsClient.ValidateMove +// - billingSubscriptionName - The ID that uniquely identifies a subscription. +// - parameters - Request parameters to transfer billing subscription. +// - options - SubscriptionsClientValidateMoveEligibilityOptions contains the optional parameters for the SubscriptionsClient.ValidateMoveEligibility // method. -func (client *SubscriptionsClient) ValidateMove(ctx context.Context, billingAccountName string, parameters TransferBillingSubscriptionRequestProperties, options *SubscriptionsClientValidateMoveOptions) (SubscriptionsClientValidateMoveResponse, error) { +func (client *SubscriptionsClient) ValidateMoveEligibility(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters MoveBillingSubscriptionRequest, options *SubscriptionsClientValidateMoveEligibilityOptions) (SubscriptionsClientValidateMoveEligibilityResponse, error) { var err error - const operationName = "SubscriptionsClient.ValidateMove" + const operationName = "SubscriptionsClient.ValidateMoveEligibility" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.validateMoveCreateRequest(ctx, billingAccountName, parameters, options) + req, err := client.validateMoveEligibilityCreateRequest(ctx, billingAccountName, billingSubscriptionName, parameters, options) if err != nil { - return SubscriptionsClientValidateMoveResponse{}, err + return SubscriptionsClientValidateMoveEligibilityResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return SubscriptionsClientValidateMoveResponse{}, err + return SubscriptionsClientValidateMoveEligibilityResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return SubscriptionsClientValidateMoveResponse{}, err + return SubscriptionsClientValidateMoveEligibilityResponse{}, err } - resp, err := client.validateMoveHandleResponse(httpResp) + resp, err := client.validateMoveEligibilityHandleResponse(httpResp) return resp, err } -// validateMoveCreateRequest creates the ValidateMove request. -func (client *SubscriptionsClient) validateMoveCreateRequest(ctx context.Context, billingAccountName string, parameters TransferBillingSubscriptionRequestProperties, options *SubscriptionsClientValidateMoveOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}/validateMoveEligibility" +// validateMoveEligibilityCreateRequest creates the ValidateMoveEligibility request. +func (client *SubscriptionsClient) validateMoveEligibilityCreateRequest(ctx context.Context, billingAccountName string, billingSubscriptionName string, parameters MoveBillingSubscriptionRequest, options *SubscriptionsClientValidateMoveEligibilityOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{billingSubscriptionName}/validateMoveEligibility" if billingAccountName == "" { return nil, errors.New("parameter billingAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") + if billingSubscriptionName == "" { + return nil, errors.New("parameter billingSubscriptionName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + urlPath = strings.ReplaceAll(urlPath, "{billingSubscriptionName}", url.PathEscape(billingSubscriptionName)) req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -549,11 +1220,11 @@ func (client *SubscriptionsClient) validateMoveCreateRequest(ctx context.Context return req, nil } -// validateMoveHandleResponse handles the ValidateMove response. -func (client *SubscriptionsClient) validateMoveHandleResponse(resp *http.Response) (SubscriptionsClientValidateMoveResponse, error) { - result := SubscriptionsClientValidateMoveResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ValidateSubscriptionTransferEligibilityResult); err != nil { - return SubscriptionsClientValidateMoveResponse{}, err +// validateMoveEligibilityHandleResponse handles the ValidateMoveEligibility response. +func (client *SubscriptionsClient) validateMoveEligibilityHandleResponse(resp *http.Response) (SubscriptionsClientValidateMoveEligibilityResponse, error) { + result := SubscriptionsClientValidateMoveEligibilityResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.MoveBillingSubscriptionEligibilityResult); err != nil { + return SubscriptionsClientValidateMoveEligibilityResponse{}, err } return result, nil } diff --git a/sdk/resourcemanager/billing/armbilling/subscriptions_client_example_test.go b/sdk/resourcemanager/billing/armbilling/subscriptions_client_example_test.go index bdc0cd07f020..e45814f6e8d1 100644 --- a/sdk/resourcemanager/billing/armbilling/subscriptions_client_example_test.go +++ b/sdk/resourcemanager/billing/armbilling/subscriptions_client_example_test.go @@ -18,8 +18,8 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingSubscriptionsListByCustomer.json -func ExampleSubscriptionsClient_NewListByCustomerPager() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionGetByBillingProfile.json +func ExampleSubscriptionsClient_GetByBillingProfile() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -29,7 +29,57 @@ func ExampleSubscriptionsClient_NewListByCustomerPager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewSubscriptionsClient().NewListByCustomerPager("{billingAccountName}", "{customerName}", nil) + res, err := clientFactory.NewSubscriptionsClient().GetByBillingProfile(ctx, "pcn.94077792", "6478903", "6b96d3f2-9008-4a9d-912f-f87744185aa3", &armbilling.SubscriptionsClientGetByBillingProfileOptions{Expand: nil}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Subscription = armbilling.Subscription{ + // Name: to.Ptr("6b96d3f2-9008-4a9d-912f-f87744185aa3"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/billingSubscriptions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/pcn.94077792/billingProfiles/6478903/billingSubscriptions/6b96d3f2-9008-4a9d-912f-f87744185aa3"), + // Properties: &armbilling.SubscriptionProperties{ + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/pcn.94077792/billingProfiles/6478903"), + // BillingProfileName: to.Ptr("47268432"), + // DisplayName: to.Ptr("My Subscription"), + // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/6564892/billingProfiles/11000000-0000-0000-0000-000000000000/invoiceSections/22000000-0000-0000-0000-000000000000"), + // ProvisioningTenantID: to.Ptr("7d62dbd1-1348-4496-b2f8-df6948c103ee"), + // Quantity: to.Ptr[int64](50), + // SKUDescription: to.Ptr("Microsoft Azure Dev/Test"), + // SKUID: to.Ptr("0001"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SubscriptionID: to.Ptr("6b96d3f2-9008-4a9d-912f-f87744185aa3"), + // SystemOverrides: &armbilling.SystemOverrides{ + // Cancellation: to.Ptr(armbilling.CancellationAllowed), + // CancellationAllowedEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsListByBillingProfileEA.json +func ExampleSubscriptionsClient_NewListByBillingProfilePager_billingSubscriptionsListByBillingProfileEa() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSubscriptionsClient().NewListByBillingProfilePager("pcn.94077792", "6478903", &armbilling.SubscriptionsClientListByBillingProfileOptions{IncludeDeleted: nil, + Expand: nil, + Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -40,68 +90,28 @@ func ExampleSubscriptionsClient_NewListByCustomerPager() { _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.SubscriptionsListResult = armbilling.SubscriptionsListResult{ + // page.SubscriptionListResult = armbilling.SubscriptionListResult{ // Value: []*armbilling.Subscription{ // { - // Name: to.Ptr("billingSubscriptionId1"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/billingSubscriptions/billinSubscriptionId1"), + // Name: to.Ptr("6b96d3f2-9008-4a9d-912f-f87744185aa3"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/billingSubscriptions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/pcn.94077792/billingProfiles/6478903/billingSubscriptions/6b96d3f2-9008-4a9d-912f-f87744185aa3"), // Properties: &armbilling.SubscriptionProperties{ - // CostCenter: to.Ptr("ABC1234"), - // CustomerDisplayName: to.Ptr("Customer1"), - // CustomerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}"), - // DisplayName: to.Ptr("My subscription"), - // LastMonthCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](5000), - // }, - // MonthToDateCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](600), - // }, - // Reseller: &armbilling.Reseller{ - // Description: to.Ptr("Reseller1"), - // ResellerID: to.Ptr("89e87bdf-a2a2-4687-925f-4c18b27bccfd"), - // }, - // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), - // SKUID: to.Ptr("0002"), - // SubscriptionBillingStatus: to.Ptr(armbilling.BillingSubscriptionStatusTypeActive), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/pcn.94077792/billingProfiles/6478903"), + // BillingProfileName: to.Ptr("47268432"), + // DisplayName: to.Ptr("My Subscription"), + // EnrollmentAccountDisplayName: to.Ptr("billtest332211@outlook.com"), + // EnrollmentAccountID: to.Ptr("172988"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), // SubscriptionID: to.Ptr("6b96d3f2-9008-4a9d-912f-f87744185aa3"), // }, - // }, - // { - // Name: to.Ptr("billingSubscriptionId2"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/billingSubscriptions/billinSubscriptionId2"), - // Properties: &armbilling.SubscriptionProperties{ - // CostCenter: to.Ptr("ABC1234"), - // CustomerDisplayName: to.Ptr("Customer1"), - // CustomerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}"), - // DisplayName: to.Ptr("Test subscription"), - // LastMonthCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](1000), - // }, - // MonthToDateCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](400), - // }, - // Reseller: &armbilling.Reseller{ - // Description: to.Ptr("Reseller3"), - // ResellerID: to.Ptr("3b65b5a8-bd4f-4084-90e9-e1bd667a2b19"), - // }, - // SKUDescription: to.Ptr("Microsoft Azure Plan for DevTest"), - // SKUID: to.Ptr("0002"), - // SubscriptionBillingStatus: to.Ptr(armbilling.BillingSubscriptionStatusTypeActive), - // SubscriptionID: to.Ptr("6b96d3f2-9008-4a9d-912f-6b96d3f2"), - // }, // }}, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingSubscriptionsListByBillingAccount.json -func ExampleSubscriptionsClient_NewListByBillingAccountPager() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsListByBillingProfileMCA.json +func ExampleSubscriptionsClient_NewListByBillingProfilePager_billingSubscriptionsListByBillingProfileMca() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -111,7 +121,15 @@ func ExampleSubscriptionsClient_NewListByBillingAccountPager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewSubscriptionsClient().NewListByBillingAccountPager("{billingAccountName}", nil) + pager := clientFactory.NewSubscriptionsClient().NewListByBillingProfilePager("a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31", "ea36e548-1505-41db-bebc-46fff3d37998", &armbilling.SubscriptionsClientListByBillingProfileOptions{IncludeDeleted: nil, + Expand: nil, + Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -122,89 +140,82 @@ func ExampleSubscriptionsClient_NewListByBillingAccountPager() { _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.SubscriptionsListResult = armbilling.SubscriptionsListResult{ + // page.SubscriptionListResult = armbilling.SubscriptionListResult{ // Value: []*armbilling.Subscription{ // { - // Name: to.Ptr("90000000-0000-0000-0000-000000000000"), + // Name: to.Ptr("6b96d3f2-9008-4a9d-912f-f87744185aa3"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/billingSubscriptions/90000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/6b96d3f2-9008-4a9d-912f-f87744185aa3"), // Properties: &armbilling.SubscriptionProperties{ // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // CostCenter: to.Ptr("ABC1234"), - // DisplayName: to.Ptr("My subscription"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // DisplayName: to.Ptr("My Subscription"), // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/22000000-0000-0000-0000-000000000000"), - // LastMonthCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](5000), - // }, - // MonthToDateCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](600), - // }, - // SKUDescription: to.Ptr("Microsoft Azure Plan"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/22000000-0000-0000-0000-000000000000"), + // ResourceURI: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/6b96d3f2-9008-4a9d-912f-f87744185aa3"), + // SKUDescription: to.Ptr("Microsoft Azure Dev/Test"), // SKUID: to.Ptr("0001"), - // SubscriptionBillingStatus: to.Ptr(armbilling.BillingSubscriptionStatusTypeActive), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), // SubscriptionID: to.Ptr("6b96d3f2-9008-4a9d-912f-f87744185aa3"), // }, // }, // { - // Name: to.Ptr("90000000-0000-0000-0000-000000000001"), + // Name: to.Ptr("CD0BBD7A-461A-4D9A-9C59-EAE51A0D5D12"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/billingSubscriptions/90000000-0000-0000-0000-000000000001"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/CD0BBD7A-461A-4D9A-9C59-EAE51A0D5D12"), // Properties: &armbilling.SubscriptionProperties{ // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // CostCenter: to.Ptr("ABC1234"), - // DisplayName: to.Ptr("Test subscription"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // DisplayName: to.Ptr("Test Subscription"), // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/22000000-0000-0000-0000-000000000000"), - // LastMonthCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](1000), - // }, - // MonthToDateCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](400), - // }, - // SKUDescription: to.Ptr("Microsoft Azure Plan"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/22000000-0000-0000-0000-000000000000"), + // ResourceURI: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/CD0BBD7A-461A-4D9A-9C59-EAE51A0D5D12"), + // SKUDescription: to.Ptr("Microsoft Azure Dev/Test"), // SKUID: to.Ptr("0001"), - // SubscriptionBillingStatus: to.Ptr(armbilling.BillingSubscriptionStatusTypeActive), - // SubscriptionID: to.Ptr("6b96d3f2-9008-4a9d-912f-6b96d3f2"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SubscriptionID: to.Ptr("CD0BBD7A-461A-4D9A-9C59-EAE51A0D5D12"), // }, // }, // { - // Name: to.Ptr("90000000-0000-0000-0000-000000000002"), + // Name: to.Ptr("90D31600-D46D-4084-84C6-1235CDAFFB56"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/billingSubscriptions/90000000-0000-0000-0000-000000000002"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/90D31600-D46D-4084-84C6-1235CDAFFB56"), // Properties: &armbilling.SubscriptionProperties{ // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // CostCenter: to.Ptr("ABC1234"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), // DisplayName: to.Ptr("Dev Subscription"), // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/22000000-0000-0000-0000-000000000000"), - // LastMonthCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](6000), - // }, - // MonthToDateCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](900), - // }, - // SKUDescription: to.Ptr("Microsoft Azure Plan"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/22000000-0000-0000-0000-000000000000"), + // ResourceURI: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/90D31600-D46D-4084-84C6-1235CDAFFB56"), + // SKUDescription: to.Ptr("Microsoft Azure Dev/Test"), + // SKUID: to.Ptr("0001"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SubscriptionID: to.Ptr("90D31600-D46D-4084-84C6-1235CDAFFB56"), + // }, + // }, + // { + // Name: to.Ptr("9e90f86b-22fc-42f3-bfe2-0ac3e7c01d32"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/9e90f86b-22fc-42f3-bfe2-0ac3e7c01d32"), + // Properties: &armbilling.SubscriptionProperties{ + // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // DisplayName: to.Ptr("Dev Test Subscription"), + // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/22000000-0000-0000-0000-000000000000"), + // ResourceURI: to.Ptr("/providers/Microsoft.Domain/domainSubscriptions/9e90f86b-22fc-42f3-bfe2-0ac3e7c01d32"), + // SKUDescription: to.Ptr("Domain Name Registration ORG"), // SKUID: to.Ptr("0001"), - // SubscriptionBillingStatus: to.Ptr(armbilling.BillingSubscriptionStatusTypeActive), - // SubscriptionID: to.Ptr("6b96d3f2-4a9d-9008-912f-f87744185aa3"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SubscriptionID: to.Ptr("9e90f86b-22fc-42f3-bfe2-0ac3e7c01d32"), // }, // }}, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingSubscriptionsListByBillingProfile.json -func ExampleSubscriptionsClient_NewListByBillingProfilePager() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsListByCustomer.json +func ExampleSubscriptionsClient_NewListByCustomerPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -214,7 +225,15 @@ func ExampleSubscriptionsClient_NewListByBillingProfilePager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewSubscriptionsClient().NewListByBillingProfilePager("{billingAccountName}", "{billingProfileName}", nil) + pager := clientFactory.NewSubscriptionsClient().NewListByCustomerPager("a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31", "ea36e548-1505-41db-bebc-46fff3d37998", "Q7GV-UUVA-PJA-TGB", &armbilling.SubscriptionsClientListByCustomerOptions{IncludeDeleted: nil, + Expand: nil, + Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -225,88 +244,75 @@ func ExampleSubscriptionsClient_NewListByBillingProfilePager() { _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.SubscriptionsListResult = armbilling.SubscriptionsListResult{ + // page.SubscriptionListResult = armbilling.SubscriptionListResult{ // Value: []*armbilling.Subscription{ // { - // Name: to.Ptr("billingSubscriptionId1"), + // Name: to.Ptr("6b96d3f2-9008-4a9d-912f-f87744185aa3"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/billingSubscriptions/billinSubscriptionId1"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/6b96d3f2-9008-4a9d-912f-f87744185aa3"), // Properties: &armbilling.SubscriptionProperties{ - // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"), - // CostCenter: to.Ptr("ABC1234"), - // DisplayName: to.Ptr("My subscription"), - // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/22000000-0000-0000-0000-000000000000"), - // LastMonthCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](5000), - // }, - // MonthToDateCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](600), + // BillingProfileDisplayName: to.Ptr("BillingProfile1"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // BillingProfileName: to.Ptr("ea36e548-1505-41db-bebc-46fff3d37998"), + // CustomerDisplayName: to.Ptr("Customer1"), + // CustomerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/customers/Q7GV-UUVA-PJA-TGB"), + // DisplayName: to.Ptr("My Subscription"), + // Reseller: &armbilling.Reseller{ + // Description: to.Ptr("Reseller1"), + // ResellerID: to.Ptr("89e87bdf-a2a2-4687-925f-4c18b27bccfd"), // }, - // SKUDescription: to.Ptr("Microsoft Azure Plan"), - // SKUID: to.Ptr("0001"), - // SubscriptionBillingStatus: to.Ptr(armbilling.BillingSubscriptionStatusTypeActive), + // ResourceURI: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/6b96d3f2-9008-4a9d-912f-f87744185aa3"), + // SKUDescription: to.Ptr("Microsoft Azure Standard"), + // SKUID: to.Ptr("0002"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), // SubscriptionID: to.Ptr("6b96d3f2-9008-4a9d-912f-f87744185aa3"), // }, // }, // { - // Name: to.Ptr("billingSubscriptionId2"), + // Name: to.Ptr("CD0BBD7A-461A-4D9A-9C59-EAE51A0D5D12"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/billingSubscriptions/billinSubscriptionId2"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/CD0BBD7A-461A-4D9A-9C59-EAE51A0D5D12"), // Properties: &armbilling.SubscriptionProperties{ - // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"), - // CostCenter: to.Ptr("ABC1234"), - // DisplayName: to.Ptr("Test subscription"), - // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/22000000-0000-0000-0000-000000000000"), - // LastMonthCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](1000), - // }, - // MonthToDateCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](400), + // BillingProfileDisplayName: to.Ptr("BillingProfile1"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // BillingProfileName: to.Ptr("ea36e548-1505-41db-bebc-46fff3d37998"), + // CustomerDisplayName: to.Ptr("Customer1"), + // CustomerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/customers/Q7GV-UUVA-PJA-TGB"), + // DisplayName: to.Ptr("Test Subscription"), + // Reseller: &armbilling.Reseller{ + // Description: to.Ptr("Reseller3"), + // ResellerID: to.Ptr("3b65b5a8-bd4f-4084-90e9-e1bd667a2b19"), // }, - // SKUDescription: to.Ptr("Microsoft Azure Plan"), - // SKUID: to.Ptr("0001"), - // SubscriptionBillingStatus: to.Ptr(armbilling.BillingSubscriptionStatusTypeActive), - // SubscriptionID: to.Ptr("6b96d3f2-9008-4a9d-912f-6b96d3f2"), + // ResourceURI: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/CD0BBD7A-461A-4D9A-9C59-EAE51A0D5D12"), + // SKUDescription: to.Ptr("Microsoft Azure Standard"), + // SKUID: to.Ptr("0002"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SubscriptionID: to.Ptr("CD0BBD7A-461A-4D9A-9C59-EAE51A0D5D12"), // }, // }, // { - // Name: to.Ptr("billingSubscriptionId3"), + // Name: to.Ptr("9e90f86b-22fc-42f3-bfe2-0ac3e7c01d32"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/billingSubscriptions/billinSubscriptionId3"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/9e90f86b-22fc-42f3-bfe2-0ac3e7c01d32"), // Properties: &armbilling.SubscriptionProperties{ - // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"), - // CostCenter: to.Ptr("ABC1234"), - // DisplayName: to.Ptr("Dev Subscription"), - // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/22000000-0000-0000-0000-000000000000"), - // LastMonthCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](6000), - // }, - // MonthToDateCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](900), - // }, - // SKUDescription: to.Ptr("Microsoft Azure Plan"), + // BillingProfileDisplayName: to.Ptr("BillingProfile1"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // BillingProfileName: to.Ptr("ea36e548-1505-41db-bebc-46fff3d37998"), + // CustomerDisplayName: to.Ptr("Customer1"), + // CustomerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/customers/Q7GV-UUVA-PJA-TGB"), + // DisplayName: to.Ptr("Dev Test Subscription"), + // ResourceURI: to.Ptr("/providers/Microsoft.Domain/domainSubscriptions/9e90f86b-22fc-42f3-bfe2-0ac3e7c01d32"), + // SKUDescription: to.Ptr("Domain Name Registration ORG"), // SKUID: to.Ptr("0001"), - // SubscriptionBillingStatus: to.Ptr(armbilling.BillingSubscriptionStatusTypeActive), - // SubscriptionID: to.Ptr("6b96d3f2-4a9d-9008-912f-f87744185aa3"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SubscriptionID: to.Ptr("9e90f86b-22fc-42f3-bfe2-0ac3e7c01d32"), // }, // }}, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingSubscriptionsListByInvoiceSection.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsListByInvoiceSection.json func ExampleSubscriptionsClient_NewListByInvoiceSectionPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -317,7 +323,15 @@ func ExampleSubscriptionsClient_NewListByInvoiceSectionPager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewSubscriptionsClient().NewListByInvoiceSectionPager("{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", nil) + pager := clientFactory.NewSubscriptionsClient().NewListByInvoiceSectionPager("a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31", "ea36e548-1505-41db-bebc-46fff3d37998", "Q7GV-UUVA-PJA-TGB", &armbilling.SubscriptionsClientListByInvoiceSectionOptions{IncludeDeleted: nil, + Expand: nil, + Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -328,89 +342,106 @@ func ExampleSubscriptionsClient_NewListByInvoiceSectionPager() { _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.SubscriptionsListResult = armbilling.SubscriptionsListResult{ + // page.SubscriptionListResult = armbilling.SubscriptionListResult{ // Value: []*armbilling.Subscription{ // { - // Name: to.Ptr("billingSubscriptionId1"), + // Name: to.Ptr("6b96d3f2-9008-4a9d-912f-f87744185aa3"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/billingSubscriptions/billinSubscriptionId1"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/6b96d3f2-9008-4a9d-912f-f87744185aa3"), // Properties: &armbilling.SubscriptionProperties{ // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // CostCenter: to.Ptr("ABC1234"), - // DisplayName: to.Ptr("My subscription"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // DisplayName: to.Ptr("My Subscription"), // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}"), - // LastMonthCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](5000), - // }, - // MonthToDateCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](600), - // }, - // SKUDescription: to.Ptr("Microsoft Azure Plan"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB"), + // ResourceURI: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/6b96d3f2-9008-4a9d-912f-f87744185aa3"), + // SKUDescription: to.Ptr("Microsoft Azure Dev/Test"), // SKUID: to.Ptr("0001"), - // SubscriptionBillingStatus: to.Ptr(armbilling.BillingSubscriptionStatusTypeActive), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), // SubscriptionID: to.Ptr("6b96d3f2-9008-4a9d-912f-f87744185aa3"), // }, // }, // { - // Name: to.Ptr("billingSubscriptionId2"), + // Name: to.Ptr("CD0BBD7A-461A-4D9A-9C59-EAE51A0D5D12"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/billingSubscriptions/billinSubscriptionId2"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/CD0BBD7A-461A-4D9A-9C59-EAE51A0D5D12"), // Properties: &armbilling.SubscriptionProperties{ // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // CostCenter: to.Ptr("ABC1234"), - // DisplayName: to.Ptr("Test subscription"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // DisplayName: to.Ptr("Test Subscription"), // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}"), - // LastMonthCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](1000), - // }, - // MonthToDateCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](400), - // }, - // SKUDescription: to.Ptr("Microsoft Azure Plan"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB"), + // ResourceURI: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/CD0BBD7A-461A-4D9A-9C59-EAE51A0D5D12"), + // SKUDescription: to.Ptr("Microsoft Azure Dev/Test"), // SKUID: to.Ptr("0001"), - // SubscriptionBillingStatus: to.Ptr(armbilling.BillingSubscriptionStatusTypeActive), - // SubscriptionID: to.Ptr("6b96d3f2-9008-4a9d-912f-6b96d3f2"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SubscriptionID: to.Ptr("CD0BBD7A-461A-4D9A-9C59-EAE51A0D5D12"), // }, // }, // { - // Name: to.Ptr("billingSubscriptionId3"), + // Name: to.Ptr("90D31600-D46D-4084-84C6-1235CDAFFB56"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/billingSubscriptions/billinSubscriptionId3"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/90D31600-D46D-4084-84C6-1235CDAFFB56"), // Properties: &armbilling.SubscriptionProperties{ // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // CostCenter: to.Ptr("ABC1234"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), // DisplayName: to.Ptr("Dev Subscription"), // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}"), - // LastMonthCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](6000), - // }, - // MonthToDateCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](900), - // }, - // SKUDescription: to.Ptr("Microsoft Azure Plan"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB"), + // ResourceURI: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/90D31600-D46D-4084-84C6-1235CDAFFB56"), + // SKUDescription: to.Ptr("Microsoft Azure Dev/Test"), + // SKUID: to.Ptr("0001"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SubscriptionID: to.Ptr("90D31600-D46D-4084-84C6-1235CDAFFB56"), + // }, + // }, + // { + // Name: to.Ptr("9e90f86b-22fc-42f3-bfe2-0ac3e7c01d32"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/9e90f86b-22fc-42f3-bfe2-0ac3e7c01d32"), + // Properties: &armbilling.SubscriptionProperties{ + // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // DisplayName: to.Ptr("Dev Test Subscription"), + // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB"), + // ResourceURI: to.Ptr("/providers/Microsoft.Domain/domainSubscriptions/9e90f86b-22fc-42f3-bfe2-0ac3e7c01d32"), + // SKUDescription: to.Ptr("Domain Name Registration ORG"), // SKUID: to.Ptr("0001"), - // SubscriptionBillingStatus: to.Ptr(armbilling.BillingSubscriptionStatusTypeActive), - // SubscriptionID: to.Ptr("6b96d3f2-4a9d-9008-912f-f87744185aa3"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SubscriptionID: to.Ptr("9e90f86b-22fc-42f3-bfe2-0ac3e7c01d32"), // }, // }}, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/BillingSubscription.json -func ExampleSubscriptionsClient_Get() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsCancel.json +func ExampleSubscriptionsClient_BeginCancel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewSubscriptionsClient().BeginCancel(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "11111111-1111-1111-1111-111111111111", armbilling.CancelSubscriptionRequest{ + CancellationReason: to.Ptr(armbilling.CancellationReasonCompromise), + CustomerID: to.Ptr("11111111-1111-1111-1111-111111111111"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsMerge.json +func ExampleSubscriptionsClient_BeginMerge() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -420,42 +451,57 @@ func ExampleSubscriptionsClient_Get() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewSubscriptionsClient().Get(ctx, "{billingAccountName}", nil) + poller, err := clientFactory.NewSubscriptionsClient().BeginMerge(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "11111111-1111-1111-1111-111111111111", armbilling.SubscriptionMergeRequest{ + Quantity: to.Ptr[int32](1), + TargetBillingSubscriptionName: to.Ptr("22222222-2222-2222-2222-222222222222"), + }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Subscription = armbilling.Subscription{ - // Name: to.Ptr("{subscriptionId}"), + // Name: to.Ptr("22222222-2222-2222-2222-222222222222"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingSubscriptions/22222222-2222-2222-2222-222222222222"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-25T22:39:34.260Z"); return t}()), + // }, // Properties: &armbilling.SubscriptionProperties{ - // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // CostCenter: to.Ptr("ABC1234"), - // DisplayName: to.Ptr("My Subscription"), - // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000/invoiceSections/22000000-0000-0000-0000-000000000000"), - // LastMonthCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](5000), - // }, - // MonthToDateCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](600), - // }, - // SKUDescription: to.Ptr("Microsoft Azure Plan"), + // AutoRenew: to.Ptr(armbilling.AutoRenewOn), + // BillingProfileDisplayName: to.Ptr("Billing Profile Display Name"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileName: to.Ptr("xxxx-xxxx-xxx-xxx"), + // DisplayName: to.Ptr("Billing Subscription Display Name"), + // InvoiceSectionDisplayName: to.Ptr("Invoice Section Display Name"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy"), + // InvoiceSectionName: to.Ptr("yyyy-yyyy-yyy-yyy"), + // ProductCategory: to.Ptr("SeatBased"), + // ProductType: to.Ptr("Seat-Based Product Type"), + // ProductTypeID: to.Ptr("XYZ56789"), + // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // Quantity: to.Ptr[int64](2), + // SKUDescription: to.Ptr("SKU Description"), // SKUID: to.Ptr("0001"), - // SubscriptionBillingStatus: to.Ptr(armbilling.BillingSubscriptionStatusTypeActive), - // SubscriptionID: to.Ptr("6b96d3f2-9008-4a9d-912f-f87744185aa3"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SystemOverrides: &armbilling.SystemOverrides{ + // CancellationAllowedEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T22:39:34.260Z"); return t}()), + // }, + // TermDuration: to.Ptr("P1M"), + // TermEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-05T22:39:34.260Z"); return t}()), + // TermStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/UpdateBillingSubscription.json -func ExampleSubscriptionsClient_Update() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionMove.json +func ExampleSubscriptionsClient_BeginMove() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -465,46 +511,40 @@ func ExampleSubscriptionsClient_Update() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewSubscriptionsClient().Update(ctx, "{billingAccountName}", armbilling.Subscription{ - Properties: &armbilling.SubscriptionProperties{ - CostCenter: to.Ptr("ABC1234"), - }, + poller, err := clientFactory.NewSubscriptionsClient().BeginMove(ctx, "a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31", "6b96d3f2-9008-4a9d-912f-f87744185aa3", armbilling.MoveBillingSubscriptionRequest{ + DestinationInvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB"), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Subscription = armbilling.Subscription{ - // Name: to.Ptr("{subscriptionId}"), + // Name: to.Ptr("6b96d3f2-9008-4a9d-912f-f87744185aa3"), // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/6b96d3f2-9008-4a9d-912f-f87744185aa3"), // Properties: &armbilling.SubscriptionProperties{ // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // CostCenter: to.Ptr("ABC1234"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // ConsumptionCostCenter: to.Ptr("ABC1234"), // DisplayName: to.Ptr("My Subscription"), // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000/invoiceSections/22000000-0000-0000-0000-000000000000"), - // LastMonthCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](5000), - // }, - // MonthToDateCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](600), - // }, + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB"), // SKUDescription: to.Ptr("Microsoft Azure Plan"), // SKUID: to.Ptr("0001"), - // SubscriptionBillingStatus: to.Ptr(armbilling.BillingSubscriptionStatusTypeActive), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), // SubscriptionID: to.Ptr("6b96d3f2-9008-4a9d-912f-f87744185aa3"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/MoveBillingSubscription.json -func ExampleSubscriptionsClient_BeginMove() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsSplit.json +func ExampleSubscriptionsClient_BeginSplit() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -514,8 +554,12 @@ func ExampleSubscriptionsClient_BeginMove() { if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := clientFactory.NewSubscriptionsClient().BeginMove(ctx, "{billingAccountName}", armbilling.TransferBillingSubscriptionRequestProperties{ - DestinationInvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{newInvoiceSectionName}"), + poller, err := clientFactory.NewSubscriptionsClient().BeginSplit(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "11111111-1111-1111-1111-111111111111", armbilling.SubscriptionSplitRequest{ + BillingFrequency: to.Ptr("P1M"), + Quantity: to.Ptr[int32](1), + TargetProductTypeID: to.Ptr("XYZ56789"), + TargetSKUID: to.Ptr("0001"), + TermDuration: to.Ptr("P1M"), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -528,31 +572,42 @@ func ExampleSubscriptionsClient_BeginMove() { _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Subscription = armbilling.Subscription{ + // Name: to.Ptr("11111111-1111-1111-1111-111111111111"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingSubscriptions/11111111-1111-1111-1111-111111111111"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-25T22:39:34.260Z"); return t}()), + // }, // Properties: &armbilling.SubscriptionProperties{ - // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000"), - // CostCenter: to.Ptr("ABC1234"), - // DisplayName: to.Ptr("My Subscription"), - // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/11000000-0000-0000-0000-000000000000/invoiceSections/22000000-0000-0000-0000-000000000000"), - // LastMonthCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](5000), - // }, - // MonthToDateCharges: &armbilling.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float32](600), - // }, - // SKUDescription: to.Ptr("Microsoft Azure Plan"), + // AutoRenew: to.Ptr(armbilling.AutoRenewOn), + // BillingProfileDisplayName: to.Ptr("Billing Profile Display Name"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileName: to.Ptr("xxxx-xxxx-xxx-xxx"), + // DisplayName: to.Ptr("Billing Subscription Display Name"), + // InvoiceSectionDisplayName: to.Ptr("Invoice Section Display Name"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy"), + // InvoiceSectionName: to.Ptr("yyyy-yyyy-yyy-yyy"), + // ProductCategory: to.Ptr("SeatBased"), + // ProductType: to.Ptr("Seat-Based Product Type"), + // ProductTypeID: to.Ptr("XYZ56789"), + // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // Quantity: to.Ptr[int64](1), + // SKUDescription: to.Ptr("SKU Description"), // SKUID: to.Ptr("0001"), - // SubscriptionBillingStatus: to.Ptr(armbilling.BillingSubscriptionStatusTypeActive), - // SubscriptionID: to.Ptr("6b96d3f2-9008-4a9d-912f-f87744185aa3"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SystemOverrides: &armbilling.SystemOverrides{ + // CancellationAllowedEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T22:39:34.260Z"); return t}()), + // }, + // TermDuration: to.Ptr("P1M"), + // TermEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-05T22:39:34.260Z"); return t}()), + // TermStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/ValidateSubscriptionMoveFailure.json -func ExampleSubscriptionsClient_ValidateMove_subscriptionMoveValidateFailure() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionValidateMoveFailure.json +func ExampleSubscriptionsClient_ValidateMoveEligibility_billingSubscriptionValidateMoveFailure() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -562,8 +617,8 @@ func ExampleSubscriptionsClient_ValidateMove_subscriptionMoveValidateFailure() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewSubscriptionsClient().ValidateMove(ctx, "{billingAccountName}", armbilling.TransferBillingSubscriptionRequestProperties{ - DestinationInvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{newInvoiceSectionName}"), + res, err := clientFactory.NewSubscriptionsClient().ValidateMoveEligibility(ctx, "a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31", "6b96d3f2-9008-4a9d-912f-f87744185aa3", armbilling.MoveBillingSubscriptionRequest{ + DestinationInvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB"), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -571,17 +626,16 @@ func ExampleSubscriptionsClient_ValidateMove_subscriptionMoveValidateFailure() { // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ValidateSubscriptionTransferEligibilityResult = armbilling.ValidateSubscriptionTransferEligibilityResult{ - // ErrorDetails: &armbilling.ValidateSubscriptionTransferEligibilityError{ + // res.MoveBillingSubscriptionEligibilityResult = armbilling.MoveBillingSubscriptionEligibilityResult{ + // ErrorDetails: &armbilling.MoveBillingSubscriptionErrorDetails{ // Code: to.Ptr(armbilling.SubscriptionTransferValidationErrorCodeSubscriptionNotActive), // Message: to.Ptr("Invoice Sections can only be changed for active subscriptions."), // }, - // IsMoveEligible: to.Ptr(false), // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/ValidateSubscriptionMoveSuccess.json -func ExampleSubscriptionsClient_ValidateMove_subscriptionMoveValidateSuccess() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionValidateMoveSuccess.json +func ExampleSubscriptionsClient_ValidateMoveEligibility_billingSubscriptionValidateMoveSuccess() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -591,8 +645,8 @@ func ExampleSubscriptionsClient_ValidateMove_subscriptionMoveValidateSuccess() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewSubscriptionsClient().ValidateMove(ctx, "{billingAccountName}", armbilling.TransferBillingSubscriptionRequestProperties{ - DestinationInvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{newInvoiceSectionName}"), + res, err := clientFactory.NewSubscriptionsClient().ValidateMoveEligibility(ctx, "a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31", "6b96d3f2-9008-4a9d-912f-f87744185aa3", armbilling.MoveBillingSubscriptionRequest{ + DestinationInvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB"), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -600,7 +654,453 @@ func ExampleSubscriptionsClient_ValidateMove_subscriptionMoveValidateSuccess() { // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ValidateSubscriptionTransferEligibilityResult = armbilling.ValidateSubscriptionTransferEligibilityResult{ + // res.MoveBillingSubscriptionEligibilityResult = armbilling.MoveBillingSubscriptionEligibilityResult{ // IsMoveEligible: to.Ptr(true), // } } + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsDelete.json +func ExampleSubscriptionsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewSubscriptionsClient().BeginDelete(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "11111111-1111-1111-1111-111111111111", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsGet.json +func ExampleSubscriptionsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSubscriptionsClient().Get(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "11111111-1111-1111-1111-111111111111", &armbilling.SubscriptionsClientGetOptions{Expand: nil}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Subscription = armbilling.Subscription{ + // Name: to.Ptr("90000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingSubscriptions/90000000-0000-0000-0000-000000000000"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // }, + // Properties: &armbilling.SubscriptionProperties{ + // AutoRenew: to.Ptr(armbilling.AutoRenewOn), + // BillingProfileDisplayName: to.Ptr("Billing Profile Display Name"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileName: to.Ptr("xxxx-xxxx-xxx-xxx"), + // DisplayName: to.Ptr("My subscription"), + // InvoiceSectionDisplayName: to.Ptr("Invoice Section Display Name"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy"), + // InvoiceSectionName: to.Ptr("yyyy-yyyy-yyy-yyy"), + // ProductCategory: to.Ptr("SeatBased"), + // ProductType: to.Ptr("Seat-Based Product Type"), + // ProductTypeID: to.Ptr("XYZ56789"), + // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // Quantity: to.Ptr[int64](1), + // ResourceURI: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingSubscriptions/90000000-0000-0000-0000-000000000000"), + // SKUDescription: to.Ptr("SKU Description"), + // SKUID: to.Ptr("0001"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SystemOverrides: &armbilling.SystemOverrides{ + // CancellationAllowedEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T22:39:34.260Z"); return t}()), + // }, + // TermDuration: to.Ptr("P1M"), + // TermEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-05T22:39:34.260Z"); return t}()), + // TermStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsUpdate.json +func ExampleSubscriptionsClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewSubscriptionsClient().BeginUpdate(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "11111111-1111-1111-1111-111111111111", armbilling.SubscriptionPatch{ + Properties: &armbilling.SubscriptionProperties{ + ConsumptionCostCenter: to.Ptr("ABC1234"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Subscription = armbilling.Subscription{ + // Name: to.Ptr("11111111-1111-1111-1111-111111111111"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingSubscriptions/11111111-1111-1111-1111-111111111111"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-25T22:39:34.260Z"); return t}()), + // }, + // Properties: &armbilling.SubscriptionProperties{ + // AutoRenew: to.Ptr(armbilling.AutoRenewOn), + // BillingProfileDisplayName: to.Ptr("Billing Profile Display Name"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileName: to.Ptr("xxxx-xxxx-xxx-xxx"), + // DisplayName: to.Ptr("Billing Subscription Display Name"), + // InvoiceSectionDisplayName: to.Ptr("Invoice Section Display Name"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy"), + // InvoiceSectionName: to.Ptr("yyyy-yyyy-yyy-yyy"), + // ProductCategory: to.Ptr("SeatBased"), + // ProductType: to.Ptr("Seat-Based Product Type"), + // ProductTypeID: to.Ptr("XYZ56789"), + // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // Quantity: to.Ptr[int64](1), + // SKUDescription: to.Ptr("SKU Description"), + // SKUID: to.Ptr("0001"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SystemOverrides: &armbilling.SystemOverrides{ + // CancellationAllowedEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T22:39:34.260Z"); return t}()), + // }, + // TermDuration: to.Ptr("P1M"), + // TermEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-05T22:39:34.260Z"); return t}()), + // TermStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsListByBillingAccount.json +func ExampleSubscriptionsClient_NewListByBillingAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSubscriptionsClient().NewListByBillingAccountPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", &armbilling.SubscriptionsClientListByBillingAccountOptions{IncludeDeleted: to.Ptr(false), + IncludeTenantSubscriptions: to.Ptr(false), + IncludeFailed: nil, + Expand: nil, + Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.SubscriptionListResult = armbilling.SubscriptionListResult{ + // Value: []*armbilling.Subscription{ + // { + // Name: to.Ptr("90000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingSubscriptions/90000000-0000-0000-0000-000000000000"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // }, + // Properties: &armbilling.SubscriptionProperties{ + // AutoRenew: to.Ptr(armbilling.AutoRenewOn), + // BillingProfileDisplayName: to.Ptr("Billing Profile Display Name"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileName: to.Ptr("xxxx-xxxx-xxx-xxx"), + // DisplayName: to.Ptr("My subscription"), + // InvoiceSectionDisplayName: to.Ptr("Invoice Section Display Name"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy"), + // InvoiceSectionName: to.Ptr("yyyy-yyyy-yyy-yyy"), + // ProductCategory: to.Ptr("SeatBased"), + // ProductType: to.Ptr("Seat-Based Product Type"), + // ProductTypeID: to.Ptr("XYZ56789"), + // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // Quantity: to.Ptr[int64](1), + // ResourceURI: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingSubscriptions/90000000-0000-0000-0000-000000000000"), + // SKUDescription: to.Ptr("SKU Description"), + // SKUID: to.Ptr("0001"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SystemOverrides: &armbilling.SystemOverrides{ + // CancellationAllowedEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T22:39:34.260Z"); return t}()), + // }, + // TermDuration: to.Ptr("P1M"), + // TermEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-05T22:39:34.260Z"); return t}()), + // TermStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("90000000-0000-0000-0000-000000000001"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingSubscriptions/90000000-0000-0000-0000-000000000001"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-06T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-07T22:39:34.260Z"); return t}()), + // }, + // Properties: &armbilling.SubscriptionProperties{ + // AutoRenew: to.Ptr(armbilling.AutoRenewOn), + // BillingProfileDisplayName: to.Ptr("Billing Profile Display Name"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileName: to.Ptr("xxxx-xxxx-xxx-xxx"), + // DisplayName: to.Ptr("Test subscription"), + // InvoiceSectionDisplayName: to.Ptr("Invoice Section Display Name"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy"), + // InvoiceSectionName: to.Ptr("yyyy-yyyy-yyy-yyy"), + // ProductCategory: to.Ptr("Software"), + // ProductType: to.Ptr("Software Product Type"), + // ProductTypeID: to.Ptr("EFG456"), + // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-06T22:39:34.260Z"); return t}()), + // Quantity: to.Ptr[int64](1), + // ResourceURI: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingSubscriptions/90000000-0000-0000-0000-000000000001"), + // SKUDescription: to.Ptr("SKU Description"), + // SKUID: to.Ptr("0001"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SystemOverrides: &armbilling.SystemOverrides{ + // CancellationAllowedEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T22:39:34.260Z"); return t}()), + // }, + // TermDuration: to.Ptr("P1M"), + // TermEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-07T22:39:34.260Z"); return t}()), + // TermStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-07T22:39:34.260Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("90000000-0000-0000-0000-000000000002"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingSubscriptions/90000000-0000-0000-0000-000000000002"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-25T22:39:34.260Z"); return t}()), + // }, + // Properties: &armbilling.SubscriptionProperties{ + // AutoRenew: to.Ptr(armbilling.AutoRenewOn), + // BillingProfileDisplayName: to.Ptr("Billing Profile Display Name"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileName: to.Ptr("xxxx-xxxx-xxx-xxx"), + // DisplayName: to.Ptr("Dev subscription"), + // InvoiceSectionDisplayName: to.Ptr("Invoice Section Display Name"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy"), + // InvoiceSectionName: to.Ptr("yyyy-yyyy-yyy-yyy"), + // ProductCategory: to.Ptr("ReservationOrder"), + // ProductType: to.Ptr("Reservation Product Type"), + // ProductTypeID: to.Ptr("JKL789"), + // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // Quantity: to.Ptr[int64](1), + // ResourceURI: to.Ptr("/providers/Microsoft.Capacity/reservationOrders/90000000-0000-0000-0000-000000000002"), + // SKUDescription: to.Ptr("SKU Description"), + // SKUID: to.Ptr("0001"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusSuspended), + // SuspensionReasonDetails: []*armbilling.SubscriptionStatusDetails{ + // { + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-15T22:39:34.260Z"); return t}()), + // Reason: to.Ptr(armbilling.SubscriptionStatusReasonCancelled), + // }}, + // SuspensionReasons: []*string{ + // to.Ptr("Cancelled")}, + // SystemOverrides: &armbilling.SystemOverrides{ + // CancellationAllowedEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T22:39:34.260Z"); return t}()), + // }, + // TermDuration: to.Ptr("P1M"), + // TermEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-05T22:39:34.260Z"); return t}()), + // TermStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsListByCustomerAtBillingAccount.json +func ExampleSubscriptionsClient_NewListByCustomerAtBillingAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSubscriptionsClient().NewListByCustomerAtBillingAccountPager("a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31", "Q7GV-UUVA-PJA-TGB", &armbilling.SubscriptionsClientListByCustomerAtBillingAccountOptions{IncludeDeleted: nil, + Expand: nil, + Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.SubscriptionListResult = armbilling.SubscriptionListResult{ + // Value: []*armbilling.Subscription{ + // { + // Name: to.Ptr("6b96d3f2-9008-4a9d-912f-f87744185aa3"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/6b96d3f2-9008-4a9d-912f-f87744185aa3"), + // Properties: &armbilling.SubscriptionProperties{ + // BillingProfileDisplayName: to.Ptr("BillingProfile1"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // BillingProfileName: to.Ptr("ea36e548-1505-41db-bebc-46fff3d37998"), + // CustomerDisplayName: to.Ptr("Customer1"), + // CustomerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/customers/Q7GV-UUVA-PJA-TGB"), + // DisplayName: to.Ptr("My Subscription"), + // Reseller: &armbilling.Reseller{ + // Description: to.Ptr("Reseller1"), + // ResellerID: to.Ptr("89e87bdf-a2a2-4687-925f-4c18b27bccfd"), + // }, + // ResourceURI: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/6b96d3f2-9008-4a9d-912f-f87744185aa3"), + // SKUDescription: to.Ptr("Microsoft Azure Standard"), + // SKUID: to.Ptr("0002"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SubscriptionID: to.Ptr("6b96d3f2-9008-4a9d-912f-f87744185aa3"), + // }, + // }, + // { + // Name: to.Ptr("CD0BBD7A-461A-4D9A-9C59-EAE51A0D5D12"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/CD0BBD7A-461A-4D9A-9C59-EAE51A0D5D12"), + // Properties: &armbilling.SubscriptionProperties{ + // BillingProfileDisplayName: to.Ptr("BillingProfile1"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // BillingProfileName: to.Ptr("ea36e548-1505-41db-bebc-46fff3d37998"), + // CustomerDisplayName: to.Ptr("Customer1"), + // CustomerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/customers/Q7GV-UUVA-PJA-TGB"), + // DisplayName: to.Ptr("Test Subscription"), + // Reseller: &armbilling.Reseller{ + // Description: to.Ptr("Reseller3"), + // ResellerID: to.Ptr("3b65b5a8-bd4f-4084-90e9-e1bd667a2b19"), + // }, + // ResourceURI: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/CD0BBD7A-461A-4D9A-9C59-EAE51A0D5D12"), + // SKUDescription: to.Ptr("Microsoft Azure Standard"), + // SKUID: to.Ptr("0002"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SubscriptionID: to.Ptr("CD0BBD7A-461A-4D9A-9C59-EAE51A0D5D12"), + // }, + // }, + // { + // Name: to.Ptr("9e90f86b-22fc-42f3-bfe2-0ac3e7c01d32"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingSubscriptions/9e90f86b-22fc-42f3-bfe2-0ac3e7c01d32"), + // Properties: &armbilling.SubscriptionProperties{ + // BillingProfileDisplayName: to.Ptr("BillingProfile1"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998"), + // BillingProfileName: to.Ptr("ea36e548-1505-41db-bebc-46fff3d37998"), + // CustomerDisplayName: to.Ptr("Customer1"), + // CustomerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/customers/Q7GV-UUVA-PJA-TGB"), + // DisplayName: to.Ptr("Dev Test Subscription"), + // ResourceURI: to.Ptr("/providers/Microsoft.Domain/domainSubscriptions/9e90f86b-22fc-42f3-bfe2-0ac3e7c01d32"), + // SKUDescription: to.Ptr("Domain Name Registration ORG"), + // SKUID: to.Ptr("0001"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SubscriptionID: to.Ptr("9e90f86b-22fc-42f3-bfe2-0ac3e7c01d32"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsListByEnrollmentAccount.json +func ExampleSubscriptionsClient_NewListByEnrollmentAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSubscriptionsClient().NewListByEnrollmentAccountPager("6564892", "172988", &armbilling.SubscriptionsClientListByEnrollmentAccountOptions{Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.SubscriptionListResult = armbilling.SubscriptionListResult{ + // Value: []*armbilling.Subscription{ + // { + // Name: to.Ptr("90000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), + // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/6564892/billingSubscriptions/90000000-0000-0000-0000-000000000000"), + // Properties: &armbilling.SubscriptionProperties{ + // ConsumptionCostCenter: to.Ptr("123"), + // DisplayName: to.Ptr("TestSubscription"), + // EnrollmentAccountDisplayName: to.Ptr("billtest332211@outlook.com"), + // EnrollmentAccountID: to.Ptr("172988"), + // EnrollmentAccountSubscriptionDetails: &armbilling.EnrollmentAccountSubscriptionDetails{ + // EnrollmentAccountStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T00:00:00.000Z"); return t}()), + // }, + // SubscriptionID: to.Ptr("90000000-0000-0000-0000-000000000000"), + // }, + // }, + // { + // Name: to.Ptr("90000000-0000-0000-0000-000000000001"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptions"), + // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/6564892/billingSubscriptions/90000000-0000-0000-0000-000000000001"), + // Properties: &armbilling.SubscriptionProperties{ + // ConsumptionCostCenter: to.Ptr(""), + // DisplayName: to.Ptr("Microsoft Azure Enterprise-1"), + // EnrollmentAccountDisplayName: to.Ptr("billtest332211@outlook.com"), + // EnrollmentAccountID: to.Ptr("172988"), + // EnrollmentAccountSubscriptionDetails: &armbilling.EnrollmentAccountSubscriptionDetails{ + // EnrollmentAccountStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T00:00:00.000Z"); return t}()), + // SubscriptionEnrollmentAccountStatus: to.Ptr(armbilling.SubscriptionEnrollmentAccountStatusDeleted), + // }, + // SubscriptionID: to.Ptr("90000000-0000-0000-0000-000000000001"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/billing/armbilling/subscriptionsaliases_client.go b/sdk/resourcemanager/billing/armbilling/subscriptionsaliases_client.go new file mode 100644 index 000000000000..e815c0f17923 --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/subscriptionsaliases_client.go @@ -0,0 +1,261 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armbilling + +import ( + "context" + "errors" + "net/http" + "net/url" + "strconv" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// SubscriptionsAliasesClient contains the methods for the BillingSubscriptionsAliases group. +// Don't use this type directly, use NewSubscriptionsAliasesClient() instead. +type SubscriptionsAliasesClient struct { + internal *arm.Client +} + +// NewSubscriptionsAliasesClient creates a new instance of SubscriptionsAliasesClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewSubscriptionsAliasesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*SubscriptionsAliasesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &SubscriptionsAliasesClient{ + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates or updates a billing subscription by its alias ID. The operation is supported for seat based +// billing subscriptions. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - aliasName - The ID that uniquely identifies a subscription alias. +// - parameters - A billing subscription alias. +// - options - SubscriptionsAliasesClientBeginCreateOrUpdateOptions contains the optional parameters for the SubscriptionsAliasesClient.BeginCreateOrUpdate +// method. +func (client *SubscriptionsAliasesClient) BeginCreateOrUpdate(ctx context.Context, billingAccountName string, aliasName string, parameters SubscriptionAlias, options *SubscriptionsAliasesClientBeginCreateOrUpdateOptions) (*runtime.Poller[SubscriptionsAliasesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, billingAccountName, aliasName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SubscriptionsAliasesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[SubscriptionsAliasesClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Creates or updates a billing subscription by its alias ID. The operation is supported for seat based billing +// subscriptions. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *SubscriptionsAliasesClient) createOrUpdate(ctx context.Context, billingAccountName string, aliasName string, parameters SubscriptionAlias, options *SubscriptionsAliasesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "SubscriptionsAliasesClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, billingAccountName, aliasName, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *SubscriptionsAliasesClient) createOrUpdateCreateRequest(ctx context.Context, billingAccountName string, aliasName string, parameters SubscriptionAlias, options *SubscriptionsAliasesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptionAliases/{aliasName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if aliasName == "" { + return nil, errors.New("parameter aliasName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{aliasName}", url.PathEscape(aliasName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// Get - Gets a subscription by its alias ID. The operation is supported for seat based billing subscriptions. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - aliasName - The ID that uniquely identifies a subscription alias. +// - options - SubscriptionsAliasesClientGetOptions contains the optional parameters for the SubscriptionsAliasesClient.Get +// method. +func (client *SubscriptionsAliasesClient) Get(ctx context.Context, billingAccountName string, aliasName string, options *SubscriptionsAliasesClientGetOptions) (SubscriptionsAliasesClientGetResponse, error) { + var err error + const operationName = "SubscriptionsAliasesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, billingAccountName, aliasName, options) + if err != nil { + return SubscriptionsAliasesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SubscriptionsAliasesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SubscriptionsAliasesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *SubscriptionsAliasesClient) getCreateRequest(ctx context.Context, billingAccountName string, aliasName string, options *SubscriptionsAliasesClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptionAliases/{aliasName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if aliasName == "" { + return nil, errors.New("parameter aliasName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{aliasName}", url.PathEscape(aliasName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *SubscriptionsAliasesClient) getHandleResponse(resp *http.Response) (SubscriptionsAliasesClientGetResponse, error) { + result := SubscriptionsAliasesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionAlias); err != nil { + return SubscriptionsAliasesClientGetResponse{}, err + } + return result, nil +} + +// NewListByBillingAccountPager - Lists the subscription aliases for a billing account. The operation is supported for seat +// based billing subscriptions. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - options - SubscriptionsAliasesClientListByBillingAccountOptions contains the optional parameters for the SubscriptionsAliasesClient.NewListByBillingAccountPager +// method. +func (client *SubscriptionsAliasesClient) NewListByBillingAccountPager(billingAccountName string, options *SubscriptionsAliasesClientListByBillingAccountOptions) *runtime.Pager[SubscriptionsAliasesClientListByBillingAccountResponse] { + return runtime.NewPager(runtime.PagingHandler[SubscriptionsAliasesClientListByBillingAccountResponse]{ + More: func(page SubscriptionsAliasesClientListByBillingAccountResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SubscriptionsAliasesClientListByBillingAccountResponse) (SubscriptionsAliasesClientListByBillingAccountResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SubscriptionsAliasesClient.NewListByBillingAccountPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByBillingAccountCreateRequest(ctx, billingAccountName, options) + }, nil) + if err != nil { + return SubscriptionsAliasesClientListByBillingAccountResponse{}, err + } + return client.listByBillingAccountHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByBillingAccountCreateRequest creates the ListByBillingAccount request. +func (client *SubscriptionsAliasesClient) listByBillingAccountCreateRequest(ctx context.Context, billingAccountName string, options *SubscriptionsAliasesClientListByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptionAliases" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.IncludeDeleted != nil { + reqQP.Set("includeDeleted", strconv.FormatBool(*options.IncludeDeleted)) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByBillingAccountHandleResponse handles the ListByBillingAccount response. +func (client *SubscriptionsAliasesClient) listByBillingAccountHandleResponse(resp *http.Response) (SubscriptionsAliasesClientListByBillingAccountResponse, error) { + result := SubscriptionsAliasesClientListByBillingAccountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionAliasListResult); err != nil { + return SubscriptionsAliasesClientListByBillingAccountResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/subscriptionsaliases_client_example_test.go b/sdk/resourcemanager/billing/armbilling/subscriptionsaliases_client_example_test.go new file mode 100644 index 000000000000..566ca7b56a4f --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/subscriptionsaliases_client_example_test.go @@ -0,0 +1,286 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armbilling_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionAliasGet.json +func ExampleSubscriptionsAliasesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSubscriptionsAliasesClient().Get(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "c356b7c7-7545-4686-b843-c1a49cf853fc", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SubscriptionAlias = armbilling.SubscriptionAlias{ + // Name: to.Ptr("c356b7c7-7545-4686-b843-c1a49cf853fc"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptionAliases"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingSubscriptionAliases/c356b7c7-7545-4686-b843-c1a49cf853fc"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-25T22:39:34.260Z"); return t}()), + // }, + // Properties: &armbilling.SubscriptionAliasProperties{ + // AutoRenew: to.Ptr(armbilling.AutoRenewOn), + // BillingProfileDisplayName: to.Ptr("Billing Profile Display Name"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileName: to.Ptr("xxxx-xxxx-xxx-xxx"), + // DisplayName: to.Ptr("Billing Subscription Display Name"), + // InvoiceSectionDisplayName: to.Ptr("Invoice Section Display Name"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy"), + // InvoiceSectionName: to.Ptr("yyyy-yyyy-yyy-yyy"), + // ProductCategory: to.Ptr("SeatBased"), + // ProductType: to.Ptr("Seat-Based Product Type"), + // ProductTypeID: to.Ptr("XYZ56789"), + // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // Quantity: to.Ptr[int64](1), + // SKUDescription: to.Ptr("SKU Description"), + // SKUID: to.Ptr("0001"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SystemOverrides: &armbilling.SystemOverrides{ + // CancellationAllowedEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T22:39:34.260Z"); return t}()), + // }, + // TermDuration: to.Ptr("P1M"), + // TermEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-05T22:39:34.260Z"); return t}()), + // TermStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // BillingSubscriptionID: to.Ptr("11111111-1111-1111-1111-111111111111"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionAliasCreateOrUpdate.json +func ExampleSubscriptionsAliasesClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewSubscriptionsAliasesClient().BeginCreateOrUpdate(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "c356b7c7-7545-4686-b843-c1a49cf853fc", armbilling.SubscriptionAlias{ + Properties: &armbilling.SubscriptionAliasProperties{ + BillingFrequency: to.Ptr("P1M"), + DisplayName: to.Ptr("Subscription 3"), + Quantity: to.Ptr[int64](1), + SKUID: to.Ptr("0001"), + TermDuration: to.Ptr("P1M"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SubscriptionAlias = armbilling.SubscriptionAlias{ + // Name: to.Ptr("c356b7c7-7545-4686-b843-c1a49cf853fc"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptionAliases"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingSubscriptionAliases/c356b7c7-7545-4686-b843-c1a49cf853fc"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-25T22:39:34.260Z"); return t}()), + // }, + // Properties: &armbilling.SubscriptionAliasProperties{ + // AutoRenew: to.Ptr(armbilling.AutoRenewOn), + // BillingProfileDisplayName: to.Ptr("Billing Profile Display Name"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileName: to.Ptr("xxxx-xxxx-xxx-xxx"), + // DisplayName: to.Ptr("Billing Subscription Display Name"), + // InvoiceSectionDisplayName: to.Ptr("Invoice Section Display Name"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy"), + // InvoiceSectionName: to.Ptr("yyyy-yyyy-yyy-yyy"), + // ProductCategory: to.Ptr("SeatBased"), + // ProductType: to.Ptr("Seat-Based Product Type"), + // ProductTypeID: to.Ptr("XYZ56789"), + // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // Quantity: to.Ptr[int64](1), + // SKUDescription: to.Ptr("SKU Description"), + // SKUID: to.Ptr("0001"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SystemOverrides: &armbilling.SystemOverrides{ + // CancellationAllowedEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T22:39:34.260Z"); return t}()), + // }, + // TermDuration: to.Ptr("P1M"), + // TermEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-05T22:39:34.260Z"); return t}()), + // TermStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // BillingSubscriptionID: to.Ptr("11111111-1111-1111-1111-111111111111"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionAliasList.json +func ExampleSubscriptionsAliasesClient_NewListByBillingAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSubscriptionsAliasesClient().NewListByBillingAccountPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", &armbilling.SubscriptionsAliasesClientListByBillingAccountOptions{IncludeDeleted: nil, + Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.SubscriptionAliasListResult = armbilling.SubscriptionAliasListResult{ + // Value: []*armbilling.SubscriptionAlias{ + // { + // Name: to.Ptr("90000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptionAliases"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingSubscriptionAliases/90000000-0000-0000-0000-000000000000"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // }, + // Properties: &armbilling.SubscriptionAliasProperties{ + // AutoRenew: to.Ptr(armbilling.AutoRenewOn), + // BillingProfileDisplayName: to.Ptr("Billing Profile Display Name"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileName: to.Ptr("xxxx-xxxx-xxx-xxx"), + // DisplayName: to.Ptr("My subscription"), + // InvoiceSectionDisplayName: to.Ptr("Invoice Section Display Name"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy"), + // InvoiceSectionName: to.Ptr("yyyy-yyyy-yyy-yyy"), + // ProductCategory: to.Ptr("SeatBased"), + // ProductType: to.Ptr("Seat-Based Product Type"), + // ProductTypeID: to.Ptr("XYZ56789"), + // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-04T22:39:34.260Z"); return t}()), + // Quantity: to.Ptr[int64](1), + // ResourceURI: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingSubscriptionAliases/11111111-1111-1111-1111-111111111111"), + // SKUDescription: to.Ptr("SKU Description"), + // SKUID: to.Ptr("0001"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SystemOverrides: &armbilling.SystemOverrides{ + // CancellationAllowedEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T22:39:34.260Z"); return t}()), + // }, + // TermDuration: to.Ptr("P1M"), + // TermEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-05T22:39:34.260Z"); return t}()), + // TermStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // BillingSubscriptionID: to.Ptr("11111111-1111-1111-1111-111111111111"), + // }, + // }, + // { + // Name: to.Ptr("90000000-0000-0000-0000-000000000001"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptionAliases"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingSubscriptionAliases/90000000-0000-0000-0000-000000000001"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-06T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-07T22:39:34.260Z"); return t}()), + // }, + // Properties: &armbilling.SubscriptionAliasProperties{ + // AutoRenew: to.Ptr(armbilling.AutoRenewOn), + // BillingProfileDisplayName: to.Ptr("Billing Profile Display Name"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileName: to.Ptr("xxxx-xxxx-xxx-xxx"), + // DisplayName: to.Ptr("Test subscription"), + // InvoiceSectionDisplayName: to.Ptr("Invoice Section Display Name"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy"), + // InvoiceSectionName: to.Ptr("yyyy-yyyy-yyy-yyy"), + // ProductCategory: to.Ptr("Software"), + // ProductType: to.Ptr("Software Product Type"), + // ProductTypeID: to.Ptr("EFG456"), + // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-06T22:39:34.260Z"); return t}()), + // Quantity: to.Ptr[int64](1), + // ResourceURI: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingSubscriptionAliases/22222222-2222-2222-2222-222222222222"), + // SKUDescription: to.Ptr("SKU Description"), + // SKUID: to.Ptr("0001"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusActive), + // SystemOverrides: &armbilling.SystemOverrides{ + // CancellationAllowedEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T22:39:34.260Z"); return t}()), + // }, + // TermDuration: to.Ptr("P1M"), + // TermEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-07T22:39:34.260Z"); return t}()), + // TermStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-07T22:39:34.260Z"); return t}()), + // BillingSubscriptionID: to.Ptr("22222222-2222-2222-2222-222222222222"), + // }, + // }, + // { + // Name: to.Ptr("90000000-0000-0000-0000-000000000002"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingSubscriptionAliases"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingSubscriptionAliases/90000000-0000-0000-0000-000000000002"), + // SystemData: &armbilling.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-25T22:39:34.260Z"); return t}()), + // }, + // Properties: &armbilling.SubscriptionAliasProperties{ + // AutoRenew: to.Ptr(armbilling.AutoRenewOn), + // BillingProfileDisplayName: to.Ptr("Billing Profile Display Name"), + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // BillingProfileName: to.Ptr("xxxx-xxxx-xxx-xxx"), + // DisplayName: to.Ptr("Dev subscription"), + // InvoiceSectionDisplayName: to.Ptr("Invoice Section Display Name"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy"), + // InvoiceSectionName: to.Ptr("yyyy-yyyy-yyy-yyy"), + // ProductCategory: to.Ptr("ReservationOrder"), + // ProductType: to.Ptr("Reservation Product Type"), + // ProductTypeID: to.Ptr("JKL789"), + // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // Quantity: to.Ptr[int64](1), + // ResourceURI: to.Ptr("/providers/Microsoft.Capacity/reservationOrders/33333333-3333-3333-3333-333333333333"), + // SKUDescription: to.Ptr("SKU Description"), + // SKUID: to.Ptr("0001"), + // Status: to.Ptr(armbilling.BillingSubscriptionStatusSuspended), + // SuspensionReasonDetails: []*armbilling.SubscriptionStatusDetails{ + // { + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-15T22:39:34.260Z"); return t}()), + // Reason: to.Ptr(armbilling.SubscriptionStatusReasonCancelled), + // }}, + // SuspensionReasons: []*string{ + // to.Ptr("Cancelled")}, + // SystemOverrides: &armbilling.SystemOverrides{ + // CancellationAllowedEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-01T22:39:34.260Z"); return t}()), + // }, + // TermDuration: to.Ptr("P1M"), + // TermEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-05T22:39:34.260Z"); return t}()), + // TermStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-05T22:39:34.260Z"); return t}()), + // BillingSubscriptionID: to.Ptr("33333333-3333-3333-3333-333333333333"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/billing/armbilling/time_rfc3339.go b/sdk/resourcemanager/billing/armbilling/time_rfc3339.go index 4f295588f8c3..7615ead1d286 100644 --- a/sdk/resourcemanager/billing/armbilling/time_rfc3339.go +++ b/sdk/resourcemanager/billing/armbilling/time_rfc3339.go @@ -11,20 +11,25 @@ package armbilling import ( "encoding/json" "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" "reflect" "regexp" "strings" "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +45,33 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +82,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +99,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/billing/armbilling/transactions_client.go b/sdk/resourcemanager/billing/armbilling/transactions_client.go index 8288f20992cd..397ac3f24097 100644 --- a/sdk/resourcemanager/billing/armbilling/transactions_client.go +++ b/sdk/resourcemanager/billing/armbilling/transactions_client.go @@ -11,13 +11,16 @@ package armbilling import ( "context" "errors" + "net/http" + "net/url" + "strconv" + "strings" + "time" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" ) // TransactionsClient contains the methods for the Transactions group. @@ -40,10 +43,257 @@ func NewTransactionsClient(credential azcore.TokenCredential, options *arm.Clien return client, nil } +// GetTransactionSummaryByInvoice - Gets the transaction summary for an invoice. Transactions include purchases, refunds and +// Azure usage charges. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - invoiceName - The ID that uniquely identifies an invoice. +// - options - TransactionsClientGetTransactionSummaryByInvoiceOptions contains the optional parameters for the TransactionsClient.GetTransactionSummaryByInvoice +// method. +func (client *TransactionsClient) GetTransactionSummaryByInvoice(ctx context.Context, billingAccountName string, invoiceName string, options *TransactionsClientGetTransactionSummaryByInvoiceOptions) (TransactionsClientGetTransactionSummaryByInvoiceResponse, error) { + var err error + const operationName = "TransactionsClient.GetTransactionSummaryByInvoice" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getTransactionSummaryByInvoiceCreateRequest(ctx, billingAccountName, invoiceName, options) + if err != nil { + return TransactionsClientGetTransactionSummaryByInvoiceResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TransactionsClientGetTransactionSummaryByInvoiceResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TransactionsClientGetTransactionSummaryByInvoiceResponse{}, err + } + resp, err := client.getTransactionSummaryByInvoiceHandleResponse(httpResp) + return resp, err +} + +// getTransactionSummaryByInvoiceCreateRequest creates the GetTransactionSummaryByInvoice request. +func (client *TransactionsClient) getTransactionSummaryByInvoiceCreateRequest(ctx context.Context, billingAccountName string, invoiceName string, options *TransactionsClientGetTransactionSummaryByInvoiceOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/transactionSummary" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if invoiceName == "" { + return nil, errors.New("parameter invoiceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{invoiceName}", url.PathEscape(invoiceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getTransactionSummaryByInvoiceHandleResponse handles the GetTransactionSummaryByInvoice response. +func (client *TransactionsClient) getTransactionSummaryByInvoiceHandleResponse(resp *http.Response) (TransactionsClientGetTransactionSummaryByInvoiceResponse, error) { + result := TransactionsClientGetTransactionSummaryByInvoiceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TransactionSummary); err != nil { + return TransactionsClientGetTransactionSummaryByInvoiceResponse{}, err + } + return result, nil +} + +// NewListByBillingProfilePager - Lists the billed or unbilled transactions by billing profile name for given start and end +// date. Transactions include purchases, refunds and Azure usage charges. Unbilled transactions are listed under +// pending invoice Id and do not include tax. Tax is added to the amount once an invoice is generated. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - periodStartDate - The start date to fetch the transactions. The date should be specified in MM-DD-YYYY format. +// - periodEndDate - The end date to fetch the transactions. The date should be specified in MM-DD-YYYY format. +// - typeParam - The type of transaction. +// - options - TransactionsClientListByBillingProfileOptions contains the optional parameters for the TransactionsClient.NewListByBillingProfilePager +// method. +func (client *TransactionsClient) NewListByBillingProfilePager(billingAccountName string, billingProfileName string, periodStartDate time.Time, periodEndDate time.Time, typeParam TransactionType, options *TransactionsClientListByBillingProfileOptions) *runtime.Pager[TransactionsClientListByBillingProfileResponse] { + return runtime.NewPager(runtime.PagingHandler[TransactionsClientListByBillingProfileResponse]{ + More: func(page TransactionsClientListByBillingProfileResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *TransactionsClientListByBillingProfileResponse) (TransactionsClientListByBillingProfileResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TransactionsClient.NewListByBillingProfilePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, periodStartDate, periodEndDate, typeParam, options) + }, nil) + if err != nil { + return TransactionsClientListByBillingProfileResponse{}, err + } + return client.listByBillingProfileHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByBillingProfileCreateRequest creates the ListByBillingProfile request. +func (client *TransactionsClient) listByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, periodStartDate time.Time, periodEndDate time.Time, typeParam TransactionType, options *TransactionsClientListByBillingProfileOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/transactions" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + reqQP.Set("periodEndDate", periodEndDate.Format("2006-01-02")) + reqQP.Set("periodStartDate", periodStartDate.Format("2006-01-02")) + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } + reqQP.Set("type", string(typeParam)) + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByBillingProfileHandleResponse handles the ListByBillingProfile response. +func (client *TransactionsClient) listByBillingProfileHandleResponse(resp *http.Response) (TransactionsClientListByBillingProfileResponse, error) { + result := TransactionsClientListByBillingProfileResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TransactionListResult); err != nil { + return TransactionsClientListByBillingProfileResponse{}, err + } + return result, nil +} + +// NewListByCustomerPager - Lists the billed or unbilled transactions by customer id for given start date and end date. Transactions +// include purchases, refunds and Azure usage charges. Unbilled transactions are listed under +// pending invoice Id and do not include tax. Tax is added to the amount once an invoice is generated. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - customerName - The ID that uniquely identifies a customer. +// - periodStartDate - The start date to fetch the transactions. The date should be specified in MM-DD-YYYY format. +// - periodEndDate - The end date to fetch the transactions. The date should be specified in MM-DD-YYYY format. +// - typeParam - The type of transaction. +// - options - TransactionsClientListByCustomerOptions contains the optional parameters for the TransactionsClient.NewListByCustomerPager +// method. +func (client *TransactionsClient) NewListByCustomerPager(billingAccountName string, billingProfileName string, customerName string, periodStartDate time.Time, periodEndDate time.Time, typeParam TransactionType, options *TransactionsClientListByCustomerOptions) *runtime.Pager[TransactionsClientListByCustomerResponse] { + return runtime.NewPager(runtime.PagingHandler[TransactionsClientListByCustomerResponse]{ + More: func(page TransactionsClientListByCustomerResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *TransactionsClientListByCustomerResponse) (TransactionsClientListByCustomerResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TransactionsClient.NewListByCustomerPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByCustomerCreateRequest(ctx, billingAccountName, billingProfileName, customerName, periodStartDate, periodEndDate, typeParam, options) + }, nil) + if err != nil { + return TransactionsClientListByCustomerResponse{}, err + } + return client.listByCustomerHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByCustomerCreateRequest creates the ListByCustomer request. +func (client *TransactionsClient) listByCustomerCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, customerName string, periodStartDate time.Time, periodEndDate time.Time, typeParam TransactionType, options *TransactionsClientListByCustomerOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/transactions" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if customerName == "" { + return nil, errors.New("parameter customerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{customerName}", url.PathEscape(customerName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + reqQP.Set("periodEndDate", periodEndDate.Format("2006-01-02")) + reqQP.Set("periodStartDate", periodStartDate.Format("2006-01-02")) + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } + reqQP.Set("type", string(typeParam)) + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByCustomerHandleResponse handles the ListByCustomer response. +func (client *TransactionsClient) listByCustomerHandleResponse(resp *http.Response) (TransactionsClientListByCustomerResponse, error) { + result := TransactionsClientListByCustomerResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TransactionListResult); err != nil { + return TransactionsClientListByCustomerResponse{}, err + } + return result, nil +} + // NewListByInvoicePager - Lists the transactions for an invoice. Transactions include purchases, refunds and Azure usage // charges. // -// Generated from API version 2020-05-01 +// Generated from API version 2024-04-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - invoiceName - The ID that uniquely identifies an invoice. // - options - TransactionsClientListByInvoiceOptions contains the optional parameters for the TransactionsClient.NewListByInvoicePager @@ -87,7 +337,25 @@ func (client *TransactionsClient) listByInvoiceCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -101,3 +369,170 @@ func (client *TransactionsClient) listByInvoiceHandleResponse(resp *http.Respons } return result, nil } + +// NewListByInvoiceSectionPager - Lists the billed or unbilled transactions by invoice section name for given start date and +// end date. Transactions include purchases, refunds and Azure usage charges. Unbilled transactions are listed +// under pending invoice Id and do not include tax. Tax is added to the amount once an invoice is generated. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - invoiceSectionName - The ID that uniquely identifies an invoice section. +// - periodStartDate - The start date to fetch the transactions. The date should be specified in MM-DD-YYYY format. +// - periodEndDate - The end date to fetch the transactions. The date should be specified in MM-DD-YYYY format. +// - typeParam - The type of transaction. +// - options - TransactionsClientListByInvoiceSectionOptions contains the optional parameters for the TransactionsClient.NewListByInvoiceSectionPager +// method. +func (client *TransactionsClient) NewListByInvoiceSectionPager(billingAccountName string, billingProfileName string, invoiceSectionName string, periodStartDate time.Time, periodEndDate time.Time, typeParam TransactionType, options *TransactionsClientListByInvoiceSectionOptions) *runtime.Pager[TransactionsClientListByInvoiceSectionResponse] { + return runtime.NewPager(runtime.PagingHandler[TransactionsClientListByInvoiceSectionResponse]{ + More: func(page TransactionsClientListByInvoiceSectionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *TransactionsClientListByInvoiceSectionResponse) (TransactionsClientListByInvoiceSectionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TransactionsClient.NewListByInvoiceSectionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByInvoiceSectionCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, periodStartDate, periodEndDate, typeParam, options) + }, nil) + if err != nil { + return TransactionsClientListByInvoiceSectionResponse{}, err + } + return client.listByInvoiceSectionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByInvoiceSectionCreateRequest creates the ListByInvoiceSection request. +func (client *TransactionsClient) listByInvoiceSectionCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, periodStartDate time.Time, periodEndDate time.Time, typeParam TransactionType, options *TransactionsClientListByInvoiceSectionOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/transactions" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if invoiceSectionName == "" { + return nil, errors.New("parameter invoiceSectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + if options != nil && options.Count != nil { + reqQP.Set("count", strconv.FormatBool(*options.Count)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("orderBy", *options.OrderBy) + } + reqQP.Set("periodEndDate", periodEndDate.Format("2006-01-02")) + reqQP.Set("periodStartDate", periodStartDate.Format("2006-01-02")) + if options != nil && options.Search != nil { + reqQP.Set("search", *options.Search) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(*options.Skip, 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(*options.Top, 10)) + } + reqQP.Set("type", string(typeParam)) + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByInvoiceSectionHandleResponse handles the ListByInvoiceSection response. +func (client *TransactionsClient) listByInvoiceSectionHandleResponse(resp *http.Response) (TransactionsClientListByInvoiceSectionResponse, error) { + result := TransactionsClientListByInvoiceSectionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TransactionListResult); err != nil { + return TransactionsClientListByInvoiceSectionResponse{}, err + } + return result, nil +} + +// BeginTransactionsDownloadByInvoice - Gets a URL to download the transactions document for an invoice. The operation is +// supported for billing accounts with agreement type Enterprise Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - invoiceName - The ID that uniquely identifies an invoice. +// - options - TransactionsClientBeginTransactionsDownloadByInvoiceOptions contains the optional parameters for the TransactionsClient.BeginTransactionsDownloadByInvoice +// method. +func (client *TransactionsClient) BeginTransactionsDownloadByInvoice(ctx context.Context, billingAccountName string, invoiceName string, options *TransactionsClientBeginTransactionsDownloadByInvoiceOptions) (*runtime.Poller[TransactionsClientTransactionsDownloadByInvoiceResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.transactionsDownloadByInvoice(ctx, billingAccountName, invoiceName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TransactionsClientTransactionsDownloadByInvoiceResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[TransactionsClientTransactionsDownloadByInvoiceResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// TransactionsDownloadByInvoice - Gets a URL to download the transactions document for an invoice. The operation is supported +// for billing accounts with agreement type Enterprise Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +func (client *TransactionsClient) transactionsDownloadByInvoice(ctx context.Context, billingAccountName string, invoiceName string, options *TransactionsClientBeginTransactionsDownloadByInvoiceOptions) (*http.Response, error) { + var err error + const operationName = "TransactionsClient.BeginTransactionsDownloadByInvoice" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.transactionsDownloadByInvoiceCreateRequest(ctx, billingAccountName, invoiceName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// transactionsDownloadByInvoiceCreateRequest creates the TransactionsDownloadByInvoice request. +func (client *TransactionsClient) transactionsDownloadByInvoiceCreateRequest(ctx context.Context, billingAccountName string, invoiceName string, options *TransactionsClientBeginTransactionsDownloadByInvoiceOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/transactionsDownload" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if invoiceName == "" { + return nil, errors.New("parameter invoiceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{invoiceName}", url.PathEscape(invoiceName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/transactions_client_example_test.go b/sdk/resourcemanager/billing/armbilling/transactions_client_example_test.go index 4cab4cef2c9c..4af70387df40 100644 --- a/sdk/resourcemanager/billing/armbilling/transactions_client_example_test.go +++ b/sdk/resourcemanager/billing/armbilling/transactions_client_example_test.go @@ -13,11 +13,461 @@ import ( "context" "log" + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/TransactionsListByInvoice.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/transactionsListByCustomer.json +func ExampleTransactionsClient_NewListByCustomerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewTransactionsClient().NewListByCustomerPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "22000000-0000-0000-0000-000000000000", func() time.Time { t, _ := time.Parse("2006-01-02", "2024-04-01"); return t }(), func() time.Time { t, _ := time.Parse("2006-01-02", "2023-05-30"); return t }(), armbilling.TransactionTypeBilled, &armbilling.TransactionsClientListByCustomerOptions{Filter: to.Ptr("properties/date gt '2020-10-01'"), + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: to.Ptr("storage"), + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.TransactionListResult = armbilling.TransactionListResult{ + // Value: []*armbilling.Transaction{ + // { + // Name: to.Ptr("41000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/transactions"), + // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/BillingProfiles/xxxx-xxxx-xxx-xxx/transactions/41000000-0000-0000-0000-000000000000"), + // Properties: &armbilling.TransactionProperties{ + // AzureCreditApplied: &armbilling.TransactionPropertiesAzureCreditApplied{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](2000), + // }, + // BillingCurrency: to.Ptr("USD"), + // BillingProfileDisplayName: "Contoso operations billing", + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // ConsumptionCommitmentDecremented: &armbilling.TransactionPropertiesConsumptionCommitmentDecremented{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](100), + // }, + // CustomerDisplayName: to.Ptr("Contoso operations customer"), + // CustomerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/customers/22000000-0000-0000-0000-000000000000"), + // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-01T00:00:00.000Z"); return t}()), + // Discount: to.Ptr[float32](0.1), + // EffectivePrice: &armbilling.TransactionPropertiesEffectivePrice{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](10), + // }, + // ExchangeRate: to.Ptr[float32](1), + // Invoice: to.Ptr("G123456789"), + // InvoiceID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/G123456789"), + // MarketPrice: &armbilling.TransactionPropertiesMarketPrice{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](20), + // }, + // PartNumber: to.Ptr("0001"), + // PricingCurrency: to.Ptr("USD"), + // ProductDescription: to.Ptr("Standard D1, US West 3"), + // ProductFamily: to.Ptr("Storage"), + // ProductType: to.Ptr("VM Instance"), + // ProductTypeID: to.Ptr("A12345"), + // Quantity: to.Ptr[int32](1), + // ServicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-30T00:00:00.000Z"); return t}()), + // ServicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-01T00:00:00.000Z"); return t}()), + // SubTotal: &armbilling.TransactionPropertiesSubTotal{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](4500), + // }, + // Tax: &armbilling.TransactionPropertiesTax{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](500), + // }, + // TransactionAmount: &armbilling.TransactionPropertiesTransactionAmount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](5000), + // }, + // TransactionType: to.Ptr("Purchase"), + // UnitOfMeasure: to.Ptr("1 Minute"), + // UnitType: to.Ptr("1 Runtime Minute"), + // Units: to.Ptr[float32](11.25), + // }, + // }, + // { + // Name: to.Ptr("51000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/transactions"), + // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/BillingProfiles/xxxx-xxxx-xxx-xxx/transactions/51000000-0000-0000-0000-000000000000"), + // Properties: &armbilling.TransactionProperties{ + // AzureCreditApplied: &armbilling.TransactionPropertiesAzureCreditApplied{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](20), + // }, + // BillingCurrency: to.Ptr("USD"), + // BillingProfileDisplayName: "Contoso operations billing", + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // ConsumptionCommitmentDecremented: &armbilling.TransactionPropertiesConsumptionCommitmentDecremented{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](50), + // }, + // CustomerDisplayName: to.Ptr("Contoso operations customer"), + // CustomerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/customers/22000000-0000-0000-0000-000000000000"), + // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-01T00:00:00.000Z"); return t}()), + // Discount: to.Ptr[float32](0.1), + // EffectivePrice: &armbilling.TransactionPropertiesEffectivePrice{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](10), + // }, + // ExchangeRate: to.Ptr[float32](1), + // Invoice: to.Ptr("pending"), + // MarketPrice: &armbilling.TransactionPropertiesMarketPrice{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](20), + // }, + // PartNumber: to.Ptr("0002"), + // PricingCurrency: to.Ptr("USD"), + // ProductDescription: to.Ptr("Standard Support"), + // ProductFamily: to.Ptr("Storage"), + // ProductType: to.Ptr("VM Instance"), + // ProductTypeID: to.Ptr("A12345"), + // Quantity: to.Ptr[int32](1), + // ServicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-30T00:00:00.000Z"); return t}()), + // ServicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-01T00:00:00.000Z"); return t}()), + // SubTotal: &armbilling.TransactionPropertiesSubTotal{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](45), + // }, + // Tax: &armbilling.TransactionPropertiesTax{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](5), + // }, + // TransactionAmount: &armbilling.TransactionPropertiesTransactionAmount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](50), + // }, + // TransactionType: to.Ptr("Cancel"), + // UnitOfMeasure: to.Ptr("1 Minute"), + // UnitType: to.Ptr("1 Runtime Minute"), + // Units: to.Ptr[float32](1.25), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/transactionsListByInvoiceSection.json +func ExampleTransactionsClient_NewListByInvoiceSectionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewTransactionsClient().NewListByInvoiceSectionPager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "22000000-0000-0000-0000-000000000000", func() time.Time { t, _ := time.Parse("2006-01-02", "2024-04-01"); return t }(), func() time.Time { t, _ := time.Parse("2006-01-02", "2023-05-30"); return t }(), armbilling.TransactionTypeBilled, &armbilling.TransactionsClientListByInvoiceSectionOptions{Filter: to.Ptr("properties/date gt '2020-10-01'"), + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: to.Ptr("storage"), + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.TransactionListResult = armbilling.TransactionListResult{ + // Value: []*armbilling.Transaction{ + // { + // Name: to.Ptr("41000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/transactions"), + // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/BillingProfiles/xxxx-xxxx-xxx-xxx/transactions/41000000-0000-0000-0000-000000000000"), + // Properties: &armbilling.TransactionProperties{ + // AzureCreditApplied: &armbilling.TransactionPropertiesAzureCreditApplied{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](2000), + // }, + // BillingCurrency: to.Ptr("USD"), + // BillingProfileDisplayName: "Contoso operations billing", + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // ConsumptionCommitmentDecremented: &armbilling.TransactionPropertiesConsumptionCommitmentDecremented{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](100), + // }, + // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-01T00:00:00.000Z"); return t}()), + // Discount: to.Ptr[float32](0.1), + // EffectivePrice: &armbilling.TransactionPropertiesEffectivePrice{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](10), + // }, + // ExchangeRate: to.Ptr[float32](1), + // Invoice: to.Ptr("G123456789"), + // InvoiceID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/G123456789"), + // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/22000000-0000-0000-0000-000000000000"), + // MarketPrice: &armbilling.TransactionPropertiesMarketPrice{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](20), + // }, + // PartNumber: to.Ptr("0001"), + // PricingCurrency: to.Ptr("USD"), + // ProductDescription: to.Ptr("Standard D1, US West 3"), + // ProductFamily: to.Ptr("Storage"), + // ProductType: to.Ptr("VM Instance"), + // ProductTypeID: to.Ptr("A12345"), + // Quantity: to.Ptr[int32](1), + // ServicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-30T00:00:00.000Z"); return t}()), + // ServicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-01T00:00:00.000Z"); return t}()), + // SubTotal: &armbilling.TransactionPropertiesSubTotal{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](4500), + // }, + // Tax: &armbilling.TransactionPropertiesTax{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](500), + // }, + // TransactionAmount: &armbilling.TransactionPropertiesTransactionAmount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](5000), + // }, + // TransactionType: to.Ptr("Purchase"), + // UnitOfMeasure: to.Ptr("1 Minute"), + // UnitType: to.Ptr("1 Runtime Minute"), + // Units: to.Ptr[float32](11.25), + // }, + // }, + // { + // Name: to.Ptr("51000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/transactions"), + // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/BillingProfiles/xxxx-xxxx-xxx-xxx/transactions/51000000-0000-0000-0000-000000000000"), + // Properties: &armbilling.TransactionProperties{ + // AzureCreditApplied: &armbilling.TransactionPropertiesAzureCreditApplied{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](20), + // }, + // BillingCurrency: to.Ptr("USD"), + // BillingProfileDisplayName: "Contoso operations billing", + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // ConsumptionCommitmentDecremented: &armbilling.TransactionPropertiesConsumptionCommitmentDecremented{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](50), + // }, + // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-01T00:00:00.000Z"); return t}()), + // Discount: to.Ptr[float32](0.1), + // EffectivePrice: &armbilling.TransactionPropertiesEffectivePrice{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](10), + // }, + // ExchangeRate: to.Ptr[float32](1), + // Invoice: to.Ptr("pending"), + // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/22000000-0000-0000-0000-000000000000"), + // MarketPrice: &armbilling.TransactionPropertiesMarketPrice{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](20), + // }, + // PartNumber: to.Ptr("0002"), + // PricingCurrency: to.Ptr("USD"), + // ProductDescription: to.Ptr("Standard Support"), + // ProductFamily: to.Ptr("Storage"), + // ProductType: to.Ptr("VM Instance"), + // ProductTypeID: to.Ptr("A12345"), + // Quantity: to.Ptr[int32](1), + // ServicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-30T00:00:00.000Z"); return t}()), + // ServicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-01T00:00:00.000Z"); return t}()), + // SubTotal: &armbilling.TransactionPropertiesSubTotal{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](45), + // }, + // Tax: &armbilling.TransactionPropertiesTax{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](5), + // }, + // TransactionAmount: &armbilling.TransactionPropertiesTransactionAmount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](50), + // }, + // TransactionType: to.Ptr("Cancel"), + // UnitOfMeasure: to.Ptr("1 Minute"), + // UnitType: to.Ptr("1 Runtime Minute"), + // Units: to.Ptr[float32](1.25), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/transactionsListByBillingProfile.json +func ExampleTransactionsClient_NewListByBillingProfilePager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewTransactionsClient().NewListByBillingProfilePager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", func() time.Time { t, _ := time.Parse("2006-01-02", "2024-04-01"); return t }(), func() time.Time { t, _ := time.Parse("2006-01-02", "2023-05-30"); return t }(), armbilling.TransactionTypeBilled, &armbilling.TransactionsClientListByBillingProfileOptions{Filter: to.Ptr("properties/date gt '2020-10-01'"), + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: to.Ptr("storage"), + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.TransactionListResult = armbilling.TransactionListResult{ + // Value: []*armbilling.Transaction{ + // { + // Name: to.Ptr("41000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/transactions"), + // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/BillingProfiles/xxxx-xxxx-xxx-xxx/transactions/41000000-0000-0000-0000-000000000000"), + // Properties: &armbilling.TransactionProperties{ + // AzureCreditApplied: &armbilling.TransactionPropertiesAzureCreditApplied{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](2000), + // }, + // BillingCurrency: to.Ptr("USD"), + // BillingProfileDisplayName: "Contoso operations billing", + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // ConsumptionCommitmentDecremented: &armbilling.TransactionPropertiesConsumptionCommitmentDecremented{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](100), + // }, + // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-01T00:00:00.000Z"); return t}()), + // Discount: to.Ptr[float32](0.1), + // EffectivePrice: &armbilling.TransactionPropertiesEffectivePrice{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](10), + // }, + // ExchangeRate: to.Ptr[float32](1), + // Invoice: to.Ptr("G123456789"), + // InvoiceID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/G123456789"), + // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/22000000-0000-0000-0000-000000000000"), + // MarketPrice: &armbilling.TransactionPropertiesMarketPrice{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](20), + // }, + // PartNumber: to.Ptr("0001"), + // PricingCurrency: to.Ptr("USD"), + // ProductDescription: to.Ptr("Standard D1, US West 3"), + // ProductFamily: to.Ptr("Storage"), + // ProductType: to.Ptr("VM Instance"), + // ProductTypeID: to.Ptr("A12345"), + // Quantity: to.Ptr[int32](1), + // ServicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-30T00:00:00.000Z"); return t}()), + // ServicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-01T00:00:00.000Z"); return t}()), + // SubTotal: &armbilling.TransactionPropertiesSubTotal{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](4500), + // }, + // Tax: &armbilling.TransactionPropertiesTax{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](500), + // }, + // TransactionAmount: &armbilling.TransactionPropertiesTransactionAmount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](5000), + // }, + // TransactionType: to.Ptr("Purchase"), + // UnitOfMeasure: to.Ptr("1 Minute"), + // UnitType: to.Ptr("1 Runtime Minute"), + // Units: to.Ptr[float32](11.25), + // }, + // }, + // { + // Name: to.Ptr("51000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/transactions"), + // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/BillingProfiles/xxxx-xxxx-xxx-xxx/transactions/51000000-0000-0000-0000-000000000000"), + // Properties: &armbilling.TransactionProperties{ + // AzureCreditApplied: &armbilling.TransactionPropertiesAzureCreditApplied{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](20), + // }, + // BillingCurrency: to.Ptr("USD"), + // BillingProfileDisplayName: "Contoso operations billing", + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // ConsumptionCommitmentDecremented: &armbilling.TransactionPropertiesConsumptionCommitmentDecremented{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](50), + // }, + // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-01T00:00:00.000Z"); return t}()), + // Discount: to.Ptr[float32](0.1), + // EffectivePrice: &armbilling.TransactionPropertiesEffectivePrice{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](10), + // }, + // ExchangeRate: to.Ptr[float32](1), + // Invoice: to.Ptr("pending"), + // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/22000000-0000-0000-0000-000000000000"), + // MarketPrice: &armbilling.TransactionPropertiesMarketPrice{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](20), + // }, + // PartNumber: to.Ptr("0002"), + // PricingCurrency: to.Ptr("USD"), + // ProductDescription: to.Ptr("Standard Support"), + // ProductFamily: to.Ptr("Storage"), + // ProductType: to.Ptr("VM Instance"), + // ProductTypeID: to.Ptr("A12345"), + // Quantity: to.Ptr[int32](1), + // ServicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-30T00:00:00.000Z"); return t}()), + // ServicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-01T00:00:00.000Z"); return t}()), + // SubTotal: &armbilling.TransactionPropertiesSubTotal{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](45), + // }, + // Tax: &armbilling.TransactionPropertiesTax{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](5), + // }, + // TransactionAmount: &armbilling.TransactionPropertiesTransactionAmount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](50), + // }, + // TransactionType: to.Ptr("Cancel"), + // UnitOfMeasure: to.Ptr("1 Minute"), + // UnitType: to.Ptr("1 Runtime Minute"), + // Units: to.Ptr[float32](1.25), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/transactionsListByInvoice.json func ExampleTransactionsClient_NewListByInvoicePager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -28,7 +478,13 @@ func ExampleTransactionsClient_NewListByInvoicePager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewTransactionsClient().NewListByInvoicePager("{billingAccountName}", "{invoiceName}", nil) + pager := clientFactory.NewTransactionsClient().NewListByInvoicePager("00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "G123456789", &armbilling.TransactionsClientListByInvoiceOptions{Filter: nil, + OrderBy: nil, + Top: nil, + Skip: nil, + Count: nil, + Search: nil, + }) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -43,54 +499,57 @@ func ExampleTransactionsClient_NewListByInvoicePager() { // Value: []*armbilling.Transaction{ // { // Name: to.Ptr("41000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/transactions"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/transactions/41000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/transactions"), + // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/BillingProfiles/xxxx-xxxx-xxx-xxx/transactions/41000000-0000-0000-0000-000000000000"), // Properties: &armbilling.TransactionProperties{ - // AzureCreditApplied: &armbilling.Amount{ + // AzureCreditApplied: &armbilling.TransactionPropertiesAzureCreditApplied{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](2000), // }, - // AzurePlan: to.Ptr("Microsoft Azure Plan for DevTest"), // BillingCurrency: to.Ptr("USD"), - // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00.000Z"); return t}()), + // BillingProfileDisplayName: "Contoso operations billing", + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // ConsumptionCommitmentDecremented: &armbilling.TransactionPropertiesConsumptionCommitmentDecremented{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](100), + // }, + // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-01T00:00:00.000Z"); return t}()), // Discount: to.Ptr[float32](0.1), - // EffectivePrice: &armbilling.Amount{ + // EffectivePrice: &armbilling.TransactionPropertiesEffectivePrice{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](10), // }, // ExchangeRate: to.Ptr[float32](1), - // Invoice: to.Ptr("2344233"), - // InvoiceID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/2344233"), + // Invoice: to.Ptr("G123456789"), + // InvoiceID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/invoices/G123456789"), // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/22000000-0000-0000-0000-000000000000"), - // Kind: to.Ptr(armbilling.TransactionTypeKindAll), - // MarketPrice: &armbilling.Amount{ + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/22000000-0000-0000-0000-000000000000"), + // MarketPrice: &armbilling.TransactionPropertiesMarketPrice{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](20), // }, + // PartNumber: to.Ptr("0001"), // PricingCurrency: to.Ptr("USD"), // ProductDescription: to.Ptr("Standard D1, US West 3"), // ProductFamily: to.Ptr("Storage"), // ProductType: to.Ptr("VM Instance"), // ProductTypeID: to.Ptr("A12345"), // Quantity: to.Ptr[int32](1), - // ServicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-30T00:00:00.000Z"); return t}()), - // ServicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00.000Z"); return t}()), - // SubTotal: &armbilling.Amount{ + // ServicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-30T00:00:00.000Z"); return t}()), + // ServicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-01T00:00:00.000Z"); return t}()), + // SubTotal: &armbilling.TransactionPropertiesSubTotal{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](4500), // }, - // Tax: &armbilling.Amount{ + // Tax: &armbilling.TransactionPropertiesTax{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](500), // }, - // TransactionAmount: &armbilling.Amount{ + // TransactionAmount: &armbilling.TransactionPropertiesTransactionAmount{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](5000), // }, - // TransactionType: to.Ptr(armbilling.ReservationTypePurchase), + // TransactionType: to.Ptr("Purchase"), // UnitOfMeasure: to.Ptr("1 Minute"), // UnitType: to.Ptr("1 Runtime Minute"), // Units: to.Ptr[float32](11.25), @@ -98,53 +557,56 @@ func ExampleTransactionsClient_NewListByInvoicePager() { // }, // { // Name: to.Ptr("51000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Billing/billingAccounts/transactions"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/{billingAccountName}/transactions/51000000-0000-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/transactions"), + // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/BillingProfiles/xxxx-xxxx-xxx-xxx/transactions/51000000-0000-0000-0000-000000000000"), // Properties: &armbilling.TransactionProperties{ - // AzureCreditApplied: &armbilling.Amount{ + // AzureCreditApplied: &armbilling.TransactionPropertiesAzureCreditApplied{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](20), // }, - // AzurePlan: to.Ptr("Microsoft Azure Plan for DevTest"), // BillingCurrency: to.Ptr("USD"), - // BillingProfileDisplayName: to.Ptr("Contoso operations billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-01T00:00:00.000Z"); return t}()), + // BillingProfileDisplayName: "Contoso operations billing", + // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx"), + // ConsumptionCommitmentDecremented: &armbilling.TransactionPropertiesConsumptionCommitmentDecremented{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](50), + // }, + // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-01T00:00:00.000Z"); return t}()), // Discount: to.Ptr[float32](0.1), - // EffectivePrice: &armbilling.Amount{ + // EffectivePrice: &armbilling.TransactionPropertiesEffectivePrice{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](10), // }, // ExchangeRate: to.Ptr[float32](1), // Invoice: to.Ptr("pending"), // InvoiceSectionDisplayName: to.Ptr("Contoso operations invoiceSection"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/22000000-0000-0000-0000-000000000000"), - // Kind: to.Ptr(armbilling.TransactionTypeKindAll), - // MarketPrice: &armbilling.Amount{ + // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/22000000-0000-0000-0000-000000000000"), + // MarketPrice: &armbilling.TransactionPropertiesMarketPrice{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](20), // }, + // PartNumber: to.Ptr("0002"), // PricingCurrency: to.Ptr("USD"), // ProductDescription: to.Ptr("Standard Support"), // ProductFamily: to.Ptr("Storage"), // ProductType: to.Ptr("VM Instance"), // ProductTypeID: to.Ptr("A12345"), // Quantity: to.Ptr[int32](1), - // ServicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-30T00:00:00.000Z"); return t}()), - // ServicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00.000Z"); return t}()), - // SubTotal: &armbilling.Amount{ + // ServicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-30T00:00:00.000Z"); return t}()), + // ServicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-01T00:00:00.000Z"); return t}()), + // SubTotal: &armbilling.TransactionPropertiesSubTotal{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](45), // }, - // Tax: &armbilling.Amount{ + // Tax: &armbilling.TransactionPropertiesTax{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](5), // }, - // TransactionAmount: &armbilling.Amount{ + // TransactionAmount: &armbilling.TransactionPropertiesTransactionAmount{ // Currency: to.Ptr("USD"), // Value: to.Ptr[float32](50), // }, - // TransactionType: to.Ptr(armbilling.ReservationType("Cancel")), + // TransactionType: to.Ptr("Cancel"), // UnitOfMeasure: to.Ptr("1 Minute"), // UnitType: to.Ptr("1 Runtime Minute"), // Units: to.Ptr[float32](1.25), @@ -153,3 +615,61 @@ func ExampleTransactionsClient_NewListByInvoicePager() { // } } } + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/transactionsDownloadByInvoice.json +func ExampleTransactionsClient_BeginTransactionsDownloadByInvoice() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTransactionsClient().BeginTransactionsDownloadByInvoice(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "G123456789", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DocumentDownloadResult = armbilling.DocumentDownloadResult{ + // ExpiryTime: to.Ptr("2023-02-16T17:32:28Z"), + // URL: to.Ptr("https://myaccount.blob.core.windows.net/invoices/1383724_invoice.csv?sv=2019-02-02&sr=b&sp=r"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/transactionSummaryGetByInvoice.json +func ExampleTransactionsClient_GetTransactionSummaryByInvoice() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTransactionsClient().GetTransactionSummaryByInvoice(ctx, "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "G123456789", &armbilling.TransactionsClientGetTransactionSummaryByInvoiceOptions{Filter: nil, + Search: nil, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.TransactionSummary = armbilling.TransactionSummary{ + // AzureCreditApplied: to.Ptr[float32](100), + // BillingCurrency: to.Ptr("USD"), + // ConsumptionCommitmentDecremented: to.Ptr[float32](1000), + // SubTotal: to.Ptr[float32](1000), + // Tax: to.Ptr[float32](500), + // Total: to.Ptr[float32](5400), + // } +} diff --git a/sdk/resourcemanager/billing/armbilling/transfers_client.go b/sdk/resourcemanager/billing/armbilling/transfers_client.go new file mode 100644 index 000000000000..33dd865c36fd --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/transfers_client.go @@ -0,0 +1,326 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armbilling + +import ( + "context" + "errors" + "net/http" + "net/url" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// TransfersClient contains the methods for the Transfers group. +// Don't use this type directly, use NewTransfersClient() instead. +type TransfersClient struct { + internal *arm.Client +} + +// NewTransfersClient creates a new instance of TransfersClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewTransfersClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*TransfersClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &TransfersClient{ + internal: cl, + } + return client, nil +} + +// Cancel - Cancels a transfer request. The operation is supported only for billing accounts with agreement type Microsoft +// Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - invoiceSectionName - The ID that uniquely identifies an invoice section. +// - transferName - The ID that uniquely identifies a transfer request. +// - options - TransfersClientCancelOptions contains the optional parameters for the TransfersClient.Cancel method. +func (client *TransfersClient) Cancel(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, transferName string, options *TransfersClientCancelOptions) (TransfersClientCancelResponse, error) { + var err error + const operationName = "TransfersClient.Cancel" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.cancelCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, transferName, options) + if err != nil { + return TransfersClientCancelResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TransfersClientCancelResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TransfersClientCancelResponse{}, err + } + resp, err := client.cancelHandleResponse(httpResp) + return resp, err +} + +// cancelCreateRequest creates the Cancel request. +func (client *TransfersClient) cancelCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, transferName string, options *TransfersClientCancelOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/transfers/{transferName}/cancel" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if invoiceSectionName == "" { + return nil, errors.New("parameter invoiceSectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) + if transferName == "" { + return nil, errors.New("parameter transferName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{transferName}", url.PathEscape(transferName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// cancelHandleResponse handles the Cancel response. +func (client *TransfersClient) cancelHandleResponse(resp *http.Response) (TransfersClientCancelResponse, error) { + result := TransfersClientCancelResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TransferDetails); err != nil { + return TransfersClientCancelResponse{}, err + } + return result, nil +} + +// Get - Gets a transfer request by ID. The operation is supported only for billing accounts with agreement type Microsoft +// Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - invoiceSectionName - The ID that uniquely identifies an invoice section. +// - transferName - The ID that uniquely identifies a transfer request. +// - options - TransfersClientGetOptions contains the optional parameters for the TransfersClient.Get method. +func (client *TransfersClient) Get(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, transferName string, options *TransfersClientGetOptions) (TransfersClientGetResponse, error) { + var err error + const operationName = "TransfersClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, transferName, options) + if err != nil { + return TransfersClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TransfersClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TransfersClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *TransfersClient) getCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, transferName string, options *TransfersClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/transfers/{transferName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if invoiceSectionName == "" { + return nil, errors.New("parameter invoiceSectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) + if transferName == "" { + return nil, errors.New("parameter transferName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{transferName}", url.PathEscape(transferName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *TransfersClient) getHandleResponse(resp *http.Response) (TransfersClientGetResponse, error) { + result := TransfersClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TransferDetails); err != nil { + return TransfersClientGetResponse{}, err + } + return result, nil +} + +// Initiate - Sends a request to a user in another billing account to transfer billing ownership of their subscriptions. The +// operation is supported only for billing accounts with agreement type Microsoft Customer +// Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - invoiceSectionName - The ID that uniquely identifies an invoice section. +// - transferName - The ID that uniquely identifies a transfer request. +// - parameters - Request parameters that are provided to the initiate transfer operation. +// - options - TransfersClientInitiateOptions contains the optional parameters for the TransfersClient.Initiate method. +func (client *TransfersClient) Initiate(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, transferName string, parameters InitiateTransferRequest, options *TransfersClientInitiateOptions) (TransfersClientInitiateResponse, error) { + var err error + const operationName = "TransfersClient.Initiate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.initiateCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, transferName, parameters, options) + if err != nil { + return TransfersClientInitiateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TransfersClientInitiateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return TransfersClientInitiateResponse{}, err + } + resp, err := client.initiateHandleResponse(httpResp) + return resp, err +} + +// initiateCreateRequest creates the Initiate request. +func (client *TransfersClient) initiateCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, transferName string, parameters InitiateTransferRequest, options *TransfersClientInitiateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/transfers/{transferName}" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if invoiceSectionName == "" { + return nil, errors.New("parameter invoiceSectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) + if transferName == "" { + return nil, errors.New("parameter transferName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{transferName}", url.PathEscape(transferName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// initiateHandleResponse handles the Initiate response. +func (client *TransfersClient) initiateHandleResponse(resp *http.Response) (TransfersClientInitiateResponse, error) { + result := TransfersClientInitiateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TransferDetails); err != nil { + return TransfersClientInitiateResponse{}, err + } + return result, nil +} + +// NewListPager - Lists the transfer requests for an invoice section. The operation is supported only for billing accounts +// with agreement type Microsoft Customer Agreement. +// +// Generated from API version 2024-04-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - invoiceSectionName - The ID that uniquely identifies an invoice section. +// - options - TransfersClientListOptions contains the optional parameters for the TransfersClient.NewListPager method. +func (client *TransfersClient) NewListPager(billingAccountName string, billingProfileName string, invoiceSectionName string, options *TransfersClientListOptions) *runtime.Pager[TransfersClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[TransfersClientListResponse]{ + More: func(page TransfersClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *TransfersClientListResponse) (TransfersClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TransfersClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, options) + }, nil) + if err != nil { + return TransfersClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *TransfersClient) listCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, options *TransfersClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/transfers" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if invoiceSectionName == "" { + return nil, errors.New("parameter invoiceSectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *TransfersClient) listHandleResponse(resp *http.Response) (TransfersClientListResponse, error) { + result := TransfersClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TransferDetailsListResult); err != nil { + return TransfersClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/billing/armbilling/transfers_client_example_test.go b/sdk/resourcemanager/billing/armbilling/transfers_client_example_test.go new file mode 100644 index 000000000000..59ef5e50ef3d --- /dev/null +++ b/sdk/resourcemanager/billing/armbilling/transfers_client_example_test.go @@ -0,0 +1,186 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armbilling_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/transfersGet.json +func ExampleTransfersClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTransfersClient().Get(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "yyyy-yyyy-yyy-yyy", "aabb123", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.TransferDetails = armbilling.TransferDetails{ + // Name: to.Ptr("aabb123"), + // Type: to.Ptr("Microsoft.Billing/transfers"), + // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy/transfers/aabb123"), + // Properties: &armbilling.TransferProperties{ + // DetailedTransferStatus: []*armbilling.DetailedTransferStatus{ + // { + // ProductID: to.Ptr("subscriptionId"), + // ProductName: to.Ptr("Azure subscription 1"), + // ProductType: to.Ptr(armbilling.ProductTypeAzureSubscription), + // SKUDescription: to.Ptr("MS-AZR-0017G"), + // TransferStatus: to.Ptr(armbilling.ProductTransferStatusInProgress), + // }, + // { + // ProductID: to.Ptr("reservedInstanceId"), + // ProductName: to.Ptr("Reservation name"), + // ProductType: to.Ptr(armbilling.ProductTypeAzureReservation), + // SKUDescription: to.Ptr("Standard_D2s_v3;VirtualMachines;P1Y"), + // TransferStatus: to.Ptr(armbilling.ProductTransferStatusInProgress), + // }}, + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-05T17:32:28.000Z"); return t}()), + // InitiatorEmailID: to.Ptr("xyz@contoso.com"), + // RecipientEmailID: to.Ptr("user@contoso.com"), + // TransferStatus: to.Ptr(armbilling.TransferStatusInProgress), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/transfersInitiate.json +func ExampleTransfersClient_Initiate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTransfersClient().Initiate(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "yyyy-yyyy-yyy-yyy", "aabb123", armbilling.InitiateTransferRequest{ + Properties: &armbilling.InitiateTransferProperties{ + RecipientEmailID: to.Ptr("user@contoso.com"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.TransferDetails = armbilling.TransferDetails{ + // Name: to.Ptr("aabb123"), + // Type: to.Ptr("Microsoft.Billing/transfers"), + // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy/transfers/aabb123"), + // Properties: &armbilling.TransferProperties{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-05T17:32:28.000Z"); return t}()), + // InitiatorEmailID: to.Ptr("xyz@contoso.com"), + // RecipientEmailID: to.Ptr("user@contoso.com"), + // TransferStatus: to.Ptr(armbilling.TransferStatusPending), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/transfersCancel.json +func ExampleTransfersClient_Cancel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTransfersClient().Cancel(ctx, "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "yyyy-yyyy-yyy-yyy", "aabb123", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.TransferDetails = armbilling.TransferDetails{ + // Name: to.Ptr("aabb123"), + // Type: to.Ptr("Microsoft.Billing/transfers"), + // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy/transfers/aabb123"), + // Properties: &armbilling.TransferProperties{ + // CanceledBy: to.Ptr("user@contoso.com"), + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-05T17:32:28.000Z"); return t}()), + // InitiatorEmailID: to.Ptr("xyz@contoso.com"), + // RecipientEmailID: to.Ptr("user@contoso.com"), + // TransferStatus: to.Ptr(armbilling.TransferStatusPending), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c08ac9813477921ad8295b98ced8f82d11b8f913/specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/transfersList.json +func ExampleTransfersClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbilling.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewTransfersClient().NewListPager("10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31", "xxxx-xxxx-xxx-xxx", "yyyy-yyyy-yyy-yyy", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.TransferDetailsListResult = armbilling.TransferDetailsListResult{ + // Value: []*armbilling.TransferDetails{ + // { + // Name: to.Ptr("aabb123"), + // Type: to.Ptr("Microsoft.Billing/transfers"), + // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx/invoiceSections/yyyy-yyyy-yyy-yyy/transfers/aabb123"), + // Properties: &armbilling.TransferProperties{ + // DetailedTransferStatus: []*armbilling.DetailedTransferStatus{ + // { + // ProductID: to.Ptr("subscriptionId"), + // ProductName: to.Ptr("Azure subscription 1"), + // ProductType: to.Ptr(armbilling.ProductTypeAzureSubscription), + // SKUDescription: to.Ptr("MS-AZR-0017G"), + // TransferStatus: to.Ptr(armbilling.ProductTransferStatusInProgress), + // }, + // { + // ProductID: to.Ptr("reservedInstanceId"), + // ProductName: to.Ptr("Reservation name"), + // ProductType: to.Ptr(armbilling.ProductTypeAzureReservation), + // SKUDescription: to.Ptr("Standard_D2s_v3;VirtualMachines;P1Y"), + // TransferStatus: to.Ptr(armbilling.ProductTransferStatusInProgress), + // }}, + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-05T17:32:28.000Z"); return t}()), + // InitiatorEmailID: to.Ptr("xyz@contoso.com"), + // RecipientEmailID: to.Ptr("user@contoso.com"), + // TransferStatus: to.Ptr(armbilling.TransferStatusInProgress), + // }, + // }}, + // } + } +}