From 44521f18ee5778a4f0555423b75af014cace2328 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 26 Feb 2025 20:01:45 +0000 Subject: [PATCH] CodeGen from PR 32829 in Azure/azure-rest-api-specs Merge b8e27981b70e6bbcf7d720a98bbc46c3975631a7 into 15af9f5125486f6fe45fcd4730a3803c4b6c81ee --- .../armbillingbenefits/CHANGELOG.md | 71 + .../armbillingbenefits/README.md | 4 +- .../armbillingbenefits/autorest.md | 6 +- .../armbillingbenefits/client_factory.go | 57 +- .../armbillingbenefits/constants.go | 224 +++- .../armbillingbenefits/date_type.go | 6 +- .../armbillingbenefits/discount_client.go | 185 +++ .../armbillingbenefits/discounts_client.go | 443 ++++++ .../armbillingbenefits/fake/date_type.go | 6 +- .../fake/discount_server.go | 180 +++ .../fake/discounts_server.go | 377 ++++++ .../armbillingbenefits/fake/internal.go | 8 +- .../fake/operations_server.go | 54 +- .../fake/reservationorderalias_server.go | 58 +- .../armbillingbenefits/fake/rp_server.go | 54 +- .../fake/savingsplan_server.go | 144 +- .../fake/savingsplanorder_server.go | 62 +- .../fake/savingsplanorderalias_server.go | 58 +- .../armbillingbenefits/fake/server_factory.go | 36 +- .../armbillingbenefits/fake/time_rfc3339.go | 48 +- .../billingbenefits/armbillingbenefits/go.mod | 14 +- .../billingbenefits/armbillingbenefits/go.sum | 23 - .../armbillingbenefits/interfaces.go | 35 + .../armbillingbenefits/models.go | 678 +++++++++- .../armbillingbenefits/models_serde.go | 1187 ++++++++++++++++- .../armbillingbenefits/operations_client.go | 9 +- .../operations_client_example_test.go | 118 -- .../armbillingbenefits/options.go | 64 +- .../armbillingbenefits/polymorphic_helpers.go | 60 + .../reservationorderalias_client.go | 17 +- ...servationorderalias_client_example_test.go | 137 -- .../{response_types.go => responses.go} | 55 +- .../armbillingbenefits/rp_client.go | 9 +- .../rp_client_example_test.go | 90 -- .../armbillingbenefits/savingsplan_client.go | 85 +- .../savingsplan_client_example_test.go | 517 ------- .../savingsplanorder_client.go | 19 +- .../savingsplanorder_client_example_test.go | 478 ------- .../savingsplanorderalias_client.go | 17 +- ...vingsplanorderalias_client_example_test.go | 194 --- .../armbillingbenefits/time_rfc3339.go | 48 +- 41 files changed, 3974 insertions(+), 1961 deletions(-) create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/discount_client.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/discounts_client.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/discount_server.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/discounts_server.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/interfaces.go delete mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/operations_client_example_test.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/polymorphic_helpers.go delete mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/reservationorderalias_client_example_test.go rename sdk/resourcemanager/billingbenefits/armbillingbenefits/{response_types.go => responses.go} (67%) delete mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/rp_client_example_test.go delete mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplan_client_example_test.go delete mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorder_client_example_test.go delete mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorderalias_client_example_test.go diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/CHANGELOG.md b/sdk/resourcemanager/billingbenefits/armbillingbenefits/CHANGELOG.md index 9c09c44ba906..087b43c632b9 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/CHANGELOG.md +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/CHANGELOG.md @@ -1,5 +1,76 @@ # Release History +## 3.0.0-beta.1 (2025-02-26) +### Breaking Changes + +- Type of `PurchaseRequest.SKU` has been changed from `*SKU` to `*ResourceSKU` +- Type of `ReservationOrderAliasRequest.SKU` has been changed from `*SKU` to `*ResourceSKU` +- Type of `ReservationOrderAliasResponse.SKU` has been changed from `*SKU` to `*ResourceSKU` +- Type of `SavingsPlanModel.SKU` has been changed from `*SKU` to `*ResourceSKU` +- Type of `SavingsPlanOrderAliasModel.SKU` has been changed from `*SKU` to `*ResourceSKU` +- Type of `SavingsPlanOrderModel.SKU` has been changed from `*SKU` to `*ResourceSKU` +- Operation `*SavingsPlanClient.Update` has been changed to LRO, use `*SavingsPlanClient.BeginUpdate` instead. + +### Features Added + +- New value `CommitmentGrainFullTerm`, `CommitmentGrainUnknown` added to enum type `CommitmentGrain` +- New enum type `ApplyDiscountOn` with values `ApplyDiscountOnConsume`, `ApplyDiscountOnPurchase`, `ApplyDiscountOnRenew` +- New enum type `DiscountAppliedScopeType` with values `DiscountAppliedScopeTypeBillingAccount`, `DiscountAppliedScopeTypeBillingProfile`, `DiscountAppliedScopeTypeCustomer` +- New enum type `DiscountCombinationRule` with values `DiscountCombinationRuleBestOf`, `DiscountCombinationRuleStackable` +- New enum type `DiscountEntityType` with values `DiscountEntityTypeAffiliate`, `DiscountEntityTypePrimary` +- New enum type `DiscountProvisioningState` with values `DiscountProvisioningStateCanceled`, `DiscountProvisioningStateFailed`, `DiscountProvisioningStatePending`, `DiscountProvisioningStateSucceeded`, `DiscountProvisioningStateUnknown` +- New enum type `DiscountRuleType` with values `DiscountRuleTypeFixedListPrice`, `DiscountRuleTypeFixedPriceLock`, `DiscountRuleTypePriceCeiling` +- New enum type `DiscountStatus` with values `DiscountStatusActive`, `DiscountStatusCanceled`, `DiscountStatusExpired`, `DiscountStatusFailed`, `DiscountStatusPending` +- New enum type `DiscountType` with values `DiscountTypeCustomPrice`, `DiscountTypeCustomPriceMultiCurrency`, `DiscountTypeProduct`, `DiscountTypeProductFamily`, `DiscountTypeSKU` +- New enum type `ManagedServiceIdentityType` with values `ManagedServiceIdentityTypeNone`, `ManagedServiceIdentityTypeSystemAssigned`, `ManagedServiceIdentityTypeSystemAssignedUserAssigned`, `ManagedServiceIdentityTypeUserAssigned` +- New enum type `PricingPolicy` with values `PricingPolicyLocked`, `PricingPolicyProtected` +- New enum type `SKUTier` with values `SKUTierBasic`, `SKUTierFree`, `SKUTierPremium`, `SKUTierStandard` +- New function `*ClientFactory.NewDiscountClient(string) *DiscountClient` +- New function `*ClientFactory.NewDiscountsClient(string) *DiscountsClient` +- New function `NewDiscountClient(string, azcore.TokenCredential, *arm.ClientOptions) (*DiscountClient, error)` +- New function `*DiscountClient.Get(context.Context, string, string, *DiscountClientGetOptions) (DiscountClientGetResponse, error)` +- New function `*DiscountClient.BeginUpdate(context.Context, string, string, DiscountPatchRequest, *DiscountClientBeginUpdateOptions) (*runtime.Poller[DiscountClientUpdateResponse], error)` +- New function `*DiscountProperties.GetDiscountProperties() *DiscountProperties` +- New function `*DiscountTypeCustomPrice.GetDiscountTypeCustomPrice() *DiscountTypeCustomPrice` +- New function `*DiscountTypeCustomPrice.GetDiscountTypeProperties() *DiscountTypeProperties` +- New function `*DiscountTypeCustomPriceMultiCurrency.GetDiscountTypeCustomPrice() *DiscountTypeCustomPrice` +- New function `*DiscountTypeCustomPriceMultiCurrency.GetDiscountTypeProperties() *DiscountTypeProperties` +- New function `*DiscountTypeProduct.GetDiscountTypeProperties() *DiscountTypeProperties` +- New function `*DiscountTypeProductFamily.GetDiscountTypeProperties() *DiscountTypeProperties` +- New function `*DiscountTypeProductSKU.GetDiscountTypeProperties() *DiscountTypeProperties` +- New function `*DiscountTypeProperties.GetDiscountTypeProperties() *DiscountTypeProperties` +- New function `NewDiscountsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*DiscountsClient, error)` +- New function `*DiscountsClient.BeginCancel(context.Context, string, string, *DiscountsClientBeginCancelOptions) (*runtime.Poller[DiscountsClientCancelResponse], error)` +- New function `*DiscountsClient.BeginCreate(context.Context, string, string, Discount, *DiscountsClientBeginCreateOptions) (*runtime.Poller[DiscountsClientCreateResponse], error)` +- New function `*DiscountsClient.BeginDelete(context.Context, string, string, *DiscountsClientBeginDeleteOptions) (*runtime.Poller[DiscountsClientDeleteResponse], error)` +- New function `*DiscountsClient.NewResourceGroupListPager(string, *DiscountsClientResourceGroupListOptions) *runtime.Pager[DiscountsClientResourceGroupListResponse]` +- New function `*DiscountsClient.NewScopeListPager(string, *DiscountsClientScopeListOptions) *runtime.Pager[DiscountsClientScopeListResponse]` +- New function `*DiscountsClient.NewSubscriptionListPager(*DiscountsClientSubscriptionListOptions) *runtime.Pager[DiscountsClientSubscriptionListResponse]` +- New function `*EntityTypeAffiliateDiscount.GetDiscountProperties() *DiscountProperties` +- New function `*EntityTypePrimaryDiscount.GetDiscountProperties() *DiscountProperties` +- New struct `CatalogClaimsItem` +- New struct `ConditionsItem` +- New struct `CustomPriceProperties` +- New struct `Discount` +- New struct `DiscountList` +- New struct `DiscountPatchRequest` +- New struct `DiscountPatchRequestProperties` +- New struct `DiscountTypeCustomPriceMultiCurrency` +- New struct `DiscountTypeProduct` +- New struct `DiscountTypeProductFamily` +- New struct `DiscountTypeProductSKU` +- New struct `EntityTypeAffiliateDiscount` +- New struct `EntityTypePrimaryDiscount` +- New struct `ManagedServiceIdentity` +- New struct `MarketSetPricesItems` +- New struct `Plan` +- New struct `PriceGuaranteeProperties` +- New struct `ResourceSKU` +- New struct `UserAssignedIdentity` +- New field `Capacity`, `Family`, `Size`, `Tier` in struct `SKU` +- New field `Renew` in struct `SavingsPlanOrderAliasProperties` + + ## 2.1.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/README.md b/sdk/resourcemanager/billingbenefits/armbillingbenefits/README.md index 68203c7c1d82..7de602bcf72e 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/README.md +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/README.md @@ -18,7 +18,7 @@ This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for ve Install the Azure Billingbenefits module: ```sh -go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billingbenefits/armbillingbenefits/v2 +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billingbenefits/armbillingbenefits/v3 ``` ## Authorization @@ -55,7 +55,7 @@ clientFactory, err := armbillingbenefits.NewClientFactory(, cre A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. ```go -client := clientFactory.NewRPClient() +client := clientFactory.NewDiscountClient() ``` ## Fakes diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/autorest.md b/sdk/resourcemanager/billingbenefits/armbillingbenefits/autorest.md index 61d3836fccb3..4ecb9f4e04de 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/autorest.md +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/billingbenefits/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/billingbenefits/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/billingbenefits/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/billingbenefits/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 2.1.0 +module-version: 3.0.0-beta.1 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/client_factory.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/client_factory.go index d19f40addd82..aa6ecf6bd39d 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/client_factory.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/client_factory.go @@ -1,6 +1,3 @@ -//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. @@ -16,8 +13,7 @@ import ( // ClientFactory is a client factory used to create any client in this module. // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. @@ -25,48 +21,69 @@ type ClientFactory struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClientFactory(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{ - credential: credential, - options: options.Clone(), + internal: internal, }, nil } +// NewDiscountClient creates a new instance of DiscountClient. +func (c *ClientFactory) NewDiscountClient(subscriptionID string) *DiscountClient { + return &DiscountClient{ + subscriptionID: subscriptionID, + internal: c.internal, + } +} + +// NewDiscountsClient creates a new instance of DiscountsClient. +func (c *ClientFactory) NewDiscountsClient(subscriptionID string) *DiscountsClient { + return &DiscountsClient{ + subscriptionID: 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, + } } // NewRPClient creates a new instance of RPClient. func (c *ClientFactory) NewRPClient() *RPClient { - subClient, _ := NewRPClient(c.credential, c.options) - return subClient + return &RPClient{ + internal: c.internal, + } } // NewReservationOrderAliasClient creates a new instance of ReservationOrderAliasClient. func (c *ClientFactory) NewReservationOrderAliasClient() *ReservationOrderAliasClient { - subClient, _ := NewReservationOrderAliasClient(c.credential, c.options) - return subClient + return &ReservationOrderAliasClient{ + internal: c.internal, + } } // NewSavingsPlanClient creates a new instance of SavingsPlanClient. func (c *ClientFactory) NewSavingsPlanClient() *SavingsPlanClient { - subClient, _ := NewSavingsPlanClient(c.credential, c.options) - return subClient + return &SavingsPlanClient{ + internal: c.internal, + } } // NewSavingsPlanOrderAliasClient creates a new instance of SavingsPlanOrderAliasClient. func (c *ClientFactory) NewSavingsPlanOrderAliasClient() *SavingsPlanOrderAliasClient { - subClient, _ := NewSavingsPlanOrderAliasClient(c.credential, c.options) - return subClient + return &SavingsPlanOrderAliasClient{ + internal: c.internal, + } } // NewSavingsPlanOrderClient creates a new instance of SavingsPlanOrderClient. func (c *ClientFactory) NewSavingsPlanOrderClient() *SavingsPlanOrderClient { - subClient, _ := NewSavingsPlanOrderClient(c.credential, c.options) - return subClient + return &SavingsPlanOrderClient{ + internal: c.internal, + } } diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/constants.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/constants.go index 4148b8b6579d..396a9c65eadd 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/constants.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/constants.go @@ -1,6 +1,3 @@ -//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. @@ -10,7 +7,7 @@ package armbillingbenefits const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billingbenefits/armbillingbenefits" - moduleVersion = "v2.1.0" + moduleVersion = "v3.0.0-beta.1" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. @@ -45,6 +42,25 @@ func PossibleAppliedScopeTypeValues() []AppliedScopeType { } } +// ApplyDiscountOn - The customer action on which the discount is applied. Supported values are Purchase, Consume, and Renew. +// Validation: Required, one of supported values. +type ApplyDiscountOn string + +const ( + ApplyDiscountOnConsume ApplyDiscountOn = "Consume" + ApplyDiscountOnPurchase ApplyDiscountOn = "Purchase" + ApplyDiscountOnRenew ApplyDiscountOn = "Renew" +) + +// PossibleApplyDiscountOnValues returns the possible values for the ApplyDiscountOn const type. +func PossibleApplyDiscountOnValues() []ApplyDiscountOn { + return []ApplyDiscountOn{ + ApplyDiscountOnConsume, + ApplyDiscountOnPurchase, + ApplyDiscountOnRenew, + } +} + // BillingPlan - Represents the billing plan in ISO 8601 format. Required only for monthly billing plans. type BillingPlan string @@ -63,13 +79,17 @@ func PossibleBillingPlanValues() []BillingPlan { type CommitmentGrain string const ( - CommitmentGrainHourly CommitmentGrain = "Hourly" + CommitmentGrainFullTerm CommitmentGrain = "FullTerm" + CommitmentGrainHourly CommitmentGrain = "Hourly" + CommitmentGrainUnknown CommitmentGrain = "Unknown" ) // PossibleCommitmentGrainValues returns the possible values for the CommitmentGrain const type. func PossibleCommitmentGrainValues() []CommitmentGrain { return []CommitmentGrain{ + CommitmentGrainFullTerm, CommitmentGrainHourly, + CommitmentGrainUnknown, } } @@ -93,6 +113,143 @@ func PossibleCreatedByTypeValues() []CreatedByType { } } +// DiscountAppliedScopeType - List of applied scopes supported for discounts. +type DiscountAppliedScopeType string + +const ( + DiscountAppliedScopeTypeBillingAccount DiscountAppliedScopeType = "BillingAccount" + DiscountAppliedScopeTypeBillingProfile DiscountAppliedScopeType = "BillingProfile" + DiscountAppliedScopeTypeCustomer DiscountAppliedScopeType = "Customer" +) + +// PossibleDiscountAppliedScopeTypeValues returns the possible values for the DiscountAppliedScopeType const type. +func PossibleDiscountAppliedScopeTypeValues() []DiscountAppliedScopeType { + return []DiscountAppliedScopeType{ + DiscountAppliedScopeTypeBillingAccount, + DiscountAppliedScopeTypeBillingProfile, + DiscountAppliedScopeTypeCustomer, + } +} + +// DiscountCombinationRule - The discount combination rule when there are multiple applicable custom prices. Validation: Required. +// Supported values are Stackable and BestOf. +type DiscountCombinationRule string + +const ( + DiscountCombinationRuleBestOf DiscountCombinationRule = "BestOf" + DiscountCombinationRuleStackable DiscountCombinationRule = "Stackable" +) + +// PossibleDiscountCombinationRuleValues returns the possible values for the DiscountCombinationRule const type. +func PossibleDiscountCombinationRuleValues() []DiscountCombinationRule { + return []DiscountCombinationRule{ + DiscountCombinationRuleBestOf, + DiscountCombinationRuleStackable, + } +} + +// DiscountEntityType - This defines whether the entity being created is primary or affiliate. Supported values: primary, +// affiliate. Validation: Required, must match one of the 2 values. +type DiscountEntityType string + +const ( + DiscountEntityTypeAffiliate DiscountEntityType = "Affiliate" + DiscountEntityTypePrimary DiscountEntityType = "Primary" +) + +// PossibleDiscountEntityTypeValues returns the possible values for the DiscountEntityType const type. +func PossibleDiscountEntityTypeValues() []DiscountEntityType { + return []DiscountEntityType{ + DiscountEntityTypeAffiliate, + DiscountEntityTypePrimary, + } +} + +// DiscountProvisioningState - Provisioning states of Discount. +type DiscountProvisioningState string + +const ( + DiscountProvisioningStateCanceled DiscountProvisioningState = "Canceled" + DiscountProvisioningStateFailed DiscountProvisioningState = "Failed" + DiscountProvisioningStatePending DiscountProvisioningState = "Pending" + DiscountProvisioningStateSucceeded DiscountProvisioningState = "Succeeded" + DiscountProvisioningStateUnknown DiscountProvisioningState = "Unknown" +) + +// PossibleDiscountProvisioningStateValues returns the possible values for the DiscountProvisioningState const type. +func PossibleDiscountProvisioningStateValues() []DiscountProvisioningState { + return []DiscountProvisioningState{ + DiscountProvisioningStateCanceled, + DiscountProvisioningStateFailed, + DiscountProvisioningStatePending, + DiscountProvisioningStateSucceeded, + DiscountProvisioningStateUnknown, + } +} + +// DiscountRuleType - The type of the priceable node pricing rule. Validation: Required. Supported values are fixedPriceLock, +// fixedListPrice, and priceCeiling. +type DiscountRuleType string + +const ( + DiscountRuleTypeFixedListPrice DiscountRuleType = "FixedListPrice" + DiscountRuleTypeFixedPriceLock DiscountRuleType = "FixedPriceLock" + DiscountRuleTypePriceCeiling DiscountRuleType = "PriceCeiling" +) + +// PossibleDiscountRuleTypeValues returns the possible values for the DiscountRuleType const type. +func PossibleDiscountRuleTypeValues() []DiscountRuleType { + return []DiscountRuleType{ + DiscountRuleTypeFixedListPrice, + DiscountRuleTypeFixedPriceLock, + DiscountRuleTypePriceCeiling, + } +} + +// DiscountStatus - Represents the current status of the discount. +type DiscountStatus string + +const ( + DiscountStatusActive DiscountStatus = "Active" + DiscountStatusCanceled DiscountStatus = "Canceled" + DiscountStatusExpired DiscountStatus = "Expired" + DiscountStatusFailed DiscountStatus = "Failed" + DiscountStatusPending DiscountStatus = "Pending" +) + +// PossibleDiscountStatusValues returns the possible values for the DiscountStatus const type. +func PossibleDiscountStatusValues() []DiscountStatus { + return []DiscountStatus{ + DiscountStatusActive, + DiscountStatusCanceled, + DiscountStatusExpired, + DiscountStatusFailed, + DiscountStatusPending, + } +} + +// DiscountType - Defines the type of discount. Supported values are ProductFamily, Product, Sku, CustomPrice, and CustomPriceMultiCurrency. +type DiscountType string + +const ( + DiscountTypeCustomPrice DiscountType = "CustomPrice" + DiscountTypeCustomPriceMultiCurrency DiscountType = "CustomPriceMultiCurrency" + DiscountTypeProduct DiscountType = "Product" + DiscountTypeProductFamily DiscountType = "ProductFamily" + DiscountTypeSKU DiscountType = "Sku" +) + +// PossibleDiscountTypeValues returns the possible values for the DiscountType const type. +func PossibleDiscountTypeValues() []DiscountType { + return []DiscountType{ + DiscountTypeCustomPrice, + DiscountTypeCustomPriceMultiCurrency, + DiscountTypeProduct, + DiscountTypeProductFamily, + DiscountTypeSKU, + } +} + // InstanceFlexibility - Turning this on will apply the reservation discount to other VMs in the same VM size group. type InstanceFlexibility string @@ -109,6 +266,26 @@ func PossibleInstanceFlexibilityValues() []InstanceFlexibility { } } +// ManagedServiceIdentityType - Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). +type ManagedServiceIdentityType string + +const ( + ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" + ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" + ManagedServiceIdentityTypeSystemAssignedUserAssigned ManagedServiceIdentityType = "SystemAssigned,UserAssigned" + ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned" +) + +// PossibleManagedServiceIdentityTypeValues returns the possible values for the ManagedServiceIdentityType const type. +func PossibleManagedServiceIdentityTypeValues() []ManagedServiceIdentityType { + return []ManagedServiceIdentityType{ + ManagedServiceIdentityTypeNone, + ManagedServiceIdentityTypeSystemAssigned, + ManagedServiceIdentityTypeSystemAssignedUserAssigned, + ManagedServiceIdentityTypeUserAssigned, + } +} + // Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default // value is "user,system" type Origin string @@ -148,6 +325,22 @@ func PossiblePaymentStatusValues() []PaymentStatus { } } +// PricingPolicy - Supported values: Protected, Locked +type PricingPolicy string + +const ( + PricingPolicyLocked PricingPolicy = "Locked" + PricingPolicyProtected PricingPolicy = "Protected" +) + +// PossiblePricingPolicyValues returns the possible values for the PricingPolicy const type. +func PossiblePricingPolicyValues() []PricingPolicy { + return []PricingPolicy{ + PricingPolicyLocked, + PricingPolicyProtected, + } +} + // ProvisioningState - Provisioning state type ProvisioningState string @@ -240,6 +433,27 @@ func PossibleReservedResourceTypeValues() []ReservedResourceType { } } +// SKUTier - This field is required to be implemented by the Resource Provider if the service has more than one tier, but +// is not required on a PUT. +type SKUTier string + +const ( + SKUTierBasic SKUTier = "Basic" + SKUTierFree SKUTier = "Free" + SKUTierPremium SKUTier = "Premium" + SKUTierStandard SKUTier = "Standard" +) + +// PossibleSKUTierValues returns the possible values for the SKUTier const type. +func PossibleSKUTierValues() []SKUTier { + return []SKUTier{ + SKUTierBasic, + SKUTierFree, + SKUTierPremium, + SKUTierStandard, + } +} + // Term - Represent benefit term in ISO 8601 format. type Term string diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/date_type.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/date_type.go index d3689b9bd621..783fde33e61d 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/date_type.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/date_type.go @@ -1,6 +1,3 @@ -//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. @@ -13,7 +10,6 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "reflect" - "strings" "time" ) @@ -47,7 +43,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/billingbenefits/armbillingbenefits/discount_client.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/discount_client.go new file mode 100644 index 000000000000..674a846eb973 --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/discount_client.go @@ -0,0 +1,185 @@ +// 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 armbillingbenefits + +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" +) + +// DiscountClient contains the methods for the Discount group. +// Don't use this type directly, use NewDiscountClient() instead. +type DiscountClient struct { + internal *arm.Client + subscriptionID string +} + +// NewDiscountClient creates a new instance of DiscountClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewDiscountClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DiscountClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &DiscountClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Get discount at resource group level +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - discountName - Name of the discount +// - options - DiscountClientGetOptions contains the optional parameters for the DiscountClient.Get method. +func (client *DiscountClient) Get(ctx context.Context, resourceGroupName string, discountName string, options *DiscountClientGetOptions) (DiscountClientGetResponse, error) { + var err error + const operationName = "DiscountClient.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, resourceGroupName, discountName, options) + if err != nil { + return DiscountClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DiscountClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DiscountClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *DiscountClient) getCreateRequest(ctx context.Context, resourceGroupName string, discountName string, _ *DiscountClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BillingBenefits/discounts/{discountName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if discountName == "" { + return nil, errors.New("parameter discountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{discountName}", url.PathEscape(discountName)) + 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-11-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 *DiscountClient) getHandleResponse(resp *http.Response) (DiscountClientGetResponse, error) { + result := DiscountClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Discount); err != nil { + return DiscountClientGetResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update discounts +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - discountName - Name of the discount +// - body - Request body for updating discounts +// - options - DiscountClientBeginUpdateOptions contains the optional parameters for the DiscountClient.BeginUpdate method. +func (client *DiscountClient) BeginUpdate(ctx context.Context, resourceGroupName string, discountName string, body DiscountPatchRequest, options *DiscountClientBeginUpdateOptions) (*runtime.Poller[DiscountClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, discountName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DiscountClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DiscountClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update discounts +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *DiscountClient) update(ctx context.Context, resourceGroupName string, discountName string, body DiscountPatchRequest, options *DiscountClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "DiscountClient.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, resourceGroupName, discountName, 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 +} + +// updateCreateRequest creates the Update request. +func (client *DiscountClient) updateCreateRequest(ctx context.Context, resourceGroupName string, discountName string, body DiscountPatchRequest, _ *DiscountClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BillingBenefits/discounts/{discountName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if discountName == "" { + return nil, errors.New("parameter discountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{discountName}", url.PathEscape(discountName)) + 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-11-01-preview") + 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/billingbenefits/armbillingbenefits/discounts_client.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/discounts_client.go new file mode 100644 index 000000000000..8b4c3f7d42af --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/discounts_client.go @@ -0,0 +1,443 @@ +// 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 armbillingbenefits + +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" +) + +// DiscountsClient contains the methods for the Discounts group. +// Don't use this type directly, use NewDiscountsClient() instead. +type DiscountsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewDiscountsClient creates a new instance of DiscountsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewDiscountsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DiscountsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &DiscountsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCancel - Cancel discount. Stops applying the benefit. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - discountName - Name of the discount +// - options - DiscountsClientBeginCancelOptions contains the optional parameters for the DiscountsClient.BeginCancel method. +func (client *DiscountsClient) BeginCancel(ctx context.Context, resourceGroupName string, discountName string, options *DiscountsClientBeginCancelOptions) (*runtime.Poller[DiscountsClientCancelResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.cancel(ctx, resourceGroupName, discountName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DiscountsClientCancelResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DiscountsClientCancelResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Cancel - Cancel discount. Stops applying the benefit. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *DiscountsClient) cancel(ctx context.Context, resourceGroupName string, discountName string, options *DiscountsClientBeginCancelOptions) (*http.Response, error) { + var err error + const operationName = "DiscountsClient.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, resourceGroupName, discountName, 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 +} + +// cancelCreateRequest creates the Cancel request. +func (client *DiscountsClient) cancelCreateRequest(ctx context.Context, resourceGroupName string, discountName string, _ *DiscountsClientBeginCancelOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BillingBenefits/discounts/{discountName}/cancel" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if discountName == "" { + return nil, errors.New("parameter discountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{discountName}", url.PathEscape(discountName)) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginCreate - Create discount. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - discountName - Name of the discount +// - body - Request body for creating a discount. +// - options - DiscountsClientBeginCreateOptions contains the optional parameters for the DiscountsClient.BeginCreate method. +func (client *DiscountsClient) BeginCreate(ctx context.Context, resourceGroupName string, discountName string, body Discount, options *DiscountsClientBeginCreateOptions) (*runtime.Poller[DiscountsClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, discountName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DiscountsClientCreateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DiscountsClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Create - Create discount. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *DiscountsClient) create(ctx context.Context, resourceGroupName string, discountName string, body Discount, options *DiscountsClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "DiscountsClient.BeginCreate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createCreateRequest(ctx, resourceGroupName, discountName, 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.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createCreateRequest creates the Create request. +func (client *DiscountsClient) createCreateRequest(ctx context.Context, resourceGroupName string, discountName string, body Discount, _ *DiscountsClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BillingBenefits/discounts/{discountName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if discountName == "" { + return nil, errors.New("parameter discountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{discountName}", url.PathEscape(discountName)) + 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-11-01-preview") + 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 +} + +// BeginDelete - Delete discount. Clears the metadata from the user's view. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - discountName - Name of the discount +// - options - DiscountsClientBeginDeleteOptions contains the optional parameters for the DiscountsClient.BeginDelete method. +func (client *DiscountsClient) BeginDelete(ctx context.Context, resourceGroupName string, discountName string, options *DiscountsClientBeginDeleteOptions) (*runtime.Poller[DiscountsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, discountName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DiscountsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DiscountsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete discount. Clears the metadata from the user's view. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *DiscountsClient) deleteOperation(ctx context.Context, resourceGroupName string, discountName string, options *DiscountsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "DiscountsClient.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, resourceGroupName, discountName, 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 *DiscountsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, discountName string, _ *DiscountsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BillingBenefits/discounts/{discountName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if discountName == "" { + return nil, errors.New("parameter discountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{discountName}", url.PathEscape(discountName)) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// NewResourceGroupListPager - List discounts at resource group level +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - DiscountsClientResourceGroupListOptions contains the optional parameters for the DiscountsClient.NewResourceGroupListPager +// method. +func (client *DiscountsClient) NewResourceGroupListPager(resourceGroupName string, options *DiscountsClientResourceGroupListOptions) *runtime.Pager[DiscountsClientResourceGroupListResponse] { + return runtime.NewPager(runtime.PagingHandler[DiscountsClientResourceGroupListResponse]{ + More: func(page DiscountsClientResourceGroupListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DiscountsClientResourceGroupListResponse) (DiscountsClientResourceGroupListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DiscountsClient.NewResourceGroupListPager") + 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.resourceGroupListCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return DiscountsClientResourceGroupListResponse{}, err + } + return client.resourceGroupListHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// resourceGroupListCreateRequest creates the ResourceGroupList request. +func (client *DiscountsClient) resourceGroupListCreateRequest(ctx context.Context, resourceGroupName string, _ *DiscountsClientResourceGroupListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BillingBenefits/discounts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// resourceGroupListHandleResponse handles the ResourceGroupList response. +func (client *DiscountsClient) resourceGroupListHandleResponse(resp *http.Response) (DiscountsClientResourceGroupListResponse, error) { + result := DiscountsClientResourceGroupListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DiscountList); err != nil { + return DiscountsClientResourceGroupListResponse{}, err + } + return result, nil +} + +// NewScopeListPager - List discounts that are applicable for a given scope. Currently supported scopes: billing accounts +// +// Generated from API version 2024-11-01-preview +// - scope - The scope at which the benefits are listed. +// - options - DiscountsClientScopeListOptions contains the optional parameters for the DiscountsClient.NewScopeListPager method. +func (client *DiscountsClient) NewScopeListPager(scope string, options *DiscountsClientScopeListOptions) *runtime.Pager[DiscountsClientScopeListResponse] { + return runtime.NewPager(runtime.PagingHandler[DiscountsClientScopeListResponse]{ + More: func(page DiscountsClientScopeListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DiscountsClientScopeListResponse) (DiscountsClientScopeListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DiscountsClient.NewScopeListPager") + 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.scopeListCreateRequest(ctx, scope, options) + }, nil) + if err != nil { + return DiscountsClientScopeListResponse{}, err + } + return client.scopeListHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// scopeListCreateRequest creates the ScopeList request. +func (client *DiscountsClient) scopeListCreateRequest(ctx context.Context, scope string, _ *DiscountsClientScopeListOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.BillingBenefits/applicableDiscounts" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// scopeListHandleResponse handles the ScopeList response. +func (client *DiscountsClient) scopeListHandleResponse(resp *http.Response) (DiscountsClientScopeListResponse, error) { + result := DiscountsClientScopeListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DiscountList); err != nil { + return DiscountsClientScopeListResponse{}, err + } + return result, nil +} + +// NewSubscriptionListPager - List discounts at subscription level +// +// Generated from API version 2024-11-01-preview +// - options - DiscountsClientSubscriptionListOptions contains the optional parameters for the DiscountsClient.NewSubscriptionListPager +// method. +func (client *DiscountsClient) NewSubscriptionListPager(options *DiscountsClientSubscriptionListOptions) *runtime.Pager[DiscountsClientSubscriptionListResponse] { + return runtime.NewPager(runtime.PagingHandler[DiscountsClientSubscriptionListResponse]{ + More: func(page DiscountsClientSubscriptionListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DiscountsClientSubscriptionListResponse) (DiscountsClientSubscriptionListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DiscountsClient.NewSubscriptionListPager") + 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.subscriptionListCreateRequest(ctx, options) + }, nil) + if err != nil { + return DiscountsClientSubscriptionListResponse{}, err + } + return client.subscriptionListHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// subscriptionListCreateRequest creates the SubscriptionList request. +func (client *DiscountsClient) subscriptionListCreateRequest(ctx context.Context, _ *DiscountsClientSubscriptionListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.BillingBenefits/discounts" + 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", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// subscriptionListHandleResponse handles the SubscriptionList response. +func (client *DiscountsClient) subscriptionListHandleResponse(resp *http.Response) (DiscountsClientSubscriptionListResponse, error) { + result := DiscountsClientSubscriptionListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DiscountList); err != nil { + return DiscountsClientSubscriptionListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/date_type.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/date_type.go index efb0b705ae45..fc08a215e031 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/date_type.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/date_type.go @@ -1,6 +1,3 @@ -//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. @@ -13,7 +10,6 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "reflect" - "strings" "time" ) @@ -47,7 +43,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/billingbenefits/armbillingbenefits/fake/discount_server.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/discount_server.go new file mode 100644 index 000000000000..0c1f94edeadc --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/discount_server.go @@ -0,0 +1,180 @@ +// 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/resourcemanager/billingbenefits/armbillingbenefits/v3" + "net/http" + "net/url" + "regexp" +) + +// DiscountServer is a fake server for instances of the armbillingbenefits.DiscountClient type. +type DiscountServer struct { + // Get is the fake for method DiscountClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, discountName string, options *armbillingbenefits.DiscountClientGetOptions) (resp azfake.Responder[armbillingbenefits.DiscountClientGetResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method DiscountClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, discountName string, body armbillingbenefits.DiscountPatchRequest, options *armbillingbenefits.DiscountClientBeginUpdateOptions) (resp azfake.PollerResponder[armbillingbenefits.DiscountClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewDiscountServerTransport creates a new instance of DiscountServerTransport with the provided implementation. +// The returned DiscountServerTransport instance is connected to an instance of armbillingbenefits.DiscountClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDiscountServerTransport(srv *DiscountServer) *DiscountServerTransport { + return &DiscountServerTransport{ + srv: srv, + beginUpdate: newTracker[azfake.PollerResponder[armbillingbenefits.DiscountClientUpdateResponse]](), + } +} + +// DiscountServerTransport connects instances of armbillingbenefits.DiscountClient to instances of DiscountServer. +// Don't use this type directly, use NewDiscountServerTransport instead. +type DiscountServerTransport struct { + srv *DiscountServer + beginUpdate *tracker[azfake.PollerResponder[armbillingbenefits.DiscountClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for DiscountServerTransport. +func (d *DiscountServerTransport) 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")} + } + + return d.dispatchToMethodFake(req, method) +} + +func (d *DiscountServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if discountServerTransportInterceptor != nil { + res.resp, res.err, intercepted = discountServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "DiscountClient.Get": + res.resp, res.err = d.dispatchGet(req) + case "DiscountClient.BeginUpdate": + res.resp, res.err = d.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (d *DiscountServerTransport) 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 = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BillingBenefits/discounts/(?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) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + discountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("discountName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Get(req.Context(), resourceGroupNameParam, discountNameParam, 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).Discount, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DiscountServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if d.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := d.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BillingBenefits/discounts/(?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[armbillingbenefits.DiscountPatchRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + discountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("discountName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.BeginUpdate(req.Context(), resourceGroupNameParam, discountNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + d.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) { + d.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) { + d.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to DiscountServerTransport +var discountServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/discounts_server.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/discounts_server.go new file mode 100644 index 000000000000..6fed8a83aa42 --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/discounts_server.go @@ -0,0 +1,377 @@ +// 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/billingbenefits/armbillingbenefits/v3" + "net/http" + "net/url" + "regexp" +) + +// DiscountsServer is a fake server for instances of the armbillingbenefits.DiscountsClient type. +type DiscountsServer struct { + // BeginCancel is the fake for method DiscountsClient.BeginCancel + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginCancel func(ctx context.Context, resourceGroupName string, discountName string, options *armbillingbenefits.DiscountsClientBeginCancelOptions) (resp azfake.PollerResponder[armbillingbenefits.DiscountsClientCancelResponse], errResp azfake.ErrorResponder) + + // BeginCreate is the fake for method DiscountsClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, discountName string, body armbillingbenefits.Discount, options *armbillingbenefits.DiscountsClientBeginCreateOptions) (resp azfake.PollerResponder[armbillingbenefits.DiscountsClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method DiscountsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, discountName string, options *armbillingbenefits.DiscountsClientBeginDeleteOptions) (resp azfake.PollerResponder[armbillingbenefits.DiscountsClientDeleteResponse], errResp azfake.ErrorResponder) + + // NewResourceGroupListPager is the fake for method DiscountsClient.NewResourceGroupListPager + // HTTP status codes to indicate success: http.StatusOK + NewResourceGroupListPager func(resourceGroupName string, options *armbillingbenefits.DiscountsClientResourceGroupListOptions) (resp azfake.PagerResponder[armbillingbenefits.DiscountsClientResourceGroupListResponse]) + + // NewScopeListPager is the fake for method DiscountsClient.NewScopeListPager + // HTTP status codes to indicate success: http.StatusOK + NewScopeListPager func(scope string, options *armbillingbenefits.DiscountsClientScopeListOptions) (resp azfake.PagerResponder[armbillingbenefits.DiscountsClientScopeListResponse]) + + // NewSubscriptionListPager is the fake for method DiscountsClient.NewSubscriptionListPager + // HTTP status codes to indicate success: http.StatusOK + NewSubscriptionListPager func(options *armbillingbenefits.DiscountsClientSubscriptionListOptions) (resp azfake.PagerResponder[armbillingbenefits.DiscountsClientSubscriptionListResponse]) +} + +// NewDiscountsServerTransport creates a new instance of DiscountsServerTransport with the provided implementation. +// The returned DiscountsServerTransport instance is connected to an instance of armbillingbenefits.DiscountsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDiscountsServerTransport(srv *DiscountsServer) *DiscountsServerTransport { + return &DiscountsServerTransport{ + srv: srv, + beginCancel: newTracker[azfake.PollerResponder[armbillingbenefits.DiscountsClientCancelResponse]](), + beginCreate: newTracker[azfake.PollerResponder[armbillingbenefits.DiscountsClientCreateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armbillingbenefits.DiscountsClientDeleteResponse]](), + newResourceGroupListPager: newTracker[azfake.PagerResponder[armbillingbenefits.DiscountsClientResourceGroupListResponse]](), + newScopeListPager: newTracker[azfake.PagerResponder[armbillingbenefits.DiscountsClientScopeListResponse]](), + newSubscriptionListPager: newTracker[azfake.PagerResponder[armbillingbenefits.DiscountsClientSubscriptionListResponse]](), + } +} + +// DiscountsServerTransport connects instances of armbillingbenefits.DiscountsClient to instances of DiscountsServer. +// Don't use this type directly, use NewDiscountsServerTransport instead. +type DiscountsServerTransport struct { + srv *DiscountsServer + beginCancel *tracker[azfake.PollerResponder[armbillingbenefits.DiscountsClientCancelResponse]] + beginCreate *tracker[azfake.PollerResponder[armbillingbenefits.DiscountsClientCreateResponse]] + beginDelete *tracker[azfake.PollerResponder[armbillingbenefits.DiscountsClientDeleteResponse]] + newResourceGroupListPager *tracker[azfake.PagerResponder[armbillingbenefits.DiscountsClientResourceGroupListResponse]] + newScopeListPager *tracker[azfake.PagerResponder[armbillingbenefits.DiscountsClientScopeListResponse]] + newSubscriptionListPager *tracker[azfake.PagerResponder[armbillingbenefits.DiscountsClientSubscriptionListResponse]] +} + +// Do implements the policy.Transporter interface for DiscountsServerTransport. +func (d *DiscountsServerTransport) 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")} + } + + return d.dispatchToMethodFake(req, method) +} + +func (d *DiscountsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if discountsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = discountsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "DiscountsClient.BeginCancel": + res.resp, res.err = d.dispatchBeginCancel(req) + case "DiscountsClient.BeginCreate": + res.resp, res.err = d.dispatchBeginCreate(req) + case "DiscountsClient.BeginDelete": + res.resp, res.err = d.dispatchBeginDelete(req) + case "DiscountsClient.NewResourceGroupListPager": + res.resp, res.err = d.dispatchNewResourceGroupListPager(req) + case "DiscountsClient.NewScopeListPager": + res.resp, res.err = d.dispatchNewScopeListPager(req) + case "DiscountsClient.NewSubscriptionListPager": + res.resp, res.err = d.dispatchNewSubscriptionListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (d *DiscountsServerTransport) dispatchBeginCancel(req *http.Request) (*http.Response, error) { + if d.srv.BeginCancel == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCancel not implemented")} + } + beginCancel := d.beginCancel.get(req) + if beginCancel == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BillingBenefits/discounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/cancel` + 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) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + discountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("discountName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.BeginCancel(req.Context(), resourceGroupNameParam, discountNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCancel = &respr + d.beginCancel.add(req, beginCancel) + } + + resp, err := server.PollerResponderNext(beginCancel, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + d.beginCancel.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCancel) { + d.beginCancel.remove(req) + } + + return resp, nil +} + +func (d *DiscountsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if d.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := d.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BillingBenefits/discounts/(?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[armbillingbenefits.Discount](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + discountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("discountName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.BeginCreate(req.Context(), resourceGroupNameParam, discountNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + d.beginCreate.add(req, beginCreate) + } + + resp, err := server.PollerResponderNext(beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + d.beginCreate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreate) { + d.beginCreate.remove(req) + } + + return resp, nil +} + +func (d *DiscountsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if d.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := d.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BillingBenefits/discounts/(?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) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + discountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("discountName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.BeginDelete(req.Context(), resourceGroupNameParam, discountNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + d.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + d.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + d.beginDelete.remove(req) + } + + return resp, nil +} + +func (d *DiscountsServerTransport) dispatchNewResourceGroupListPager(req *http.Request) (*http.Response, error) { + if d.srv.NewResourceGroupListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewResourceGroupListPager not implemented")} + } + newResourceGroupListPager := d.newResourceGroupListPager.get(req) + if newResourceGroupListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BillingBenefits/discounts` + 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) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := d.srv.NewResourceGroupListPager(resourceGroupNameParam, nil) + newResourceGroupListPager = &resp + d.newResourceGroupListPager.add(req, newResourceGroupListPager) + server.PagerResponderInjectNextLinks(newResourceGroupListPager, req, func(page *armbillingbenefits.DiscountsClientResourceGroupListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newResourceGroupListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newResourceGroupListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newResourceGroupListPager) { + d.newResourceGroupListPager.remove(req) + } + return resp, nil +} + +func (d *DiscountsServerTransport) dispatchNewScopeListPager(req *http.Request) (*http.Response, error) { + if d.srv.NewScopeListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewScopeListPager not implemented")} + } + newScopeListPager := d.newScopeListPager.get(req) + if newScopeListPager == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BillingBenefits/applicableDiscounts` + 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) + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + resp := d.srv.NewScopeListPager(scopeParam, nil) + newScopeListPager = &resp + d.newScopeListPager.add(req, newScopeListPager) + server.PagerResponderInjectNextLinks(newScopeListPager, req, func(page *armbillingbenefits.DiscountsClientScopeListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newScopeListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newScopeListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newScopeListPager) { + d.newScopeListPager.remove(req) + } + return resp, nil +} + +func (d *DiscountsServerTransport) dispatchNewSubscriptionListPager(req *http.Request) (*http.Response, error) { + if d.srv.NewSubscriptionListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewSubscriptionListPager not implemented")} + } + newSubscriptionListPager := d.newSubscriptionListPager.get(req) + if newSubscriptionListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BillingBenefits/discounts` + 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) + } + resp := d.srv.NewSubscriptionListPager(nil) + newSubscriptionListPager = &resp + d.newSubscriptionListPager.add(req, newSubscriptionListPager) + server.PagerResponderInjectNextLinks(newSubscriptionListPager, req, func(page *armbillingbenefits.DiscountsClientSubscriptionListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newSubscriptionListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newSubscriptionListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newSubscriptionListPager) { + d.newSubscriptionListPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to DiscountsServerTransport +var discountsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/internal.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/internal.go index 7d2f89ba4bb2..c614f8d5643a 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/internal.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/internal.go @@ -1,6 +1,3 @@ -//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. @@ -15,6 +12,11 @@ import ( "sync" ) +type result struct { + resp *http.Response + err error +} + type nonRetriableError struct { error } diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/operations_server.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/operations_server.go index 8160f63a5bc4..7c3cd4e105c4 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/operations_server.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/operations_server.go @@ -1,6 +1,3 @@ -//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. @@ -15,7 +12,7 @@ import ( "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/billingbenefits/armbillingbenefits/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billingbenefits/armbillingbenefits/v3" "net/http" ) @@ -51,21 +48,40 @@ func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return o.dispatchToMethodFake(req, method) +} - switch method { - case "OperationsClient.NewListPager": - resp, err = o.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (o *OperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if operationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationsClient.NewListPager": + res.resp, res.err = o.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -94,3 +110,9 @@ func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*ht } return resp, nil } + +// set this to conditionally intercept incoming requests to OperationsServerTransport +var operationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/reservationorderalias_server.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/reservationorderalias_server.go index 25ceb09c5d33..e7ddc7c7488f 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/reservationorderalias_server.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/reservationorderalias_server.go @@ -1,6 +1,3 @@ -//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. @@ -15,7 +12,7 @@ import ( 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/billingbenefits/armbillingbenefits/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billingbenefits/armbillingbenefits/v3" "net/http" "net/url" "regexp" @@ -57,23 +54,42 @@ func (r *ReservationOrderAliasServerTransport) Do(req *http.Request) (*http.Resp return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return r.dispatchToMethodFake(req, method) +} - switch method { - case "ReservationOrderAliasClient.BeginCreate": - resp, err = r.dispatchBeginCreate(req) - case "ReservationOrderAliasClient.Get": - resp, err = r.dispatchGet(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (r *ReservationOrderAliasServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if reservationOrderAliasServerTransportInterceptor != nil { + res.resp, res.err, intercepted = reservationOrderAliasServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ReservationOrderAliasClient.BeginCreate": + res.resp, res.err = r.dispatchBeginCreate(req) + case "ReservationOrderAliasClient.Get": + res.resp, res.err = r.dispatchGet(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (r *ReservationOrderAliasServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { @@ -148,3 +164,9 @@ func (r *ReservationOrderAliasServerTransport) dispatchGet(req *http.Request) (* } return resp, nil } + +// set this to conditionally intercept incoming requests to ReservationOrderAliasServerTransport +var reservationOrderAliasServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/rp_server.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/rp_server.go index e5cad4633aa6..451c02f79fb7 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/rp_server.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/rp_server.go @@ -1,6 +1,3 @@ -//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. @@ -15,7 +12,7 @@ import ( 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/billingbenefits/armbillingbenefits/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billingbenefits/armbillingbenefits/v3" "net/http" ) @@ -47,21 +44,40 @@ func (r *RPServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return r.dispatchToMethodFake(req, method) +} - switch method { - case "RPClient.ValidatePurchase": - resp, err = r.dispatchValidatePurchase(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (r *RPServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if rpServerTransportInterceptor != nil { + res.resp, res.err, intercepted = rpServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "RPClient.ValidatePurchase": + res.resp, res.err = r.dispatchValidatePurchase(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (r *RPServerTransport) dispatchValidatePurchase(req *http.Request) (*http.Response, error) { @@ -86,3 +102,9 @@ func (r *RPServerTransport) dispatchValidatePurchase(req *http.Request) (*http.R } return resp, nil } + +// set this to conditionally intercept incoming requests to RPServerTransport +var rpServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/savingsplan_server.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/savingsplan_server.go index cc3054a919a3..fbf57381efdc 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/savingsplan_server.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/savingsplan_server.go @@ -1,6 +1,3 @@ -//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. @@ -16,7 +13,7 @@ import ( "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/billingbenefits/armbillingbenefits/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billingbenefits/armbillingbenefits/v3" "net/http" "net/url" "regexp" @@ -37,9 +34,9 @@ type SavingsPlanServer struct { // HTTP status codes to indicate success: http.StatusOK NewListAllPager func(options *armbillingbenefits.SavingsPlanClientListAllOptions) (resp azfake.PagerResponder[armbillingbenefits.SavingsPlanClientListAllResponse]) - // Update is the fake for method SavingsPlanClient.Update + // BeginUpdate is the fake for method SavingsPlanClient.BeginUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - Update func(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, body armbillingbenefits.SavingsPlanUpdateRequest, options *armbillingbenefits.SavingsPlanClientUpdateOptions) (resp azfake.Responder[armbillingbenefits.SavingsPlanClientUpdateResponse], errResp azfake.ErrorResponder) + BeginUpdate func(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, body armbillingbenefits.SavingsPlanUpdateRequest, options *armbillingbenefits.SavingsPlanClientBeginUpdateOptions) (resp azfake.PollerResponder[armbillingbenefits.SavingsPlanClientUpdateResponse], errResp azfake.ErrorResponder) // ValidateUpdate is the fake for method SavingsPlanClient.ValidateUpdate // HTTP status codes to indicate success: http.StatusOK @@ -54,6 +51,7 @@ func NewSavingsPlanServerTransport(srv *SavingsPlanServer) *SavingsPlanServerTra srv: srv, newListPager: newTracker[azfake.PagerResponder[armbillingbenefits.SavingsPlanClientListResponse]](), newListAllPager: newTracker[azfake.PagerResponder[armbillingbenefits.SavingsPlanClientListAllResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armbillingbenefits.SavingsPlanClientUpdateResponse]](), } } @@ -63,6 +61,7 @@ type SavingsPlanServerTransport struct { srv *SavingsPlanServer newListPager *tracker[azfake.PagerResponder[armbillingbenefits.SavingsPlanClientListResponse]] newListAllPager *tracker[azfake.PagerResponder[armbillingbenefits.SavingsPlanClientListAllResponse]] + beginUpdate *tracker[azfake.PollerResponder[armbillingbenefits.SavingsPlanClientUpdateResponse]] } // Do implements the policy.Transporter interface for SavingsPlanServerTransport. @@ -73,29 +72,48 @@ func (s *SavingsPlanServerTransport) Do(req *http.Request) (*http.Response, erro return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return s.dispatchToMethodFake(req, method) +} - switch method { - case "SavingsPlanClient.Get": - resp, err = s.dispatchGet(req) - case "SavingsPlanClient.NewListPager": - resp, err = s.dispatchNewListPager(req) - case "SavingsPlanClient.NewListAllPager": - resp, err = s.dispatchNewListAllPager(req) - case "SavingsPlanClient.Update": - resp, err = s.dispatchUpdate(req) - case "SavingsPlanClient.ValidateUpdate": - resp, err = s.dispatchValidateUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (s *SavingsPlanServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if savingsPlanServerTransportInterceptor != nil { + res.resp, res.err, intercepted = savingsPlanServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "SavingsPlanClient.Get": + res.resp, res.err = s.dispatchGet(req) + case "SavingsPlanClient.NewListPager": + res.resp, res.err = s.dispatchNewListPager(req) + case "SavingsPlanClient.NewListAllPager": + res.resp, res.err = s.dispatchNewListAllPager(req) + case "SavingsPlanClient.BeginUpdate": + res.resp, res.err = s.dispatchBeginUpdate(req) + case "SavingsPlanClient.ValidateUpdate": + res.resp, res.err = s.dispatchValidateUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (s *SavingsPlanServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { @@ -267,43 +285,51 @@ func (s *SavingsPlanServerTransport) dispatchNewListAllPager(req *http.Request) return resp, nil } -func (s *SavingsPlanServerTransport) 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 *SavingsPlanServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if s.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} } - const regexStr = `/providers/Microsoft\.BillingBenefits/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) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armbillingbenefits.SavingsPlanUpdateRequest](req) - if err != nil { - return nil, err - } - savingsPlanOrderIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("savingsPlanOrderId")]) - if err != nil { - return nil, err + beginUpdate := s.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/providers/Microsoft\.BillingBenefits/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) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbillingbenefits.SavingsPlanUpdateRequest](req) + 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.BeginUpdate(req.Context(), savingsPlanOrderIDParam, savingsPlanIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + s.beginUpdate.add(req, beginUpdate) } - savingsPlanIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("savingsPlanId")]) + + resp, err := server.PollerResponderNext(beginUpdate, req) if err != nil { return nil, err } - respr, errRespr := s.srv.Update(req.Context(), savingsPlanOrderIDParam, savingsPlanIDParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - 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)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SavingsPlanModel, 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 val := server.GetResponse(respr).Location; val != nil { - resp.Header.Set("Location", *val) + if !server.PollerResponderMore(beginUpdate) { + s.beginUpdate.remove(req) } + return resp, nil } @@ -343,3 +369,9 @@ func (s *SavingsPlanServerTransport) dispatchValidateUpdate(req *http.Request) ( } return resp, nil } + +// set this to conditionally intercept incoming requests to SavingsPlanServerTransport +var savingsPlanServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/savingsplanorder_server.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/savingsplanorder_server.go index 2498a1038021..08a2e3e1b7e1 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/savingsplanorder_server.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/savingsplanorder_server.go @@ -1,6 +1,3 @@ -//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. @@ -16,7 +13,7 @@ import ( "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/billingbenefits/armbillingbenefits/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billingbenefits/armbillingbenefits/v3" "net/http" "net/url" "regexp" @@ -62,25 +59,44 @@ func (s *SavingsPlanOrderServerTransport) Do(req *http.Request) (*http.Response, return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return s.dispatchToMethodFake(req, method) +} - switch method { - case "SavingsPlanOrderClient.Elevate": - resp, err = s.dispatchElevate(req) - case "SavingsPlanOrderClient.Get": - resp, err = s.dispatchGet(req) - case "SavingsPlanOrderClient.NewListPager": - resp, err = s.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (s *SavingsPlanOrderServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if savingsPlanOrderServerTransportInterceptor != nil { + res.resp, res.err, intercepted = savingsPlanOrderServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "SavingsPlanOrderClient.Elevate": + res.resp, res.err = s.dispatchElevate(req) + case "SavingsPlanOrderClient.Get": + res.resp, res.err = s.dispatchGet(req) + case "SavingsPlanOrderClient.NewListPager": + res.resp, res.err = s.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (s *SavingsPlanOrderServerTransport) dispatchElevate(req *http.Request) (*http.Response, error) { @@ -179,3 +195,9 @@ func (s *SavingsPlanOrderServerTransport) dispatchNewListPager(req *http.Request } return resp, nil } + +// set this to conditionally intercept incoming requests to SavingsPlanOrderServerTransport +var savingsPlanOrderServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/savingsplanorderalias_server.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/savingsplanorderalias_server.go index cb2fb24822b7..2e2e801d7077 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/savingsplanorderalias_server.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/savingsplanorderalias_server.go @@ -1,6 +1,3 @@ -//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. @@ -15,7 +12,7 @@ import ( 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/billingbenefits/armbillingbenefits/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billingbenefits/armbillingbenefits/v3" "net/http" "net/url" "regexp" @@ -57,23 +54,42 @@ func (s *SavingsPlanOrderAliasServerTransport) Do(req *http.Request) (*http.Resp return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return s.dispatchToMethodFake(req, method) +} - switch method { - case "SavingsPlanOrderAliasClient.BeginCreate": - resp, err = s.dispatchBeginCreate(req) - case "SavingsPlanOrderAliasClient.Get": - resp, err = s.dispatchGet(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (s *SavingsPlanOrderAliasServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if savingsPlanOrderAliasServerTransportInterceptor != nil { + res.resp, res.err, intercepted = savingsPlanOrderAliasServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "SavingsPlanOrderAliasClient.BeginCreate": + res.resp, res.err = s.dispatchBeginCreate(req) + case "SavingsPlanOrderAliasClient.Get": + res.resp, res.err = s.dispatchGet(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (s *SavingsPlanOrderAliasServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { @@ -148,3 +164,9 @@ func (s *SavingsPlanOrderAliasServerTransport) dispatchGet(req *http.Request) (* } return resp, nil } + +// set this to conditionally intercept incoming requests to SavingsPlanOrderAliasServerTransport +var savingsPlanOrderAliasServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/server_factory.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/server_factory.go index 99915d6d87ea..8f846dae12d6 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/server_factory.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/server_factory.go @@ -1,6 +1,3 @@ -//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. @@ -19,12 +16,29 @@ import ( // ServerFactory is a fake server for instances of the armbillingbenefits.ClientFactory type. type ServerFactory struct { - OperationsServer OperationsServer - RPServer RPServer + // DiscountServer contains the fakes for client DiscountClient + DiscountServer DiscountServer + + // DiscountsServer contains the fakes for client DiscountsClient + DiscountsServer DiscountsServer + + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer + + // RPServer contains the fakes for client RPClient + RPServer RPServer + + // ReservationOrderAliasServer contains the fakes for client ReservationOrderAliasClient ReservationOrderAliasServer ReservationOrderAliasServer - SavingsPlanServer SavingsPlanServer + + // SavingsPlanServer contains the fakes for client SavingsPlanClient + SavingsPlanServer SavingsPlanServer + + // SavingsPlanOrderAliasServer contains the fakes for client SavingsPlanOrderAliasClient SavingsPlanOrderAliasServer SavingsPlanOrderAliasServer - SavingsPlanOrderServer SavingsPlanOrderServer + + // SavingsPlanOrderServer contains the fakes for client SavingsPlanOrderClient + SavingsPlanOrderServer SavingsPlanOrderServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -41,6 +55,8 @@ func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { type ServerFactoryTransport struct { srv *ServerFactory trMu sync.Mutex + trDiscountServer *DiscountServerTransport + trDiscountsServer *DiscountsServerTransport trOperationsServer *OperationsServerTransport trRPServer *RPServerTransport trReservationOrderAliasServer *ReservationOrderAliasServerTransport @@ -62,6 +78,12 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { var err error switch client { + case "DiscountClient": + initServer(s, &s.trDiscountServer, func() *DiscountServerTransport { return NewDiscountServerTransport(&s.srv.DiscountServer) }) + resp, err = s.trDiscountServer.Do(req) + case "DiscountsClient": + initServer(s, &s.trDiscountsServer, func() *DiscountsServerTransport { return NewDiscountsServerTransport(&s.srv.DiscountsServer) }) + resp, err = s.trDiscountsServer.Do(req) case "OperationsClient": initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) resp, err = s.trOperationsServer.Do(req) diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/time_rfc3339.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/time_rfc3339.go index b0535a7b63e6..7691a451714b 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/time_rfc3339.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/fake/time_rfc3339.go @@ -1,6 +1,3 @@ -//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. @@ -19,12 +16,16 @@ import ( ) // 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 +41,36 @@ 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) { + if len(data) == 0 { + return nil + } + 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 +81,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 +98,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/billingbenefits/armbillingbenefits/go.mod b/sdk/resourcemanager/billingbenefits/armbillingbenefits/go.mod index 813cdabaa521..ce04924b419c 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/go.mod +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/go.mod @@ -1,21 +1,11 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billingbenefits/armbillingbenefits/v2 +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billingbenefits/armbillingbenefits/v3 go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.0 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.4.0 // indirect - github.com/golang-jwt/jwt/v5 v5.2.1 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - golang.org/x/crypto v0.33.0 // indirect golang.org/x/net v0.35.0 // indirect - golang.org/x/sys v0.30.0 // indirect golang.org/x/text v0.22.0 // indirect ) diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/go.sum b/sdk/resourcemanager/billingbenefits/armbillingbenefits/go.sum index 6324123af695..da9d756575fb 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/go.sum +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/go.sum @@ -1,35 +1,12 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.0 h1:g0EZJwz7xkXQiZAI5xi9f3WWFYBlX1CPTrR+NDToRkQ= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.0/go.mod h1:XCW7KnZet0Opnr7HccfUw1PLc4CjHqpcaxW8DHklNkQ= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 h1:F0gBpfdPLGsw+nsgk6aqqkZS1jiixa5WwFe3fk/T3Ys= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2/go.mod h1:SqINnQ9lVVdRlyC8cd1lCI0SdX4n2paeABd2K8ggfnE= -github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2 h1:yz1bePFlP5Vws5+8ez6T3HWXPmwOK7Yvq8QxDBD3SKY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= -github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= -github.com/AzureAD/microsoft-authentication-library-for-go v1.4.0 h1:MUkXAnvvDHgvPItl0nBj0hgk0f7hnnQbGm0h0+YxbN4= -github.com/AzureAD/microsoft-authentication-library-for-go v1.4.0/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= -github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= -github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6 h1:IsMZxCuZqKuao2vNdfD82fjjgPLfyHLpR41Z88viRWs= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= -golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8= golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= -golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/interfaces.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/interfaces.go new file mode 100644 index 000000000000..53f5498b58c6 --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/interfaces.go @@ -0,0 +1,35 @@ +// 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 armbillingbenefits + +// DiscountPropertiesClassification provides polymorphic access to related types. +// Call the interface's GetDiscountProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *DiscountProperties, *EntityTypeAffiliateDiscount, *EntityTypePrimaryDiscount +type DiscountPropertiesClassification interface { + // GetDiscountProperties returns the DiscountProperties content of the underlying type. + GetDiscountProperties() *DiscountProperties +} + +// DiscountTypeCustomPriceClassification provides polymorphic access to related types. +// Call the interface's GetDiscountTypeCustomPrice() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *DiscountTypeCustomPrice, *DiscountTypeCustomPriceMultiCurrency +type DiscountTypeCustomPriceClassification interface { + DiscountTypePropertiesClassification + // GetDiscountTypeCustomPrice returns the DiscountTypeCustomPrice content of the underlying type. + GetDiscountTypeCustomPrice() *DiscountTypeCustomPrice +} + +// DiscountTypePropertiesClassification provides polymorphic access to related types. +// Call the interface's GetDiscountTypeProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *DiscountTypeCustomPrice, *DiscountTypeCustomPriceMultiCurrency, *DiscountTypeProduct, *DiscountTypeProductFamily, *DiscountTypeProductSKU, +// - *DiscountTypeProperties +type DiscountTypePropertiesClassification interface { + // GetDiscountTypeProperties returns the DiscountTypeProperties content of the underlying type. + GetDiscountTypeProperties() *DiscountTypeProperties +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/models.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/models.go index ca40e66711c3..5de55b63d055 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/models.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/models.go @@ -1,6 +1,3 @@ -//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. @@ -41,6 +38,12 @@ type BillingPlanInformation struct { Transactions []*PaymentDetail } +// CatalogClaimsItem - Catalog claim for a discount. +type CatalogClaimsItem struct { + CatalogClaimsItemType *string + Value *string +} + // Commitment towards the benefit. type Commitment struct { Amount *float64 @@ -52,6 +55,555 @@ type Commitment struct { Grain *CommitmentGrain } +// ConditionsItem - Condition for a discount. +type ConditionsItem struct { + ConditionName *string + Type *string + + // These items are open-ended strings. + Value []*string +} + +// CustomPriceProperties - Custom price properties for a given discount. +type CustomPriceProperties struct { + // REQUIRED; The set of BigCat claims. Validation: Required. Must contain AgreementType, NationalCloud, and PricingAudience + // claims. Additionally requires AccessPass claim when creating custom price with action == + // consume on the pricing instructions. + CatalogClaims []*CatalogClaimsItem + + // REQUIRED; The catalog instance where the priceable node lives. Validation: Required. No defined format, will vary per team. + CatalogID *string + + // REQUIRED; The set of market set prices of the priceable node. Validation: Required. Must contain at least one element. + MarketSetPrices []*MarketSetPricesItems + + // REQUIRED; The type of the priceable node pricing rule. Validation: Required. Supported values are fixedPriceLock, fixedListPrice, + // and priceCeiling. + RuleType *DiscountRuleType + + // The billing period of the priceable node. Validation: Optional, Maximum length 128 characters. Only allowed if the availability + // derived by market, product, sku, and claims has terms and at least one + // of those terms has a billing period. When specified, termUnits must be specified. + BillingPeriod *string + + // Must be present if the market, product, sku, and claims, and optional term information resolves to multiple availabilities + // that only differ by meter type. Validation: Maximum length 128 characters. + MeterType *string + + // The term units for the priceable node. Validation: Optional, Maximum length 128 characters. Must be present if and only + // if the availability derived by market, product, sku, and claims has terms. + TermUnits *string +} + +// Discount - Resource definition for Discounts. +type Discount struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // Managed service identity (system assigned and/or user assigned identities) + Identity *ManagedServiceIdentity + + // Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type. E.g. ApiApps are + // a kind of Microsoft.Web/sites type. If supported, the resource provider must + // validate and persist this value. + Kind *string + + // The fully qualified resource ID of the resource that manages this resource. Indicates if this resource is managed by another + // Azure resource. If this is present, complete mode deployment will not + // delete the resource if it is removed from the template since it is managed by another resource. + ManagedBy *string + + // Plan for the resource. + Plan *Plan + + // Discount properties + Properties DiscountPropertiesClassification + + // The resource model definition representing SKU + SKU *SKU + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; The etag field is not required. If it is provided in the response body, it must also be provided as a header + // per the normal etag convention. Entity tags are used for comparing two or more entities + // from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match + // (section 14.26), and If-Range (section 14.27) header fields. + Etag *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 +} + +// DiscountList - Discount list +type DiscountList struct { + // Url to get the next page. + NextLink *string + + // List of discounts. + Value []*Discount +} + +// DiscountPatchRequest - Discounts patch request +type DiscountPatchRequest struct { + // Discounts patch request properties + Properties *DiscountPatchRequestProperties + + // Resource tags. + Tags map[string]*string +} + +// DiscountPatchRequestProperties - Discounts patch request properties +type DiscountPatchRequestProperties struct { + // Display name + DisplayName *string +} + +// DiscountProperties - Properties belonging to discounts. +type DiscountProperties struct { + // REQUIRED; This defines whether the entity being created is primary or affiliate. Supported values: primary, affiliate. + // Validation: Required, must match one of the 2 values. + EntityType *DiscountEntityType + + // REQUIRED; This is the catalog UPN for the product. + ProductCode *string + + // REQUIRED; Start date of the discount. Value is the date the discount started or will start in the future. + StartAt *time.Time + + // List of applied scopes supported for discounts. + AppliedScopeType *DiscountAppliedScopeType + + // This defines a user friendly display name for the discount. + DisplayName *string + + // This is the globally unique identifier of the Discount which will not change for the lifetime of the Discount. + SystemID *string + + // READ-ONLY; Fully-qualified identifier of the benefit under applicable benefit list. + BenefitResourceID *string + + // READ-ONLY; Billing account resource id where the discount metadata is present. + BillingAccountResourceID *string + + // READ-ONLY; Billing profile resource id where the discount is scoped to. + BillingProfileResourceID *string + + // READ-ONLY; Customer resource id where the discount is scoped to. + CustomerResourceID *string + + // READ-ONLY; The state of the resource. Supported values are Pending, Failed, Succeeded, Canceled. + ProvisioningState *DiscountProvisioningState + + // READ-ONLY; Represents the current status of the discount. + Status *DiscountStatus +} + +// GetDiscountProperties implements the DiscountPropertiesClassification interface for type DiscountProperties. +func (d *DiscountProperties) GetDiscountProperties() *DiscountProperties { return d } + +// DiscountTypeCustomPrice - Discount type properties including product family name, product id, sku, and custom price properties. +// Allows a single entry in marketSetPrices. +type DiscountTypeCustomPrice struct { + // REQUIRED; The customer action on which the discount is applied. Supported values are Purchase, Consume, and Renew. Validation: + // Required, one of supported values. + ApplyDiscountOn *ApplyDiscountOn + + // REQUIRED; Defines the type of discount. Supported values are ProductFamily, Product, Sku, CustomPrice, and CustomPriceMultiCurrency. + DiscountType *DiscountType + + // Array of conditions for the discount. Validation: Optional. Maximum length is 1000. + Conditions []*ConditionsItem + + // Custom price properties for a given discount. + CustomPriceProperties *CustomPriceProperties + + // The discount combination rule when there are multiple applicable custom prices. Validation: Required. Supported values + // are Stackable and BestOf. + DiscountCombinationRule *DiscountCombinationRule + + // Discount percentage provided for the customer. Validation: Required unless this is a price rule. + DiscountPercentage *float32 + + // Set only in price guarantee scenario. + PriceGuaranteeProperties *PriceGuaranteeProperties + + // Product family for which the discount is given. Validation: Optional + ProductFamilyName *string + + // Product ID for which the discount is given. Validation: Optional. No specific format, example: DZH318Z09V6F + ProductID *string + + // ResourceSku for the given discount. Validation: Optional. + SKUID *string +} + +// GetDiscountTypeCustomPrice implements the DiscountTypeCustomPriceClassification interface for type DiscountTypeCustomPrice. +func (d *DiscountTypeCustomPrice) GetDiscountTypeCustomPrice() *DiscountTypeCustomPrice { return d } + +// GetDiscountTypeProperties implements the DiscountTypePropertiesClassification interface for type DiscountTypeCustomPrice. +func (d *DiscountTypeCustomPrice) GetDiscountTypeProperties() *DiscountTypeProperties { + return &DiscountTypeProperties{ + ApplyDiscountOn: d.ApplyDiscountOn, + Conditions: d.Conditions, + DiscountCombinationRule: d.DiscountCombinationRule, + DiscountPercentage: d.DiscountPercentage, + DiscountType: d.DiscountType, + PriceGuaranteeProperties: d.PriceGuaranteeProperties, + } +} + +// DiscountTypeCustomPriceMultiCurrency - Discount type properties including product family name, product id, sku, and custom +// price properties. Allows multiple entries in marketSetPrices. +type DiscountTypeCustomPriceMultiCurrency struct { + // REQUIRED; The customer action on which the discount is applied. Supported values are Purchase, Consume, and Renew. Validation: + // Required, one of supported values. + ApplyDiscountOn *ApplyDiscountOn + + // REQUIRED; Defines the type of discount. Supported values are ProductFamily, Product, Sku, CustomPrice, and CustomPriceMultiCurrency. + DiscountType *DiscountType + + // Array of conditions for the discount. Validation: Optional. Maximum length is 1000. + Conditions []*ConditionsItem + + // Custom price properties for a given discount. + CustomPriceProperties *CustomPriceProperties + + // The discount combination rule when there are multiple applicable custom prices. Validation: Required. Supported values + // are Stackable and BestOf. + DiscountCombinationRule *DiscountCombinationRule + + // Discount percentage provided for the customer. Validation: Required unless this is a price rule. + DiscountPercentage *float32 + + // Set only in price guarantee scenario. + PriceGuaranteeProperties *PriceGuaranteeProperties + + // Product family for which the discount is given. Validation: Optional + ProductFamilyName *string + + // Product ID for which the discount is given. Validation: Optional. No specific format, example: DZH318Z09V6F + ProductID *string + + // ResourceSku for the given discount. Validation: Optional. + SKUID *string +} + +// GetDiscountTypeCustomPrice implements the DiscountTypeCustomPriceClassification interface for type DiscountTypeCustomPriceMultiCurrency. +func (d *DiscountTypeCustomPriceMultiCurrency) GetDiscountTypeCustomPrice() *DiscountTypeCustomPrice { + return &DiscountTypeCustomPrice{ + ApplyDiscountOn: d.ApplyDiscountOn, + Conditions: d.Conditions, + CustomPriceProperties: d.CustomPriceProperties, + DiscountCombinationRule: d.DiscountCombinationRule, + DiscountPercentage: d.DiscountPercentage, + DiscountType: d.DiscountType, + PriceGuaranteeProperties: d.PriceGuaranteeProperties, + ProductFamilyName: d.ProductFamilyName, + ProductID: d.ProductID, + SKUID: d.SKUID, + } +} + +// GetDiscountTypeProperties implements the DiscountTypePropertiesClassification interface for type DiscountTypeCustomPriceMultiCurrency. +func (d *DiscountTypeCustomPriceMultiCurrency) GetDiscountTypeProperties() *DiscountTypeProperties { + return &DiscountTypeProperties{ + ApplyDiscountOn: d.ApplyDiscountOn, + Conditions: d.Conditions, + DiscountCombinationRule: d.DiscountCombinationRule, + DiscountPercentage: d.DiscountPercentage, + DiscountType: d.DiscountType, + PriceGuaranteeProperties: d.PriceGuaranteeProperties, + } +} + +// DiscountTypeProduct - Discount type properties including product family name and product id. +type DiscountTypeProduct struct { + // REQUIRED; The customer action on which the discount is applied. Supported values are Purchase, Consume, and Renew. Validation: + // Required, one of supported values. + ApplyDiscountOn *ApplyDiscountOn + + // REQUIRED; Defines the type of discount. Supported values are ProductFamily, Product, Sku, CustomPrice, and CustomPriceMultiCurrency. + DiscountType *DiscountType + + // Array of conditions for the discount. Validation: Optional. Maximum length is 1000. + Conditions []*ConditionsItem + + // The discount combination rule when there are multiple applicable custom prices. Validation: Required. Supported values + // are Stackable and BestOf. + DiscountCombinationRule *DiscountCombinationRule + + // Discount percentage provided for the customer. Validation: Required unless this is a price rule. + DiscountPercentage *float32 + + // Set only in price guarantee scenario. + PriceGuaranteeProperties *PriceGuaranteeProperties + + // Product family for which the discount is given. Validation: Optional + ProductFamilyName *string + + // Product ID for which the discount is given. Validation: Optional. No specific format, example: DZH318Z09V6F + ProductID *string +} + +// GetDiscountTypeProperties implements the DiscountTypePropertiesClassification interface for type DiscountTypeProduct. +func (d *DiscountTypeProduct) GetDiscountTypeProperties() *DiscountTypeProperties { + return &DiscountTypeProperties{ + ApplyDiscountOn: d.ApplyDiscountOn, + Conditions: d.Conditions, + DiscountCombinationRule: d.DiscountCombinationRule, + DiscountPercentage: d.DiscountPercentage, + DiscountType: d.DiscountType, + PriceGuaranteeProperties: d.PriceGuaranteeProperties, + } +} + +// DiscountTypeProductFamily - Discount type properties including product family name +type DiscountTypeProductFamily struct { + // REQUIRED; The customer action on which the discount is applied. Supported values are Purchase, Consume, and Renew. Validation: + // Required, one of supported values. + ApplyDiscountOn *ApplyDiscountOn + + // REQUIRED; Defines the type of discount. Supported values are ProductFamily, Product, Sku, CustomPrice, and CustomPriceMultiCurrency. + DiscountType *DiscountType + + // Array of conditions for the discount. Validation: Optional. Maximum length is 1000. + Conditions []*ConditionsItem + + // The discount combination rule when there are multiple applicable custom prices. Validation: Required. Supported values + // are Stackable and BestOf. + DiscountCombinationRule *DiscountCombinationRule + + // Discount percentage provided for the customer. Validation: Required unless this is a price rule. + DiscountPercentage *float32 + + // Set only in price guarantee scenario. + PriceGuaranteeProperties *PriceGuaranteeProperties + + // Product family for which the discount is given. Validation: Optional + ProductFamilyName *string +} + +// GetDiscountTypeProperties implements the DiscountTypePropertiesClassification interface for type DiscountTypeProductFamily. +func (d *DiscountTypeProductFamily) GetDiscountTypeProperties() *DiscountTypeProperties { + return &DiscountTypeProperties{ + ApplyDiscountOn: d.ApplyDiscountOn, + Conditions: d.Conditions, + DiscountCombinationRule: d.DiscountCombinationRule, + DiscountPercentage: d.DiscountPercentage, + DiscountType: d.DiscountType, + PriceGuaranteeProperties: d.PriceGuaranteeProperties, + } +} + +// DiscountTypeProductSKU - Discount type properties including product family name, product id, and sku id. +type DiscountTypeProductSKU struct { + // REQUIRED; The customer action on which the discount is applied. Supported values are Purchase, Consume, and Renew. Validation: + // Required, one of supported values. + ApplyDiscountOn *ApplyDiscountOn + + // REQUIRED; Defines the type of discount. Supported values are ProductFamily, Product, Sku, CustomPrice, and CustomPriceMultiCurrency. + DiscountType *DiscountType + + // Array of conditions for the discount. Validation: Optional. Maximum length is 1000. + Conditions []*ConditionsItem + + // The discount combination rule when there are multiple applicable custom prices. Validation: Required. Supported values + // are Stackable and BestOf. + DiscountCombinationRule *DiscountCombinationRule + + // Discount percentage provided for the customer. Validation: Required unless this is a price rule. + DiscountPercentage *float32 + + // Set only in price guarantee scenario. + PriceGuaranteeProperties *PriceGuaranteeProperties + + // Product family for which the discount is given. Validation: Optional + ProductFamilyName *string + + // Product ID for which the discount is given. Validation: Optional. No specific format, example: DZH318Z09V6F + ProductID *string + + // ResourceSku for the given discount. Validation: Optional. + SKUID *string +} + +// GetDiscountTypeProperties implements the DiscountTypePropertiesClassification interface for type DiscountTypeProductSKU. +func (d *DiscountTypeProductSKU) GetDiscountTypeProperties() *DiscountTypeProperties { + return &DiscountTypeProperties{ + ApplyDiscountOn: d.ApplyDiscountOn, + Conditions: d.Conditions, + DiscountCombinationRule: d.DiscountCombinationRule, + DiscountPercentage: d.DiscountPercentage, + DiscountType: d.DiscountType, + PriceGuaranteeProperties: d.PriceGuaranteeProperties, + } +} + +// DiscountTypeProperties - This defines the conditions for a given discount type. +type DiscountTypeProperties struct { + // REQUIRED; The customer action on which the discount is applied. Supported values are Purchase, Consume, and Renew. Validation: + // Required, one of supported values. + ApplyDiscountOn *ApplyDiscountOn + + // REQUIRED; Defines the type of discount. Supported values are ProductFamily, Product, Sku, CustomPrice, and CustomPriceMultiCurrency. + DiscountType *DiscountType + + // Array of conditions for the discount. Validation: Optional. Maximum length is 1000. + Conditions []*ConditionsItem + + // The discount combination rule when there are multiple applicable custom prices. Validation: Required. Supported values + // are Stackable and BestOf. + DiscountCombinationRule *DiscountCombinationRule + + // Discount percentage provided for the customer. Validation: Required unless this is a price rule. + DiscountPercentage *float32 + + // Set only in price guarantee scenario. + PriceGuaranteeProperties *PriceGuaranteeProperties +} + +// GetDiscountTypeProperties implements the DiscountTypePropertiesClassification interface for type DiscountTypeProperties. +func (d *DiscountTypeProperties) GetDiscountTypeProperties() *DiscountTypeProperties { return d } + +// EntityTypeAffiliateDiscount - Entity type for affiliate discounts +type EntityTypeAffiliateDiscount struct { + // REQUIRED; This defines whether the entity being created is primary or affiliate. Supported values: primary, affiliate. + // Validation: Required, must match one of the 2 values. + EntityType *DiscountEntityType + + // REQUIRED; This is the catalog UPN for the product. + ProductCode *string + + // REQUIRED; Start date of the discount. Value is the date the discount started or will start in the future. + StartAt *time.Time + + // List of applied scopes supported for discounts. + AppliedScopeType *DiscountAppliedScopeType + + // This defines a user friendly display name for the discount. + DisplayName *string + + // This is the globally unique identifier of the Discount which will not change for the lifetime of the Discount. + SystemID *string + + // READ-ONLY; Fully-qualified identifier of the benefit under applicable benefit list. + BenefitResourceID *string + + // READ-ONLY; Billing account resource id where the discount metadata is present. + BillingAccountResourceID *string + + // READ-ONLY; Billing profile resource id where the discount is scoped to. + BillingProfileResourceID *string + + // READ-ONLY; Customer resource id where the discount is scoped to. + CustomerResourceID *string + + // READ-ONLY; End date of the discount. No duration will be supported. Allowed value is any date greater than or equal to + // startDate. + EndAt *time.Time + + // READ-ONLY; This will be present in the response if the primary has a resource ID + PrimaryResourceID *string + + // READ-ONLY; The state of the resource. Supported values are Pending, Failed, Succeeded, Canceled. + ProvisioningState *DiscountProvisioningState + + // READ-ONLY; Represents the current status of the discount. + Status *DiscountStatus +} + +// GetDiscountProperties implements the DiscountPropertiesClassification interface for type EntityTypeAffiliateDiscount. +func (e *EntityTypeAffiliateDiscount) GetDiscountProperties() *DiscountProperties { + return &DiscountProperties{ + AppliedScopeType: e.AppliedScopeType, + BenefitResourceID: e.BenefitResourceID, + BillingAccountResourceID: e.BillingAccountResourceID, + BillingProfileResourceID: e.BillingProfileResourceID, + CustomerResourceID: e.CustomerResourceID, + DisplayName: e.DisplayName, + EntityType: e.EntityType, + ProductCode: e.ProductCode, + ProvisioningState: e.ProvisioningState, + StartAt: e.StartAt, + Status: e.Status, + SystemID: e.SystemID, + } +} + +// EntityTypePrimaryDiscount - Entity type for primary discounts +type EntityTypePrimaryDiscount struct { + // REQUIRED; End date of the discount. No duration will be supported. Allowed value is any date greater than or equal to startDate. + EndAt *time.Time + + // REQUIRED; This defines whether the entity being created is primary or affiliate. Supported values: primary, affiliate. + // Validation: Required, must match one of the 2 values. + EntityType *DiscountEntityType + + // REQUIRED; This is the catalog UPN for the product. + ProductCode *string + + // REQUIRED; Start date of the discount. Value is the date the discount started or will start in the future. + StartAt *time.Time + + // List of applied scopes supported for discounts. + AppliedScopeType *DiscountAppliedScopeType + + // This defines the conditions for a given discount type. + DiscountTypeProperties DiscountTypePropertiesClassification + + // This defines a user friendly display name for the discount. + DisplayName *string + + // This is the globally unique identifier of the Discount which will not change for the lifetime of the Discount. + SystemID *string + + // READ-ONLY; Fully-qualified identifier of the benefit under applicable benefit list. + BenefitResourceID *string + + // READ-ONLY; Billing account resource id where the discount metadata is present. + BillingAccountResourceID *string + + // READ-ONLY; Billing profile resource id where the discount is scoped to. + BillingProfileResourceID *string + + // READ-ONLY; Customer resource id where the discount is scoped to. + CustomerResourceID *string + + // READ-ONLY; The state of the resource. Supported values are Pending, Failed, Succeeded, Canceled. + ProvisioningState *DiscountProvisioningState + + // READ-ONLY; Represents the current status of the discount. + Status *DiscountStatus +} + +// GetDiscountProperties implements the DiscountPropertiesClassification interface for type EntityTypePrimaryDiscount. +func (e *EntityTypePrimaryDiscount) GetDiscountProperties() *DiscountProperties { + return &DiscountProperties{ + AppliedScopeType: e.AppliedScopeType, + BenefitResourceID: e.BenefitResourceID, + BillingAccountResourceID: e.BillingAccountResourceID, + BillingProfileResourceID: e.BillingProfileResourceID, + CustomerResourceID: e.CustomerResourceID, + DisplayName: e.DisplayName, + EntityType: e.EntityType, + ProductCode: e.ProductCode, + ProvisioningState: e.ProvisioningState, + StartAt: e.StartAt, + Status: e.Status, + SystemID: e.SystemID, + } +} + type ExtendedStatusInfo struct { // The message giving detailed information about the status code. Message *string @@ -60,6 +612,39 @@ type ExtendedStatusInfo struct { StatusCode *string } +// ManagedServiceIdentity - Managed service identity (system assigned and/or user assigned identities) +type ManagedServiceIdentity struct { + // REQUIRED; Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + Type *ManagedServiceIdentityType + + // The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM + // resource ids in the form: + // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + // The dictionary values can be empty objects ({}) in + // requests. + UserAssignedIdentities map[string]*UserAssignedIdentity + + // READ-ONLY; The service principal ID of the system assigned identity. This property will only be provided for a system assigned + // identity. + PrincipalID *string + + // READ-ONLY; The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. + TenantID *string +} + +// MarketSetPricesItems - Items in the MarketSetPrices array. +type MarketSetPricesItems struct { + // REQUIRED; The currency of the locked price value. Validation: Required. Must be a valid ISO 4217 3-letter currency code. + Currency *string + + // REQUIRED + Markets []*string + + // REQUIRED; The locked price for the priceable node. Validation: Required. Must be greater than or equal to 0. If the case + // of billing plans. This represents the price for each cycle charge. + Value *float32 +} + // Operation - Details of a REST API operation, returned from the Resource Provider Operations API type Operation struct { // Localized display information for this particular operation. @@ -133,6 +718,25 @@ type PaymentDetail struct { ExtendedStatusInfo *ExtendedStatusInfo } +// Plan for the resource. +type Plan struct { + // REQUIRED; A user defined name of the 3rd Party Artifact that is being procured. + Name *string + + // REQUIRED; The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the artifact + // at the time of Data Market onboarding. + Product *string + + // REQUIRED; The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic + Publisher *string + + // A publisher provided promotion code as provisioned in Data Market for the said product/artifact. + PromotionCode *string + + // The version of the desired product/artifact. + Version *string +} + type Price struct { Amount *float64 @@ -140,11 +744,21 @@ type Price struct { CurrencyCode *string } +// PriceGuaranteeProperties - Set only in price guarantee scenario. +type PriceGuaranteeProperties struct { + // The date on which prices are to be used for guarantee calculation. Validation: expected to be 00 hours, Format: 2024-09-30T00:00:00Z. + // Must be in UTC. + PriceGuaranteeDate *time.Time + + // Supported values: Protected, Locked + PricingPolicy *PricingPolicy +} + type PurchaseRequest struct { Properties *PurchaseRequestProperties // The SKU to be applied for this resource - SKU *SKU + SKU *ResourceSKU } type PurchaseRequestProperties struct { @@ -183,7 +797,7 @@ type RenewProperties struct { // ReservationOrderAliasRequest - Reservation order alias type ReservationOrderAliasRequest struct { // REQUIRED; Reservation order SKU - SKU *SKU + SKU *ResourceSKU // The Azure Region where the reservation benefits are applied to. Location *string @@ -191,7 +805,7 @@ type ReservationOrderAliasRequest struct { // Reservation order alias request properties Properties *ReservationOrderAliasRequestProperties - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // 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 @@ -250,7 +864,7 @@ type ReservationOrderAliasRequestPropertiesReservedResourceProperties struct { // ReservationOrderAliasResponse - Reservation order alias type ReservationOrderAliasResponse struct { // REQUIRED; Reservation order SKU - SKU *SKU + SKU *ResourceSKU // The Azure Region where the reserved resource lives. Location *string @@ -258,7 +872,7 @@ type ReservationOrderAliasResponse struct { // Reservation order alias response properties Properties *ReservationOrderAliasResponseProperties - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // 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 @@ -320,6 +934,12 @@ type ReservationOrderAliasResponsePropertiesReservedResourceProperties struct { InstanceFlexibility *InstanceFlexibility } +// ResourceSKU - The SKU to be applied for this resource +type ResourceSKU struct { + // Name of the SKU to be applied + Name *string +} + // RoleAssignmentEntity - Role assignment entity type RoleAssignmentEntity struct { // Role assignment entity id @@ -344,21 +964,35 @@ type RoleAssignmentEntityProperties struct { Scope *string } -// SKU - The SKU to be applied for this resource +// SKU - The resource model definition representing SKU type SKU struct { - // Name of the SKU to be applied + // REQUIRED; The name of the SKU. E.g. P3. It is typically a letter+number code Name *string + + // If the SKU supports scale out/in then the capacity integer should be included. If scale out/in is not possible for the + // resource this may be omitted. + Capacity *int32 + + // If the service has different generations of hardware, for the same SKU, then that can be captured here. + Family *string + + // The SKU size. When the name field is the combination of tier and some other value, this would be the standalone code. + Size *string + + // This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required + // on a PUT. + Tier *SKUTier } // SavingsPlanModel - Savings plan type SavingsPlanModel struct { // REQUIRED; Savings plan SKU - SKU *SKU + SKU *ResourceSKU // Savings plan properties Properties *SavingsPlanModelProperties - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // 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 @@ -463,7 +1097,7 @@ type SavingsPlanModelProperties struct { // SavingsPlanOrderAliasModel - Savings plan order alias type SavingsPlanOrderAliasModel struct { // REQUIRED; Savings plan SKU - SKU *SKU + SKU *ResourceSKU // Resource provider kind Kind *string @@ -471,7 +1105,7 @@ type SavingsPlanOrderAliasModel struct { // Savings plan order alias properties Properties *SavingsPlanOrderAliasProperties - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // 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 @@ -504,6 +1138,9 @@ type SavingsPlanOrderAliasProperties struct { // Display name DisplayName *string + // Setting this to true will automatically purchase a new benefit on the expiration date time. + Renew *bool + // Represent benefit term in ISO 8601 format. Term *Term @@ -517,12 +1154,12 @@ type SavingsPlanOrderAliasProperties struct { // SavingsPlanOrderModel - Savings plan order type SavingsPlanOrderModel struct { // REQUIRED; Savings plan SKU - SKU *SKU + SKU *ResourceSKU // Savings plan order properties Properties *SavingsPlanOrderModelProperties - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // 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 @@ -692,6 +1329,15 @@ type SystemData struct { LastModifiedByType *CreatedByType } +// UserAssignedIdentity - User assigned identity properties +type UserAssignedIdentity struct { + // READ-ONLY; The client ID of the assigned identity. + ClientID *string + + // READ-ONLY; The principal ID of the assigned identity. + PrincipalID *string +} + // Utilization - Savings plan utilization type Utilization struct { // The array of aggregates of a savings plan's utilization diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/models_serde.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/models_serde.go index 6e2f9c652d06..bb92cdbb4fc1 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/models_serde.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/models_serde.go @@ -1,6 +1,3 @@ -//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. @@ -15,118 +12,966 @@ import ( "reflect" ) -// MarshalJSON implements the json.Marshaller interface for type AppliedScopeProperties. -func (a AppliedScopeProperties) 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 BillingPlanInformation. +func (b BillingPlanInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateType(objectMap, "nextPaymentDueDate", b.NextPaymentDueDate) + populate(objectMap, "pricingCurrencyTotal", b.PricingCurrencyTotal) + populateDateType(objectMap, "startDate", b.StartDate) + populate(objectMap, "transactions", b.Transactions) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BillingPlanInformation. +func (b *BillingPlanInformation) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextPaymentDueDate": + err = unpopulateDateType(val, "NextPaymentDueDate", &b.NextPaymentDueDate) + delete(rawMsg, key) + case "pricingCurrencyTotal": + err = unpopulate(val, "PricingCurrencyTotal", &b.PricingCurrencyTotal) + delete(rawMsg, key) + case "startDate": + err = unpopulateDateType(val, "StartDate", &b.StartDate) + delete(rawMsg, key) + case "transactions": + err = unpopulate(val, "Transactions", &b.Transactions) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CatalogClaimsItem. +func (c CatalogClaimsItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "catalogClaimsItemType", c.CatalogClaimsItemType) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CatalogClaimsItem. +func (c *CatalogClaimsItem) 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "catalogClaimsItemType": + err = unpopulate(val, "CatalogClaimsItemType", &c.CatalogClaimsItemType) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Commitment. +func (c Commitment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 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", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "amount": + err = unpopulate(val, "Amount", &c.Amount) + delete(rawMsg, key) + case "currencyCode": + err = unpopulate(val, "CurrencyCode", &c.CurrencyCode) + delete(rawMsg, key) + case "grain": + err = unpopulate(val, "Grain", &c.Grain) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ConditionsItem. +func (c ConditionsItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "conditionName", c.ConditionName) + populate(objectMap, "type", c.Type) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConditionsItem. +func (c *ConditionsItem) 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "conditionName": + err = unpopulate(val, "ConditionName", &c.ConditionName) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CustomPriceProperties. +func (c CustomPriceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "billingPeriod", c.BillingPeriod) + populate(objectMap, "catalogClaims", c.CatalogClaims) + populate(objectMap, "catalogId", c.CatalogID) + populate(objectMap, "marketSetPrices", c.MarketSetPrices) + populate(objectMap, "meterType", c.MeterType) + populate(objectMap, "ruleType", c.RuleType) + populate(objectMap, "termUnits", c.TermUnits) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomPriceProperties. +func (c *CustomPriceProperties) 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "billingPeriod": + err = unpopulate(val, "BillingPeriod", &c.BillingPeriod) + delete(rawMsg, key) + case "catalogClaims": + err = unpopulate(val, "CatalogClaims", &c.CatalogClaims) + delete(rawMsg, key) + case "catalogId": + err = unpopulate(val, "CatalogID", &c.CatalogID) + delete(rawMsg, key) + case "marketSetPrices": + err = unpopulate(val, "MarketSetPrices", &c.MarketSetPrices) + delete(rawMsg, key) + case "meterType": + err = unpopulate(val, "MeterType", &c.MeterType) + delete(rawMsg, key) + case "ruleType": + err = unpopulate(val, "RuleType", &c.RuleType) + delete(rawMsg, key) + case "termUnits": + err = unpopulate(val, "TermUnits", &c.TermUnits) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Discount. +func (d Discount) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", d.Etag) + populate(objectMap, "id", d.ID) + populate(objectMap, "identity", d.Identity) + populate(objectMap, "kind", d.Kind) + populate(objectMap, "location", d.Location) + populate(objectMap, "managedBy", d.ManagedBy) + populate(objectMap, "name", d.Name) + populate(objectMap, "plan", d.Plan) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "sku", d.SKU) + 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 Discount. +func (d *Discount) 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "etag": + err = unpopulate(val, "Etag", &d.Etag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &d.Identity) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &d.Kind) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &d.Location) + delete(rawMsg, key) + case "managedBy": + err = unpopulate(val, "ManagedBy", &d.ManagedBy) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "plan": + err = unpopulate(val, "Plan", &d.Plan) + delete(rawMsg, key) + case "properties": + d.Properties, err = unmarshalDiscountPropertiesClassification(val) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &d.SKU) + 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", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DiscountList. +func (d DiscountList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DiscountList. +func (d *DiscountList) 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DiscountPatchRequest. +func (d DiscountPatchRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "tags", d.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DiscountPatchRequest. +func (d *DiscountPatchRequest) 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &d.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DiscountPatchRequestProperties. +func (d DiscountPatchRequestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", d.DisplayName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DiscountPatchRequestProperties. +func (d *DiscountPatchRequestProperties) 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "displayName": + err = unpopulate(val, "DisplayName", &d.DisplayName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DiscountProperties. +func (d DiscountProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "appliedScopeType", d.AppliedScopeType) + populate(objectMap, "benefitResourceId", d.BenefitResourceID) + populate(objectMap, "billingAccountResourceId", d.BillingAccountResourceID) + populate(objectMap, "billingProfileResourceId", d.BillingProfileResourceID) + populate(objectMap, "customerResourceId", d.CustomerResourceID) + populate(objectMap, "displayName", d.DisplayName) + objectMap["entityType"] = d.EntityType + populate(objectMap, "productCode", d.ProductCode) + populate(objectMap, "provisioningState", d.ProvisioningState) + populateDateTimeRFC3339(objectMap, "startAt", d.StartAt) + populate(objectMap, "status", d.Status) + populate(objectMap, "systemId", d.SystemID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DiscountProperties. +func (d *DiscountProperties) 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "appliedScopeType": + err = unpopulate(val, "AppliedScopeType", &d.AppliedScopeType) + delete(rawMsg, key) + case "benefitResourceId": + err = unpopulate(val, "BenefitResourceID", &d.BenefitResourceID) + delete(rawMsg, key) + case "billingAccountResourceId": + err = unpopulate(val, "BillingAccountResourceID", &d.BillingAccountResourceID) + delete(rawMsg, key) + case "billingProfileResourceId": + err = unpopulate(val, "BillingProfileResourceID", &d.BillingProfileResourceID) + delete(rawMsg, key) + case "customerResourceId": + err = unpopulate(val, "CustomerResourceID", &d.CustomerResourceID) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &d.DisplayName) + delete(rawMsg, key) + case "entityType": + err = unpopulate(val, "EntityType", &d.EntityType) + delete(rawMsg, key) + case "productCode": + err = unpopulate(val, "ProductCode", &d.ProductCode) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) + delete(rawMsg, key) + case "startAt": + err = unpopulateDateTimeRFC3339(val, "StartAt", &d.StartAt) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &d.Status) + delete(rawMsg, key) + case "systemId": + err = unpopulate(val, "SystemID", &d.SystemID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DiscountTypeCustomPrice. +func (d DiscountTypeCustomPrice) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "applyDiscountOn", d.ApplyDiscountOn) + populate(objectMap, "conditions", d.Conditions) + populate(objectMap, "customPriceProperties", d.CustomPriceProperties) + populate(objectMap, "discountCombinationRule", d.DiscountCombinationRule) + populate(objectMap, "discountPercentage", d.DiscountPercentage) + objectMap["discountType"] = DiscountTypeCustomPrice + populate(objectMap, "priceGuaranteeProperties", d.PriceGuaranteeProperties) + populate(objectMap, "productFamilyName", d.ProductFamilyName) + populate(objectMap, "productId", d.ProductID) + populate(objectMap, "skuId", d.SKUID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DiscountTypeCustomPrice. +func (d *DiscountTypeCustomPrice) 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "applyDiscountOn": + err = unpopulate(val, "ApplyDiscountOn", &d.ApplyDiscountOn) + delete(rawMsg, key) + case "conditions": + err = unpopulate(val, "Conditions", &d.Conditions) + delete(rawMsg, key) + case "customPriceProperties": + err = unpopulate(val, "CustomPriceProperties", &d.CustomPriceProperties) + delete(rawMsg, key) + case "discountCombinationRule": + err = unpopulate(val, "DiscountCombinationRule", &d.DiscountCombinationRule) + delete(rawMsg, key) + case "discountPercentage": + err = unpopulate(val, "DiscountPercentage", &d.DiscountPercentage) + delete(rawMsg, key) + case "discountType": + err = unpopulate(val, "DiscountType", &d.DiscountType) + delete(rawMsg, key) + case "priceGuaranteeProperties": + err = unpopulate(val, "PriceGuaranteeProperties", &d.PriceGuaranteeProperties) + delete(rawMsg, key) + case "productFamilyName": + err = unpopulate(val, "ProductFamilyName", &d.ProductFamilyName) + delete(rawMsg, key) + case "productId": + err = unpopulate(val, "ProductID", &d.ProductID) + delete(rawMsg, key) + case "skuId": + err = unpopulate(val, "SKUID", &d.SKUID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DiscountTypeCustomPriceMultiCurrency. +func (d DiscountTypeCustomPriceMultiCurrency) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "applyDiscountOn", d.ApplyDiscountOn) + populate(objectMap, "conditions", d.Conditions) + populate(objectMap, "customPriceProperties", d.CustomPriceProperties) + populate(objectMap, "discountCombinationRule", d.DiscountCombinationRule) + populate(objectMap, "discountPercentage", d.DiscountPercentage) + objectMap["discountType"] = DiscountTypeCustomPriceMultiCurrency + populate(objectMap, "priceGuaranteeProperties", d.PriceGuaranteeProperties) + populate(objectMap, "productFamilyName", d.ProductFamilyName) + populate(objectMap, "productId", d.ProductID) + populate(objectMap, "skuId", d.SKUID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DiscountTypeCustomPriceMultiCurrency. +func (d *DiscountTypeCustomPriceMultiCurrency) 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "applyDiscountOn": + err = unpopulate(val, "ApplyDiscountOn", &d.ApplyDiscountOn) + delete(rawMsg, key) + case "conditions": + err = unpopulate(val, "Conditions", &d.Conditions) + delete(rawMsg, key) + case "customPriceProperties": + err = unpopulate(val, "CustomPriceProperties", &d.CustomPriceProperties) + delete(rawMsg, key) + case "discountCombinationRule": + err = unpopulate(val, "DiscountCombinationRule", &d.DiscountCombinationRule) + delete(rawMsg, key) + case "discountPercentage": + err = unpopulate(val, "DiscountPercentage", &d.DiscountPercentage) + delete(rawMsg, key) + case "discountType": + err = unpopulate(val, "DiscountType", &d.DiscountType) + delete(rawMsg, key) + case "priceGuaranteeProperties": + err = unpopulate(val, "PriceGuaranteeProperties", &d.PriceGuaranteeProperties) + delete(rawMsg, key) + case "productFamilyName": + err = unpopulate(val, "ProductFamilyName", &d.ProductFamilyName) + delete(rawMsg, key) + case "productId": + err = unpopulate(val, "ProductID", &d.ProductID) + delete(rawMsg, key) + case "skuId": + err = unpopulate(val, "SKUID", &d.SKUID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DiscountTypeProduct. +func (d DiscountTypeProduct) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "applyDiscountOn", d.ApplyDiscountOn) + populate(objectMap, "conditions", d.Conditions) + populate(objectMap, "discountCombinationRule", d.DiscountCombinationRule) + populate(objectMap, "discountPercentage", d.DiscountPercentage) + objectMap["discountType"] = DiscountTypeProduct + populate(objectMap, "priceGuaranteeProperties", d.PriceGuaranteeProperties) + populate(objectMap, "productFamilyName", d.ProductFamilyName) + populate(objectMap, "productId", d.ProductID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DiscountTypeProduct. +func (d *DiscountTypeProduct) 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "applyDiscountOn": + err = unpopulate(val, "ApplyDiscountOn", &d.ApplyDiscountOn) + delete(rawMsg, key) + case "conditions": + err = unpopulate(val, "Conditions", &d.Conditions) + delete(rawMsg, key) + case "discountCombinationRule": + err = unpopulate(val, "DiscountCombinationRule", &d.DiscountCombinationRule) + delete(rawMsg, key) + case "discountPercentage": + err = unpopulate(val, "DiscountPercentage", &d.DiscountPercentage) + delete(rawMsg, key) + case "discountType": + err = unpopulate(val, "DiscountType", &d.DiscountType) + delete(rawMsg, key) + case "priceGuaranteeProperties": + err = unpopulate(val, "PriceGuaranteeProperties", &d.PriceGuaranteeProperties) + delete(rawMsg, key) + case "productFamilyName": + err = unpopulate(val, "ProductFamilyName", &d.ProductFamilyName) + delete(rawMsg, key) + case "productId": + err = unpopulate(val, "ProductID", &d.ProductID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DiscountTypeProductFamily. +func (d DiscountTypeProductFamily) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "applyDiscountOn", d.ApplyDiscountOn) + populate(objectMap, "conditions", d.Conditions) + populate(objectMap, "discountCombinationRule", d.DiscountCombinationRule) + populate(objectMap, "discountPercentage", d.DiscountPercentage) + objectMap["discountType"] = DiscountTypeProductFamily + populate(objectMap, "priceGuaranteeProperties", d.PriceGuaranteeProperties) + populate(objectMap, "productFamilyName", d.ProductFamilyName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DiscountTypeProductFamily. +func (d *DiscountTypeProductFamily) 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "applyDiscountOn": + err = unpopulate(val, "ApplyDiscountOn", &d.ApplyDiscountOn) + delete(rawMsg, key) + case "conditions": + err = unpopulate(val, "Conditions", &d.Conditions) + delete(rawMsg, key) + case "discountCombinationRule": + err = unpopulate(val, "DiscountCombinationRule", &d.DiscountCombinationRule) + delete(rawMsg, key) + case "discountPercentage": + err = unpopulate(val, "DiscountPercentage", &d.DiscountPercentage) + delete(rawMsg, key) + case "discountType": + err = unpopulate(val, "DiscountType", &d.DiscountType) + delete(rawMsg, key) + case "priceGuaranteeProperties": + err = unpopulate(val, "PriceGuaranteeProperties", &d.PriceGuaranteeProperties) + delete(rawMsg, key) + case "productFamilyName": + err = unpopulate(val, "ProductFamilyName", &d.ProductFamilyName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DiscountTypeProductSKU. +func (d DiscountTypeProductSKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "applyDiscountOn", d.ApplyDiscountOn) + populate(objectMap, "conditions", d.Conditions) + populate(objectMap, "discountCombinationRule", d.DiscountCombinationRule) + populate(objectMap, "discountPercentage", d.DiscountPercentage) + objectMap["discountType"] = DiscountTypeSKU + populate(objectMap, "priceGuaranteeProperties", d.PriceGuaranteeProperties) + populate(objectMap, "productFamilyName", d.ProductFamilyName) + populate(objectMap, "productId", d.ProductID) + populate(objectMap, "skuId", d.SKUID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DiscountTypeProductSKU. +func (d *DiscountTypeProductSKU) 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "applyDiscountOn": + err = unpopulate(val, "ApplyDiscountOn", &d.ApplyDiscountOn) + delete(rawMsg, key) + case "conditions": + err = unpopulate(val, "Conditions", &d.Conditions) + delete(rawMsg, key) + case "discountCombinationRule": + err = unpopulate(val, "DiscountCombinationRule", &d.DiscountCombinationRule) + delete(rawMsg, key) + case "discountPercentage": + err = unpopulate(val, "DiscountPercentage", &d.DiscountPercentage) + delete(rawMsg, key) + case "discountType": + err = unpopulate(val, "DiscountType", &d.DiscountType) + delete(rawMsg, key) + case "priceGuaranteeProperties": + err = unpopulate(val, "PriceGuaranteeProperties", &d.PriceGuaranteeProperties) + delete(rawMsg, key) + case "productFamilyName": + err = unpopulate(val, "ProductFamilyName", &d.ProductFamilyName) + delete(rawMsg, key) + case "productId": + err = unpopulate(val, "ProductID", &d.ProductID) + delete(rawMsg, key) + case "skuId": + err = unpopulate(val, "SKUID", &d.SKUID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DiscountTypeProperties. +func (d DiscountTypeProperties) 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) + populate(objectMap, "applyDiscountOn", d.ApplyDiscountOn) + populate(objectMap, "conditions", d.Conditions) + populate(objectMap, "discountCombinationRule", d.DiscountCombinationRule) + populate(objectMap, "discountPercentage", d.DiscountPercentage) + objectMap["discountType"] = d.DiscountType + populate(objectMap, "priceGuaranteeProperties", d.PriceGuaranteeProperties) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AppliedScopeProperties. -func (a *AppliedScopeProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type DiscountTypeProperties. +func (d *DiscountTypeProperties) 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) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { - case "displayName": - err = unpopulate(val, "DisplayName", &a.DisplayName) + case "applyDiscountOn": + err = unpopulate(val, "ApplyDiscountOn", &d.ApplyDiscountOn) delete(rawMsg, key) - case "managementGroupId": - err = unpopulate(val, "ManagementGroupID", &a.ManagementGroupID) + case "conditions": + err = unpopulate(val, "Conditions", &d.Conditions) delete(rawMsg, key) - case "resourceGroupId": - err = unpopulate(val, "ResourceGroupID", &a.ResourceGroupID) + case "discountCombinationRule": + err = unpopulate(val, "DiscountCombinationRule", &d.DiscountCombinationRule) delete(rawMsg, key) - case "subscriptionId": - err = unpopulate(val, "SubscriptionID", &a.SubscriptionID) + case "discountPercentage": + err = unpopulate(val, "DiscountPercentage", &d.DiscountPercentage) delete(rawMsg, key) - case "tenantId": - err = unpopulate(val, "TenantID", &a.TenantID) + case "discountType": + err = unpopulate(val, "DiscountType", &d.DiscountType) + delete(rawMsg, key) + case "priceGuaranteeProperties": + err = unpopulate(val, "PriceGuaranteeProperties", &d.PriceGuaranteeProperties) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type BillingPlanInformation. -func (b BillingPlanInformation) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type EntityTypeAffiliateDiscount. +func (e EntityTypeAffiliateDiscount) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateDateType(objectMap, "nextPaymentDueDate", b.NextPaymentDueDate) - populate(objectMap, "pricingCurrencyTotal", b.PricingCurrencyTotal) - populateDateType(objectMap, "startDate", b.StartDate) - populate(objectMap, "transactions", b.Transactions) + populate(objectMap, "appliedScopeType", e.AppliedScopeType) + populate(objectMap, "benefitResourceId", e.BenefitResourceID) + populate(objectMap, "billingAccountResourceId", e.BillingAccountResourceID) + populate(objectMap, "billingProfileResourceId", e.BillingProfileResourceID) + populate(objectMap, "customerResourceId", e.CustomerResourceID) + populate(objectMap, "displayName", e.DisplayName) + populateDateTimeRFC3339(objectMap, "endAt", e.EndAt) + objectMap["entityType"] = DiscountEntityTypeAffiliate + populate(objectMap, "primaryResourceId", e.PrimaryResourceID) + populate(objectMap, "productCode", e.ProductCode) + populate(objectMap, "provisioningState", e.ProvisioningState) + populateDateTimeRFC3339(objectMap, "startAt", e.StartAt) + populate(objectMap, "status", e.Status) + populate(objectMap, "systemId", e.SystemID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type BillingPlanInformation. -func (b *BillingPlanInformation) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type EntityTypeAffiliateDiscount. +func (e *EntityTypeAffiliateDiscount) 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", b, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "nextPaymentDueDate": - err = unpopulateDateType(val, "NextPaymentDueDate", &b.NextPaymentDueDate) + case "appliedScopeType": + err = unpopulate(val, "AppliedScopeType", &e.AppliedScopeType) delete(rawMsg, key) - case "pricingCurrencyTotal": - err = unpopulate(val, "PricingCurrencyTotal", &b.PricingCurrencyTotal) + case "benefitResourceId": + err = unpopulate(val, "BenefitResourceID", &e.BenefitResourceID) delete(rawMsg, key) - case "startDate": - err = unpopulateDateType(val, "StartDate", &b.StartDate) + case "billingAccountResourceId": + err = unpopulate(val, "BillingAccountResourceID", &e.BillingAccountResourceID) delete(rawMsg, key) - case "transactions": - err = unpopulate(val, "Transactions", &b.Transactions) + case "billingProfileResourceId": + err = unpopulate(val, "BillingProfileResourceID", &e.BillingProfileResourceID) + delete(rawMsg, key) + case "customerResourceId": + err = unpopulate(val, "CustomerResourceID", &e.CustomerResourceID) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &e.DisplayName) + delete(rawMsg, key) + case "endAt": + err = unpopulateDateTimeRFC3339(val, "EndAt", &e.EndAt) + delete(rawMsg, key) + case "entityType": + err = unpopulate(val, "EntityType", &e.EntityType) + delete(rawMsg, key) + case "primaryResourceId": + err = unpopulate(val, "PrimaryResourceID", &e.PrimaryResourceID) + delete(rawMsg, key) + case "productCode": + err = unpopulate(val, "ProductCode", &e.ProductCode) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) + delete(rawMsg, key) + case "startAt": + err = unpopulateDateTimeRFC3339(val, "StartAt", &e.StartAt) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &e.Status) + delete(rawMsg, key) + case "systemId": + err = unpopulate(val, "SystemID", &e.SystemID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Commitment. -func (c Commitment) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type EntityTypePrimaryDiscount. +func (e EntityTypePrimaryDiscount) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "amount", c.Amount) - populate(objectMap, "currencyCode", c.CurrencyCode) - populate(objectMap, "grain", c.Grain) + populate(objectMap, "appliedScopeType", e.AppliedScopeType) + populate(objectMap, "benefitResourceId", e.BenefitResourceID) + populate(objectMap, "billingAccountResourceId", e.BillingAccountResourceID) + populate(objectMap, "billingProfileResourceId", e.BillingProfileResourceID) + populate(objectMap, "customerResourceId", e.CustomerResourceID) + populate(objectMap, "discountTypeProperties", e.DiscountTypeProperties) + populate(objectMap, "displayName", e.DisplayName) + populateDateTimeRFC3339(objectMap, "endAt", e.EndAt) + objectMap["entityType"] = DiscountEntityTypePrimary + populate(objectMap, "productCode", e.ProductCode) + populate(objectMap, "provisioningState", e.ProvisioningState) + populateDateTimeRFC3339(objectMap, "startAt", e.StartAt) + populate(objectMap, "status", e.Status) + populate(objectMap, "systemId", e.SystemID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Commitment. -func (c *Commitment) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type EntityTypePrimaryDiscount. +func (e *EntityTypePrimaryDiscount) 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", e, err) } for key, val := range rawMsg { var err error switch key { - case "amount": - err = unpopulate(val, "Amount", &c.Amount) + case "appliedScopeType": + err = unpopulate(val, "AppliedScopeType", &e.AppliedScopeType) delete(rawMsg, key) - case "currencyCode": - err = unpopulate(val, "CurrencyCode", &c.CurrencyCode) + case "benefitResourceId": + err = unpopulate(val, "BenefitResourceID", &e.BenefitResourceID) delete(rawMsg, key) - case "grain": - err = unpopulate(val, "Grain", &c.Grain) + case "billingAccountResourceId": + err = unpopulate(val, "BillingAccountResourceID", &e.BillingAccountResourceID) + delete(rawMsg, key) + case "billingProfileResourceId": + err = unpopulate(val, "BillingProfileResourceID", &e.BillingProfileResourceID) + delete(rawMsg, key) + case "customerResourceId": + err = unpopulate(val, "CustomerResourceID", &e.CustomerResourceID) + delete(rawMsg, key) + case "discountTypeProperties": + e.DiscountTypeProperties, err = unmarshalDiscountTypePropertiesClassification(val) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &e.DisplayName) + delete(rawMsg, key) + case "endAt": + err = unpopulateDateTimeRFC3339(val, "EndAt", &e.EndAt) + delete(rawMsg, key) + case "entityType": + err = unpopulate(val, "EntityType", &e.EntityType) + delete(rawMsg, key) + case "productCode": + err = unpopulate(val, "ProductCode", &e.ProductCode) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) + delete(rawMsg, key) + case "startAt": + err = unpopulateDateTimeRFC3339(val, "StartAt", &e.StartAt) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &e.Status) + delete(rawMsg, key) + case "systemId": + err = unpopulate(val, "SystemID", &e.SystemID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil @@ -163,6 +1008,80 @@ func (e *ExtendedStatusInfo) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ManagedServiceIdentity. +func (m ManagedServiceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "principalId", m.PrincipalID) + populate(objectMap, "tenantId", m.TenantID) + populate(objectMap, "type", m.Type) + populate(objectMap, "userAssignedIdentities", m.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedServiceIdentity. +func (m *ManagedServiceIdentity) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "principalId": + err = unpopulate(val, "PrincipalID", &m.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &m.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &m.Type) + delete(rawMsg, key) + case "userAssignedIdentities": + err = unpopulate(val, "UserAssignedIdentities", &m.UserAssignedIdentities) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MarketSetPricesItems. +func (m MarketSetPricesItems) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "currency", m.Currency) + populate(objectMap, "markets", m.Markets) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MarketSetPricesItems. +func (m *MarketSetPricesItems) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "currency": + err = unpopulate(val, "Currency", &m.Currency) + delete(rawMsg, key) + case "markets": + err = unpopulate(val, "Markets", &m.Markets) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &m.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Operation. func (o Operation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -327,6 +1246,49 @@ func (p *PaymentDetail) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type Plan. +func (p Plan) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", p.Name) + populate(objectMap, "product", p.Product) + populate(objectMap, "promotionCode", p.PromotionCode) + populate(objectMap, "publisher", p.Publisher) + populate(objectMap, "version", p.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Plan. +func (p *Plan) 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 "product": + err = unpopulate(val, "Product", &p.Product) + delete(rawMsg, key) + case "promotionCode": + err = unpopulate(val, "PromotionCode", &p.PromotionCode) + delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &p.Publisher) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &p.Version) + 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) @@ -358,6 +1320,37 @@ func (p *Price) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type PriceGuaranteeProperties. +func (p PriceGuaranteeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "priceGuaranteeDate", p.PriceGuaranteeDate) + populate(objectMap, "pricingPolicy", p.PricingPolicy) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PriceGuaranteeProperties. +func (p *PriceGuaranteeProperties) 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 "priceGuaranteeDate": + err = unpopulateDateTimeRFC3339(val, "PriceGuaranteeDate", &p.PriceGuaranteeDate) + delete(rawMsg, key) + case "pricingPolicy": + err = unpopulate(val, "PricingPolicy", &p.PricingPolicy) + 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) @@ -773,6 +1766,33 @@ func (r *ReservationOrderAliasResponsePropertiesReservedResourceProperties) Unma return nil } +// MarshalJSON implements the json.Marshaller interface for type ResourceSKU. +func (r ResourceSKU) 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 ResourceSKU. +func (r *ResourceSKU) 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 RoleAssignmentEntity. func (r RoleAssignmentEntity) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -846,7 +1866,11 @@ func (r *RoleAssignmentEntityProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SKU. func (s SKU) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "capacity", s.Capacity) + populate(objectMap, "family", s.Family) populate(objectMap, "name", s.Name) + populate(objectMap, "size", s.Size) + populate(objectMap, "tier", s.Tier) return json.Marshal(objectMap) } @@ -859,9 +1883,21 @@ func (s *SKU) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "capacity": + err = unpopulate(val, "Capacity", &s.Capacity) + delete(rawMsg, key) + case "family": + err = unpopulate(val, "Family", &s.Family) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &s.Name) delete(rawMsg, key) + case "size": + err = unpopulate(val, "Size", &s.Size) + delete(rawMsg, key) + case "tier": + err = unpopulate(val, "Tier", &s.Tier) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) @@ -1159,6 +2195,7 @@ func (s SavingsPlanOrderAliasProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "commitment", s.Commitment) populate(objectMap, "displayName", s.DisplayName) populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "renew", s.Renew) populate(objectMap, "savingsPlanOrderId", s.SavingsPlanOrderID) populate(objectMap, "term", s.Term) return json.Marshal(objectMap) @@ -1194,6 +2231,9 @@ func (s *SavingsPlanOrderAliasProperties) UnmarshalJSON(data []byte) error { case "provisioningState": err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) delete(rawMsg, key) + case "renew": + err = unpopulate(val, "Renew", &s.Renew) + delete(rawMsg, key) case "savingsPlanOrderId": err = unpopulate(val, "SavingsPlanOrderID", &s.SavingsPlanOrderID) delete(rawMsg, key) @@ -1688,6 +2728,37 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentity. +func (u UserAssignedIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientId", u.ClientID) + populate(objectMap, "principalId", u.PrincipalID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentity. +func (u *UserAssignedIdentity) 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", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "clientId": + err = unpopulate(val, "ClientID", &u.ClientID) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &u.PrincipalID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Utilization. func (u Utilization) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1769,7 +2840,7 @@ func populate(m map[string]any, k string, v any) { } 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/billingbenefits/armbillingbenefits/operations_client.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/operations_client.go index 5ba91ae7ba9d..bfec73c11bed 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/operations_client.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/operations_client.go @@ -1,6 +1,3 @@ -//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. @@ -39,7 +36,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // NewListPager - List all the operations. // -// Generated from API version 2022-11-01 +// Generated from API version 2024-11-01-preview // - 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]{ @@ -65,14 +62,14 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption } // listCreateRequest creates the List request. -func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { +func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.BillingBenefits/operations" 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", "2022-11-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/operations_client_example_test.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/operations_client_example_test.go deleted file mode 100644 index 6b6bf3d6b2b4..000000000000 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/operations_client_example_test.go +++ /dev/null @@ -1,118 +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 armbillingbenefits_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billingbenefits/armbillingbenefits/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/billingbenefits/resource-manager/Microsoft.BillingBenefits/stable/2022-11-01/examples/OperationsGet.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 := armbillingbenefits.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 = armbillingbenefits.OperationListResult{ - // Value: []*armbillingbenefits.Operation{ - // { - // Name: to.Ptr("Microsoft.BillingBenefits/savingsPlanOrderAliases/read"), - // Display: &armbillingbenefits.OperationDisplay{ - // Description: to.Ptr("Read all savings plan order aliases"), - // Operation: to.Ptr("Get Savings plan order alias"), - // Provider: to.Ptr("Microsoft Benefits"), - // Resource: to.Ptr("SavingsPlanOrderAliases"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.BillingBenefits/savingsPlanOrderAliases/write"), - // Display: &armbillingbenefits.OperationDisplay{ - // Description: to.Ptr("Create a Savings plan order alias"), - // Operation: to.Ptr("Create SavingsPlanOrderAliases"), - // Provider: to.Ptr("Microsoft Benefits"), - // Resource: to.Ptr("SavingsPlanOrderAliases"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.BillingBenefits/savingsPlanOrders/read"), - // Display: &armbillingbenefits.OperationDisplay{ - // Description: to.Ptr("Read all savings plan orders"), - // Operation: to.Ptr("Get Savings plan orders"), - // Provider: to.Ptr("Microsoft Benefits"), - // Resource: to.Ptr("SavingsPlanOrders"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.BillingBenefits/savingsPlanOrders/write"), - // Display: &armbillingbenefits.OperationDisplay{ - // Description: to.Ptr("Patch a Savings plan order"), - // Operation: to.Ptr("Patch SavingsPlanOrders"), - // Provider: to.Ptr("Microsoft Benefits"), - // Resource: to.Ptr("SavingsPlanOrders"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.BillingBenefits/savingsPlanOrders/action"), - // Display: &armbillingbenefits.OperationDisplay{ - // Description: to.Ptr("Update a Savings plan order"), - // Operation: to.Ptr("Update SavingsPlanOrders"), - // Provider: to.Ptr("Microsoft Benefits"), - // Resource: to.Ptr("SavingsPlanOrders"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.BillingBenefits/savingsPlanOrders/savingsPlans/read"), - // Display: &armbillingbenefits.OperationDisplay{ - // Description: to.Ptr("Read All SavingsPlans"), - // Operation: to.Ptr("Get SavingsPlans"), - // Provider: to.Ptr("Microsoft Benefits"), - // Resource: to.Ptr("SavingsPlans"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.BillingBenefits/savingsPlanOrders/savingsPlans/write"), - // Display: &armbillingbenefits.OperationDisplay{ - // Description: to.Ptr("Patch an existing Savings plan"), - // Operation: to.Ptr("Patch SavingsPlans"), - // Provider: to.Ptr("Microsoft Benefits"), - // Resource: to.Ptr("SavingsPlans"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.BillingBenefits/register/action"), - // Display: &armbillingbenefits.OperationDisplay{ - // Description: to.Ptr("Registers the Benefits resource provider and enables the creation of Benefits resources."), - // Operation: to.Ptr("Registers the Benefits Resource Provider."), - // Provider: to.Ptr("Microsoft Benefits"), - // Resource: to.Ptr("SavingsPlans"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/options.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/options.go index ffd3a44abd73..4605d8672012 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/options.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/options.go @@ -1,6 +1,3 @@ -//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. @@ -8,6 +5,52 @@ package armbillingbenefits +// DiscountClientBeginUpdateOptions contains the optional parameters for the DiscountClient.BeginUpdate method. +type DiscountClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// DiscountClientGetOptions contains the optional parameters for the DiscountClient.Get method. +type DiscountClientGetOptions struct { + // placeholder for future optional parameters +} + +// DiscountsClientBeginCancelOptions contains the optional parameters for the DiscountsClient.BeginCancel method. +type DiscountsClientBeginCancelOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// DiscountsClientBeginCreateOptions contains the optional parameters for the DiscountsClient.BeginCreate method. +type DiscountsClientBeginCreateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// DiscountsClientBeginDeleteOptions contains the optional parameters for the DiscountsClient.BeginDelete method. +type DiscountsClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// DiscountsClientResourceGroupListOptions contains the optional parameters for the DiscountsClient.NewResourceGroupListPager +// method. +type DiscountsClientResourceGroupListOptions struct { + // placeholder for future optional parameters +} + +// DiscountsClientScopeListOptions contains the optional parameters for the DiscountsClient.NewScopeListPager method. +type DiscountsClientScopeListOptions struct { + // placeholder for future optional parameters +} + +// DiscountsClientSubscriptionListOptions contains the optional parameters for the DiscountsClient.NewSubscriptionListPager +// method. +type DiscountsClientSubscriptionListOptions struct { + // placeholder for future optional parameters +} + // OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters @@ -21,7 +64,7 @@ type RPClientValidatePurchaseOptions struct { // ReservationOrderAliasClientBeginCreateOptions contains the optional parameters for the ReservationOrderAliasClient.BeginCreate // method. type ReservationOrderAliasClientBeginCreateOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -30,6 +73,12 @@ type ReservationOrderAliasClientGetOptions struct { // placeholder for future optional parameters } +// SavingsPlanClientBeginUpdateOptions contains the optional parameters for the SavingsPlanClient.BeginUpdate method. +type SavingsPlanClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + // SavingsPlanClientGetOptions contains the optional parameters for the SavingsPlanClient.Get method. type SavingsPlanClientGetOptions struct { // May be used to expand the detail information of some properties. @@ -66,11 +115,6 @@ type SavingsPlanClientListOptions struct { // placeholder for future optional parameters } -// SavingsPlanClientUpdateOptions contains the optional parameters for the SavingsPlanClient.Update method. -type SavingsPlanClientUpdateOptions struct { - // placeholder for future optional parameters -} - // SavingsPlanClientValidateUpdateOptions contains the optional parameters for the SavingsPlanClient.ValidateUpdate method. type SavingsPlanClientValidateUpdateOptions struct { // placeholder for future optional parameters @@ -79,7 +123,7 @@ type SavingsPlanClientValidateUpdateOptions struct { // SavingsPlanOrderAliasClientBeginCreateOptions contains the optional parameters for the SavingsPlanOrderAliasClient.BeginCreate // method. type SavingsPlanOrderAliasClientBeginCreateOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/polymorphic_helpers.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/polymorphic_helpers.go new file mode 100644 index 000000000000..afad90e8d14a --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/polymorphic_helpers.go @@ -0,0 +1,60 @@ +// 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 armbillingbenefits + +import "encoding/json" + +func unmarshalDiscountPropertiesClassification(rawMsg json.RawMessage) (DiscountPropertiesClassification, error) { + if rawMsg == nil || string(rawMsg) == "null" { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b DiscountPropertiesClassification + switch m["entityType"] { + case string(DiscountEntityTypeAffiliate): + b = &EntityTypeAffiliateDiscount{} + case string(DiscountEntityTypePrimary): + b = &EntityTypePrimaryDiscount{} + default: + b = &DiscountProperties{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + +func unmarshalDiscountTypePropertiesClassification(rawMsg json.RawMessage) (DiscountTypePropertiesClassification, error) { + if rawMsg == nil || string(rawMsg) == "null" { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b DiscountTypePropertiesClassification + switch m["discountType"] { + case string(DiscountTypeCustomPrice): + b = &DiscountTypeCustomPrice{} + case string(DiscountTypeCustomPriceMultiCurrency): + b = &DiscountTypeCustomPriceMultiCurrency{} + case string(DiscountTypeProduct): + b = &DiscountTypeProduct{} + case string(DiscountTypeProductFamily): + b = &DiscountTypeProductFamily{} + case string(DiscountTypeSKU): + b = &DiscountTypeProductSKU{} + default: + b = &DiscountTypeProperties{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/reservationorderalias_client.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/reservationorderalias_client.go index 2e34b2796497..7cc5143e264b 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/reservationorderalias_client.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/reservationorderalias_client.go @@ -1,6 +1,3 @@ -//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. @@ -43,7 +40,7 @@ func NewReservationOrderAliasClient(credential azcore.TokenCredential, options * // BeginCreate - Create a reservation order alias. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-01 +// Generated from API version 2024-11-01-preview // - reservationOrderAliasName - Name of the reservation order alias // - body - Request body for creating a reservation order alias // - options - ReservationOrderAliasClientBeginCreateOptions contains the optional parameters for the ReservationOrderAliasClient.BeginCreate @@ -69,7 +66,7 @@ func (client *ReservationOrderAliasClient) BeginCreate(ctx context.Context, rese // Create - Create a reservation order alias. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-01 +// Generated from API version 2024-11-01-preview func (client *ReservationOrderAliasClient) create(ctx context.Context, reservationOrderAliasName string, body ReservationOrderAliasRequest, options *ReservationOrderAliasClientBeginCreateOptions) (*http.Response, error) { var err error const operationName = "ReservationOrderAliasClient.BeginCreate" @@ -92,7 +89,7 @@ func (client *ReservationOrderAliasClient) create(ctx context.Context, reservati } // createCreateRequest creates the Create request. -func (client *ReservationOrderAliasClient) createCreateRequest(ctx context.Context, reservationOrderAliasName string, body ReservationOrderAliasRequest, options *ReservationOrderAliasClientBeginCreateOptions) (*policy.Request, error) { +func (client *ReservationOrderAliasClient) createCreateRequest(ctx context.Context, reservationOrderAliasName string, body ReservationOrderAliasRequest, _ *ReservationOrderAliasClientBeginCreateOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.BillingBenefits/reservationOrderAliases/{reservationOrderAliasName}" if reservationOrderAliasName == "" { return nil, errors.New("parameter reservationOrderAliasName cannot be empty") @@ -103,7 +100,7 @@ func (client *ReservationOrderAliasClient) createCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-11-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, body); err != nil { @@ -115,7 +112,7 @@ func (client *ReservationOrderAliasClient) createCreateRequest(ctx context.Conte // Get - Get a reservation order alias. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-01 +// Generated from API version 2024-11-01-preview // - reservationOrderAliasName - Name of the reservation order alias // - options - ReservationOrderAliasClientGetOptions contains the optional parameters for the ReservationOrderAliasClient.Get // method. @@ -142,7 +139,7 @@ func (client *ReservationOrderAliasClient) Get(ctx context.Context, reservationO } // getCreateRequest creates the Get request. -func (client *ReservationOrderAliasClient) getCreateRequest(ctx context.Context, reservationOrderAliasName string, options *ReservationOrderAliasClientGetOptions) (*policy.Request, error) { +func (client *ReservationOrderAliasClient) getCreateRequest(ctx context.Context, reservationOrderAliasName string, _ *ReservationOrderAliasClientGetOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.BillingBenefits/reservationOrderAliases/{reservationOrderAliasName}" if reservationOrderAliasName == "" { return nil, errors.New("parameter reservationOrderAliasName cannot be empty") @@ -153,7 +150,7 @@ func (client *ReservationOrderAliasClient) getCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-11-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/reservationorderalias_client_example_test.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/reservationorderalias_client_example_test.go deleted file mode 100644 index 405f798c6840..000000000000 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/reservationorderalias_client_example_test.go +++ /dev/null @@ -1,137 +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 armbillingbenefits_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/billingbenefits/armbillingbenefits/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/billingbenefits/resource-manager/Microsoft.BillingBenefits/stable/2022-11-01/examples/ReservationOrderAliasCreate.json -func ExampleReservationOrderAliasClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbillingbenefits.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewReservationOrderAliasClient().BeginCreate(ctx, "reservationOrderAlias123", armbillingbenefits.ReservationOrderAliasRequest{ - Location: to.Ptr("eastus"), - Properties: &armbillingbenefits.ReservationOrderAliasRequestProperties{ - AppliedScopeProperties: &armbillingbenefits.AppliedScopeProperties{ - ResourceGroupID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/testrg"), - }, - AppliedScopeType: to.Ptr(armbillingbenefits.AppliedScopeTypeSingle), - BillingPlan: to.Ptr(armbillingbenefits.BillingPlanP1M), - BillingScopeID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000"), - DisplayName: to.Ptr("ReservationOrder_2022-06-02"), - Quantity: to.Ptr[int32](5), - Renew: to.Ptr(true), - ReservedResourceProperties: &armbillingbenefits.ReservationOrderAliasRequestPropertiesReservedResourceProperties{ - InstanceFlexibility: to.Ptr(armbillingbenefits.InstanceFlexibilityOn), - }, - ReservedResourceType: to.Ptr(armbillingbenefits.ReservedResourceTypeVirtualMachines), - Term: to.Ptr(armbillingbenefits.TermP1Y), - }, - SKU: &armbillingbenefits.SKU{ - Name: to.Ptr("Standard_M64s_v2"), - }, - }, 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.ReservationOrderAliasResponse = armbillingbenefits.ReservationOrderAliasResponse{ - // Name: to.Ptr("reservationOrderAlias123"), - // Type: to.Ptr("Microsoft.BillingBenefits/reservationOrderAliases"), - // ID: to.Ptr("/providers/microsoft.billingbenefits/reservationOrderAliases/reservationOrderAlias123"), - // Properties: &armbillingbenefits.ReservationOrderAliasResponseProperties{ - // AppliedScopeProperties: &armbillingbenefits.AppliedScopeProperties{ - // ResourceGroupID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/testrg"), - // }, - // AppliedScopeType: to.Ptr(armbillingbenefits.AppliedScopeTypeSingle), - // BillingPlan: to.Ptr(armbillingbenefits.BillingPlanP1M), - // BillingScopeID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000"), - // DisplayName: to.Ptr("ReservationOrder_2022-06-02"), - // ProvisioningState: to.Ptr(armbillingbenefits.ProvisioningStateSucceeded), - // Quantity: to.Ptr[int32](5), - // Renew: to.Ptr(true), - // ReservationOrderID: to.Ptr("/providers/Microsoft.Capacity/reservationOrders/30000000-0000-0000-0000-000000000000"), - // ReservedResourceProperties: &armbillingbenefits.ReservationOrderAliasResponsePropertiesReservedResourceProperties{ - // InstanceFlexibility: to.Ptr(armbillingbenefits.InstanceFlexibilityOn), - // }, - // ReservedResourceType: to.Ptr(armbillingbenefits.ReservedResourceTypeVirtualMachines), - // Term: to.Ptr(armbillingbenefits.TermP1Y), - // }, - // SKU: &armbillingbenefits.SKU{ - // Name: to.Ptr("Standard_M64s_v2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/billingbenefits/resource-manager/Microsoft.BillingBenefits/stable/2022-11-01/examples/ReservationOrderAliasGet.json -func ExampleReservationOrderAliasClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbillingbenefits.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewReservationOrderAliasClient().Get(ctx, "reservationOrderAlias123", 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.ReservationOrderAliasResponse = armbillingbenefits.ReservationOrderAliasResponse{ - // Name: to.Ptr("reservationOrderAlias123"), - // Type: to.Ptr("Microsoft.BillingBenefits/reservationOrderAliases"), - // ID: to.Ptr("/providers/microsoft.billingbenefits/reservationOrderAliases/reservationOrderAlias123"), - // Location: to.Ptr("eastus"), - // Properties: &armbillingbenefits.ReservationOrderAliasResponseProperties{ - // AppliedScopeProperties: &armbillingbenefits.AppliedScopeProperties{ - // ResourceGroupID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/testrg"), - // }, - // AppliedScopeType: to.Ptr(armbillingbenefits.AppliedScopeTypeSingle), - // BillingPlan: to.Ptr(armbillingbenefits.BillingPlanP1M), - // BillingScopeID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000"), - // DisplayName: to.Ptr("ReservationOrder_2022-06-02"), - // ProvisioningState: to.Ptr(armbillingbenefits.ProvisioningStateSucceeded), - // Quantity: to.Ptr[int32](5), - // Renew: to.Ptr(true), - // ReservationOrderID: to.Ptr("/providers/Microsoft.Capacity/reservationOrders/30000000-0000-0000-0000-000000000000"), - // ReservedResourceProperties: &armbillingbenefits.ReservationOrderAliasResponsePropertiesReservedResourceProperties{ - // InstanceFlexibility: to.Ptr(armbillingbenefits.InstanceFlexibilityOn), - // }, - // ReservedResourceType: to.Ptr(armbillingbenefits.ReservedResourceTypeVirtualMachines), - // Term: to.Ptr(armbillingbenefits.TermP1Y), - // }, - // SKU: &armbillingbenefits.SKU{ - // Name: to.Ptr("Standard_M64s_v2"), - // }, - // } -} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/response_types.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/responses.go similarity index 67% rename from sdk/resourcemanager/billingbenefits/armbillingbenefits/response_types.go rename to sdk/resourcemanager/billingbenefits/armbillingbenefits/responses.go index c1fff9452532..0251ef080a0c 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/response_types.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/responses.go @@ -1,6 +1,3 @@ -//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. @@ -8,6 +5,53 @@ package armbillingbenefits +// DiscountClientGetResponse contains the response from method DiscountClient.Get. +type DiscountClientGetResponse struct { + // Resource definition for Discounts. + Discount +} + +// DiscountClientUpdateResponse contains the response from method DiscountClient.BeginUpdate. +type DiscountClientUpdateResponse struct { + // Resource definition for Discounts. + Discount +} + +// DiscountsClientCancelResponse contains the response from method DiscountsClient.BeginCancel. +type DiscountsClientCancelResponse struct { + // Resource definition for Discounts. + Discount +} + +// DiscountsClientCreateResponse contains the response from method DiscountsClient.BeginCreate. +type DiscountsClientCreateResponse struct { + // Resource definition for Discounts. + Discount +} + +// DiscountsClientDeleteResponse contains the response from method DiscountsClient.BeginDelete. +type DiscountsClientDeleteResponse struct { + // placeholder for future response values +} + +// DiscountsClientResourceGroupListResponse contains the response from method DiscountsClient.NewResourceGroupListPager. +type DiscountsClientResourceGroupListResponse struct { + // Discount list + DiscountList +} + +// DiscountsClientScopeListResponse contains the response from method DiscountsClient.NewScopeListPager. +type DiscountsClientScopeListResponse struct { + // Discount list + DiscountList +} + +// DiscountsClientSubscriptionListResponse contains the response from method DiscountsClient.NewSubscriptionListPager. +type DiscountsClientSubscriptionListResponse struct { + // Discount list + DiscountList +} + // OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. @@ -47,13 +91,10 @@ type SavingsPlanClientListResponse struct { SavingsPlanModelList } -// SavingsPlanClientUpdateResponse contains the response from method SavingsPlanClient.Update. +// SavingsPlanClientUpdateResponse contains the response from method SavingsPlanClient.BeginUpdate. type SavingsPlanClientUpdateResponse struct { // Savings plan SavingsPlanModel - - // Location contains the information returned from the Location header response. - Location *string } // SavingsPlanClientValidateUpdateResponse contains the response from method SavingsPlanClient.ValidateUpdate. diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/rp_client.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/rp_client.go index 36ab52da3413..986d6640fc56 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/rp_client.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/rp_client.go @@ -1,6 +1,3 @@ -//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. @@ -40,7 +37,7 @@ func NewRPClient(credential azcore.TokenCredential, options *arm.ClientOptions) // ValidatePurchase - Validate savings plan purchase. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-01 +// Generated from API version 2024-11-01-preview // - body - Request body for validating the purchase of a savings plan // - options - RPClientValidatePurchaseOptions contains the optional parameters for the RPClient.ValidatePurchase method. func (client *RPClient) ValidatePurchase(ctx context.Context, body SavingsPlanPurchaseValidateRequest, options *RPClientValidatePurchaseOptions) (RPClientValidatePurchaseResponse, error) { @@ -66,14 +63,14 @@ func (client *RPClient) ValidatePurchase(ctx context.Context, body SavingsPlanPu } // validatePurchaseCreateRequest creates the ValidatePurchase request. -func (client *RPClient) validatePurchaseCreateRequest(ctx context.Context, body SavingsPlanPurchaseValidateRequest, options *RPClientValidatePurchaseOptions) (*policy.Request, error) { +func (client *RPClient) validatePurchaseCreateRequest(ctx context.Context, body SavingsPlanPurchaseValidateRequest, _ *RPClientValidatePurchaseOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.BillingBenefits/validate" 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", "2022-11-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, body); err != nil { diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/rp_client_example_test.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/rp_client_example_test.go deleted file mode 100644 index 07d095d08117..000000000000 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/rp_client_example_test.go +++ /dev/null @@ -1,90 +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 armbillingbenefits_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/billingbenefits/armbillingbenefits/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/billingbenefits/resource-manager/Microsoft.BillingBenefits/stable/2022-11-01/examples/SavingsPlanValidatePurchase.json -func ExampleRPClient_ValidatePurchase() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbillingbenefits.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewRPClient().ValidatePurchase(ctx, armbillingbenefits.SavingsPlanPurchaseValidateRequest{ - Benefits: []*armbillingbenefits.SavingsPlanOrderAliasModel{ - { - Properties: &armbillingbenefits.SavingsPlanOrderAliasProperties{ - AppliedScopeProperties: &armbillingbenefits.AppliedScopeProperties{ - ResourceGroupID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/testrg"), - }, - AppliedScopeType: to.Ptr(armbillingbenefits.AppliedScopeTypeSingle), - BillingScopeID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000"), - Commitment: &armbillingbenefits.Commitment{ - Amount: to.Ptr[float64](15.23), - CurrencyCode: to.Ptr("USD"), - Grain: to.Ptr(armbillingbenefits.CommitmentGrainHourly), - }, - DisplayName: to.Ptr("ComputeSavingsPlan_2021-07-01"), - Term: to.Ptr(armbillingbenefits.TermP1Y), - }, - SKU: &armbillingbenefits.SKU{ - Name: to.Ptr("Compute_Savings_Plan"), - }, - }, - { - Properties: &armbillingbenefits.SavingsPlanOrderAliasProperties{ - AppliedScopeProperties: &armbillingbenefits.AppliedScopeProperties{ - ResourceGroupID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/RG"), - }, - AppliedScopeType: to.Ptr(armbillingbenefits.AppliedScopeTypeSingle), - BillingScopeID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000"), - Commitment: &armbillingbenefits.Commitment{ - Amount: to.Ptr[float64](20), - CurrencyCode: to.Ptr("USD"), - Grain: to.Ptr(armbillingbenefits.CommitmentGrainHourly), - }, - DisplayName: to.Ptr("ComputeSavingsPlan_2021-07-01"), - Term: to.Ptr(armbillingbenefits.TermP1Y), - }, - SKU: &armbillingbenefits.SKU{ - Name: to.Ptr("Compute_Savings_Plan"), - }, - }}, - }, 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 = armbillingbenefits.SavingsPlanValidateResponse{ - // Benefits: []*armbillingbenefits.SavingsPlanValidResponseProperty{ - // { - // Reason: to.Ptr("Your provider has not enabled Savings Plan purchase on this subscription."), - // ReasonCode: to.Ptr("CustomerCannotPurchaseSavingsPlan"), - // Valid: to.Ptr(false), - // }, - // { - // Valid: to.Ptr(true), - // }}, - // } -} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplan_client.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplan_client.go index 46240f0f4c9e..b9ed91906e86 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplan_client.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplan_client.go @@ -1,6 +1,3 @@ -//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. @@ -44,7 +41,7 @@ func NewSavingsPlanClient(credential azcore.TokenCredential, options *arm.Client // Get - Get savings plan. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-01 +// Generated from API version 2024-11-01-preview // - savingsPlanOrderID - Order ID of the savings plan // - savingsPlanID - ID of the savings plan // - options - SavingsPlanClientGetOptions contains the optional parameters for the SavingsPlanClient.Get method. @@ -86,10 +83,10 @@ func (client *SavingsPlanClient) getCreateRequest(ctx context.Context, savingsPl return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-11-01") if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -106,7 +103,7 @@ func (client *SavingsPlanClient) getHandleResponse(resp *http.Response) (Savings // NewListPager - List savings plans in an order. // -// Generated from API version 2022-11-01 +// Generated from API version 2024-11-01-preview // - savingsPlanOrderID - Order ID of the savings plan // - options - SavingsPlanClientListOptions contains the optional parameters for the SavingsPlanClient.NewListPager method. func (client *SavingsPlanClient) NewListPager(savingsPlanOrderID string, options *SavingsPlanClientListOptions) *runtime.Pager[SavingsPlanClientListResponse] { @@ -133,7 +130,7 @@ func (client *SavingsPlanClient) NewListPager(savingsPlanOrderID string, options } // listCreateRequest creates the List request. -func (client *SavingsPlanClient) listCreateRequest(ctx context.Context, savingsPlanOrderID string, options *SavingsPlanClientListOptions) (*policy.Request, error) { +func (client *SavingsPlanClient) listCreateRequest(ctx context.Context, savingsPlanOrderID string, _ *SavingsPlanClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.BillingBenefits/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans" if savingsPlanOrderID == "" { return nil, errors.New("parameter savingsPlanOrderID cannot be empty") @@ -144,7 +141,7 @@ func (client *SavingsPlanClient) listCreateRequest(ctx context.Context, savingsP return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-11-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -161,7 +158,7 @@ func (client *SavingsPlanClient) listHandleResponse(resp *http.Response) (Saving // NewListAllPager - List savings plans. // -// Generated from API version 2022-11-01 +// Generated from API version 2024-11-01-preview // - options - SavingsPlanClientListAllOptions contains the optional parameters for the SavingsPlanClient.NewListAllPager method. func (client *SavingsPlanClient) NewListAllPager(options *SavingsPlanClientListAllOptions) *runtime.Pager[SavingsPlanClientListAllResponse] { return runtime.NewPager(runtime.PagingHandler[SavingsPlanClientListAllResponse]{ @@ -194,19 +191,19 @@ func (client *SavingsPlanClient) listAllCreateRequest(ctx context.Context, optio return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-11-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.Skiptoken != nil { reqQP.Set("$skiptoken", strconv.FormatFloat(float64(*options.Skiptoken), 'f', -1, 32)) } + reqQP.Set("api-version", "2024-11-01-preview") + if options != nil && options.RefreshSummary != nil { + reqQP.Set("refreshSummary", *options.RefreshSummary) + } if options != nil && options.SelectedState != nil { reqQP.Set("selectedState", *options.SelectedState) } @@ -227,38 +224,58 @@ func (client *SavingsPlanClient) listAllHandleResponse(resp *http.Response) (Sav return result, nil } -// Update - Update savings plan. +// BeginUpdate - Update savings plan. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-01 +// Generated from API version 2024-11-01-preview // - savingsPlanOrderID - Order ID of the savings plan // - savingsPlanID - ID of the savings plan // - body - Request body for patching a savings plan order alias -// - options - SavingsPlanClientUpdateOptions contains the optional parameters for the SavingsPlanClient.Update method. -func (client *SavingsPlanClient) Update(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, body SavingsPlanUpdateRequest, options *SavingsPlanClientUpdateOptions) (SavingsPlanClientUpdateResponse, error) { +// - options - SavingsPlanClientBeginUpdateOptions contains the optional parameters for the SavingsPlanClient.BeginUpdate method. +func (client *SavingsPlanClient) BeginUpdate(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, body SavingsPlanUpdateRequest, options *SavingsPlanClientBeginUpdateOptions) (*runtime.Poller[SavingsPlanClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, savingsPlanOrderID, savingsPlanID, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SavingsPlanClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[SavingsPlanClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update savings plan. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *SavingsPlanClient) update(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, body SavingsPlanUpdateRequest, options *SavingsPlanClientBeginUpdateOptions) (*http.Response, error) { var err error - const operationName = "SavingsPlanClient.Update" + const operationName = "SavingsPlanClient.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, savingsPlanOrderID, savingsPlanID, body, options) if err != nil { - return SavingsPlanClientUpdateResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return SavingsPlanClientUpdateResponse{}, err + return nil, err } if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) - return SavingsPlanClientUpdateResponse{}, err + return nil, err } - resp, err := client.updateHandleResponse(httpResp) - return resp, err + return httpResp, nil } // updateCreateRequest creates the Update request. -func (client *SavingsPlanClient) updateCreateRequest(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, body SavingsPlanUpdateRequest, options *SavingsPlanClientUpdateOptions) (*policy.Request, error) { +func (client *SavingsPlanClient) updateCreateRequest(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, body SavingsPlanUpdateRequest, _ *SavingsPlanClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.BillingBenefits/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans/{savingsPlanId}" if savingsPlanOrderID == "" { return nil, errors.New("parameter savingsPlanOrderID cannot be empty") @@ -273,7 +290,7 @@ func (client *SavingsPlanClient) updateCreateRequest(ctx context.Context, saving return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-11-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, body); err != nil { @@ -282,22 +299,10 @@ func (client *SavingsPlanClient) updateCreateRequest(ctx context.Context, saving return req, nil } -// updateHandleResponse handles the Update response. -func (client *SavingsPlanClient) updateHandleResponse(resp *http.Response) (SavingsPlanClientUpdateResponse, error) { - result := SavingsPlanClientUpdateResponse{} - if val := resp.Header.Get("Location"); val != "" { - result.Location = &val - } - if err := runtime.UnmarshalAsJSON(resp, &result.SavingsPlanModel); err != nil { - return SavingsPlanClientUpdateResponse{}, err - } - return result, nil -} - // ValidateUpdate - Validate savings plan patch. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-01 +// Generated from API version 2024-11-01-preview // - savingsPlanOrderID - Order ID of the savings plan // - savingsPlanID - ID of the savings plan // - body - Request body for validating a savings plan patch request @@ -326,7 +331,7 @@ func (client *SavingsPlanClient) ValidateUpdate(ctx context.Context, savingsPlan } // validateUpdateCreateRequest creates the ValidateUpdate request. -func (client *SavingsPlanClient) validateUpdateCreateRequest(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, body SavingsPlanUpdateValidateRequest, options *SavingsPlanClientValidateUpdateOptions) (*policy.Request, error) { +func (client *SavingsPlanClient) validateUpdateCreateRequest(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, body SavingsPlanUpdateValidateRequest, _ *SavingsPlanClientValidateUpdateOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.BillingBenefits/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans/{savingsPlanId}/validate" if savingsPlanOrderID == "" { return nil, errors.New("parameter savingsPlanOrderID cannot be empty") @@ -341,7 +346,7 @@ func (client *SavingsPlanClient) validateUpdateCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-11-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, body); err != nil { diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplan_client_example_test.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplan_client_example_test.go deleted file mode 100644 index fa6d2fa6dcd1..000000000000 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplan_client_example_test.go +++ /dev/null @@ -1,517 +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 armbillingbenefits_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/billingbenefits/armbillingbenefits/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/billingbenefits/resource-manager/Microsoft.BillingBenefits/stable/2022-11-01/examples/SavingsPlansInOrderList.json -func ExampleSavingsPlanClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbillingbenefits.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSavingsPlanClient().NewListPager("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 = armbillingbenefits.SavingsPlanModelList{ - // Value: []*armbillingbenefits.SavingsPlanModel{ - // { - // Name: to.Ptr("20000000-0000-0000-0000-000000000000/30000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.BillingBenefits/savingsPlanOrders/savingsPlans"), - // ID: to.Ptr("/providers/microsoft.billingbenefits/savingsPlanOrders/20000000-0000-0000-0000-000000000000/savingsPlans/30000000-0000-0000-0000-000000000000"), - // Properties: &armbillingbenefits.SavingsPlanModelProperties{ - // AppliedScopeProperties: &armbillingbenefits.AppliedScopeProperties{ - // ResourceGroupID: to.Ptr("/subscriptions/eef82110-c91b-4395-9420-fcfcbefc5a47/resourcegroups/3ppRG"), - // }, - // AppliedScopeType: to.Ptr(armbillingbenefits.AppliedScopeTypeSingle), - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000000:20000000-0000-3000-0000-000000000000_2019-05-31"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000000:20000000-0000-3000-0000-000000000000_2019-05-31/billingProfiles/KPSV-DWNE-BG7-TGB"), - // BillingScopeID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000009"), - // Commitment: &armbillingbenefits.Commitment{ - // Amount: to.Ptr[float64](0.002), - // CurrencyCode: to.Ptr("USD"), - // Grain: to.Ptr(armbillingbenefits.CommitmentGrainHourly), - // }, - // DisplayName: to.Ptr("Compute_SavingsPlan_10-24-2022_15-44"), - // DisplayProvisioningState: to.Ptr("Succeeded"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-24T22:47:04.853Z"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-24T22:47:04.619Z"); return t}()), - // ProvisioningState: to.Ptr(armbillingbenefits.ProvisioningStateSucceeded), - // PurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-24T22:45:13.620Z"); return t}()), - // Renew: to.Ptr(false), - // Term: to.Ptr(armbillingbenefits.TermP1Y), - // UserFriendlyAppliedScopeType: to.Ptr("ResourceGroup"), - // Utilization: &armbillingbenefits.Utilization{ - // Aggregates: []*armbillingbenefits.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(""), - // }, - // }, - // SKU: &armbillingbenefits.SKU{ - // Name: to.Ptr("Compute_Savings_Plan"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/billingbenefits/resource-manager/Microsoft.BillingBenefits/stable/2022-11-01/examples/SavingsPlansList.json -func ExampleSavingsPlanClient_NewListAllPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbillingbenefits.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSavingsPlanClient().NewListAllPager(&armbillingbenefits.SavingsPlanClientListAllOptions{Filter: to.Ptr("(properties%2farchived+eq+false)"), - Orderby: to.Ptr("properties/displayName asc"), - RefreshSummary: nil, - Skiptoken: to.Ptr[float32](50), - SelectedState: nil, - Take: to.Ptr[float32](1), - }) - 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 = armbillingbenefits.SavingsPlanModelListResult{ - // AdditionalProperties: []*armbillingbenefits.SavingsPlanSummary{ - // { - // Name: to.Ptr("summary"), - // Value: &armbillingbenefits.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](1), - // WarningCount: to.Ptr[float32](0), - // }, - // }}, - // Value: []*armbillingbenefits.SavingsPlanModel{ - // { - // Name: to.Ptr("20000000-0000-0000-0000-000000000000/30000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.BillingBenefits/savingsPlanOrders/savingsPlans"), - // ID: to.Ptr("/providers/microsoft.billingbenefits/savingsPlanOrders/20000000-0000-0000-0000-000000000000/savingsPlans/30000000-0000-0000-0000-000000000000"), - // Properties: &armbillingbenefits.SavingsPlanModelProperties{ - // AppliedScopeProperties: &armbillingbenefits.AppliedScopeProperties{ - // DisplayName: to.Ptr("Azure subscription 1"), - // SubscriptionID: to.Ptr("/subscriptions/20000000-0000-0000-0000-000000000005"), - // }, - // AppliedScopeType: to.Ptr(armbillingbenefits.AppliedScopeTypeSingle), - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000000:20000000-0000-3000-0000-000000000000_2019-05-31"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000000:20000000-0000-3000-0000-000000000000_2019-05-31/billingProfiles/KPSV-DWNE-BG7-TGB"), - // BillingScopeID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000009"), - // Commitment: &armbillingbenefits.Commitment{ - // Amount: to.Ptr[float64](0.001), - // CurrencyCode: to.Ptr("USD"), - // Grain: to.Ptr(armbillingbenefits.CommitmentGrainHourly), - // }, - // DisplayName: to.Ptr("Compute_SavingsPlan_10-19-2022_11-03"), - // DisplayProvisioningState: to.Ptr("Succeeded"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-19T18:05:37.103Z"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-10-19T18:05:36.525Z"); return t}()), - // ProvisioningState: to.Ptr(armbillingbenefits.ProvisioningStateSucceeded), - // PurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-19T18:03:56.403Z"); return t}()), - // Renew: to.Ptr(false), - // Term: to.Ptr(armbillingbenefits.TermP1Y), - // UserFriendlyAppliedScopeType: to.Ptr("Single"), - // Utilization: &armbillingbenefits.Utilization{ - // Aggregates: []*armbillingbenefits.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](78), - // ValueUnit: to.Ptr("percentage"), - // }, - // { - // Grain: to.Ptr[float32](30), - // GrainUnit: to.Ptr("days"), - // Value: to.Ptr[float32](78.12), - // ValueUnit: to.Ptr("percentage"), - // }}, - // Trend: to.Ptr(""), - // }, - // }, - // SKU: &armbillingbenefits.SKU{ - // Name: to.Ptr("Compute_Savings_Plan"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/billingbenefits/resource-manager/Microsoft.BillingBenefits/stable/2022-11-01/examples/SavingsPlanItemGet.json -func ExampleSavingsPlanClient_Get_savingsPlanItemGet() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbillingbenefits.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSavingsPlanClient().Get(ctx, "20000000-0000-0000-0000-000000000000", "30000000-0000-0000-0000-000000000000", &armbillingbenefits.SavingsPlanClientGetOptions{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 = armbillingbenefits.SavingsPlanModel{ - // Name: to.Ptr("20000000-0000-0000-0000-000000000000/30000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.BillingBenefits/savingsPlanOrders/savingsPlans"), - // ID: to.Ptr("/providers/microsoft.billingbenefits/savingsPlanOrders/20000000-0000-0000-0000-000000000000/savingsPlans/30000000-0000-0000-0000-000000000000"), - // Properties: &armbillingbenefits.SavingsPlanModelProperties{ - // AppliedScopeType: to.Ptr(armbillingbenefits.AppliedScopeTypeShared), - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000000:20000000-0000-3000-0000-000000000000_2019-05-31"), - // BillingPlan: to.Ptr(armbillingbenefits.BillingPlanP1M), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000000:20000000-0000-3000-0000-000000000000_2019-05-31/billingProfiles/KPSV-DWNE-BG7-TGB"), - // BillingScopeID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000009"), - // Commitment: &armbillingbenefits.Commitment{ - // Amount: to.Ptr[float64](0.001), - // CurrencyCode: to.Ptr("USD"), - // Grain: to.Ptr(armbillingbenefits.CommitmentGrainHourly), - // }, - // DisplayName: to.Ptr("Compute_SavingsPlan_patch_rename2"), - // DisplayProvisioningState: to.Ptr("Succeeded"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-21T18:15:42.409Z"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-10-18T21:16:13.185Z"); return t}()), - // ProvisioningState: to.Ptr(armbillingbenefits.ProvisioningStateSucceeded), - // PurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-18T21:14:26.827Z"); return t}()), - // Renew: to.Ptr(true), - // Term: to.Ptr(armbillingbenefits.TermP3Y), - // UserFriendlyAppliedScopeType: to.Ptr("Shared"), - // Utilization: &armbillingbenefits.Utilization{ - // Aggregates: []*armbillingbenefits.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](84), - // ValueUnit: to.Ptr("percentage"), - // }, - // { - // Grain: to.Ptr[float32](30), - // GrainUnit: to.Ptr("days"), - // Value: to.Ptr[float32](83.87), - // ValueUnit: to.Ptr("percentage"), - // }}, - // Trend: to.Ptr(""), - // }, - // }, - // SKU: &armbillingbenefits.SKU{ - // Name: to.Ptr("Compute_Savings_Plan"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/billingbenefits/resource-manager/Microsoft.BillingBenefits/stable/2022-11-01/examples/SavingsPlanItemExpandedGet.json -func ExampleSavingsPlanClient_Get_savingsPlanItemWithExpandedRenewPropertiesGet() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbillingbenefits.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSavingsPlanClient().Get(ctx, "20000000-0000-0000-0000-000000000000", "30000000-0000-0000-0000-000000000000", &armbillingbenefits.SavingsPlanClientGetOptions{Expand: to.Ptr("renewProperties")}) - 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 = armbillingbenefits.SavingsPlanModel{ - // Name: to.Ptr("20000000-0000-0000-0000-000000000000/30000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.BillingBenefits/savingsPlanOrders/savingsPlans"), - // ID: to.Ptr("/providers/microsoft.billingbenefits/savingsPlanOrders/20000000-0000-0000-0000-000000000000/savingsPlans/30000000-0000-0000-0000-000000000000"), - // Properties: &armbillingbenefits.SavingsPlanModelProperties{ - // AppliedScopeType: to.Ptr(armbillingbenefits.AppliedScopeTypeShared), - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000000:20000000-0000-3000-0000-000000000000_2019-05-31"), - // BillingPlan: to.Ptr(armbillingbenefits.BillingPlanP1M), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000000:20000000-0000-3000-0000-000000000000_2019-05-31/billingProfiles/KPSV-DWNE-BG7-TGB"), - // BillingScopeID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000009"), - // Commitment: &armbillingbenefits.Commitment{ - // Amount: to.Ptr[float64](0.001), - // CurrencyCode: to.Ptr("USD"), - // Grain: to.Ptr(armbillingbenefits.CommitmentGrainHourly), - // }, - // DisplayName: to.Ptr("Compute_SavingsPlan_patch_rename2"), - // DisplayProvisioningState: to.Ptr("Succeeded"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-21T18:15:42.409Z"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-10-18T21:16:13.185Z"); return t}()), - // ProvisioningState: to.Ptr(armbillingbenefits.ProvisioningStateSucceeded), - // PurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-18T21:14:26.827Z"); return t}()), - // Renew: to.Ptr(true), - // RenewProperties: &armbillingbenefits.RenewProperties{ - // PurchaseProperties: &armbillingbenefits.PurchaseRequest{ - // Properties: &armbillingbenefits.PurchaseRequestProperties{ - // AppliedScopeType: to.Ptr(armbillingbenefits.AppliedScopeTypeShared), - // BillingPlan: to.Ptr(armbillingbenefits.BillingPlan("Upfront")), - // BillingScopeID: to.Ptr("/subscriptions/eef82110-c91b-4395-9420-fcfcbefc5a47"), - // Commitment: &armbillingbenefits.Commitment{ - // Amount: to.Ptr[float64](0.001), - // CurrencyCode: to.Ptr("USD"), - // Grain: to.Ptr(armbillingbenefits.CommitmentGrainHourly), - // }, - // DisplayName: to.Ptr("Compute_SavingsPlan_patch_rename2_renewed"), - // Term: to.Ptr(armbillingbenefits.TermP1Y), - // }, - // SKU: &armbillingbenefits.SKU{ - // Name: to.Ptr("Compute_Savings_Plan"), - // }, - // }, - // }, - // Term: to.Ptr(armbillingbenefits.TermP3Y), - // UserFriendlyAppliedScopeType: to.Ptr("Shared"), - // Utilization: &armbillingbenefits.Utilization{ - // Aggregates: []*armbillingbenefits.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](84), - // ValueUnit: to.Ptr("percentage"), - // }, - // { - // Grain: to.Ptr[float32](30), - // GrainUnit: to.Ptr("days"), - // Value: to.Ptr[float32](83.87), - // ValueUnit: to.Ptr("percentage"), - // }}, - // Trend: to.Ptr(""), - // }, - // }, - // SKU: &armbillingbenefits.SKU{ - // Name: to.Ptr("Compute_Savings_Plan"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/billingbenefits/resource-manager/Microsoft.BillingBenefits/stable/2022-11-01/examples/SavingsPlanUpdate.json -func ExampleSavingsPlanClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbillingbenefits.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSavingsPlanClient().Update(ctx, "20000000-0000-0000-0000-000000000000", "30000000-0000-0000-0000-000000000000", armbillingbenefits.SavingsPlanUpdateRequest{ - Properties: &armbillingbenefits.SavingsPlanUpdateRequestProperties{ - AppliedScopeProperties: &armbillingbenefits.AppliedScopeProperties{ - ResourceGroupID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/testrg"), - }, - AppliedScopeType: to.Ptr(armbillingbenefits.AppliedScopeTypeSingle), - DisplayName: to.Ptr("TestDisplayName"), - Renew: to.Ptr(true), - RenewProperties: &armbillingbenefits.RenewProperties{ - PurchaseProperties: &armbillingbenefits.PurchaseRequest{ - Properties: &armbillingbenefits.PurchaseRequestProperties{ - AppliedScopeProperties: &armbillingbenefits.AppliedScopeProperties{ - ResourceGroupID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/testrg"), - }, - AppliedScopeType: to.Ptr(armbillingbenefits.AppliedScopeTypeSingle), - BillingPlan: to.Ptr(armbillingbenefits.BillingPlanP1M), - BillingScopeID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000"), - Commitment: &armbillingbenefits.Commitment{ - Amount: to.Ptr[float64](15.23), - CurrencyCode: to.Ptr("USD"), - Grain: to.Ptr(armbillingbenefits.CommitmentGrainHourly), - }, - DisplayName: to.Ptr("TestDisplayName_renewed"), - Renew: to.Ptr(false), - Term: to.Ptr(armbillingbenefits.TermP1Y), - }, - SKU: &armbillingbenefits.SKU{ - Name: to.Ptr("Compute_Savings_Plan"), - }, - }, - }, - }, - }, 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 = armbillingbenefits.SavingsPlanModel{ - // Name: to.Ptr("30000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("microsoft.billingbenefits/savingsPlanOrders/savingsPlans"), - // ID: to.Ptr("/providers/microsoft.billingbenefits/savingsPlanOrders/20000000-0000-0000-0000-000000000000/savingsPlans/30000000-0000-0000-0000-000000000000"), - // Properties: &armbillingbenefits.SavingsPlanModelProperties{ - // AppliedScopeProperties: &armbillingbenefits.AppliedScopeProperties{ - // DisplayName: to.Ptr("Azure subscription 1"), - // SubscriptionID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000"), - // }, - // AppliedScopeType: to.Ptr(armbillingbenefits.AppliedScopeTypeSingle), - // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-27T00:34:33.669Z"); return t}()), - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000000:20000000-0000-3000-0000-000000000000_2019-05-31"), - // BillingPlan: to.Ptr(armbillingbenefits.BillingPlanP1M), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000000:20000000-0000-3000-0000-000000000000_2019-05-31/billingProfiles/KPSV-DWNE-BG7-TGB"), - // BillingScopeID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000"), - // Commitment: &armbillingbenefits.Commitment{ - // Amount: to.Ptr[float64](0.001), - // CurrencyCode: to.Ptr("USD"), - // Grain: to.Ptr(armbillingbenefits.CommitmentGrainHourly), - // }, - // DisplayName: to.Ptr("riName"), - // DisplayProvisioningState: to.Ptr("Succeeded"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-10T00:12:54.549Z"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-10-27T00:34:33.669Z"); return t}()), - // ProvisioningState: to.Ptr(armbillingbenefits.ProvisioningStateSucceeded), - // PurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-27T00:32:45.582Z"); return t}()), - // Renew: to.Ptr(true), - // Term: to.Ptr(armbillingbenefits.TermP3Y), - // UserFriendlyAppliedScopeType: to.Ptr("Single"), - // Utilization: &armbillingbenefits.Utilization{ - // Aggregates: []*armbillingbenefits.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](37), - // ValueUnit: to.Ptr("percentage"), - // }, - // { - // Grain: to.Ptr[float32](30), - // GrainUnit: to.Ptr("days"), - // Value: to.Ptr[float32](53.85), - // ValueUnit: to.Ptr("percentage"), - // }}, - // Trend: to.Ptr("DOWN"), - // }, - // }, - // SKU: &armbillingbenefits.SKU{ - // Name: to.Ptr("Compute_Savings_Plan"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/billingbenefits/resource-manager/Microsoft.BillingBenefits/stable/2022-11-01/examples/SavingsPlanValidateUpdate.json -func ExampleSavingsPlanClient_ValidateUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbillingbenefits.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSavingsPlanClient().ValidateUpdate(ctx, "20000000-0000-0000-0000-000000000000", "30000000-0000-0000-0000-000000000000", armbillingbenefits.SavingsPlanUpdateValidateRequest{ - Benefits: []*armbillingbenefits.SavingsPlanUpdateRequestProperties{ - { - AppliedScopeProperties: &armbillingbenefits.AppliedScopeProperties{ - ManagementGroupID: to.Ptr("/providers/Microsoft.Management/managementGroups/30000000-0000-0000-0000-000000000100"), - TenantID: to.Ptr("30000000-0000-0000-0000-000000000100"), - }, - AppliedScopeType: to.Ptr(armbillingbenefits.AppliedScopeTypeManagementGroup), - }, - { - AppliedScopeProperties: &armbillingbenefits.AppliedScopeProperties{ - ManagementGroupID: to.Ptr("/providers/Microsoft.Management/managementGroups/MockMG"), - TenantID: to.Ptr("30000000-0000-0000-0000-000000000100"), - }, - AppliedScopeType: to.Ptr(armbillingbenefits.AppliedScopeTypeManagementGroup), - }}, - }, 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 = armbillingbenefits.SavingsPlanValidateResponse{ - // Benefits: []*armbillingbenefits.SavingsPlanValidResponseProperty{ - // { - // Valid: to.Ptr(true), - // }, - // { - // Valid: to.Ptr(true), - // }}, - // } -} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorder_client.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorder_client.go index ce89f341c109..f6914c2625fb 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorder_client.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorder_client.go @@ -1,6 +1,3 @@ -//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. @@ -43,7 +40,7 @@ func NewSavingsPlanOrderClient(credential azcore.TokenCredential, options *arm.C // Elevate - Elevate as owner on savings plan order based on billing permissions. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-01 +// Generated from API version 2024-11-01-preview // - savingsPlanOrderID - Order ID of the savings plan // - options - SavingsPlanOrderClientElevateOptions contains the optional parameters for the SavingsPlanOrderClient.Elevate // method. @@ -70,7 +67,7 @@ func (client *SavingsPlanOrderClient) Elevate(ctx context.Context, savingsPlanOr } // elevateCreateRequest creates the Elevate request. -func (client *SavingsPlanOrderClient) elevateCreateRequest(ctx context.Context, savingsPlanOrderID string, options *SavingsPlanOrderClientElevateOptions) (*policy.Request, error) { +func (client *SavingsPlanOrderClient) elevateCreateRequest(ctx context.Context, savingsPlanOrderID string, _ *SavingsPlanOrderClientElevateOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.BillingBenefits/savingsPlanOrders/{savingsPlanOrderId}/elevate" if savingsPlanOrderID == "" { return nil, errors.New("parameter savingsPlanOrderID cannot be empty") @@ -81,7 +78,7 @@ func (client *SavingsPlanOrderClient) elevateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-11-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -99,7 +96,7 @@ func (client *SavingsPlanOrderClient) elevateHandleResponse(resp *http.Response) // Get - Get a savings plan order. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-01 +// Generated from API version 2024-11-01-preview // - savingsPlanOrderID - Order ID of the savings plan // - options - SavingsPlanOrderClientGetOptions contains the optional parameters for the SavingsPlanOrderClient.Get method. func (client *SavingsPlanOrderClient) Get(ctx context.Context, savingsPlanOrderID string, options *SavingsPlanOrderClientGetOptions) (SavingsPlanOrderClientGetResponse, error) { @@ -136,10 +133,10 @@ func (client *SavingsPlanOrderClient) getCreateRequest(ctx context.Context, savi return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-11-01") if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -156,7 +153,7 @@ func (client *SavingsPlanOrderClient) getHandleResponse(resp *http.Response) (Sa // NewListPager - List all Savings plan orders. // -// Generated from API version 2022-11-01 +// Generated from API version 2024-11-01-preview // - options - SavingsPlanOrderClientListOptions contains the optional parameters for the SavingsPlanOrderClient.NewListPager // method. func (client *SavingsPlanOrderClient) NewListPager(options *SavingsPlanOrderClientListOptions) *runtime.Pager[SavingsPlanOrderClientListResponse] { @@ -183,14 +180,14 @@ func (client *SavingsPlanOrderClient) NewListPager(options *SavingsPlanOrderClie } // listCreateRequest creates the List request. -func (client *SavingsPlanOrderClient) listCreateRequest(ctx context.Context, options *SavingsPlanOrderClientListOptions) (*policy.Request, error) { +func (client *SavingsPlanOrderClient) listCreateRequest(ctx context.Context, _ *SavingsPlanOrderClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.BillingBenefits/savingsPlanOrders" 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", "2022-11-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorder_client_example_test.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorder_client_example_test.go deleted file mode 100644 index 56395c67a46d..000000000000 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorder_client_example_test.go +++ /dev/null @@ -1,478 +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 armbillingbenefits_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/billingbenefits/armbillingbenefits/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/billingbenefits/resource-manager/Microsoft.BillingBenefits/stable/2022-11-01/examples/SavingsPlanOrderGet.json -func ExampleSavingsPlanOrderClient_Get_savingsPlanOrderGet() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbillingbenefits.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSavingsPlanOrderClient().Get(ctx, "20000000-0000-0000-0000-000000000000", &armbillingbenefits.SavingsPlanOrderClientGetOptions{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 = armbillingbenefits.SavingsPlanOrderModel{ - // Name: to.Ptr("20000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.BillingBenefits/savingsPlanOrders"), - // ID: to.Ptr("/providers/microsoft.billingbenefits/savingsPlanOrders/20000000-0000-0000-0000-000000000000"), - // Properties: &armbillingbenefits.SavingsPlanOrderModelProperties{ - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000000:20000000-0000-3000-0000-000000000000_2019-05-31"), - // BillingPlan: to.Ptr(armbillingbenefits.BillingPlanP1M), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000000:20000000-0000-3000-0000-000000000000_2019-05-31/billingProfiles/KPSV-DWNE-BG7-TGB"), - // BillingScopeID: to.Ptr("20000000-0000-0000-0000-000000000005"), - // DisplayName: to.Ptr("Compute_SavingsPlan_10-19-2022_11-01"), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-10-19T18:03:55.251Z"); return t}()), - // ProvisioningState: to.Ptr(armbillingbenefits.ProvisioningStateSucceeded), - // SavingsPlans: []*string{ - // to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/20000000-0000-0000-0000-000000000000/savingsPlans/30000000-0000-0000-0000-000000000000")}, - // Term: to.Ptr(armbillingbenefits.TermP3Y), - // }, - // SKU: &armbillingbenefits.SKU{ - // Name: to.Ptr("Compute_Savings_Plan"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/billingbenefits/resource-manager/Microsoft.BillingBenefits/stable/2022-11-01/examples/SavingsPlanOrderExpandedGet.json -func ExampleSavingsPlanOrderClient_Get_savingsPlanOrderWithExpandedPaymentsGet() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbillingbenefits.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSavingsPlanOrderClient().Get(ctx, "20000000-0000-0000-0000-000000000000", &armbillingbenefits.SavingsPlanOrderClientGetOptions{Expand: to.Ptr("schedule")}) - 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 = armbillingbenefits.SavingsPlanOrderModel{ - // Name: to.Ptr("20000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.BillingBenefits/savingsPlanOrders"), - // ID: to.Ptr("/providers/microsoft.billingbenefits/savingsPlanOrders/20000000-0000-0000-0000-000000000000"), - // Properties: &armbillingbenefits.SavingsPlanOrderModelProperties{ - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000000:20000000-0000-3000-0000-000000000000_2019-05-31"), - // BillingPlan: to.Ptr(armbillingbenefits.BillingPlanP1M), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000000:20000000-0000-3000-0000-000000000000_2019-05-31/billingProfiles/KPSV-DWNE-BG7-TGB"), - // BillingScopeID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234567/billingSubscriptions/30000000-0000-0000-0000-000000000003"), - // DisplayName: to.Ptr("Compute_SavingsPlan_10-19-2022_11-01"), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-10-19T18:03:55.251Z"); return t}()), - // PlanInformation: &armbillingbenefits.BillingPlanInformation{ - // NextPaymentDueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-11-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](26.28), - // CurrencyCode: to.Ptr("USD"), - // }, - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-10-19"); return t}()), - // Transactions: []*armbillingbenefits.PaymentDetail{ - // { - // BillingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-10-19"); return t}()), - // PaymentDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-10-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatus("Completed")), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-11-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2022-12-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-01-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-02-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-03-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-04-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-05-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-06-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-07-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-08-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-09-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-10-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-11-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-12-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-01-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-02-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-03-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-04-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-05-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-06-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-07-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-08-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-09-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-10-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-11-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2024-12-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2025-01-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2025-02-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2025-03-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2025-04-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2025-05-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2025-06-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2025-07-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2025-08-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2025-09-19"); return t}()), - // PricingCurrencyTotal: &armbillingbenefits.Price{ - // Amount: to.Ptr[float64](0.73), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armbillingbenefits.PaymentStatusScheduled), - // }}, - // }, - // ProvisioningState: to.Ptr(armbillingbenefits.ProvisioningStateSucceeded), - // SavingsPlans: []*string{ - // to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/20000000-0000-0000-0000-000000000000/savingsPlans/30000000-0000-0000-0000-000000000000")}, - // Term: to.Ptr(armbillingbenefits.TermP3Y), - // }, - // SKU: &armbillingbenefits.SKU{ - // Name: to.Ptr("Compute_Savings_Plan"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/billingbenefits/resource-manager/Microsoft.BillingBenefits/stable/2022-11-01/examples/SavingsPlanOrderElevate.json -func ExampleSavingsPlanOrderClient_Elevate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbillingbenefits.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSavingsPlanOrderClient().Elevate(ctx, "20000000-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.RoleAssignmentEntity = armbillingbenefits.RoleAssignmentEntity{ - // Name: to.Ptr("70000000-0000-0000-0000-000000000005"), - // ID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/20000000-0000-0000-0000-000000000009/providers/Microsoft.Authorization/roleAssignments/70000000-0000-0000-0000-000000000005"), - // Properties: &armbillingbenefits.RoleAssignmentEntityProperties{ - // PrincipalID: to.Ptr("50000000-0000-0000-0000-000000000000"), - // RoleDefinitionID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/20000000-0000-0000-0000-000000000009/providers/Microsoft.Authorization/roleDefinitions/30000000-0000-0000-0000-000000000008"), - // Scope: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/20000000-0000-0000-0000-000000000009"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/billingbenefits/resource-manager/Microsoft.BillingBenefits/stable/2022-11-01/examples/SavingsPlanOrderList.json -func ExampleSavingsPlanOrderClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbillingbenefits.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSavingsPlanOrderClient().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.SavingsPlanOrderModelList = armbillingbenefits.SavingsPlanOrderModelList{ - // Value: []*armbillingbenefits.SavingsPlanOrderModel{ - // { - // Name: to.Ptr("20000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.BillingBenefits/savingsPlanOrders"), - // ID: to.Ptr("/providers/microsoft.billingbenefits/savingsPlanOrders/20000000-0000-0000-0000-000000000000"), - // Properties: &armbillingbenefits.SavingsPlanOrderModelProperties{ - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000004:20000000-0000-3000-0000-000000000000_2019-05-31"), - // BillingPlan: to.Ptr(armbillingbenefits.BillingPlanP1M), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000004:20000000-0000-3000-0000-000000000000_2019-05-31/billingProfiles/KPSV-DWNE-BG7-TGB"), - // BillingScopeID: to.Ptr("20000000-0000-0000-0000-000000000005"), - // DisplayName: to.Ptr("Compute_SavingsPlan_10-28-2022_16-38"), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-10-28T23:40:30.602Z"); return t}()), - // ProvisioningState: to.Ptr(armbillingbenefits.ProvisioningStateSucceeded), - // SavingsPlans: []*string{ - // to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/20000000-0000-0000-0000-000000000000/savingsPlans/20000000-0000-0000-0000-000000000001")}, - // Term: to.Ptr(armbillingbenefits.TermP3Y), - // }, - // SKU: &armbillingbenefits.SKU{ - // Name: to.Ptr("Compute_Savings_Plan"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorderalias_client.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorderalias_client.go index a83d6c2c225a..69477d10edc5 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorderalias_client.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorderalias_client.go @@ -1,6 +1,3 @@ -//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. @@ -43,7 +40,7 @@ func NewSavingsPlanOrderAliasClient(credential azcore.TokenCredential, options * // BeginCreate - Create a savings plan. Learn more about permissions needed at https://go.microsoft.com/fwlink/?linkid=2215851 // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-01 +// Generated from API version 2024-11-01-preview // - savingsPlanOrderAliasName - Name of the savings plan order alias // - body - Request body for creating a savings plan order alias // - options - SavingsPlanOrderAliasClientBeginCreateOptions contains the optional parameters for the SavingsPlanOrderAliasClient.BeginCreate @@ -69,7 +66,7 @@ func (client *SavingsPlanOrderAliasClient) BeginCreate(ctx context.Context, savi // Create - Create a savings plan. Learn more about permissions needed at https://go.microsoft.com/fwlink/?linkid=2215851 // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-01 +// Generated from API version 2024-11-01-preview func (client *SavingsPlanOrderAliasClient) create(ctx context.Context, savingsPlanOrderAliasName string, body SavingsPlanOrderAliasModel, options *SavingsPlanOrderAliasClientBeginCreateOptions) (*http.Response, error) { var err error const operationName = "SavingsPlanOrderAliasClient.BeginCreate" @@ -92,7 +89,7 @@ func (client *SavingsPlanOrderAliasClient) create(ctx context.Context, savingsPl } // createCreateRequest creates the Create request. -func (client *SavingsPlanOrderAliasClient) createCreateRequest(ctx context.Context, savingsPlanOrderAliasName string, body SavingsPlanOrderAliasModel, options *SavingsPlanOrderAliasClientBeginCreateOptions) (*policy.Request, error) { +func (client *SavingsPlanOrderAliasClient) createCreateRequest(ctx context.Context, savingsPlanOrderAliasName string, body SavingsPlanOrderAliasModel, _ *SavingsPlanOrderAliasClientBeginCreateOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.BillingBenefits/savingsPlanOrderAliases/{savingsPlanOrderAliasName}" if savingsPlanOrderAliasName == "" { return nil, errors.New("parameter savingsPlanOrderAliasName cannot be empty") @@ -103,7 +100,7 @@ func (client *SavingsPlanOrderAliasClient) createCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-11-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, body); err != nil { @@ -115,7 +112,7 @@ func (client *SavingsPlanOrderAliasClient) createCreateRequest(ctx context.Conte // Get - Get a savings plan. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-01 +// Generated from API version 2024-11-01-preview // - savingsPlanOrderAliasName - Name of the savings plan order alias // - options - SavingsPlanOrderAliasClientGetOptions contains the optional parameters for the SavingsPlanOrderAliasClient.Get // method. @@ -142,7 +139,7 @@ func (client *SavingsPlanOrderAliasClient) Get(ctx context.Context, savingsPlanO } // getCreateRequest creates the Get request. -func (client *SavingsPlanOrderAliasClient) getCreateRequest(ctx context.Context, savingsPlanOrderAliasName string, options *SavingsPlanOrderAliasClientGetOptions) (*policy.Request, error) { +func (client *SavingsPlanOrderAliasClient) getCreateRequest(ctx context.Context, savingsPlanOrderAliasName string, _ *SavingsPlanOrderAliasClientGetOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.BillingBenefits/savingsPlanOrderAliases/{savingsPlanOrderAliasName}" if savingsPlanOrderAliasName == "" { return nil, errors.New("parameter savingsPlanOrderAliasName cannot be empty") @@ -153,7 +150,7 @@ func (client *SavingsPlanOrderAliasClient) getCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-11-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorderalias_client_example_test.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorderalias_client_example_test.go deleted file mode 100644 index a76dcd39d037..000000000000 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorderalias_client_example_test.go +++ /dev/null @@ -1,194 +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 armbillingbenefits_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/billingbenefits/armbillingbenefits/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/billingbenefits/resource-manager/Microsoft.BillingBenefits/stable/2022-11-01/examples/SavingsPlanOrderAliasCreate.json -func ExampleSavingsPlanOrderAliasClient_BeginCreate_savingsPlanOrderAliasCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbillingbenefits.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewSavingsPlanOrderAliasClient().BeginCreate(ctx, "spAlias123", armbillingbenefits.SavingsPlanOrderAliasModel{ - Properties: &armbillingbenefits.SavingsPlanOrderAliasProperties{ - AppliedScopeType: to.Ptr(armbillingbenefits.AppliedScopeTypeShared), - BillingPlan: to.Ptr(armbillingbenefits.BillingPlanP1M), - BillingScopeID: to.Ptr("/subscriptions/30000000-0000-0000-0000-000000000000"), - Commitment: &armbillingbenefits.Commitment{ - Amount: to.Ptr[float64](0.001), - CurrencyCode: to.Ptr("USD"), - Grain: to.Ptr(armbillingbenefits.CommitmentGrainHourly), - }, - DisplayName: to.Ptr("Compute_SavingsPlan_10-28-2022_16-38"), - Term: to.Ptr(armbillingbenefits.TermP3Y), - }, - SKU: &armbillingbenefits.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.SavingsPlanOrderAliasModel = armbillingbenefits.SavingsPlanOrderAliasModel{ - // Name: to.Ptr("SavingsPlan_1667000324595"), - // Type: to.Ptr("Microsoft.BillingBenefits/savingsPlanOrderAliases"), - // ID: to.Ptr("/providers/microsoft.billingbenefits/savingsPlanOrderAliases/SavingsPlan_1667000324595"), - // Properties: &armbillingbenefits.SavingsPlanOrderAliasProperties{ - // AppliedScopeType: to.Ptr(armbillingbenefits.AppliedScopeTypeShared), - // BillingPlan: to.Ptr(armbillingbenefits.BillingPlanP1M), - // BillingScopeID: to.Ptr("/subscriptions/30000000-0000-0000-0000-000000000000"), - // Commitment: &armbillingbenefits.Commitment{ - // Amount: to.Ptr[float64](0.001), - // CurrencyCode: to.Ptr("USD"), - // Grain: to.Ptr(armbillingbenefits.CommitmentGrainHourly), - // }, - // DisplayName: to.Ptr("Compute_SavingsPlan_10-28-2022_16-38"), - // ProvisioningState: to.Ptr(armbillingbenefits.ProvisioningStateSucceeded), - // SavingsPlanOrderID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/30000000-0000-0000-0000-000000000023"), - // Term: to.Ptr(armbillingbenefits.TermP3Y), - // }, - // SKU: &armbillingbenefits.SKU{ - // Name: to.Ptr("Compute_Savings_Plan"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/billingbenefits/resource-manager/Microsoft.BillingBenefits/stable/2022-11-01/examples/SavingsPlanOrderAliasCreateSingleScope.json -func ExampleSavingsPlanOrderAliasClient_BeginCreate_savingsPlanOrderAliasCreateSingleScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbillingbenefits.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewSavingsPlanOrderAliasClient().BeginCreate(ctx, "spAlias123", armbillingbenefits.SavingsPlanOrderAliasModel{ - Properties: &armbillingbenefits.SavingsPlanOrderAliasProperties{ - AppliedScopeProperties: &armbillingbenefits.AppliedScopeProperties{ - SubscriptionID: to.Ptr("/subscriptions/30000000-0000-0000-0000-000000000000"), - }, - AppliedScopeType: to.Ptr(armbillingbenefits.AppliedScopeTypeSingle), - BillingPlan: to.Ptr(armbillingbenefits.BillingPlanP1M), - BillingScopeID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234567/billingSubscriptions/30000000-0000-0000-0000-000000000000"), - Commitment: &armbillingbenefits.Commitment{ - Amount: to.Ptr[float64](0.001), - CurrencyCode: to.Ptr("USD"), - Grain: to.Ptr(armbillingbenefits.CommitmentGrainHourly), - }, - DisplayName: to.Ptr("Compute_SavingsPlan_10-28-2022_16-38"), - Term: to.Ptr(armbillingbenefits.TermP3Y), - }, - SKU: &armbillingbenefits.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.SavingsPlanOrderAliasModel = armbillingbenefits.SavingsPlanOrderAliasModel{ - // Name: to.Ptr("SavingsPlan_1667000324595"), - // Type: to.Ptr("Microsoft.BillingBenefits/savingsPlanOrderAliases"), - // ID: to.Ptr("/providers/microsoft.billingbenefits/savingsPlanOrderAliases/SavingsPlan_1667000324595"), - // Properties: &armbillingbenefits.SavingsPlanOrderAliasProperties{ - // AppliedScopeProperties: &armbillingbenefits.AppliedScopeProperties{ - // SubscriptionID: to.Ptr("/subscriptions/30000000-0000-0000-0000-000000000000"), - // }, - // AppliedScopeType: to.Ptr(armbillingbenefits.AppliedScopeTypeSingle), - // BillingPlan: to.Ptr(armbillingbenefits.BillingPlanP1M), - // BillingScopeID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234567/billingSubscriptions/30000000-0000-0000-0000-000000000000"), - // Commitment: &armbillingbenefits.Commitment{ - // Amount: to.Ptr[float64](0.001), - // CurrencyCode: to.Ptr("USD"), - // Grain: to.Ptr(armbillingbenefits.CommitmentGrainHourly), - // }, - // DisplayName: to.Ptr("Compute_SavingsPlan_10-28-2022_16-38"), - // ProvisioningState: to.Ptr(armbillingbenefits.ProvisioningStateSucceeded), - // SavingsPlanOrderID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/30000000-0000-0000-0000-000000000023"), - // Term: to.Ptr(armbillingbenefits.TermP3Y), - // }, - // SKU: &armbillingbenefits.SKU{ - // Name: to.Ptr("Compute_Savings_Plan"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/billingbenefits/resource-manager/Microsoft.BillingBenefits/stable/2022-11-01/examples/SavingsPlanOrderAliasGet.json -func ExampleSavingsPlanOrderAliasClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbillingbenefits.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSavingsPlanOrderAliasClient().Get(ctx, "spAlias123", 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.SavingsPlanOrderAliasModel = armbillingbenefits.SavingsPlanOrderAliasModel{ - // Name: to.Ptr("spAlias123"), - // Type: to.Ptr("Microsoft.BillingBenefits/savingsPlanOrderAliases"), - // ID: to.Ptr("/providers/microsoft.billingbenefits/savingsPlanOrderAliases/spAlias123"), - // Properties: &armbillingbenefits.SavingsPlanOrderAliasProperties{ - // AppliedScopeProperties: &armbillingbenefits.AppliedScopeProperties{ - // ResourceGroupID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/testrg"), - // }, - // AppliedScopeType: to.Ptr(armbillingbenefits.AppliedScopeTypeSingle), - // BillingPlan: to.Ptr(armbillingbenefits.BillingPlanP1M), - // BillingScopeID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000"), - // Commitment: &armbillingbenefits.Commitment{ - // Amount: to.Ptr[float64](15.23), - // CurrencyCode: to.Ptr("USD"), - // Grain: to.Ptr(armbillingbenefits.CommitmentGrainHourly), - // }, - // DisplayName: to.Ptr("ComputeSavingsPlan_2021-07-01"), - // ProvisioningState: to.Ptr(armbillingbenefits.ProvisioningStateSucceeded), - // SavingsPlanOrderID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/30000000-0000-0000-0000-000000000000"), - // Term: to.Ptr(armbillingbenefits.TermP1Y), - // }, - // SKU: &armbillingbenefits.SKU{ - // Name: to.Ptr("Compute_Savings_Plan"), - // }, - // } -} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/time_rfc3339.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/time_rfc3339.go index f1fc4176255a..cc9d6299e3e3 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/time_rfc3339.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/time_rfc3339.go @@ -1,6 +1,3 @@ -//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. @@ -19,12 +16,16 @@ import ( ) // 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 +41,36 @@ 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) { + if len(data) == 0 { + return nil + } + 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 +81,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 +98,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