From 0730323eb608c19a08a32953930e1f82bdf17842 Mon Sep 17 00:00:00 2001 From: ReleaseHelper Date: Thu, 24 Nov 2022 01:06:02 +0000 Subject: [PATCH 1/2] [Release] sdk/resourcemanager/billingbenefits/armbillingbenefits/1.0.0 generation from spec commit: 59dd84dbde43f134f8a0369e6cc40b5d1df6fbbe --- .../armbillingbenefits/CHANGELOG.md | 7 + .../armbillingbenefits/LICENSE.txt | 21 + .../armbillingbenefits/README.md | 77 + .../armbillingbenefits/autorest.md | 13 + .../armbillingbenefits/build.go | 7 + .../billingbenefits/armbillingbenefits/ci.yml | 28 + .../armbillingbenefits/constants.go | 260 +++ .../armbillingbenefits/date_type.go | 60 + .../billingbenefits/armbillingbenefits/go.mod | 21 + .../billingbenefits/armbillingbenefits/go.sum | 30 + .../armbillingbenefits/models.go | 803 ++++++++ .../armbillingbenefits/models_serde.go | 1799 +++++++++++++++++ .../armbillingbenefits/operations_client.go | 104 + .../operations_client_example_test.go | 41 + .../reservationorderalias_client.go | 158 ++ ...servationorderalias_client_example_test.go | 81 + .../armbillingbenefits/response_types.go | 82 + .../armbillingbenefits/rp_client.go | 93 + .../rp_client_example_test.go | 77 + .../armbillingbenefits/savingsplan_client.go | 353 ++++ .../savingsplan_client_example_test.go | 196 ++ .../savingsplanorder_client.go | 208 ++ .../savingsplanorder_client_example_test.go | 99 + .../savingsplanorderalias_client.go | 158 ++ ...vingsplanorderalias_client_example_test.go | 118 ++ .../armbillingbenefits/time_rfc3339.go | 87 + 26 files changed, 4981 insertions(+) create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/CHANGELOG.md create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/LICENSE.txt create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/README.md create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/autorest.md create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/build.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/ci.yml create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/constants.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/date_type.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/go.mod create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/go.sum create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/models.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/models_serde.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/operations_client.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/operations_client_example_test.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/reservationorderalias_client.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/reservationorderalias_client_example_test.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/response_types.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/rp_client.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/rp_client_example_test.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplan_client.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplan_client_example_test.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorder_client.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorder_client_example_test.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorderalias_client.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorderalias_client_example_test.go create mode 100644 sdk/resourcemanager/billingbenefits/armbillingbenefits/time_rfc3339.go diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/CHANGELOG.md b/sdk/resourcemanager/billingbenefits/armbillingbenefits/CHANGELOG.md new file mode 100644 index 000000000000..34d068a68a5d --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release History + +## 1.0.0 (2022-12-23) + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billingbenefits/armbillingbenefits` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/LICENSE.txt b/sdk/resourcemanager/billingbenefits/armbillingbenefits/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/README.md b/sdk/resourcemanager/billingbenefits/armbillingbenefits/README.md new file mode 100644 index 000000000000..c73a18270b0a --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/README.md @@ -0,0 +1,77 @@ +# Azure Billingbenefits Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billingbenefits/armbillingbenefits)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billingbenefits/armbillingbenefits) + +The `armbillingbenefits` module provides operations for working with Azure Billingbenefits. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/billingbenefits/armbillingbenefits) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Billingbenefits module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billingbenefits/armbillingbenefits +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Billingbenefits. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Clients + +Azure Billingbenefits modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. + +```go +client, err := armbillingbenefits.(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options := arm.ClientOptions{ + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +client, err := armbillingbenefits.(, cred, &options) +``` + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Billingbenefits` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/autorest.md b/sdk/resourcemanager/billingbenefits/armbillingbenefits/autorest.md new file mode 100644 index 000000000000..2f8f47766f93 --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- https://github.com/Azure/azure-rest-api-specs/blob/59dd84dbde43f134f8a0369e6cc40b5d1df6fbbe/specification/billingbenefits/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/59dd84dbde43f134f8a0369e6cc40b5d1df6fbbe/specification/billingbenefits/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 1.0.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/build.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/build.go new file mode 100644 index 000000000000..da6fd110f16d --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -removeUnreferencedTypes resourcemanager/billingbenefits/armbillingbenefits + +package armbillingbenefits diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/ci.yml b/sdk/resourcemanager/billingbenefits/armbillingbenefits/ci.yml new file mode 100644 index 000000000000..1af495825109 --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/ci.yml @@ -0,0 +1,28 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/billingbenefits/armbillingbenefits/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/billingbenefits/armbillingbenefits/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/billingbenefits/armbillingbenefits' diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/constants.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/constants.go new file mode 100644 index 000000000000..9fd6a8add0ce --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/constants.go @@ -0,0 +1,260 @@ +//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 + +const ( + moduleName = "armbillingbenefits" + moduleVersion = "v1.0.0" +) + +// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +// AppliedScopeType - Type of the Applied Scope. +type AppliedScopeType string + +const ( + AppliedScopeTypeManagementGroup AppliedScopeType = "ManagementGroup" + AppliedScopeTypeShared AppliedScopeType = "Shared" + AppliedScopeTypeSingle AppliedScopeType = "Single" +) + +// PossibleAppliedScopeTypeValues returns the possible values for the AppliedScopeType const type. +func PossibleAppliedScopeTypeValues() []AppliedScopeType { + return []AppliedScopeType{ + AppliedScopeTypeManagementGroup, + AppliedScopeTypeShared, + AppliedScopeTypeSingle, + } +} + +// BillingPlan - Represents the billing plan in ISO 8601 format. Required only for monthly billing plans. +type BillingPlan string + +const ( + BillingPlanP1M BillingPlan = "P1M" +) + +// PossibleBillingPlanValues returns the possible values for the BillingPlan const type. +func PossibleBillingPlanValues() []BillingPlan { + return []BillingPlan{ + BillingPlanP1M, + } +} + +// CommitmentGrain - Commitment grain. +type CommitmentGrain string + +const ( + CommitmentGrainHourly CommitmentGrain = "Hourly" +) + +// PossibleCommitmentGrainValues returns the possible values for the CommitmentGrain const type. +func PossibleCommitmentGrainValues() []CommitmentGrain { + return []CommitmentGrain{ + CommitmentGrainHourly, + } +} + +// CreatedByType - The type of identity that created the resource. +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// InstanceFlexibility - Turning this on will apply the reservation discount to other VMs in the same VM size group. +type InstanceFlexibility string + +const ( + InstanceFlexibilityOff InstanceFlexibility = "Off" + InstanceFlexibilityOn InstanceFlexibility = "On" +) + +// PossibleInstanceFlexibilityValues returns the possible values for the InstanceFlexibility const type. +func PossibleInstanceFlexibilityValues() []InstanceFlexibility { + return []InstanceFlexibility{ + InstanceFlexibilityOff, + InstanceFlexibilityOn, + } +} + +// 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 + +const ( + OriginSystem Origin = "system" + OriginUser Origin = "user" + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + +// PaymentStatus - Describes whether the payment is completed, failed, cancelled or scheduled in the future. +type PaymentStatus string + +const ( + PaymentStatusCancelled PaymentStatus = "Cancelled" + PaymentStatusFailed PaymentStatus = "Failed" + PaymentStatusScheduled PaymentStatus = "Scheduled" + PaymentStatusSucceeded PaymentStatus = "Succeeded" +) + +// PossiblePaymentStatusValues returns the possible values for the PaymentStatus const type. +func PossiblePaymentStatusValues() []PaymentStatus { + return []PaymentStatus{ + PaymentStatusCancelled, + PaymentStatusFailed, + PaymentStatusScheduled, + PaymentStatusSucceeded, + } +} + +// ProvisioningState - Provisioning state +type ProvisioningState string + +const ( + ProvisioningStateCancelled ProvisioningState = "Cancelled" + ProvisioningStateConfirmedBilling ProvisioningState = "ConfirmedBilling" + ProvisioningStateCreated ProvisioningState = "Created" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateExpired ProvisioningState = "Expired" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStatePendingBilling ProvisioningState = "PendingBilling" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateCancelled, + ProvisioningStateConfirmedBilling, + ProvisioningStateCreated, + ProvisioningStateCreating, + ProvisioningStateExpired, + ProvisioningStateFailed, + ProvisioningStatePendingBilling, + ProvisioningStateSucceeded, + } +} + +// ReservedResourceType - The type of the resource that is being reserved. +type ReservedResourceType string + +const ( + ReservedResourceTypeAVS ReservedResourceType = "AVS" + ReservedResourceTypeAppService ReservedResourceType = "AppService" + ReservedResourceTypeAzureDataExplorer ReservedResourceType = "AzureDataExplorer" + ReservedResourceTypeAzureFiles ReservedResourceType = "AzureFiles" + ReservedResourceTypeBlockBlob ReservedResourceType = "BlockBlob" + ReservedResourceTypeCosmosDb ReservedResourceType = "CosmosDb" + ReservedResourceTypeDataFactory ReservedResourceType = "DataFactory" + ReservedResourceTypeDatabricks ReservedResourceType = "Databricks" + ReservedResourceTypeDedicatedHost ReservedResourceType = "DedicatedHost" + ReservedResourceTypeManagedDisk ReservedResourceType = "ManagedDisk" + ReservedResourceTypeMariaDb ReservedResourceType = "MariaDb" + ReservedResourceTypeMySQL ReservedResourceType = "MySql" + ReservedResourceTypeNetAppStorage ReservedResourceType = "NetAppStorage" + ReservedResourceTypePostgreSQL ReservedResourceType = "PostgreSql" + ReservedResourceTypeRedHat ReservedResourceType = "RedHat" + ReservedResourceTypeRedHatOsa ReservedResourceType = "RedHatOsa" + ReservedResourceTypeRedisCache ReservedResourceType = "RedisCache" + ReservedResourceTypeSQLAzureHybridBenefit ReservedResourceType = "SqlAzureHybridBenefit" + ReservedResourceTypeSQLDataWarehouse ReservedResourceType = "SqlDataWarehouse" + ReservedResourceTypeSQLDatabases ReservedResourceType = "SqlDatabases" + ReservedResourceTypeSQLEdge ReservedResourceType = "SqlEdge" + ReservedResourceTypeSapHana ReservedResourceType = "SapHana" + ReservedResourceTypeSuseLinux ReservedResourceType = "SuseLinux" + ReservedResourceTypeVMwareCloudSimple ReservedResourceType = "VMwareCloudSimple" + ReservedResourceTypeVirtualMachineSoftware ReservedResourceType = "VirtualMachineSoftware" + ReservedResourceTypeVirtualMachines ReservedResourceType = "VirtualMachines" +) + +// PossibleReservedResourceTypeValues returns the possible values for the ReservedResourceType const type. +func PossibleReservedResourceTypeValues() []ReservedResourceType { + return []ReservedResourceType{ + ReservedResourceTypeAVS, + ReservedResourceTypeAppService, + ReservedResourceTypeAzureDataExplorer, + ReservedResourceTypeAzureFiles, + ReservedResourceTypeBlockBlob, + ReservedResourceTypeCosmosDb, + ReservedResourceTypeDataFactory, + ReservedResourceTypeDatabricks, + ReservedResourceTypeDedicatedHost, + ReservedResourceTypeManagedDisk, + ReservedResourceTypeMariaDb, + ReservedResourceTypeMySQL, + ReservedResourceTypeNetAppStorage, + ReservedResourceTypePostgreSQL, + ReservedResourceTypeRedHat, + ReservedResourceTypeRedHatOsa, + ReservedResourceTypeRedisCache, + ReservedResourceTypeSQLAzureHybridBenefit, + ReservedResourceTypeSQLDataWarehouse, + ReservedResourceTypeSQLDatabases, + ReservedResourceTypeSQLEdge, + ReservedResourceTypeSapHana, + ReservedResourceTypeSuseLinux, + ReservedResourceTypeVMwareCloudSimple, + ReservedResourceTypeVirtualMachineSoftware, + ReservedResourceTypeVirtualMachines, + } +} + +// Term - Represent benefit term in ISO 8601 format. +type Term string + +const ( + TermP1Y Term = "P1Y" + TermP3Y Term = "P3Y" + TermP5Y Term = "P5Y" +) + +// PossibleTermValues returns the possible values for the Term const type. +func PossibleTermValues() []Term { + return []Term{ + TermP1Y, + TermP3Y, + TermP5Y, + } +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/date_type.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/date_type.go new file mode 100644 index 000000000000..6900858f0fbf --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/date_type.go @@ -0,0 +1,60 @@ +//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 + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "strings" + "time" +) + +const ( + fullDateJSON = `"2006-01-02"` + jsonFormat = `"%04d-%02d-%02d"` +) + +type dateType time.Time + +func (t dateType) MarshalJSON() ([]byte, error) { + return []byte(fmt.Sprintf(jsonFormat, time.Time(t).Year(), time.Time(t).Month(), time.Time(t).Day())), nil +} + +func (d *dateType) UnmarshalJSON(data []byte) (err error) { + t, err := time.Parse(fullDateJSON, string(data)) + *d = (dateType)(t) + return err +} + +func populateDateType(m map[string]interface{}, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*dateType)(t) +} + +func unpopulateDateType(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux dateType + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/go.mod b/sdk/resourcemanager/billingbenefits/armbillingbenefits/go.mod new file mode 100644 index 000000000000..643e1c53b191 --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/go.mod @@ -0,0 +1,21 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billingbenefits/armbillingbenefits + +go 1.18 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0 +) + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 // indirect + github.com/golang-jwt/jwt/v4 v4.4.2 // indirect + github.com/google/uuid v1.1.1 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect + golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect + golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect + golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect + golang.org/x/text v0.3.7 // indirect +) diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/go.sum b/sdk/resourcemanager/billingbenefits/armbillingbenefits/go.sum new file mode 100644 index 000000000000..8c0539b73123 --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/go.sum @@ -0,0 +1,30 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0 h1:t/W5MYAuQy81cvM8VUNfRLzhtKpXhVUAN7Cd7KVbTyc= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0/go.mod h1:NBanQUfSWiWn3QEpWDTCU0IjBECKOYvl2R8xdRtMtiM= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 h1:VgSJlZH5u0k2qxSpqyghcFQKmvYckj46uymKK5XzkBM= +github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0/go.mod h1:BDJ5qMFKx9DugEg3+uQSDCdbYPr5s9vBTrL9P8TpqOU= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= +github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= +github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +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-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= +github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= +golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/models.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/models.go new file mode 100644 index 000000000000..0c033447edf7 --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/models.go @@ -0,0 +1,803 @@ +//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 + +import "time" + +// AppliedScopeProperties - Properties specific to applied scope type. Not required if not applicable. +type AppliedScopeProperties struct { + // Display name + DisplayName *string `json:"displayName,omitempty"` + + // Fully-qualified identifier of the management group where the benefit must be applied. + ManagementGroupID *string `json:"managementGroupId,omitempty"` + + // Fully-qualified identifier of the resource group. + ResourceGroupID *string `json:"resourceGroupId,omitempty"` + + // Fully-qualified identifier of the subscription. + SubscriptionID *string `json:"subscriptionId,omitempty"` + + // Tenant ID where the benefit is applied. + TenantID *string `json:"tenantId,omitempty"` +} + +// BillingPlanInformation - Information describing the type of billing plan for this savings plan. +type BillingPlanInformation struct { + // For recurring billing plans, indicates the date when next payment will be processed. Null when total is paid off. + NextPaymentDueDate *time.Time `json:"nextPaymentDueDate,omitempty"` + + // Amount of money to be paid for the Order. Tax is not included. + PricingCurrencyTotal *Price `json:"pricingCurrencyTotal,omitempty"` + + // Date when the billing plan has started. + StartDate *time.Time `json:"startDate,omitempty"` + Transactions []*PaymentDetail `json:"transactions,omitempty"` +} + +// Commitment towards the benefit. +type Commitment struct { + Amount *float64 `json:"amount,omitempty"` + + // The ISO 4217 3-letter currency code for the currency used by this purchase record. + CurrencyCode *string `json:"currencyCode,omitempty"` + + // Commitment grain. + Grain *CommitmentGrain `json:"grain,omitempty"` +} + +type ExtendedStatusInfo struct { + // The message giving detailed information about the status code. + Message *string `json:"message,omitempty"` + + // Status code providing additional information. + StatusCode *string `json:"statusCode,omitempty"` +} + +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay `json:"display,omitempty"` + + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType `json:"actionType,omitempty" azure:"ro"` + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane + // operations. + IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + // "Microsoft.Compute/virtualMachines/capture/action" + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + // value is "user,system" + Origin *Origin `json:"origin,omitempty" azure:"ro"` +} + +// OperationDisplay - Localized display information for this particular operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + // Machine", "Restart Virtual Machine". + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to +// get the next set of results. +type OperationListResult struct { + // READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of operations supported by the resource provider + Value []*Operation `json:"value,omitempty" azure:"ro"` +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// PaymentDetail - Information about payment related to a savings plan order. +type PaymentDetail struct { + // Billing account + BillingAccount *string `json:"billingAccount,omitempty"` + + // Amount charged in Billing currency. Tax not included. Is null for future payments + BillingCurrencyTotal *Price `json:"billingCurrencyTotal,omitempty"` + + // Date when the payment needs to be done. + DueDate *time.Time `json:"dueDate,omitempty"` + + // Date when the transaction is completed. Is null when it is scheduled. + PaymentDate *time.Time `json:"paymentDate,omitempty"` + + // Amount in pricing currency. Tax not included. + PricingCurrencyTotal *Price `json:"pricingCurrencyTotal,omitempty"` + + // Describes whether the payment is completed, failed, cancelled or scheduled in the future. + Status *PaymentStatus `json:"status,omitempty"` + + // READ-ONLY + ExtendedStatusInfo *ExtendedStatusInfo `json:"extendedStatusInfo,omitempty" azure:"ro"` +} + +type Price struct { + Amount *float64 `json:"amount,omitempty"` + + // The ISO 4217 3-letter currency code for the currency used by this purchase record. + CurrencyCode *string `json:"currencyCode,omitempty"` +} + +type PurchaseRequest struct { + Properties *PurchaseRequestProperties `json:"properties,omitempty"` + + // The SKU to be applied for this resource + SKU *SKU `json:"sku,omitempty"` +} + +type PurchaseRequestProperties struct { + // Properties specific to applied scope type. Not required if not applicable. + AppliedScopeProperties *AppliedScopeProperties `json:"appliedScopeProperties,omitempty"` + + // Type of the Applied Scope. + AppliedScopeType *AppliedScopeType `json:"appliedScopeType,omitempty"` + + // Represents the billing plan in ISO 8601 format. Required only for monthly billing plans. + BillingPlan *BillingPlan `json:"billingPlan,omitempty"` + + // Subscription that will be charged for purchasing the benefit + BillingScopeID *string `json:"billingScopeId,omitempty"` + + // Commitment towards the benefit. + Commitment *Commitment `json:"commitment,omitempty"` + + // Friendly name of the savings plan + DisplayName *string `json:"displayName,omitempty"` + + // Setting this to true will automatically purchase a new benefit on the expiration date time. + Renew *bool `json:"renew,omitempty"` + + // Represent benefit term in ISO 8601 format. + Term *Term `json:"term,omitempty"` + + // READ-ONLY; DateTime of the savings plan starts providing benefit from. + EffectiveDateTime *time.Time `json:"effectiveDateTime,omitempty" azure:"ro"` +} + +// RPClientValidatePurchaseOptions contains the optional parameters for the RPClient.ValidatePurchase method. +type RPClientValidatePurchaseOptions struct { + // placeholder for future optional parameters +} + +type RenewProperties struct { + PurchaseProperties *PurchaseRequest `json:"purchaseProperties,omitempty"` +} + +// ReservationOrderAliasClientBeginCreateOptions contains the optional parameters for the ReservationOrderAliasClient.BeginCreate +// method. +type ReservationOrderAliasClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ReservationOrderAliasClientGetOptions contains the optional parameters for the ReservationOrderAliasClient.Get method. +type ReservationOrderAliasClientGetOptions struct { + // placeholder for future optional parameters +} + +// ReservationOrderAliasRequest - Reservation order alias +type ReservationOrderAliasRequest struct { + // REQUIRED; Reservation order SKU + SKU *SKU `json:"sku,omitempty"` + + // The Azure Region where the reservation benefits are applied to. + Location *string `json:"location,omitempty"` + + // Reservation order alias request properties + Properties *ReservationOrderAliasRequestProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ReservationOrderAliasRequestProperties - Reservation properties +type ReservationOrderAliasRequestProperties struct { + // Properties specific to applied scope type. Not required if not applicable. + AppliedScopeProperties *AppliedScopeProperties `json:"appliedScopeProperties,omitempty"` + + // Type of the Applied Scope. + AppliedScopeType *AppliedScopeType `json:"appliedScopeType,omitempty"` + + // Represents the billing plan in ISO 8601 format. Required only for monthly billing plans. + BillingPlan *BillingPlan `json:"billingPlan,omitempty"` + + // Subscription that will be charged for purchasing the benefit + BillingScopeID *string `json:"billingScopeId,omitempty"` + + // Display name + DisplayName *string `json:"displayName,omitempty"` + + // Total Quantity of the SKUs purchased in the Reservation. + Quantity *int32 `json:"quantity,omitempty"` + + // Setting this to true will automatically purchase a new benefit on the expiration date time. + Renew *bool `json:"renew,omitempty"` + + // Properties specific to each reserved resource type. Not required if not applicable. + ReservedResourceProperties *ReservationOrderAliasRequestPropertiesReservedResourceProperties `json:"reservedResourceProperties,omitempty"` + + // The type of the resource that is being reserved. + ReservedResourceType *ReservedResourceType `json:"reservedResourceType,omitempty"` + + // This is the date-time when the Azure Hybrid Benefit needs to be reviewed. + ReviewDateTime *time.Time `json:"reviewDateTime,omitempty"` + + // Represent benefit term in ISO 8601 format. + Term *Term `json:"term,omitempty"` +} + +// ReservationOrderAliasRequestPropertiesReservedResourceProperties - Properties specific to each reserved resource type. +// Not required if not applicable. +type ReservationOrderAliasRequestPropertiesReservedResourceProperties struct { + // Turning this on will apply the reservation discount to other VMs in the same VM size group. + InstanceFlexibility *InstanceFlexibility `json:"instanceFlexibility,omitempty"` +} + +// ReservationOrderAliasResponse - Reservation order alias +type ReservationOrderAliasResponse struct { + // REQUIRED; Reservation order SKU + SKU *SKU `json:"sku,omitempty"` + + // The Azure Region where the reserved resource lives. + Location *string `json:"location,omitempty"` + + // Reservation order alias response properties + Properties *ReservationOrderAliasResponseProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ReservationOrderAliasResponseProperties - Reservation properties +type ReservationOrderAliasResponseProperties struct { + // Properties specific to applied scope type. Not required if not applicable. + AppliedScopeProperties *AppliedScopeProperties `json:"appliedScopeProperties,omitempty"` + + // Type of the Applied Scope. + AppliedScopeType *AppliedScopeType `json:"appliedScopeType,omitempty"` + + // Represents the billing plan in ISO 8601 format. Required only for monthly billing plans. + BillingPlan *BillingPlan `json:"billingPlan,omitempty"` + + // Subscription that will be charged for purchasing the benefit + BillingScopeID *string `json:"billingScopeId,omitempty"` + + // Display name + DisplayName *string `json:"displayName,omitempty"` + + // Total Quantity of the SKUs purchased in the Reservation. + Quantity *int32 `json:"quantity,omitempty"` + + // Setting this to true will automatically purchase a new benefit on the expiration date time. + Renew *bool `json:"renew,omitempty"` + + // Properties specific to each reserved resource type. Not required if not applicable. + ReservedResourceProperties *ReservationOrderAliasResponsePropertiesReservedResourceProperties `json:"reservedResourceProperties,omitempty"` + + // The type of the resource that is being reserved. + ReservedResourceType *ReservedResourceType `json:"reservedResourceType,omitempty"` + + // This is the date-time when the Reservation needs to be reviewed. + ReviewDateTime *time.Time `json:"reviewDateTime,omitempty"` + + // Represent benefit term in ISO 8601 format. + Term *Term `json:"term,omitempty"` + + // READ-ONLY; Provisioning state + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Identifier of the reservation order created + ReservationOrderID *string `json:"reservationOrderId,omitempty" azure:"ro"` +} + +// ReservationOrderAliasResponsePropertiesReservedResourceProperties - Properties specific to each reserved resource type. +// Not required if not applicable. +type ReservationOrderAliasResponsePropertiesReservedResourceProperties struct { + // Turning this on will apply the reservation discount to other VMs in the same VM size group. + InstanceFlexibility *InstanceFlexibility `json:"instanceFlexibility,omitempty"` +} + +// RoleAssignmentEntity - Role assignment entity +type RoleAssignmentEntity struct { + // Role assignment entity id + ID *string `json:"id,omitempty"` + + // Role assignment entity name + Name *string `json:"name,omitempty"` + + // Role assignment entity properties + Properties *RoleAssignmentEntityProperties `json:"properties,omitempty"` +} + +// RoleAssignmentEntityProperties - Role assignment entity properties +type RoleAssignmentEntityProperties struct { + // Principal Id + PrincipalID *string `json:"principalId,omitempty"` + + // Role definition id + RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` + + // Scope of the role assignment entity + Scope *string `json:"scope,omitempty"` +} + +// SKU - The SKU to be applied for this resource +type SKU struct { + // Name of the SKU to be applied + Name *string `json:"name,omitempty"` +} + +// SavingsPlanClientGetOptions contains the optional parameters for the SavingsPlanClient.Get method. +type SavingsPlanClientGetOptions struct { +} + +// SavingsPlanClientListAllOptions contains the optional parameters for the SavingsPlanClient.ListAll method. +type SavingsPlanClientListAllOptions struct { + // May be used to filter by reservation properties. The filter supports 'eq', 'or', and 'and'. It does not currently support + // 'ne', 'gt', 'le', 'ge', or 'not'. Reservation properties include sku/name, + // properties/{appliedScopeType, archived, displayName, displayProvisioningState, effectiveDateTime, expiryDate, provisioningState, + // quantity, renew, reservedResourceType, term, + // userFriendlyAppliedScopeType, userFriendlyRenewState} + Filter *string + // May be used to sort order by reservation properties. + Orderby *string + // To indicate whether to refresh the roll up counts of the savings plans group by provisioning states + RefreshSummary *string + // The selected provisioning state + SelectedState *string + // The number of savings plans to skip from the list before returning results + Skiptoken *float32 + // To number of savings plans to return + Take *float32 +} + +// SavingsPlanClientListOptions contains the optional parameters for the SavingsPlanClient.List method. +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 +} + +// SavingsPlanModel - Savings plan +type SavingsPlanModel struct { + // REQUIRED; Savings plan SKU + SKU *SKU `json:"sku,omitempty"` + + // Savings plan properties + Properties *SavingsPlanModelProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +type SavingsPlanModelList struct { + // Url to get the next page. + NextLink *string `json:"nextLink,omitempty"` + Value []*SavingsPlanModel `json:"value,omitempty"` +} + +type SavingsPlanModelListResult struct { + // READ-ONLY; The roll out count summary of the savings plans + AdditionalProperties []*SavingsPlanSummary `json:"additionalProperties,omitempty" azure:"ro"` + + // READ-ONLY; Url to get the next page. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The list of savings plans. + Value []*SavingsPlanModel `json:"value,omitempty" azure:"ro"` +} + +// SavingsPlanModelProperties - Savings plan properties +type SavingsPlanModelProperties struct { + // Properties specific to applied scope type. Not required if not applicable. + AppliedScopeProperties *AppliedScopeProperties `json:"appliedScopeProperties,omitempty"` + + // Type of the Applied Scope. + AppliedScopeType *AppliedScopeType `json:"appliedScopeType,omitempty"` + + // This is the DateTime when the savings plan benefit started. + BenefitStartTime *time.Time `json:"benefitStartTime,omitempty"` + + // Represents the billing plan in ISO 8601 format. Required only for monthly billing plans. + BillingPlan *BillingPlan `json:"billingPlan,omitempty"` + + // Subscription that will be charged for purchasing the benefit + BillingScopeID *string `json:"billingScopeId,omitempty"` + + // Commitment towards the benefit. + Commitment *Commitment `json:"commitment,omitempty"` + + // Display name + DisplayName *string `json:"displayName,omitempty"` + + // Setting this to true will automatically purchase a new benefit on the expiration date time. + Renew *bool `json:"renew,omitempty"` + RenewProperties *SavingsPlanModelPropertiesRenewProperties `json:"renewProperties,omitempty"` + + // Represent benefit term in ISO 8601 format. + Term *Term `json:"term,omitempty"` + + // READ-ONLY; Fully-qualified identifier of the billing account where the savings plan is applied. Present only for Enterprise + // Agreement customers. + BillingAccountID *string `json:"billingAccountId,omitempty" azure:"ro"` + + // READ-ONLY; Fully-qualified identifier of the billing profile where the savings plan is applied. Present only for Field-led + // or Customer-led customers. + BillingProfileID *string `json:"billingProfileId,omitempty" azure:"ro"` + + // READ-ONLY; Fully-qualified identifier of the customer where the savings plan is applied. Present only for Partner-led customers. + CustomerID *string `json:"customerId,omitempty" azure:"ro"` + + // READ-ONLY; The provisioning state of the savings plan for display, e.g. Succeeded + DisplayProvisioningState *string `json:"displayProvisioningState,omitempty" azure:"ro"` + + // READ-ONLY; DateTime of the savings plan starts providing benefit from. + EffectiveDateTime *time.Time `json:"effectiveDateTime,omitempty" azure:"ro"` + + // READ-ONLY; Expiry date time + ExpiryDateTime *time.Time `json:"expiryDateTime,omitempty" azure:"ro"` + + // READ-ONLY + ExtendedStatusInfo *ExtendedStatusInfo `json:"extendedStatusInfo,omitempty" azure:"ro"` + + // READ-ONLY; Provisioning state + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Date time when the savings plan was purchased + PurchaseDateTime *time.Time `json:"purchaseDateTime,omitempty" azure:"ro"` + + // READ-ONLY; The applied scope type of the savings plan for display, e.g. Shared + UserFriendlyAppliedScopeType *string `json:"userFriendlyAppliedScopeType,omitempty" azure:"ro"` + + // READ-ONLY; Savings plan utilization + Utilization *Utilization `json:"utilization,omitempty" azure:"ro"` +} + +type SavingsPlanModelPropertiesRenewProperties struct { + PurchaseProperties *PurchaseRequest `json:"purchaseProperties,omitempty"` +} + +// SavingsPlanOrderAliasClientBeginCreateOptions contains the optional parameters for the SavingsPlanOrderAliasClient.BeginCreate +// method. +type SavingsPlanOrderAliasClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SavingsPlanOrderAliasClientGetOptions contains the optional parameters for the SavingsPlanOrderAliasClient.Get method. +type SavingsPlanOrderAliasClientGetOptions struct { + // placeholder for future optional parameters +} + +// SavingsPlanOrderAliasModel - Savings plan order alias +type SavingsPlanOrderAliasModel struct { + // REQUIRED; Savings plan SKU + SKU *SKU `json:"sku,omitempty"` + + // Resource provider kind + Kind *string `json:"kind,omitempty"` + + // Savings plan order alias properties + Properties *SavingsPlanOrderAliasProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// SavingsPlanOrderAliasProperties - Savings plan properties +type SavingsPlanOrderAliasProperties struct { + // Properties specific to applied scope type. Not required if not applicable. + AppliedScopeProperties *AppliedScopeProperties `json:"appliedScopeProperties,omitempty"` + + // Type of the Applied Scope. + AppliedScopeType *AppliedScopeType `json:"appliedScopeType,omitempty"` + + // Represents the billing plan in ISO 8601 format. Required only for monthly billing plans. + BillingPlan *BillingPlan `json:"billingPlan,omitempty"` + + // Subscription that will be charged for purchasing the benefit + BillingScopeID *string `json:"billingScopeId,omitempty"` + + // Commitment towards the benefit. + Commitment *Commitment `json:"commitment,omitempty"` + + // Display name + DisplayName *string `json:"displayName,omitempty"` + + // Represent benefit term in ISO 8601 format. + Term *Term `json:"term,omitempty"` + + // READ-ONLY; Provisioning state + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Identifier of the savings plan created + SavingsPlanOrderID *string `json:"savingsPlanOrderId,omitempty" azure:"ro"` +} + +// SavingsPlanOrderClientElevateOptions contains the optional parameters for the SavingsPlanOrderClient.Elevate method. +type SavingsPlanOrderClientElevateOptions struct { + // placeholder for future optional parameters +} + +// SavingsPlanOrderClientGetOptions contains the optional parameters for the SavingsPlanOrderClient.Get method. +type SavingsPlanOrderClientGetOptions struct { +} + +// SavingsPlanOrderClientListOptions contains the optional parameters for the SavingsPlanOrderClient.List method. +type SavingsPlanOrderClientListOptions struct { + // placeholder for future optional parameters +} + +// SavingsPlanOrderModel - Savings plan order +type SavingsPlanOrderModel struct { + // REQUIRED; Savings plan SKU + SKU *SKU `json:"sku,omitempty"` + + // Savings plan order properties + Properties *SavingsPlanOrderModelProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +type SavingsPlanOrderModelList struct { + // Url to get the next page. + NextLink *string `json:"nextLink,omitempty"` + Value []*SavingsPlanOrderModel `json:"value,omitempty"` +} + +// SavingsPlanOrderModelProperties - Savings plan order properties +type SavingsPlanOrderModelProperties struct { + // This is the DateTime when the savings plan benefit started. + BenefitStartTime *time.Time `json:"benefitStartTime,omitempty"` + + // Represents the billing plan in ISO 8601 format. Required only for monthly billing plans. + BillingPlan *BillingPlan `json:"billingPlan,omitempty"` + + // Subscription that will be charged for purchasing the benefit + BillingScopeID *string `json:"billingScopeId,omitempty"` + + // Display name + DisplayName *string `json:"displayName,omitempty"` + + // Information describing the type of billing plan for this savings plan. + PlanInformation *BillingPlanInformation `json:"planInformation,omitempty"` + SavingsPlans []*string `json:"savingsPlans,omitempty"` + + // Represent benefit term in ISO 8601 format. + Term *Term `json:"term,omitempty"` + + // READ-ONLY; Fully-qualified identifier of the billing account where the savings plan is applied. Present only for Enterprise + // Agreement customers. + BillingAccountID *string `json:"billingAccountId,omitempty" azure:"ro"` + + // READ-ONLY; Fully-qualified identifier of the billing profile where the savings plan is applied. Present only for Field-led + // or Customer-led customers. + BillingProfileID *string `json:"billingProfileId,omitempty" azure:"ro"` + + // READ-ONLY; Fully-qualified identifier of the customer where the savings plan is applied. Present only for Partner-led customers. + CustomerID *string `json:"customerId,omitempty" azure:"ro"` + + // READ-ONLY; Expiry date time + ExpiryDateTime *time.Time `json:"expiryDateTime,omitempty" azure:"ro"` + + // READ-ONLY + ExtendedStatusInfo *ExtendedStatusInfo `json:"extendedStatusInfo,omitempty" azure:"ro"` + + // READ-ONLY; Provisioning state + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +type SavingsPlanPurchaseValidateRequest struct { + Benefits []*SavingsPlanOrderAliasModel `json:"benefits,omitempty"` +} + +// SavingsPlanSummary - Savings plans list summary +type SavingsPlanSummary struct { + // The roll up count summary of savings plans in each state + Value *SavingsPlanSummaryCount `json:"value,omitempty"` + + // READ-ONLY; This property has value 'summary' + Name *string `json:"name,omitempty" azure:"ro"` +} + +// SavingsPlanSummaryCount - The roll up count summary of savings plans in each state +type SavingsPlanSummaryCount struct { + // READ-ONLY; The number of savings plans in Cancelled state + CancelledCount *float32 `json:"cancelledCount,omitempty" azure:"ro"` + + // READ-ONLY; The number of savings plans in Expired state + ExpiredCount *float32 `json:"expiredCount,omitempty" azure:"ro"` + + // READ-ONLY; The number of savings plans in Expiring state + ExpiringCount *float32 `json:"expiringCount,omitempty" azure:"ro"` + + // READ-ONLY; The number of savings plans in Failed state + FailedCount *float32 `json:"failedCount,omitempty" azure:"ro"` + + // READ-ONLY; The number of savings plans in No Benefit state + NoBenefitCount *float32 `json:"noBenefitCount,omitempty" azure:"ro"` + + // READ-ONLY; The number of savings plans in Pending state + PendingCount *float32 `json:"pendingCount,omitempty" azure:"ro"` + + // READ-ONLY; The number of savings plans in Processing state + ProcessingCount *float32 `json:"processingCount,omitempty" azure:"ro"` + + // READ-ONLY; The number of savings plans in Succeeded state + SucceededCount *float32 `json:"succeededCount,omitempty" azure:"ro"` + + // READ-ONLY; The number of savings plans in Warning state + WarningCount *float32 `json:"warningCount,omitempty" azure:"ro"` +} + +// SavingsPlanUpdateRequest - Savings plan patch request +type SavingsPlanUpdateRequest struct { + // Savings plan patch request + Properties *SavingsPlanUpdateRequestProperties `json:"properties,omitempty"` +} + +// SavingsPlanUpdateRequestProperties - Savings plan patch request +type SavingsPlanUpdateRequestProperties struct { + // Properties specific to applied scope type. Not required if not applicable. + AppliedScopeProperties *AppliedScopeProperties `json:"appliedScopeProperties,omitempty"` + + // Type of the Applied Scope. + AppliedScopeType *AppliedScopeType `json:"appliedScopeType,omitempty"` + + // Display name + DisplayName *string `json:"displayName,omitempty"` + + // Setting this to true will automatically purchase a new benefit on the expiration date time. + Renew *bool `json:"renew,omitempty"` + RenewProperties *RenewProperties `json:"renewProperties,omitempty"` +} + +type SavingsPlanUpdateValidateRequest struct { + Benefits []*SavingsPlanUpdateRequestProperties `json:"benefits,omitempty"` +} + +// SavingsPlanValidResponseProperty - Benefit scope response property +type SavingsPlanValidResponseProperty struct { + // Failure reason if the provided input was invalid + Reason *string `json:"reason,omitempty"` + + // Failure reason code if the provided input was invalid + ReasonCode *string `json:"reasonCode,omitempty"` + + // Indicates if the provided input was valid + Valid *bool `json:"valid,omitempty"` +} + +type SavingsPlanValidateResponse struct { + Benefits []*SavingsPlanValidResponseProperty `json:"benefits,omitempty"` + + // Url to get the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + + // The type of identity that created the resource. + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + + // The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +// Utilization - Savings plan utilization +type Utilization struct { + // The array of aggregates of a savings plan's utilization + Aggregates []*UtilizationAggregates `json:"aggregates,omitempty"` + + // READ-ONLY; The number of days trend for a savings plan + Trend *string `json:"trend,omitempty" azure:"ro"` +} + +// UtilizationAggregates - The aggregate values of savings plan utilization +type UtilizationAggregates struct { + // READ-ONLY; The grain of the aggregate + Grain *float32 `json:"grain,omitempty" azure:"ro"` + + // READ-ONLY; The grain unit of the aggregate + GrainUnit *string `json:"grainUnit,omitempty" azure:"ro"` + + // READ-ONLY; The aggregate value + Value *float32 `json:"value,omitempty" azure:"ro"` + + // READ-ONLY; The aggregate value unit + ValueUnit *string `json:"valueUnit,omitempty" azure:"ro"` +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/models_serde.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/models_serde.go new file mode 100644 index 000000000000..c47c5c9c580e --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/models_serde.go @@ -0,0 +1,1799 @@ +//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 + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AppliedScopeProperties. +func (a AppliedScopeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + 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]interface{}) + 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 Commitment. +func (c Commitment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + 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 ExtendedStatusInfo. +func (e ExtendedStatusInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "message", e.Message) + populate(objectMap, "statusCode", e.StatusCode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtendedStatusInfo. +func (e *ExtendedStatusInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "statusCode": + err = unpopulate(val, "StatusCode", &e.StatusCode) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PaymentDetail. +func (p PaymentDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "billingAccount", p.BillingAccount) + populate(objectMap, "billingCurrencyTotal", p.BillingCurrencyTotal) + populateDateType(objectMap, "dueDate", p.DueDate) + populate(objectMap, "extendedStatusInfo", p.ExtendedStatusInfo) + populateDateType(objectMap, "paymentDate", p.PaymentDate) + populate(objectMap, "pricingCurrencyTotal", p.PricingCurrencyTotal) + populate(objectMap, "status", p.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PaymentDetail. +func (p *PaymentDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "billingAccount": + err = unpopulate(val, "BillingAccount", &p.BillingAccount) + delete(rawMsg, key) + case "billingCurrencyTotal": + err = unpopulate(val, "BillingCurrencyTotal", &p.BillingCurrencyTotal) + delete(rawMsg, key) + case "dueDate": + err = unpopulateDateType(val, "DueDate", &p.DueDate) + delete(rawMsg, key) + case "extendedStatusInfo": + err = unpopulate(val, "ExtendedStatusInfo", &p.ExtendedStatusInfo) + delete(rawMsg, key) + case "paymentDate": + err = unpopulateDateType(val, "PaymentDate", &p.PaymentDate) + delete(rawMsg, key) + case "pricingCurrencyTotal": + err = unpopulate(val, "PricingCurrencyTotal", &p.PricingCurrencyTotal) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Price. +func (p Price) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "amount", p.Amount) + populate(objectMap, "currencyCode", p.CurrencyCode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Price. +func (p *Price) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "amount": + err = unpopulate(val, "Amount", &p.Amount) + delete(rawMsg, key) + case "currencyCode": + err = unpopulate(val, "CurrencyCode", &p.CurrencyCode) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PurchaseRequest. +func (p PurchaseRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "sku", p.SKU) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PurchaseRequest. +func (p *PurchaseRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &p.SKU) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PurchaseRequestProperties. +func (p PurchaseRequestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "appliedScopeProperties", p.AppliedScopeProperties) + populate(objectMap, "appliedScopeType", p.AppliedScopeType) + populate(objectMap, "billingPlan", p.BillingPlan) + populate(objectMap, "billingScopeId", p.BillingScopeID) + populate(objectMap, "commitment", p.Commitment) + populate(objectMap, "displayName", p.DisplayName) + populateTimeRFC3339(objectMap, "effectiveDateTime", p.EffectiveDateTime) + populate(objectMap, "renew", p.Renew) + populate(objectMap, "term", p.Term) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PurchaseRequestProperties. +func (p *PurchaseRequestProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "appliedScopeProperties": + err = unpopulate(val, "AppliedScopeProperties", &p.AppliedScopeProperties) + delete(rawMsg, key) + case "appliedScopeType": + err = unpopulate(val, "AppliedScopeType", &p.AppliedScopeType) + delete(rawMsg, key) + case "billingPlan": + err = unpopulate(val, "BillingPlan", &p.BillingPlan) + delete(rawMsg, key) + case "billingScopeId": + err = unpopulate(val, "BillingScopeID", &p.BillingScopeID) + delete(rawMsg, key) + case "commitment": + err = unpopulate(val, "Commitment", &p.Commitment) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &p.DisplayName) + delete(rawMsg, key) + case "effectiveDateTime": + err = unpopulateTimeRFC3339(val, "EffectiveDateTime", &p.EffectiveDateTime) + delete(rawMsg, key) + case "renew": + err = unpopulate(val, "Renew", &p.Renew) + delete(rawMsg, key) + case "term": + err = unpopulate(val, "Term", &p.Term) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RenewProperties. +func (r RenewProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "purchaseProperties", r.PurchaseProperties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RenewProperties. +func (r *RenewProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "purchaseProperties": + err = unpopulate(val, "PurchaseProperties", &r.PurchaseProperties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationOrderAliasRequest. +func (r ReservationOrderAliasRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", r.ID) + populate(objectMap, "location", r.Location) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "sku", r.SKU) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationOrderAliasRequest. +func (r *ReservationOrderAliasRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &r.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &r.SKU) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationOrderAliasRequestProperties. +func (r ReservationOrderAliasRequestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "appliedScopeProperties", r.AppliedScopeProperties) + populate(objectMap, "appliedScopeType", r.AppliedScopeType) + populate(objectMap, "billingPlan", r.BillingPlan) + populate(objectMap, "billingScopeId", r.BillingScopeID) + populate(objectMap, "displayName", r.DisplayName) + populate(objectMap, "quantity", r.Quantity) + populate(objectMap, "renew", r.Renew) + populate(objectMap, "reservedResourceProperties", r.ReservedResourceProperties) + populate(objectMap, "reservedResourceType", r.ReservedResourceType) + populateTimeRFC3339(objectMap, "reviewDateTime", r.ReviewDateTime) + populate(objectMap, "term", r.Term) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationOrderAliasRequestProperties. +func (r *ReservationOrderAliasRequestProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "appliedScopeProperties": + err = unpopulate(val, "AppliedScopeProperties", &r.AppliedScopeProperties) + delete(rawMsg, key) + case "appliedScopeType": + err = unpopulate(val, "AppliedScopeType", &r.AppliedScopeType) + delete(rawMsg, key) + case "billingPlan": + err = unpopulate(val, "BillingPlan", &r.BillingPlan) + delete(rawMsg, key) + case "billingScopeId": + err = unpopulate(val, "BillingScopeID", &r.BillingScopeID) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &r.DisplayName) + delete(rawMsg, key) + case "quantity": + err = unpopulate(val, "Quantity", &r.Quantity) + delete(rawMsg, key) + case "renew": + err = unpopulate(val, "Renew", &r.Renew) + delete(rawMsg, key) + case "reservedResourceProperties": + err = unpopulate(val, "ReservedResourceProperties", &r.ReservedResourceProperties) + delete(rawMsg, key) + case "reservedResourceType": + err = unpopulate(val, "ReservedResourceType", &r.ReservedResourceType) + delete(rawMsg, key) + case "reviewDateTime": + err = unpopulateTimeRFC3339(val, "ReviewDateTime", &r.ReviewDateTime) + delete(rawMsg, key) + case "term": + err = unpopulate(val, "Term", &r.Term) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationOrderAliasRequestPropertiesReservedResourceProperties. +func (r ReservationOrderAliasRequestPropertiesReservedResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "instanceFlexibility", r.InstanceFlexibility) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationOrderAliasRequestPropertiesReservedResourceProperties. +func (r *ReservationOrderAliasRequestPropertiesReservedResourceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "instanceFlexibility": + err = unpopulate(val, "InstanceFlexibility", &r.InstanceFlexibility) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationOrderAliasResponse. +func (r ReservationOrderAliasResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", r.ID) + populate(objectMap, "location", r.Location) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "sku", r.SKU) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationOrderAliasResponse. +func (r *ReservationOrderAliasResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &r.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &r.SKU) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationOrderAliasResponseProperties. +func (r ReservationOrderAliasResponseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "appliedScopeProperties", r.AppliedScopeProperties) + populate(objectMap, "appliedScopeType", r.AppliedScopeType) + populate(objectMap, "billingPlan", r.BillingPlan) + populate(objectMap, "billingScopeId", r.BillingScopeID) + populate(objectMap, "displayName", r.DisplayName) + populate(objectMap, "provisioningState", r.ProvisioningState) + populate(objectMap, "quantity", r.Quantity) + populate(objectMap, "renew", r.Renew) + populate(objectMap, "reservationOrderId", r.ReservationOrderID) + populate(objectMap, "reservedResourceProperties", r.ReservedResourceProperties) + populate(objectMap, "reservedResourceType", r.ReservedResourceType) + populateTimeRFC3339(objectMap, "reviewDateTime", r.ReviewDateTime) + populate(objectMap, "term", r.Term) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationOrderAliasResponseProperties. +func (r *ReservationOrderAliasResponseProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "appliedScopeProperties": + err = unpopulate(val, "AppliedScopeProperties", &r.AppliedScopeProperties) + delete(rawMsg, key) + case "appliedScopeType": + err = unpopulate(val, "AppliedScopeType", &r.AppliedScopeType) + delete(rawMsg, key) + case "billingPlan": + err = unpopulate(val, "BillingPlan", &r.BillingPlan) + delete(rawMsg, key) + case "billingScopeId": + err = unpopulate(val, "BillingScopeID", &r.BillingScopeID) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &r.DisplayName) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) + delete(rawMsg, key) + case "quantity": + err = unpopulate(val, "Quantity", &r.Quantity) + delete(rawMsg, key) + case "renew": + err = unpopulate(val, "Renew", &r.Renew) + delete(rawMsg, key) + case "reservationOrderId": + err = unpopulate(val, "ReservationOrderID", &r.ReservationOrderID) + delete(rawMsg, key) + case "reservedResourceProperties": + err = unpopulate(val, "ReservedResourceProperties", &r.ReservedResourceProperties) + delete(rawMsg, key) + case "reservedResourceType": + err = unpopulate(val, "ReservedResourceType", &r.ReservedResourceType) + delete(rawMsg, key) + case "reviewDateTime": + err = unpopulateTimeRFC3339(val, "ReviewDateTime", &r.ReviewDateTime) + delete(rawMsg, key) + case "term": + err = unpopulate(val, "Term", &r.Term) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationOrderAliasResponsePropertiesReservedResourceProperties. +func (r ReservationOrderAliasResponsePropertiesReservedResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "instanceFlexibility", r.InstanceFlexibility) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationOrderAliasResponsePropertiesReservedResourceProperties. +func (r *ReservationOrderAliasResponsePropertiesReservedResourceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "instanceFlexibility": + err = unpopulate(val, "InstanceFlexibility", &r.InstanceFlexibility) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RoleAssignmentEntity. +func (r RoleAssignmentEntity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RoleAssignmentEntity. +func (r *RoleAssignmentEntity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RoleAssignmentEntityProperties. +func (r RoleAssignmentEntityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "principalId", r.PrincipalID) + populate(objectMap, "roleDefinitionId", r.RoleDefinitionID) + populate(objectMap, "scope", r.Scope) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RoleAssignmentEntityProperties. +func (r *RoleAssignmentEntityProperties) UnmarshalJSON(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 "principalId": + err = unpopulate(val, "PrincipalID", &r.PrincipalID) + delete(rawMsg, key) + case "roleDefinitionId": + err = unpopulate(val, "RoleDefinitionID", &r.RoleDefinitionID) + delete(rawMsg, key) + case "scope": + err = unpopulate(val, "Scope", &r.Scope) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SKU. +func (s SKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", s.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKU. +func (s *SKU) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanModel. +func (s SavingsPlanModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "sku", s.SKU) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanModel. +func (s *SavingsPlanModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &s.SKU) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanModelList. +func (s SavingsPlanModelList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanModelList. +func (s *SavingsPlanModelList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanModelListResult. +func (s SavingsPlanModelListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "additionalProperties", s.AdditionalProperties) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanModelListResult. +func (s *SavingsPlanModelListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalProperties": + err = unpopulate(val, "AdditionalProperties", &s.AdditionalProperties) + delete(rawMsg, key) + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanModelProperties. +func (s SavingsPlanModelProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "appliedScopeProperties", s.AppliedScopeProperties) + populate(objectMap, "appliedScopeType", s.AppliedScopeType) + populateTimeRFC3339(objectMap, "benefitStartTime", s.BenefitStartTime) + populate(objectMap, "billingAccountId", s.BillingAccountID) + populate(objectMap, "billingPlan", s.BillingPlan) + populate(objectMap, "billingProfileId", s.BillingProfileID) + populate(objectMap, "billingScopeId", s.BillingScopeID) + populate(objectMap, "commitment", s.Commitment) + populate(objectMap, "customerId", s.CustomerID) + populate(objectMap, "displayName", s.DisplayName) + populate(objectMap, "displayProvisioningState", s.DisplayProvisioningState) + populateTimeRFC3339(objectMap, "effectiveDateTime", s.EffectiveDateTime) + populateTimeRFC3339(objectMap, "expiryDateTime", s.ExpiryDateTime) + populate(objectMap, "extendedStatusInfo", s.ExtendedStatusInfo) + populate(objectMap, "provisioningState", s.ProvisioningState) + populateTimeRFC3339(objectMap, "purchaseDateTime", s.PurchaseDateTime) + populate(objectMap, "renew", s.Renew) + populate(objectMap, "renewProperties", s.RenewProperties) + populate(objectMap, "term", s.Term) + populate(objectMap, "userFriendlyAppliedScopeType", s.UserFriendlyAppliedScopeType) + populate(objectMap, "utilization", s.Utilization) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanModelProperties. +func (s *SavingsPlanModelProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "appliedScopeProperties": + err = unpopulate(val, "AppliedScopeProperties", &s.AppliedScopeProperties) + delete(rawMsg, key) + case "appliedScopeType": + err = unpopulate(val, "AppliedScopeType", &s.AppliedScopeType) + delete(rawMsg, key) + case "benefitStartTime": + err = unpopulateTimeRFC3339(val, "BenefitStartTime", &s.BenefitStartTime) + delete(rawMsg, key) + case "billingAccountId": + err = unpopulate(val, "BillingAccountID", &s.BillingAccountID) + delete(rawMsg, key) + case "billingPlan": + err = unpopulate(val, "BillingPlan", &s.BillingPlan) + delete(rawMsg, key) + case "billingProfileId": + err = unpopulate(val, "BillingProfileID", &s.BillingProfileID) + delete(rawMsg, key) + case "billingScopeId": + err = unpopulate(val, "BillingScopeID", &s.BillingScopeID) + delete(rawMsg, key) + case "commitment": + err = unpopulate(val, "Commitment", &s.Commitment) + delete(rawMsg, key) + case "customerId": + err = unpopulate(val, "CustomerID", &s.CustomerID) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &s.DisplayName) + delete(rawMsg, key) + case "displayProvisioningState": + err = unpopulate(val, "DisplayProvisioningState", &s.DisplayProvisioningState) + delete(rawMsg, key) + case "effectiveDateTime": + err = unpopulateTimeRFC3339(val, "EffectiveDateTime", &s.EffectiveDateTime) + delete(rawMsg, key) + case "expiryDateTime": + err = unpopulateTimeRFC3339(val, "ExpiryDateTime", &s.ExpiryDateTime) + delete(rawMsg, key) + case "extendedStatusInfo": + err = unpopulate(val, "ExtendedStatusInfo", &s.ExtendedStatusInfo) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + delete(rawMsg, key) + case "purchaseDateTime": + err = unpopulateTimeRFC3339(val, "PurchaseDateTime", &s.PurchaseDateTime) + delete(rawMsg, key) + case "renew": + err = unpopulate(val, "Renew", &s.Renew) + delete(rawMsg, key) + case "renewProperties": + err = unpopulate(val, "RenewProperties", &s.RenewProperties) + delete(rawMsg, key) + case "term": + err = unpopulate(val, "Term", &s.Term) + delete(rawMsg, key) + case "userFriendlyAppliedScopeType": + err = unpopulate(val, "UserFriendlyAppliedScopeType", &s.UserFriendlyAppliedScopeType) + delete(rawMsg, key) + case "utilization": + err = unpopulate(val, "Utilization", &s.Utilization) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanModelPropertiesRenewProperties. +func (s SavingsPlanModelPropertiesRenewProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "purchaseProperties", s.PurchaseProperties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanModelPropertiesRenewProperties. +func (s *SavingsPlanModelPropertiesRenewProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "purchaseProperties": + err = unpopulate(val, "PurchaseProperties", &s.PurchaseProperties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanOrderAliasModel. +func (s SavingsPlanOrderAliasModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", s.ID) + populate(objectMap, "kind", s.Kind) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "sku", s.SKU) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanOrderAliasModel. +func (s *SavingsPlanOrderAliasModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &s.Kind) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &s.SKU) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanOrderAliasProperties. +func (s SavingsPlanOrderAliasProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "appliedScopeProperties", s.AppliedScopeProperties) + populate(objectMap, "appliedScopeType", s.AppliedScopeType) + populate(objectMap, "billingPlan", s.BillingPlan) + populate(objectMap, "billingScopeId", s.BillingScopeID) + populate(objectMap, "commitment", s.Commitment) + populate(objectMap, "displayName", s.DisplayName) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "savingsPlanOrderId", s.SavingsPlanOrderID) + populate(objectMap, "term", s.Term) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanOrderAliasProperties. +func (s *SavingsPlanOrderAliasProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "appliedScopeProperties": + err = unpopulate(val, "AppliedScopeProperties", &s.AppliedScopeProperties) + delete(rawMsg, key) + case "appliedScopeType": + err = unpopulate(val, "AppliedScopeType", &s.AppliedScopeType) + delete(rawMsg, key) + case "billingPlan": + err = unpopulate(val, "BillingPlan", &s.BillingPlan) + delete(rawMsg, key) + case "billingScopeId": + err = unpopulate(val, "BillingScopeID", &s.BillingScopeID) + delete(rawMsg, key) + case "commitment": + err = unpopulate(val, "Commitment", &s.Commitment) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &s.DisplayName) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + delete(rawMsg, key) + case "savingsPlanOrderId": + err = unpopulate(val, "SavingsPlanOrderID", &s.SavingsPlanOrderID) + delete(rawMsg, key) + case "term": + err = unpopulate(val, "Term", &s.Term) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanOrderModel. +func (s SavingsPlanOrderModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "sku", s.SKU) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanOrderModel. +func (s *SavingsPlanOrderModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &s.SKU) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanOrderModelList. +func (s SavingsPlanOrderModelList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanOrderModelList. +func (s *SavingsPlanOrderModelList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanOrderModelProperties. +func (s SavingsPlanOrderModelProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "benefitStartTime", s.BenefitStartTime) + populate(objectMap, "billingAccountId", s.BillingAccountID) + populate(objectMap, "billingPlan", s.BillingPlan) + populate(objectMap, "billingProfileId", s.BillingProfileID) + populate(objectMap, "billingScopeId", s.BillingScopeID) + populate(objectMap, "customerId", s.CustomerID) + populate(objectMap, "displayName", s.DisplayName) + populateTimeRFC3339(objectMap, "expiryDateTime", s.ExpiryDateTime) + populate(objectMap, "extendedStatusInfo", s.ExtendedStatusInfo) + populate(objectMap, "planInformation", s.PlanInformation) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "savingsPlans", s.SavingsPlans) + populate(objectMap, "term", s.Term) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanOrderModelProperties. +func (s *SavingsPlanOrderModelProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "benefitStartTime": + err = unpopulateTimeRFC3339(val, "BenefitStartTime", &s.BenefitStartTime) + delete(rawMsg, key) + case "billingAccountId": + err = unpopulate(val, "BillingAccountID", &s.BillingAccountID) + delete(rawMsg, key) + case "billingPlan": + err = unpopulate(val, "BillingPlan", &s.BillingPlan) + delete(rawMsg, key) + case "billingProfileId": + err = unpopulate(val, "BillingProfileID", &s.BillingProfileID) + delete(rawMsg, key) + case "billingScopeId": + err = unpopulate(val, "BillingScopeID", &s.BillingScopeID) + delete(rawMsg, key) + case "customerId": + err = unpopulate(val, "CustomerID", &s.CustomerID) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &s.DisplayName) + delete(rawMsg, key) + case "expiryDateTime": + err = unpopulateTimeRFC3339(val, "ExpiryDateTime", &s.ExpiryDateTime) + delete(rawMsg, key) + case "extendedStatusInfo": + err = unpopulate(val, "ExtendedStatusInfo", &s.ExtendedStatusInfo) + delete(rawMsg, key) + case "planInformation": + err = unpopulate(val, "PlanInformation", &s.PlanInformation) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + delete(rawMsg, key) + case "savingsPlans": + err = unpopulate(val, "SavingsPlans", &s.SavingsPlans) + delete(rawMsg, key) + case "term": + err = unpopulate(val, "Term", &s.Term) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanPurchaseValidateRequest. +func (s SavingsPlanPurchaseValidateRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "benefits", s.Benefits) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanPurchaseValidateRequest. +func (s *SavingsPlanPurchaseValidateRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "benefits": + err = unpopulate(val, "Benefits", &s.Benefits) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanSummary. +func (s SavingsPlanSummary) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", s.Name) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanSummary. +func (s *SavingsPlanSummary) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanSummaryCount. +func (s SavingsPlanSummaryCount) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "cancelledCount", s.CancelledCount) + populate(objectMap, "expiredCount", s.ExpiredCount) + populate(objectMap, "expiringCount", s.ExpiringCount) + populate(objectMap, "failedCount", s.FailedCount) + populate(objectMap, "noBenefitCount", s.NoBenefitCount) + populate(objectMap, "pendingCount", s.PendingCount) + populate(objectMap, "processingCount", s.ProcessingCount) + populate(objectMap, "succeededCount", s.SucceededCount) + populate(objectMap, "warningCount", s.WarningCount) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanSummaryCount. +func (s *SavingsPlanSummaryCount) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "cancelledCount": + err = unpopulate(val, "CancelledCount", &s.CancelledCount) + delete(rawMsg, key) + case "expiredCount": + err = unpopulate(val, "ExpiredCount", &s.ExpiredCount) + delete(rawMsg, key) + case "expiringCount": + err = unpopulate(val, "ExpiringCount", &s.ExpiringCount) + delete(rawMsg, key) + case "failedCount": + err = unpopulate(val, "FailedCount", &s.FailedCount) + delete(rawMsg, key) + case "noBenefitCount": + err = unpopulate(val, "NoBenefitCount", &s.NoBenefitCount) + delete(rawMsg, key) + case "pendingCount": + err = unpopulate(val, "PendingCount", &s.PendingCount) + delete(rawMsg, key) + case "processingCount": + err = unpopulate(val, "ProcessingCount", &s.ProcessingCount) + delete(rawMsg, key) + case "succeededCount": + err = unpopulate(val, "SucceededCount", &s.SucceededCount) + delete(rawMsg, key) + case "warningCount": + err = unpopulate(val, "WarningCount", &s.WarningCount) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanUpdateRequest. +func (s SavingsPlanUpdateRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", s.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanUpdateRequest. +func (s *SavingsPlanUpdateRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanUpdateRequestProperties. +func (s SavingsPlanUpdateRequestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "appliedScopeProperties", s.AppliedScopeProperties) + populate(objectMap, "appliedScopeType", s.AppliedScopeType) + populate(objectMap, "displayName", s.DisplayName) + populate(objectMap, "renew", s.Renew) + populate(objectMap, "renewProperties", s.RenewProperties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanUpdateRequestProperties. +func (s *SavingsPlanUpdateRequestProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "appliedScopeProperties": + err = unpopulate(val, "AppliedScopeProperties", &s.AppliedScopeProperties) + delete(rawMsg, key) + case "appliedScopeType": + err = unpopulate(val, "AppliedScopeType", &s.AppliedScopeType) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &s.DisplayName) + delete(rawMsg, key) + case "renew": + err = unpopulate(val, "Renew", &s.Renew) + delete(rawMsg, key) + case "renewProperties": + err = unpopulate(val, "RenewProperties", &s.RenewProperties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanUpdateValidateRequest. +func (s SavingsPlanUpdateValidateRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "benefits", s.Benefits) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanUpdateValidateRequest. +func (s *SavingsPlanUpdateValidateRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "benefits": + err = unpopulate(val, "Benefits", &s.Benefits) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanValidResponseProperty. +func (s SavingsPlanValidResponseProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "reason", s.Reason) + populate(objectMap, "reasonCode", s.ReasonCode) + populate(objectMap, "valid", s.Valid) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanValidResponseProperty. +func (s *SavingsPlanValidResponseProperty) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "reason": + err = unpopulate(val, "Reason", &s.Reason) + delete(rawMsg, key) + case "reasonCode": + err = unpopulate(val, "ReasonCode", &s.ReasonCode) + delete(rawMsg, key) + case "valid": + err = unpopulate(val, "Valid", &s.Valid) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanValidateResponse. +func (s SavingsPlanValidateResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "benefits", s.Benefits) + populate(objectMap, "nextLink", s.NextLink) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanValidateResponse. +func (s *SavingsPlanValidateResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "benefits": + err = unpopulate(val, "Benefits", &s.Benefits) + delete(rawMsg, key) + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Utilization. +func (u Utilization) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "aggregates", u.Aggregates) + populate(objectMap, "trend", u.Trend) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Utilization. +func (u *Utilization) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "aggregates": + err = unpopulate(val, "Aggregates", &u.Aggregates) + delete(rawMsg, key) + case "trend": + err = unpopulate(val, "Trend", &u.Trend) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UtilizationAggregates. +func (u UtilizationAggregates) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "grain", u.Grain) + populate(objectMap, "grainUnit", u.GrainUnit) + populate(objectMap, "value", u.Value) + populate(objectMap, "valueUnit", u.ValueUnit) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UtilizationAggregates. +func (u *UtilizationAggregates) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "grain": + err = unpopulate(val, "Grain", &u.Grain) + delete(rawMsg, key) + case "grainUnit": + err = unpopulate(val, "GrainUnit", &u.GrainUnit) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &u.Value) + delete(rawMsg, key) + case "valueUnit": + err = unpopulate(val, "ValueUnit", &u.ValueUnit) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v interface{}) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/operations_client.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/operations_client.go new file mode 100644 index 000000000000..fafa9faa8bb1 --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/operations_client.go @@ -0,0 +1,104 @@ +//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 + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + host string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + host: ep, + pl: pl, + } + return client, nil +} + +// NewListPager - List all the operations. +// Generated from API version 2022-11-01 +// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ + More: func(page OperationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return OperationsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OperationsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.BillingBenefits/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/operations_client_example_test.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/operations_client_example_test.go new file mode 100644 index 000000000000..0d9c9ba03387 --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/operations_client_example_test.go @@ -0,0 +1,41 @@ +//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. + +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" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() + client, err := armbillingbenefits.NewOperationsClient(cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListPager(nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/reservationorderalias_client.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/reservationorderalias_client.go new file mode 100644 index 000000000000..176a96ef8f09 --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/reservationorderalias_client.go @@ -0,0 +1,158 @@ +//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 + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "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" +) + +// ReservationOrderAliasClient contains the methods for the ReservationOrderAlias group. +// Don't use this type directly, use NewReservationOrderAliasClient() instead. +type ReservationOrderAliasClient struct { + host string + pl runtime.Pipeline +} + +// NewReservationOrderAliasClient creates a new instance of ReservationOrderAliasClient with the specified values. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewReservationOrderAliasClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ReservationOrderAliasClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &ReservationOrderAliasClient{ + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreate - Create a reservation order alias. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-11-01 +// 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 +// method. +func (client *ReservationOrderAliasClient) BeginCreate(ctx context.Context, reservationOrderAliasName string, body ReservationOrderAliasRequest, options *ReservationOrderAliasClientBeginCreateOptions) (*runtime.Poller[ReservationOrderAliasClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, reservationOrderAliasName, body, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ReservationOrderAliasClientCreateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[ReservationOrderAliasClientCreateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Create - Create a reservation order alias. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-11-01 +func (client *ReservationOrderAliasClient) create(ctx context.Context, reservationOrderAliasName string, body ReservationOrderAliasRequest, options *ReservationOrderAliasClientBeginCreateOptions) (*http.Response, error) { + req, err := client.createCreateRequest(ctx, reservationOrderAliasName, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *ReservationOrderAliasClient) createCreateRequest(ctx context.Context, reservationOrderAliasName string, body ReservationOrderAliasRequest, options *ReservationOrderAliasClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.BillingBenefits/reservationOrderAliases/{reservationOrderAliasName}" + if reservationOrderAliasName == "" { + return nil, errors.New("parameter reservationOrderAliasName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationOrderAliasName}", url.PathEscape(reservationOrderAliasName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + +// Get - Get a reservation order alias. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-11-01 +// reservationOrderAliasName - Name of the reservation order alias +// options - ReservationOrderAliasClientGetOptions contains the optional parameters for the ReservationOrderAliasClient.Get +// method. +func (client *ReservationOrderAliasClient) Get(ctx context.Context, reservationOrderAliasName string, options *ReservationOrderAliasClientGetOptions) (ReservationOrderAliasClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, reservationOrderAliasName, options) + if err != nil { + return ReservationOrderAliasClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ReservationOrderAliasClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ReservationOrderAliasClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ReservationOrderAliasClient) getCreateRequest(ctx context.Context, reservationOrderAliasName string, options *ReservationOrderAliasClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.BillingBenefits/reservationOrderAliases/{reservationOrderAliasName}" + if reservationOrderAliasName == "" { + return nil, errors.New("parameter reservationOrderAliasName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationOrderAliasName}", url.PathEscape(reservationOrderAliasName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ReservationOrderAliasClient) getHandleResponse(resp *http.Response) (ReservationOrderAliasClientGetResponse, error) { + result := ReservationOrderAliasClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ReservationOrderAliasResponse); err != nil { + return ReservationOrderAliasClientGetResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/reservationorderalias_client_example_test.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/reservationorderalias_client_example_test.go new file mode 100644 index 000000000000..70ce2d8af2a9 --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/reservationorderalias_client_example_test.go @@ -0,0 +1,81 @@ +//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. + +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" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() + client, err := armbillingbenefits.NewReservationOrderAliasClient(cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.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) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() + client, err := armbillingbenefits.NewReservationOrderAliasClient(cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Get(ctx, "reservationOrderAlias123", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/response_types.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/response_types.go new file mode 100644 index 000000000000..e31c453557d1 --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/response_types.go @@ -0,0 +1,82 @@ +//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 + +// OperationsClientListResponse contains the response from method OperationsClient.List. +type OperationsClientListResponse struct { + OperationListResult +} + +// RPClientValidatePurchaseResponse contains the response from method RPClient.ValidatePurchase. +type RPClientValidatePurchaseResponse struct { + SavingsPlanValidateResponse +} + +// ReservationOrderAliasClientCreateResponse contains the response from method ReservationOrderAliasClient.Create. +type ReservationOrderAliasClientCreateResponse struct { + ReservationOrderAliasResponse +} + +// ReservationOrderAliasClientGetResponse contains the response from method ReservationOrderAliasClient.Get. +type ReservationOrderAliasClientGetResponse struct { + ReservationOrderAliasResponse +} + +// SavingsPlanClientGetResponse contains the response from method SavingsPlanClient.Get. +type SavingsPlanClientGetResponse struct { + SavingsPlanModel +} + +// SavingsPlanClientListAllResponse contains the response from method SavingsPlanClient.ListAll. +type SavingsPlanClientListAllResponse struct { + SavingsPlanModelListResult +} + +// SavingsPlanClientListResponse contains the response from method SavingsPlanClient.List. +type SavingsPlanClientListResponse struct { + SavingsPlanModelList +} + +// SavingsPlanClientUpdateResponse contains the response from method SavingsPlanClient.Update. +type SavingsPlanClientUpdateResponse struct { + SavingsPlanModel + // Location contains the information returned from the Location header response. + Location *string +} + +// SavingsPlanClientValidateUpdateResponse contains the response from method SavingsPlanClient.ValidateUpdate. +type SavingsPlanClientValidateUpdateResponse struct { + SavingsPlanValidateResponse +} + +// SavingsPlanOrderAliasClientCreateResponse contains the response from method SavingsPlanOrderAliasClient.Create. +type SavingsPlanOrderAliasClientCreateResponse struct { + SavingsPlanOrderAliasModel +} + +// SavingsPlanOrderAliasClientGetResponse contains the response from method SavingsPlanOrderAliasClient.Get. +type SavingsPlanOrderAliasClientGetResponse struct { + SavingsPlanOrderAliasModel +} + +// SavingsPlanOrderClientElevateResponse contains the response from method SavingsPlanOrderClient.Elevate. +type SavingsPlanOrderClientElevateResponse struct { + RoleAssignmentEntity +} + +// SavingsPlanOrderClientGetResponse contains the response from method SavingsPlanOrderClient.Get. +type SavingsPlanOrderClientGetResponse struct { + SavingsPlanOrderModel +} + +// SavingsPlanOrderClientListResponse contains the response from method SavingsPlanOrderClient.List. +type SavingsPlanOrderClientListResponse struct { + SavingsPlanOrderModelList +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/rp_client.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/rp_client.go new file mode 100644 index 000000000000..5eb6fa368b8a --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/rp_client.go @@ -0,0 +1,93 @@ +//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 + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// RPClient contains the methods for the BillingBenefitsRP group. +// Don't use this type directly, use NewRPClient() instead. +type RPClient struct { + host string + pl runtime.Pipeline +} + +// NewRPClient creates a new instance of RPClient with the specified values. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewRPClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*RPClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &RPClient{ + host: ep, + pl: pl, + } + return client, nil +} + +// ValidatePurchase - Validate savings plan purchase. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-11-01 +// 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) { + req, err := client.validatePurchaseCreateRequest(ctx, body, options) + if err != nil { + return RPClientValidatePurchaseResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return RPClientValidatePurchaseResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return RPClientValidatePurchaseResponse{}, runtime.NewResponseError(resp) + } + return client.validatePurchaseHandleResponse(resp) +} + +// validatePurchaseCreateRequest creates the ValidatePurchase request. +func (client *RPClient) validatePurchaseCreateRequest(ctx context.Context, body SavingsPlanPurchaseValidateRequest, options *RPClientValidatePurchaseOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.BillingBenefits/validate" + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + +// validatePurchaseHandleResponse handles the ValidatePurchase response. +func (client *RPClient) validatePurchaseHandleResponse(resp *http.Response) (RPClientValidatePurchaseResponse, error) { + result := RPClientValidatePurchaseResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SavingsPlanValidateResponse); err != nil { + return RPClientValidatePurchaseResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/rp_client_example_test.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/rp_client_example_test.go new file mode 100644 index 000000000000..3211d6b386f5 --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/rp_client_example_test.go @@ -0,0 +1,77 @@ +//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. + +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" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() + client, err := armbillingbenefits.NewRPClient(cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.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) + } + // TODO: use response item + _ = res +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplan_client.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplan_client.go new file mode 100644 index 000000000000..e405b4827a4a --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplan_client.go @@ -0,0 +1,353 @@ +//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 + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// SavingsPlanClient contains the methods for the SavingsPlan group. +// Don't use this type directly, use NewSavingsPlanClient() instead. +type SavingsPlanClient struct { + host string + expand *string + pl runtime.Pipeline +} + +// NewSavingsPlanClient creates a new instance of SavingsPlanClient with the specified values. +// expand - May be used to expand the detail information of some properties. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewSavingsPlanClient(expand *string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SavingsPlanClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &SavingsPlanClient{ + expand: expand, + host: ep, + pl: pl, + } + return client, nil +} + +// Get - Get savings plan. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-11-01 +// savingsPlanOrderID - Order ID of the savings plan +// savingsPlanID - ID of the savings plan +// options - SavingsPlanClientGetOptions contains the optional parameters for the SavingsPlanClient.Get method. +func (client *SavingsPlanClient) Get(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, options *SavingsPlanClientGetOptions) (SavingsPlanClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, savingsPlanOrderID, savingsPlanID, options) + if err != nil { + return SavingsPlanClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SavingsPlanClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SavingsPlanClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *SavingsPlanClient) getCreateRequest(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, options *SavingsPlanClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.BillingBenefits/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans/{savingsPlanId}" + if savingsPlanOrderID == "" { + return nil, errors.New("parameter savingsPlanOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanOrderId}", url.PathEscape(savingsPlanOrderID)) + if savingsPlanID == "" { + return nil, errors.New("parameter savingsPlanID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanId}", url.PathEscape(savingsPlanID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-11-01") + if client.expand != nil { + reqQP.Set("$expand", *client.expand) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *SavingsPlanClient) getHandleResponse(resp *http.Response) (SavingsPlanClientGetResponse, error) { + result := SavingsPlanClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SavingsPlanModel); err != nil { + return SavingsPlanClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - List savings plans in an order. +// Generated from API version 2022-11-01 +// savingsPlanOrderID - Order ID of the savings plan +// options - SavingsPlanClientListOptions contains the optional parameters for the SavingsPlanClient.List method. +func (client *SavingsPlanClient) NewListPager(savingsPlanOrderID string, options *SavingsPlanClientListOptions) *runtime.Pager[SavingsPlanClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[SavingsPlanClientListResponse]{ + More: func(page SavingsPlanClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SavingsPlanClientListResponse) (SavingsPlanClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, savingsPlanOrderID, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return SavingsPlanClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SavingsPlanClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SavingsPlanClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *SavingsPlanClient) listCreateRequest(ctx context.Context, savingsPlanOrderID string, options *SavingsPlanClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.BillingBenefits/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans" + if savingsPlanOrderID == "" { + return nil, errors.New("parameter savingsPlanOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanOrderId}", url.PathEscape(savingsPlanOrderID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *SavingsPlanClient) listHandleResponse(resp *http.Response) (SavingsPlanClientListResponse, error) { + result := SavingsPlanClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SavingsPlanModelList); err != nil { + return SavingsPlanClientListResponse{}, err + } + return result, nil +} + +// NewListAllPager - List savings plans. +// Generated from API version 2022-11-01 +// options - SavingsPlanClientListAllOptions contains the optional parameters for the SavingsPlanClient.ListAll method. +func (client *SavingsPlanClient) NewListAllPager(options *SavingsPlanClientListAllOptions) *runtime.Pager[SavingsPlanClientListAllResponse] { + return runtime.NewPager(runtime.PagingHandler[SavingsPlanClientListAllResponse]{ + More: func(page SavingsPlanClientListAllResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SavingsPlanClientListAllResponse) (SavingsPlanClientListAllResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listAllCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return SavingsPlanClientListAllResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SavingsPlanClientListAllResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SavingsPlanClientListAllResponse{}, runtime.NewResponseError(resp) + } + return client.listAllHandleResponse(resp) + }, + }) +} + +// listAllCreateRequest creates the ListAll request. +func (client *SavingsPlanClient) listAllCreateRequest(ctx context.Context, options *SavingsPlanClientListAllOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.BillingBenefits/savingsPlans" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + 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)) + } + if options != nil && options.SelectedState != nil { + reqQP.Set("selectedState", *options.SelectedState) + } + if options != nil && options.Take != nil { + reqQP.Set("take", strconv.FormatFloat(float64(*options.Take), 'f', -1, 32)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listAllHandleResponse handles the ListAll response. +func (client *SavingsPlanClient) listAllHandleResponse(resp *http.Response) (SavingsPlanClientListAllResponse, error) { + result := SavingsPlanClientListAllResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SavingsPlanModelListResult); err != nil { + return SavingsPlanClientListAllResponse{}, err + } + return result, nil +} + +// Update - Update savings plan. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-11-01 +// 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) { + req, err := client.updateCreateRequest(ctx, savingsPlanOrderID, savingsPlanID, body, options) + if err != nil { + return SavingsPlanClientUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SavingsPlanClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return SavingsPlanClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *SavingsPlanClient) updateCreateRequest(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, body SavingsPlanUpdateRequest, options *SavingsPlanClientUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.BillingBenefits/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans/{savingsPlanId}" + if savingsPlanOrderID == "" { + return nil, errors.New("parameter savingsPlanOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanOrderId}", url.PathEscape(savingsPlanOrderID)) + if savingsPlanID == "" { + return nil, errors.New("parameter savingsPlanID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanId}", url.PathEscape(savingsPlanID)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + +// 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 +// savingsPlanOrderID - Order ID of the savings plan +// savingsPlanID - ID of the savings plan +// body - Request body for validating a savings plan patch request +// options - SavingsPlanClientValidateUpdateOptions contains the optional parameters for the SavingsPlanClient.ValidateUpdate +// method. +func (client *SavingsPlanClient) ValidateUpdate(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, body SavingsPlanUpdateValidateRequest, options *SavingsPlanClientValidateUpdateOptions) (SavingsPlanClientValidateUpdateResponse, error) { + req, err := client.validateUpdateCreateRequest(ctx, savingsPlanOrderID, savingsPlanID, body, options) + if err != nil { + return SavingsPlanClientValidateUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SavingsPlanClientValidateUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SavingsPlanClientValidateUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.validateUpdateHandleResponse(resp) +} + +// validateUpdateCreateRequest creates the ValidateUpdate request. +func (client *SavingsPlanClient) validateUpdateCreateRequest(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, body SavingsPlanUpdateValidateRequest, options *SavingsPlanClientValidateUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.BillingBenefits/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans/{savingsPlanId}/validate" + if savingsPlanOrderID == "" { + return nil, errors.New("parameter savingsPlanOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanOrderId}", url.PathEscape(savingsPlanOrderID)) + if savingsPlanID == "" { + return nil, errors.New("parameter savingsPlanID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanId}", url.PathEscape(savingsPlanID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + +// validateUpdateHandleResponse handles the ValidateUpdate response. +func (client *SavingsPlanClient) validateUpdateHandleResponse(resp *http.Response) (SavingsPlanClientValidateUpdateResponse, error) { + result := SavingsPlanClientValidateUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SavingsPlanValidateResponse); err != nil { + return SavingsPlanClientValidateUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplan_client_example_test.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplan_client_example_test.go new file mode 100644 index 000000000000..f3d28ef81af3 --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplan_client_example_test.go @@ -0,0 +1,196 @@ +//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. + +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" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() + client, err := armbillingbenefits.NewSavingsPlanClient(nil, cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListPager("20000000-0000-0000-0000-000000000000", nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() + client, err := armbillingbenefits.NewSavingsPlanClient(nil, cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.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() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() + client, err := armbillingbenefits.NewSavingsPlanClient(nil, cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Get(ctx, "20000000-0000-0000-0000-000000000000", "30000000-0000-0000-0000-000000000000", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() + client, err := armbillingbenefits.NewSavingsPlanClient(to.Ptr("renewProperties"), cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Get(ctx, "20000000-0000-0000-0000-000000000000", "30000000-0000-0000-0000-000000000000", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() + client, err := armbillingbenefits.NewSavingsPlanClient(nil, cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.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) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() + client, err := armbillingbenefits.NewSavingsPlanClient(nil, cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.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) + } + // TODO: use response item + _ = res +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorder_client.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorder_client.go new file mode 100644 index 000000000000..63e8d20e036c --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorder_client.go @@ -0,0 +1,208 @@ +//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 + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "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" +) + +// SavingsPlanOrderClient contains the methods for the SavingsPlanOrder group. +// Don't use this type directly, use NewSavingsPlanOrderClient() instead. +type SavingsPlanOrderClient struct { + host string + expand *string + pl runtime.Pipeline +} + +// NewSavingsPlanOrderClient creates a new instance of SavingsPlanOrderClient with the specified values. +// expand - May be used to expand the detail information of some properties. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewSavingsPlanOrderClient(expand *string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SavingsPlanOrderClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &SavingsPlanOrderClient{ + expand: expand, + host: ep, + pl: pl, + } + return client, nil +} + +// 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 +// savingsPlanOrderID - Order ID of the savings plan +// options - SavingsPlanOrderClientElevateOptions contains the optional parameters for the SavingsPlanOrderClient.Elevate +// method. +func (client *SavingsPlanOrderClient) Elevate(ctx context.Context, savingsPlanOrderID string, options *SavingsPlanOrderClientElevateOptions) (SavingsPlanOrderClientElevateResponse, error) { + req, err := client.elevateCreateRequest(ctx, savingsPlanOrderID, options) + if err != nil { + return SavingsPlanOrderClientElevateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SavingsPlanOrderClientElevateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SavingsPlanOrderClientElevateResponse{}, runtime.NewResponseError(resp) + } + return client.elevateHandleResponse(resp) +} + +// elevateCreateRequest creates the Elevate request. +func (client *SavingsPlanOrderClient) elevateCreateRequest(ctx context.Context, savingsPlanOrderID string, options *SavingsPlanOrderClientElevateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.BillingBenefits/savingsPlanOrders/{savingsPlanOrderId}/elevate" + if savingsPlanOrderID == "" { + return nil, errors.New("parameter savingsPlanOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanOrderId}", url.PathEscape(savingsPlanOrderID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// elevateHandleResponse handles the Elevate response. +func (client *SavingsPlanOrderClient) elevateHandleResponse(resp *http.Response) (SavingsPlanOrderClientElevateResponse, error) { + result := SavingsPlanOrderClientElevateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignmentEntity); err != nil { + return SavingsPlanOrderClientElevateResponse{}, err + } + return result, nil +} + +// Get - Get a savings plan order. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-11-01 +// 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) { + req, err := client.getCreateRequest(ctx, savingsPlanOrderID, options) + if err != nil { + return SavingsPlanOrderClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SavingsPlanOrderClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SavingsPlanOrderClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *SavingsPlanOrderClient) getCreateRequest(ctx context.Context, savingsPlanOrderID string, options *SavingsPlanOrderClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.BillingBenefits/savingsPlanOrders/{savingsPlanOrderId}" + if savingsPlanOrderID == "" { + return nil, errors.New("parameter savingsPlanOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanOrderId}", url.PathEscape(savingsPlanOrderID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-11-01") + if client.expand != nil { + reqQP.Set("$expand", *client.expand) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *SavingsPlanOrderClient) getHandleResponse(resp *http.Response) (SavingsPlanOrderClientGetResponse, error) { + result := SavingsPlanOrderClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SavingsPlanOrderModel); err != nil { + return SavingsPlanOrderClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - List all Savings plan orders. +// Generated from API version 2022-11-01 +// options - SavingsPlanOrderClientListOptions contains the optional parameters for the SavingsPlanOrderClient.List method. +func (client *SavingsPlanOrderClient) NewListPager(options *SavingsPlanOrderClientListOptions) *runtime.Pager[SavingsPlanOrderClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[SavingsPlanOrderClientListResponse]{ + More: func(page SavingsPlanOrderClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SavingsPlanOrderClientListResponse) (SavingsPlanOrderClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return SavingsPlanOrderClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SavingsPlanOrderClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SavingsPlanOrderClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *SavingsPlanOrderClient) listCreateRequest(ctx context.Context, options *SavingsPlanOrderClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.BillingBenefits/savingsPlanOrders" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *SavingsPlanOrderClient) listHandleResponse(resp *http.Response) (SavingsPlanOrderClientListResponse, error) { + result := SavingsPlanOrderClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SavingsPlanOrderModelList); err != nil { + return SavingsPlanOrderClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorder_client_example_test.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorder_client_example_test.go new file mode 100644 index 000000000000..bcd3c19a7489 --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorder_client_example_test.go @@ -0,0 +1,99 @@ +//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. + +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" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() + client, err := armbillingbenefits.NewSavingsPlanOrderClient(nil, cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Get(ctx, "20000000-0000-0000-0000-000000000000", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() + client, err := armbillingbenefits.NewSavingsPlanOrderClient(to.Ptr("schedule"), cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Get(ctx, "20000000-0000-0000-0000-000000000000", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() + client, err := armbillingbenefits.NewSavingsPlanOrderClient(nil, cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Elevate(ctx, "20000000-0000-0000-0000-000000000000", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() + client, err := armbillingbenefits.NewSavingsPlanOrderClient(nil, cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListPager(nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorderalias_client.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorderalias_client.go new file mode 100644 index 000000000000..0dbd46739039 --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorderalias_client.go @@ -0,0 +1,158 @@ +//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 + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "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" +) + +// SavingsPlanOrderAliasClient contains the methods for the SavingsPlanOrderAlias group. +// Don't use this type directly, use NewSavingsPlanOrderAliasClient() instead. +type SavingsPlanOrderAliasClient struct { + host string + pl runtime.Pipeline +} + +// NewSavingsPlanOrderAliasClient creates a new instance of SavingsPlanOrderAliasClient with the specified values. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewSavingsPlanOrderAliasClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*SavingsPlanOrderAliasClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &SavingsPlanOrderAliasClient{ + host: ep, + pl: pl, + } + return client, nil +} + +// 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 +// 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 +// method. +func (client *SavingsPlanOrderAliasClient) BeginCreate(ctx context.Context, savingsPlanOrderAliasName string, body SavingsPlanOrderAliasModel, options *SavingsPlanOrderAliasClientBeginCreateOptions) (*runtime.Poller[SavingsPlanOrderAliasClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, savingsPlanOrderAliasName, body, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SavingsPlanOrderAliasClientCreateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[SavingsPlanOrderAliasClientCreateResponse](options.ResumeToken, client.pl, nil) + } +} + +// 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 +func (client *SavingsPlanOrderAliasClient) create(ctx context.Context, savingsPlanOrderAliasName string, body SavingsPlanOrderAliasModel, options *SavingsPlanOrderAliasClientBeginCreateOptions) (*http.Response, error) { + req, err := client.createCreateRequest(ctx, savingsPlanOrderAliasName, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *SavingsPlanOrderAliasClient) createCreateRequest(ctx context.Context, savingsPlanOrderAliasName string, body SavingsPlanOrderAliasModel, options *SavingsPlanOrderAliasClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.BillingBenefits/savingsPlanOrderAliases/{savingsPlanOrderAliasName}" + if savingsPlanOrderAliasName == "" { + return nil, errors.New("parameter savingsPlanOrderAliasName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanOrderAliasName}", url.PathEscape(savingsPlanOrderAliasName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + +// Get - Get a savings plan. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-11-01 +// savingsPlanOrderAliasName - Name of the savings plan order alias +// options - SavingsPlanOrderAliasClientGetOptions contains the optional parameters for the SavingsPlanOrderAliasClient.Get +// method. +func (client *SavingsPlanOrderAliasClient) Get(ctx context.Context, savingsPlanOrderAliasName string, options *SavingsPlanOrderAliasClientGetOptions) (SavingsPlanOrderAliasClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, savingsPlanOrderAliasName, options) + if err != nil { + return SavingsPlanOrderAliasClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SavingsPlanOrderAliasClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SavingsPlanOrderAliasClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *SavingsPlanOrderAliasClient) getCreateRequest(ctx context.Context, savingsPlanOrderAliasName string, options *SavingsPlanOrderAliasClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.BillingBenefits/savingsPlanOrderAliases/{savingsPlanOrderAliasName}" + if savingsPlanOrderAliasName == "" { + return nil, errors.New("parameter savingsPlanOrderAliasName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanOrderAliasName}", url.PathEscape(savingsPlanOrderAliasName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *SavingsPlanOrderAliasClient) getHandleResponse(resp *http.Response) (SavingsPlanOrderAliasClientGetResponse, error) { + result := SavingsPlanOrderAliasClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SavingsPlanOrderAliasModel); err != nil { + return SavingsPlanOrderAliasClientGetResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorderalias_client_example_test.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorderalias_client_example_test.go new file mode 100644 index 000000000000..ec0d0cb5a530 --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/savingsplanorderalias_client_example_test.go @@ -0,0 +1,118 @@ +//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. + +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" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() + client, err := armbillingbenefits.NewSavingsPlanOrderAliasClient(cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.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) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() + client, err := armbillingbenefits.NewSavingsPlanOrderAliasClient(cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.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) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() + client, err := armbillingbenefits.NewSavingsPlanOrderAliasClient(cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Get(ctx, "spAlias123", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/time_rfc3339.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/time_rfc3339.go new file mode 100644 index 000000000000..0b9656ac2fdf --- /dev/null +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/time_rfc3339.go @@ -0,0 +1,87 @@ +//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 + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// 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+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} + +func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*timeRFC3339)(t) +} + +func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux timeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} From 757aee766dc7c47d2d6fcea0d4d8445d3cd7dbf4 Mon Sep 17 00:00:00 2001 From: Alancere <804873052@qq.com> Date: Fri, 9 Dec 2022 13:44:48 +0800 Subject: [PATCH 2/2] update --- .../armbillingbenefits/autorest.md | 4 +-- .../armbillingbenefits/models.go | 14 ++++---- .../armbillingbenefits/models_serde.go | 35 +++++-------------- 3 files changed, 18 insertions(+), 35 deletions(-) diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/autorest.md b/sdk/resourcemanager/billingbenefits/armbillingbenefits/autorest.md index 2f8f47766f93..d75603e0ea27 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/autorest.md +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/autorest.md @@ -5,8 +5,8 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/59dd84dbde43f134f8a0369e6cc40b5d1df6fbbe/specification/billingbenefits/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/59dd84dbde43f134f8a0369e6cc40b5d1df6fbbe/specification/billingbenefits/resource-manager/readme.go.md +- https://github.com/Azure/azure-rest-api-specs/blob/bab95d5636c7d47cc5584ea8dadb21199d229ca7/specification/billingbenefits/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/bab95d5636c7d47cc5584ea8dadb21199d229ca7/specification/billingbenefits/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION module-version: 1.0.0 diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/models.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/models.go index 0c033447edf7..1ffe9a3b9ff2 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/models.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/models.go @@ -474,8 +474,14 @@ type SavingsPlanModelProperties struct { DisplayName *string `json:"displayName,omitempty"` // Setting this to true will automatically purchase a new benefit on the expiration date time. - Renew *bool `json:"renew,omitempty"` - RenewProperties *SavingsPlanModelPropertiesRenewProperties `json:"renewProperties,omitempty"` + Renew *bool `json:"renew,omitempty"` + + // SavingsPlan Id of the SavingsPlan which is purchased because of renew. + RenewDestination *string `json:"renewDestination,omitempty"` + RenewProperties *RenewProperties `json:"renewProperties,omitempty"` + + // SavingsPlan Id of the SavingsPlan from which this SavingsPlan is renewed. + RenewSource *string `json:"renewSource,omitempty"` // Represent benefit term in ISO 8601 format. Term *Term `json:"term,omitempty"` @@ -516,10 +522,6 @@ type SavingsPlanModelProperties struct { Utilization *Utilization `json:"utilization,omitempty" azure:"ro"` } -type SavingsPlanModelPropertiesRenewProperties struct { - PurchaseProperties *PurchaseRequest `json:"purchaseProperties,omitempty"` -} - // SavingsPlanOrderAliasClientBeginCreateOptions contains the optional parameters for the SavingsPlanOrderAliasClient.BeginCreate // method. type SavingsPlanOrderAliasClientBeginCreateOptions struct { diff --git a/sdk/resourcemanager/billingbenefits/armbillingbenefits/models_serde.go b/sdk/resourcemanager/billingbenefits/armbillingbenefits/models_serde.go index c47c5c9c580e..b1850856e3a5 100644 --- a/sdk/resourcemanager/billingbenefits/armbillingbenefits/models_serde.go +++ b/sdk/resourcemanager/billingbenefits/armbillingbenefits/models_serde.go @@ -1004,7 +1004,9 @@ func (s SavingsPlanModelProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "provisioningState", s.ProvisioningState) populateTimeRFC3339(objectMap, "purchaseDateTime", s.PurchaseDateTime) populate(objectMap, "renew", s.Renew) + populate(objectMap, "renewDestination", s.RenewDestination) populate(objectMap, "renewProperties", s.RenewProperties) + populate(objectMap, "renewSource", s.RenewSource) populate(objectMap, "term", s.Term) populate(objectMap, "userFriendlyAppliedScopeType", s.UserFriendlyAppliedScopeType) populate(objectMap, "utilization", s.Utilization) @@ -1071,9 +1073,15 @@ func (s *SavingsPlanModelProperties) UnmarshalJSON(data []byte) error { case "renew": err = unpopulate(val, "Renew", &s.Renew) delete(rawMsg, key) + case "renewDestination": + err = unpopulate(val, "RenewDestination", &s.RenewDestination) + delete(rawMsg, key) case "renewProperties": err = unpopulate(val, "RenewProperties", &s.RenewProperties) delete(rawMsg, key) + case "renewSource": + err = unpopulate(val, "RenewSource", &s.RenewSource) + delete(rawMsg, key) case "term": err = unpopulate(val, "Term", &s.Term) delete(rawMsg, key) @@ -1091,33 +1099,6 @@ func (s *SavingsPlanModelProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type SavingsPlanModelPropertiesRenewProperties. -func (s SavingsPlanModelPropertiesRenewProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "purchaseProperties", s.PurchaseProperties) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanModelPropertiesRenewProperties. -func (s *SavingsPlanModelPropertiesRenewProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "purchaseProperties": - err = unpopulate(val, "PurchaseProperties", &s.PurchaseProperties) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type SavingsPlanOrderAliasModel. func (s SavingsPlanOrderAliasModel) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{})