From 621aa4c02f27dd947f39b3591bc039d91ea59f32 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 8 Dec 2021 06:38:35 +0000 Subject: [PATCH] CodeGen from PR 16973 in Azure/azure-rest-api-specs Track2 modify readme.go.md 8 (#16973) * Track2 modify readme.go.md 8 * backup,siterecovery into recoveryservices --- .../reservations/armreservations/CHANGELOG.md | 5 + .../reservations/armreservations/LICENSE.txt | 21 + .../reservations/armreservations/README.md | 75 + .../reservations/armreservations/autorest.md | 13 + .../reservations/armreservations/build.go | 7 + .../reservations/armreservations/ci.yml | 27 + .../reservations/armreservations/go.mod | 8 + .../reservations/armreservations/go.sum | 37 + .../armreservations/go_mod_tidy_hack.go | 13 + ...zz_generated_azurereservationapi_client.go | 162 ++ .../zz_generated_calculateexchange_client.go | 103 + .../armreservations/zz_generated_constants.go | 702 ++++++ .../armreservations/zz_generated_date_type.go | 59 + .../zz_generated_exchange_client.go | 103 + .../armreservations/zz_generated_models.go | 2004 +++++++++++++++++ .../zz_generated_operation_client.go | 89 + .../armreservations/zz_generated_pagers.go | 395 ++++ .../armreservations/zz_generated_pollers.go | 402 ++++ .../zz_generated_quota_client.go | 362 +++ .../zz_generated_quotarequeststatus_client.go | 186 ++ .../zz_generated_reservation_client.go | 567 +++++ .../zz_generated_reservationorder_client.go | 330 +++ .../zz_generated_response_types.go | 671 ++++++ .../zz_generated_time_rfc3339.go | 85 + 24 files changed, 6426 insertions(+) create mode 100644 sdk/resourcemanager/reservations/armreservations/CHANGELOG.md create mode 100644 sdk/resourcemanager/reservations/armreservations/LICENSE.txt create mode 100644 sdk/resourcemanager/reservations/armreservations/README.md create mode 100644 sdk/resourcemanager/reservations/armreservations/autorest.md create mode 100644 sdk/resourcemanager/reservations/armreservations/build.go create mode 100644 sdk/resourcemanager/reservations/armreservations/ci.yml create mode 100644 sdk/resourcemanager/reservations/armreservations/go.mod create mode 100644 sdk/resourcemanager/reservations/armreservations/go.sum create mode 100644 sdk/resourcemanager/reservations/armreservations/go_mod_tidy_hack.go create mode 100644 sdk/resourcemanager/reservations/armreservations/zz_generated_azurereservationapi_client.go create mode 100644 sdk/resourcemanager/reservations/armreservations/zz_generated_calculateexchange_client.go create mode 100644 sdk/resourcemanager/reservations/armreservations/zz_generated_constants.go create mode 100644 sdk/resourcemanager/reservations/armreservations/zz_generated_date_type.go create mode 100644 sdk/resourcemanager/reservations/armreservations/zz_generated_exchange_client.go create mode 100644 sdk/resourcemanager/reservations/armreservations/zz_generated_models.go create mode 100644 sdk/resourcemanager/reservations/armreservations/zz_generated_operation_client.go create mode 100644 sdk/resourcemanager/reservations/armreservations/zz_generated_pagers.go create mode 100644 sdk/resourcemanager/reservations/armreservations/zz_generated_pollers.go create mode 100644 sdk/resourcemanager/reservations/armreservations/zz_generated_quota_client.go create mode 100644 sdk/resourcemanager/reservations/armreservations/zz_generated_quotarequeststatus_client.go create mode 100644 sdk/resourcemanager/reservations/armreservations/zz_generated_reservation_client.go create mode 100644 sdk/resourcemanager/reservations/armreservations/zz_generated_reservationorder_client.go create mode 100644 sdk/resourcemanager/reservations/armreservations/zz_generated_response_types.go create mode 100644 sdk/resourcemanager/reservations/armreservations/zz_generated_time_rfc3339.go diff --git a/sdk/resourcemanager/reservations/armreservations/CHANGELOG.md b/sdk/resourcemanager/reservations/armreservations/CHANGELOG.md new file mode 100644 index 000000000000..f35894b0071f --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2021-12-08) + +- Init release. \ No newline at end of file diff --git a/sdk/resourcemanager/reservations/armreservations/LICENSE.txt b/sdk/resourcemanager/reservations/armreservations/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/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/reservations/armreservations/README.md b/sdk/resourcemanager/reservations/armreservations/README.md new file mode 100644 index 000000000000..4142bea5f0a1 --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/README.md @@ -0,0 +1,75 @@ +# Azure Reservations Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/reservations/armreservations)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/reservations/armreservations) + +The `armreservations` module provides operations for working with Azure Reservations. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/reservations/armreservations) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.13 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Reservations module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/reservations/armreservations +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Reservations. 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 Reservations 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 := armreservations.(, 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{ + Host: arm.AzureChina, +} +client := armreservations.(, 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 `Reservations` 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/reservations/armreservations/autorest.md b/sdk/resourcemanager/reservations/armreservations/autorest.md new file mode 100644 index 000000000000..753f9a986334 --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /home/vsts/work/1/s/azure-rest-api-specs/specification/reservations/resource-manager/readme.md +- /home/vsts/work/1/s/azure-rest-api-specs/specification/reservations/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/reservations/armreservations/build.go b/sdk/resourcemanager/reservations/armreservations/build.go new file mode 100644 index 000000000000..d74eb5bdf665 --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/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.exe ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/reservations/armreservations + +package armreservations diff --git a/sdk/resourcemanager/reservations/armreservations/ci.yml b/sdk/resourcemanager/reservations/armreservations/ci.yml new file mode 100644 index 000000000000..ee40fd6aba9d --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/ci.yml @@ -0,0 +1,27 @@ +# 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/reservations/armreservations/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/reservations/armreservations/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/reservations/armreservations' diff --git a/sdk/resourcemanager/reservations/armreservations/go.mod b/sdk/resourcemanager/reservations/armreservations/go.mod new file mode 100644 index 000000000000..c463a2385441 --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/reservations/armreservations + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v60.0.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 +) diff --git a/sdk/resourcemanager/reservations/armreservations/go.sum b/sdk/resourcemanager/reservations/armreservations/go.sum new file mode 100644 index 000000000000..4cb1a2cbfc46 --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/go.sum @@ -0,0 +1,37 @@ +github.com/Azure/azure-sdk-for-go v60.0.0+incompatible h1:vVRJhSSTwhIHQTzTjqoZCItFJeBwfdNSqHcgGV10FHQ= +github.com/Azure/azure-sdk-for-go v60.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 h1:KQgdWmEOmaJKxaUUZwHAYh12t+b+ZJf8q3friycK1kA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0/go.mod h1:ZPW/Z0kLCTdDZaDbYTetxc9Cxl/2lNqxYHYNOF2bti0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1 h1:BUYIbDf/mMZ8945v3QkG3OuqGVyS4Iek0AOLwdRAYoc= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/reservations/armreservations/go_mod_tidy_hack.go b/sdk/resourcemanager/reservations/armreservations/go_mod_tidy_hack.go new file mode 100644 index 000000000000..fa745792c6e9 --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/go_mod_tidy_hack.go @@ -0,0 +1,13 @@ +//go:build modhack +// +build modhack + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file, and the github.com/Azure/azure-sdk-for-go import, won't actually become part of +// the resultant binary. + +package armreservations + +// Necessary for safely adding multi-module repo. See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository +import _ "github.com/Azure/azure-sdk-for-go" diff --git a/sdk/resourcemanager/reservations/armreservations/zz_generated_azurereservationapi_client.go b/sdk/resourcemanager/reservations/armreservations/zz_generated_azurereservationapi_client.go new file mode 100644 index 000000000000..bbd2ff13a2b0 --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/zz_generated_azurereservationapi_client.go @@ -0,0 +1,162 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armreservations + +import ( + "context" + "errors" + "fmt" + "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/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// AzureReservationAPIClient contains the methods for the AzureReservationAPI group. +// Don't use this type directly, use NewAzureReservationAPIClient() instead. +type AzureReservationAPIClient struct { + ep string + pl runtime.Pipeline +} + +// NewAzureReservationAPIClient creates a new instance of AzureReservationAPIClient with the specified values. +func NewAzureReservationAPIClient(credential azcore.TokenCredential, options *arm.ClientOptions) *AzureReservationAPIClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &AzureReservationAPIClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// GetAppliedReservationList - Get applicable Reservations that are applied to this subscription or a resource group under this subscription. +// If the operation fails it returns the *Error error type. +func (client *AzureReservationAPIClient) GetAppliedReservationList(ctx context.Context, subscriptionID string, options *AzureReservationAPIGetAppliedReservationListOptions) (AzureReservationAPIGetAppliedReservationListResponse, error) { + req, err := client.getAppliedReservationListCreateRequest(ctx, subscriptionID, options) + if err != nil { + return AzureReservationAPIGetAppliedReservationListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AzureReservationAPIGetAppliedReservationListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AzureReservationAPIGetAppliedReservationListResponse{}, client.getAppliedReservationListHandleError(resp) + } + return client.getAppliedReservationListHandleResponse(resp) +} + +// getAppliedReservationListCreateRequest creates the GetAppliedReservationList request. +func (client *AzureReservationAPIClient) getAppliedReservationListCreateRequest(ctx context.Context, subscriptionID string, options *AzureReservationAPIGetAppliedReservationListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/appliedReservations" + if subscriptionID == "" { + return nil, errors.New("parameter subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getAppliedReservationListHandleResponse handles the GetAppliedReservationList response. +func (client *AzureReservationAPIClient) getAppliedReservationListHandleResponse(resp *http.Response) (AzureReservationAPIGetAppliedReservationListResponse, error) { + result := AzureReservationAPIGetAppliedReservationListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AppliedReservations); err != nil { + return AzureReservationAPIGetAppliedReservationListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getAppliedReservationListHandleError handles the GetAppliedReservationList error response. +func (client *AzureReservationAPIClient) getAppliedReservationListHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := Error{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// GetCatalog - Get the regions and skus that are available for RI purchase for the specified Azure subscription. +// If the operation fails it returns the *Error error type. +func (client *AzureReservationAPIClient) GetCatalog(ctx context.Context, subscriptionID string, options *AzureReservationAPIGetCatalogOptions) (AzureReservationAPIGetCatalogResponse, error) { + req, err := client.getCatalogCreateRequest(ctx, subscriptionID, options) + if err != nil { + return AzureReservationAPIGetCatalogResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AzureReservationAPIGetCatalogResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AzureReservationAPIGetCatalogResponse{}, client.getCatalogHandleError(resp) + } + return client.getCatalogHandleResponse(resp) +} + +// getCatalogCreateRequest creates the GetCatalog request. +func (client *AzureReservationAPIClient) getCatalogCreateRequest(ctx context.Context, subscriptionID string, options *AzureReservationAPIGetCatalogOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/catalogs" + if subscriptionID == "" { + return nil, errors.New("parameter subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + if options != nil && options.ReservedResourceType != nil { + reqQP.Set("reservedResourceType", *options.ReservedResourceType) + } + if options != nil && options.Location != nil { + reqQP.Set("location", *options.Location) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getCatalogHandleResponse handles the GetCatalog response. +func (client *AzureReservationAPIClient) getCatalogHandleResponse(resp *http.Response) (AzureReservationAPIGetCatalogResponse, error) { + result := AzureReservationAPIGetCatalogResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CatalogArray); err != nil { + return AzureReservationAPIGetCatalogResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getCatalogHandleError handles the GetCatalog error response. +func (client *AzureReservationAPIClient) getCatalogHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := Error{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/reservations/armreservations/zz_generated_calculateexchange_client.go b/sdk/resourcemanager/reservations/armreservations/zz_generated_calculateexchange_client.go new file mode 100644 index 000000000000..a14685c5c3fc --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/zz_generated_calculateexchange_client.go @@ -0,0 +1,103 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armreservations + +import ( + "context" + "fmt" + "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/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// CalculateExchangeClient contains the methods for the CalculateExchange group. +// Don't use this type directly, use NewCalculateExchangeClient() instead. +type CalculateExchangeClient struct { + ep string + pl runtime.Pipeline +} + +// NewCalculateExchangeClient creates a new instance of CalculateExchangeClient with the specified values. +func NewCalculateExchangeClient(credential azcore.TokenCredential, options *arm.ClientOptions) *CalculateExchangeClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &CalculateExchangeClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginPost - Calculates price for exchanging Reservations if there are no policy errors. +// If the operation fails it returns the *Error error type. +func (client *CalculateExchangeClient) BeginPost(ctx context.Context, body CalculateExchangeRequest, options *CalculateExchangeBeginPostOptions) (CalculateExchangePostPollerResponse, error) { + resp, err := client.post(ctx, body, options) + if err != nil { + return CalculateExchangePostPollerResponse{}, err + } + result := CalculateExchangePostPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("CalculateExchangeClient.Post", "azure-async-operation", resp, client.pl, client.postHandleError) + if err != nil { + return CalculateExchangePostPollerResponse{}, err + } + result.Poller = &CalculateExchangePostPoller{ + pt: pt, + } + return result, nil +} + +// Post - Calculates price for exchanging Reservations if there are no policy errors. +// If the operation fails it returns the *Error error type. +func (client *CalculateExchangeClient) post(ctx context.Context, body CalculateExchangeRequest, options *CalculateExchangeBeginPostOptions) (*http.Response, error) { + req, err := client.postCreateRequest(ctx, 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.StatusAccepted) { + return nil, client.postHandleError(resp) + } + return resp, nil +} + +// postCreateRequest creates the Post request. +func (client *CalculateExchangeClient) postCreateRequest(ctx context.Context, body CalculateExchangeRequest, options *CalculateExchangeBeginPostOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/calculateExchange" + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// postHandleError handles the Post error response. +func (client *CalculateExchangeClient) postHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := Error{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/reservations/armreservations/zz_generated_constants.go b/sdk/resourcemanager/reservations/armreservations/zz_generated_constants.go new file mode 100644 index 000000000000..f3075304df89 --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/zz_generated_constants.go @@ -0,0 +1,702 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armreservations + +const ( + module = "armreservations" + version = "v0.1.0" +) + +// AppliedScopeType - Type of the Applied Scope. +type AppliedScopeType string + +const ( + AppliedScopeTypeShared AppliedScopeType = "Shared" + AppliedScopeTypeSingle AppliedScopeType = "Single" +) + +// PossibleAppliedScopeTypeValues returns the possible values for the AppliedScopeType const type. +func PossibleAppliedScopeTypeValues() []AppliedScopeType { + return []AppliedScopeType{ + AppliedScopeTypeShared, + AppliedScopeTypeSingle, + } +} + +// ToPtr returns a *AppliedScopeType pointing to the current value. +func (c AppliedScopeType) ToPtr() *AppliedScopeType { + return &c +} + +// CalculateExchangeOperationResultStatus - Status of the operation. +type CalculateExchangeOperationResultStatus string + +const ( + CalculateExchangeOperationResultStatusCancelled CalculateExchangeOperationResultStatus = "Cancelled" + CalculateExchangeOperationResultStatusFailed CalculateExchangeOperationResultStatus = "Failed" + CalculateExchangeOperationResultStatusPending CalculateExchangeOperationResultStatus = "Pending" + CalculateExchangeOperationResultStatusSucceeded CalculateExchangeOperationResultStatus = "Succeeded" +) + +// PossibleCalculateExchangeOperationResultStatusValues returns the possible values for the CalculateExchangeOperationResultStatus const type. +func PossibleCalculateExchangeOperationResultStatusValues() []CalculateExchangeOperationResultStatus { + return []CalculateExchangeOperationResultStatus{ + CalculateExchangeOperationResultStatusCancelled, + CalculateExchangeOperationResultStatusFailed, + CalculateExchangeOperationResultStatusPending, + CalculateExchangeOperationResultStatusSucceeded, + } +} + +// ToPtr returns a *CalculateExchangeOperationResultStatus pointing to the current value. +func (c CalculateExchangeOperationResultStatus) ToPtr() *CalculateExchangeOperationResultStatus { + return &c +} + +// 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, + } +} + +// ToPtr returns a *CreatedByType pointing to the current value. +func (c CreatedByType) ToPtr() *CreatedByType { + return &c +} + +// DisplayProvisioningState - Represent the current display state of the Reservation. +type DisplayProvisioningState string + +const ( + DisplayProvisioningStateCancelled DisplayProvisioningState = "Cancelled" + DisplayProvisioningStateExpired DisplayProvisioningState = "Expired" + DisplayProvisioningStateExpiring DisplayProvisioningState = "Expiring" + DisplayProvisioningStateFailed DisplayProvisioningState = "Failed" + DisplayProvisioningStatePending DisplayProvisioningState = "Pending" + DisplayProvisioningStateSucceeded DisplayProvisioningState = "Succeeded" +) + +// PossibleDisplayProvisioningStateValues returns the possible values for the DisplayProvisioningState const type. +func PossibleDisplayProvisioningStateValues() []DisplayProvisioningState { + return []DisplayProvisioningState{ + DisplayProvisioningStateCancelled, + DisplayProvisioningStateExpired, + DisplayProvisioningStateExpiring, + DisplayProvisioningStateFailed, + DisplayProvisioningStatePending, + DisplayProvisioningStateSucceeded, + } +} + +// ToPtr returns a *DisplayProvisioningState pointing to the current value. +func (c DisplayProvisioningState) ToPtr() *DisplayProvisioningState { + return &c +} + +type ErrorResponseCode string + +const ( + ErrorResponseCodeActivateQuoteFailed ErrorResponseCode = "ActivateQuoteFailed" + ErrorResponseCodeAppliedScopesNotAssociatedWithCommerceAccount ErrorResponseCode = "AppliedScopesNotAssociatedWithCommerceAccount" + ErrorResponseCodeAppliedScopesSameAsExisting ErrorResponseCode = "AppliedScopesSameAsExisting" + ErrorResponseCodeAuthorizationFailed ErrorResponseCode = "AuthorizationFailed" + ErrorResponseCodeBadRequest ErrorResponseCode = "BadRequest" + ErrorResponseCodeBillingCustomerInputError ErrorResponseCode = "BillingCustomerInputError" + ErrorResponseCodeBillingError ErrorResponseCode = "BillingError" + ErrorResponseCodeBillingPaymentInstrumentHardError ErrorResponseCode = "BillingPaymentInstrumentHardError" + ErrorResponseCodeBillingPaymentInstrumentSoftError ErrorResponseCode = "BillingPaymentInstrumentSoftError" + ErrorResponseCodeBillingScopeIDCannotBeChanged ErrorResponseCode = "BillingScopeIdCannotBeChanged" + ErrorResponseCodeBillingTransientError ErrorResponseCode = "BillingTransientError" + ErrorResponseCodeCalculatePriceFailed ErrorResponseCode = "CalculatePriceFailed" + ErrorResponseCodeCapacityUpdateScopesFailed ErrorResponseCode = "CapacityUpdateScopesFailed" + ErrorResponseCodeClientCertificateThumbprintNotSet ErrorResponseCode = "ClientCertificateThumbprintNotSet" + ErrorResponseCodeCreateQuoteFailed ErrorResponseCode = "CreateQuoteFailed" + ErrorResponseCodeForbidden ErrorResponseCode = "Forbidden" + ErrorResponseCodeFulfillmentConfigurationError ErrorResponseCode = "FulfillmentConfigurationError" + ErrorResponseCodeFulfillmentError ErrorResponseCode = "FulfillmentError" + ErrorResponseCodeFulfillmentOutOfStockError ErrorResponseCode = "FulfillmentOutOfStockError" + ErrorResponseCodeFulfillmentTransientError ErrorResponseCode = "FulfillmentTransientError" + ErrorResponseCodeHTTPMethodNotSupported ErrorResponseCode = "HttpMethodNotSupported" + ErrorResponseCodeInternalServerError ErrorResponseCode = "InternalServerError" + ErrorResponseCodeInvalidAccessToken ErrorResponseCode = "InvalidAccessToken" + ErrorResponseCodeInvalidFulfillmentRequestParameters ErrorResponseCode = "InvalidFulfillmentRequestParameters" + ErrorResponseCodeInvalidHealthCheckType ErrorResponseCode = "InvalidHealthCheckType" + ErrorResponseCodeInvalidLocationID ErrorResponseCode = "InvalidLocationId" + ErrorResponseCodeInvalidRefundQuantity ErrorResponseCode = "InvalidRefundQuantity" + ErrorResponseCodeInvalidRequestContent ErrorResponseCode = "InvalidRequestContent" + ErrorResponseCodeInvalidRequestURI ErrorResponseCode = "InvalidRequestUri" + ErrorResponseCodeInvalidReservationID ErrorResponseCode = "InvalidReservationId" + ErrorResponseCodeInvalidReservationOrderID ErrorResponseCode = "InvalidReservationOrderId" + ErrorResponseCodeInvalidSingleAppliedScopesCount ErrorResponseCode = "InvalidSingleAppliedScopesCount" + ErrorResponseCodeInvalidSubscriptionID ErrorResponseCode = "InvalidSubscriptionId" + ErrorResponseCodeInvalidTenantID ErrorResponseCode = "InvalidTenantId" + ErrorResponseCodeMissingAppliedScopesForSingle ErrorResponseCode = "MissingAppliedScopesForSingle" + ErrorResponseCodeMissingTenantID ErrorResponseCode = "MissingTenantId" + ErrorResponseCodeNoValidReservationsToReRate ErrorResponseCode = "NoValidReservationsToReRate" + ErrorResponseCodeNonsupportedAccountID ErrorResponseCode = "NonsupportedAccountId" + ErrorResponseCodeNotSpecified ErrorResponseCode = "NotSpecified" + ErrorResponseCodeNotSupportedCountry ErrorResponseCode = "NotSupportedCountry" + ErrorResponseCodeOperationCannotBePerformedInCurrentState ErrorResponseCode = "OperationCannotBePerformedInCurrentState" + ErrorResponseCodeOperationFailed ErrorResponseCode = "OperationFailed" + ErrorResponseCodePatchValuesSameAsExisting ErrorResponseCode = "PatchValuesSameAsExisting" + ErrorResponseCodePaymentInstrumentNotFound ErrorResponseCode = "PaymentInstrumentNotFound" + ErrorResponseCodePurchaseError ErrorResponseCode = "PurchaseError" + ErrorResponseCodeReRateOnlyAllowedForEA ErrorResponseCode = "ReRateOnlyAllowedForEA" + ErrorResponseCodeReservationIDNotInReservationOrder ErrorResponseCode = "ReservationIdNotInReservationOrder" + ErrorResponseCodeReservationOrderCreationFailed ErrorResponseCode = "ReservationOrderCreationFailed" + ErrorResponseCodeReservationOrderIDAlreadyExists ErrorResponseCode = "ReservationOrderIdAlreadyExists" + ErrorResponseCodeReservationOrderNotEnabled ErrorResponseCode = "ReservationOrderNotEnabled" + ErrorResponseCodeReservationOrderNotFound ErrorResponseCode = "ReservationOrderNotFound" + ErrorResponseCodeRiskCheckFailed ErrorResponseCode = "RiskCheckFailed" + ErrorResponseCodeRoleAssignmentCreationFailed ErrorResponseCode = "RoleAssignmentCreationFailed" + ErrorResponseCodeServerTimeout ErrorResponseCode = "ServerTimeout" + ErrorResponseCodeUnauthenticatedRequestsThrottled ErrorResponseCode = "UnauthenticatedRequestsThrottled" + ErrorResponseCodeUnsupportedReservationTerm ErrorResponseCode = "UnsupportedReservationTerm" +) + +// PossibleErrorResponseCodeValues returns the possible values for the ErrorResponseCode const type. +func PossibleErrorResponseCodeValues() []ErrorResponseCode { + return []ErrorResponseCode{ + ErrorResponseCodeActivateQuoteFailed, + ErrorResponseCodeAppliedScopesNotAssociatedWithCommerceAccount, + ErrorResponseCodeAppliedScopesSameAsExisting, + ErrorResponseCodeAuthorizationFailed, + ErrorResponseCodeBadRequest, + ErrorResponseCodeBillingCustomerInputError, + ErrorResponseCodeBillingError, + ErrorResponseCodeBillingPaymentInstrumentHardError, + ErrorResponseCodeBillingPaymentInstrumentSoftError, + ErrorResponseCodeBillingScopeIDCannotBeChanged, + ErrorResponseCodeBillingTransientError, + ErrorResponseCodeCalculatePriceFailed, + ErrorResponseCodeCapacityUpdateScopesFailed, + ErrorResponseCodeClientCertificateThumbprintNotSet, + ErrorResponseCodeCreateQuoteFailed, + ErrorResponseCodeForbidden, + ErrorResponseCodeFulfillmentConfigurationError, + ErrorResponseCodeFulfillmentError, + ErrorResponseCodeFulfillmentOutOfStockError, + ErrorResponseCodeFulfillmentTransientError, + ErrorResponseCodeHTTPMethodNotSupported, + ErrorResponseCodeInternalServerError, + ErrorResponseCodeInvalidAccessToken, + ErrorResponseCodeInvalidFulfillmentRequestParameters, + ErrorResponseCodeInvalidHealthCheckType, + ErrorResponseCodeInvalidLocationID, + ErrorResponseCodeInvalidRefundQuantity, + ErrorResponseCodeInvalidRequestContent, + ErrorResponseCodeInvalidRequestURI, + ErrorResponseCodeInvalidReservationID, + ErrorResponseCodeInvalidReservationOrderID, + ErrorResponseCodeInvalidSingleAppliedScopesCount, + ErrorResponseCodeInvalidSubscriptionID, + ErrorResponseCodeInvalidTenantID, + ErrorResponseCodeMissingAppliedScopesForSingle, + ErrorResponseCodeMissingTenantID, + ErrorResponseCodeNoValidReservationsToReRate, + ErrorResponseCodeNonsupportedAccountID, + ErrorResponseCodeNotSpecified, + ErrorResponseCodeNotSupportedCountry, + ErrorResponseCodeOperationCannotBePerformedInCurrentState, + ErrorResponseCodeOperationFailed, + ErrorResponseCodePatchValuesSameAsExisting, + ErrorResponseCodePaymentInstrumentNotFound, + ErrorResponseCodePurchaseError, + ErrorResponseCodeReRateOnlyAllowedForEA, + ErrorResponseCodeReservationIDNotInReservationOrder, + ErrorResponseCodeReservationOrderCreationFailed, + ErrorResponseCodeReservationOrderIDAlreadyExists, + ErrorResponseCodeReservationOrderNotEnabled, + ErrorResponseCodeReservationOrderNotFound, + ErrorResponseCodeRiskCheckFailed, + ErrorResponseCodeRoleAssignmentCreationFailed, + ErrorResponseCodeServerTimeout, + ErrorResponseCodeUnauthenticatedRequestsThrottled, + ErrorResponseCodeUnsupportedReservationTerm, + } +} + +// ToPtr returns a *ErrorResponseCode pointing to the current value. +func (c ErrorResponseCode) ToPtr() *ErrorResponseCode { + return &c +} + +// ExchangeOperationResultStatus - Status of the operation. +type ExchangeOperationResultStatus string + +const ( + ExchangeOperationResultStatusCancelled ExchangeOperationResultStatus = "Cancelled" + ExchangeOperationResultStatusFailed ExchangeOperationResultStatus = "Failed" + ExchangeOperationResultStatusPendingPurchases ExchangeOperationResultStatus = "PendingPurchases" + ExchangeOperationResultStatusPendingRefunds ExchangeOperationResultStatus = "PendingRefunds" + ExchangeOperationResultStatusSucceeded ExchangeOperationResultStatus = "Succeeded" +) + +// PossibleExchangeOperationResultStatusValues returns the possible values for the ExchangeOperationResultStatus const type. +func PossibleExchangeOperationResultStatusValues() []ExchangeOperationResultStatus { + return []ExchangeOperationResultStatus{ + ExchangeOperationResultStatusCancelled, + ExchangeOperationResultStatusFailed, + ExchangeOperationResultStatusPendingPurchases, + ExchangeOperationResultStatusPendingRefunds, + ExchangeOperationResultStatusSucceeded, + } +} + +// ToPtr returns a *ExchangeOperationResultStatus pointing to the current value. +func (c ExchangeOperationResultStatus) ToPtr() *ExchangeOperationResultStatus { + return &c +} + +// InstanceFlexibility - Turning this on will apply the reservation discount to other VMs in the same VM size group. Only specify for VirtualMachines reserved +// resource type. +type InstanceFlexibility string + +const ( + InstanceFlexibilityOff InstanceFlexibility = "Off" + InstanceFlexibilityOn InstanceFlexibility = "On" +) + +// PossibleInstanceFlexibilityValues returns the possible values for the InstanceFlexibility const type. +func PossibleInstanceFlexibilityValues() []InstanceFlexibility { + return []InstanceFlexibility{ + InstanceFlexibilityOff, + InstanceFlexibilityOn, + } +} + +// ToPtr returns a *InstanceFlexibility pointing to the current value. +func (c InstanceFlexibility) ToPtr() *InstanceFlexibility { + return &c +} + +// Location - Location in which the Resources needs to be reserved. It cannot be changed after the resource has been created. +type Location string + +const ( + LocationAustraliaeast Location = "australiaeast" + LocationAustraliasoutheast Location = "australiasoutheast" + LocationBrazilsouth Location = "brazilsouth" + LocationCanadacentral Location = "canadacentral" + LocationCanadaeast Location = "canadaeast" + LocationCentralindia Location = "centralindia" + LocationCentralus Location = "centralus" + LocationEastasia Location = "eastasia" + LocationEastus Location = "eastus" + LocationEastus2 Location = "eastus2" + LocationJapaneast Location = "japaneast" + LocationJapanwest Location = "japanwest" + LocationNorthcentralus Location = "northcentralus" + LocationNortheurope Location = "northeurope" + LocationSouthcentralus Location = "southcentralus" + LocationSoutheastasia Location = "southeastasia" + LocationSouthindia Location = "southindia" + LocationUksouth Location = "uksouth" + LocationUkwest Location = "ukwest" + LocationWestcentralus Location = "westcentralus" + LocationWesteurope Location = "westeurope" + LocationWestindia Location = "westindia" + LocationWestus Location = "westus" + LocationWestus2 Location = "westus2" +) + +// PossibleLocationValues returns the possible values for the Location const type. +func PossibleLocationValues() []Location { + return []Location{ + LocationAustraliaeast, + LocationAustraliasoutheast, + LocationBrazilsouth, + LocationCanadacentral, + LocationCanadaeast, + LocationCentralindia, + LocationCentralus, + LocationEastasia, + LocationEastus, + LocationEastus2, + LocationJapaneast, + LocationJapanwest, + LocationNorthcentralus, + LocationNortheurope, + LocationSouthcentralus, + LocationSoutheastasia, + LocationSouthindia, + LocationUksouth, + LocationUkwest, + LocationWestcentralus, + LocationWesteurope, + LocationWestindia, + LocationWestus, + LocationWestus2, + } +} + +// ToPtr returns a *Location pointing to the current value. +func (c Location) ToPtr() *Location { + return &c +} + +// OperationStatus - Status of the individual operation. +type OperationStatus string + +const ( + OperationStatusCancelled OperationStatus = "Cancelled" + OperationStatusFailed OperationStatus = "Failed" + OperationStatusPending OperationStatus = "Pending" + OperationStatusSucceeded OperationStatus = "Succeeded" +) + +// PossibleOperationStatusValues returns the possible values for the OperationStatus const type. +func PossibleOperationStatusValues() []OperationStatus { + return []OperationStatus{ + OperationStatusCancelled, + OperationStatusFailed, + OperationStatusPending, + OperationStatusSucceeded, + } +} + +// ToPtr returns a *OperationStatus pointing to the current value. +func (c OperationStatus) ToPtr() *OperationStatus { + return &c +} + +// 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, + } +} + +// ToPtr returns a *PaymentStatus pointing to the current value. +func (c PaymentStatus) ToPtr() *PaymentStatus { + return &c +} + +// ProvisioningState - Represent the current state of the Reservation. +type ProvisioningState string + +const ( + ProvisioningStateBillingFailed ProvisioningState = "BillingFailed" + ProvisioningStateCancelled ProvisioningState = "Cancelled" + ProvisioningStateConfirmedBilling ProvisioningState = "ConfirmedBilling" + ProvisioningStateConfirmedResourceHold ProvisioningState = "ConfirmedResourceHold" + ProvisioningStateCreated ProvisioningState = "Created" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateExpired ProvisioningState = "Expired" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMerged ProvisioningState = "Merged" + ProvisioningStatePendingBilling ProvisioningState = "PendingBilling" + ProvisioningStatePendingResourceHold ProvisioningState = "PendingResourceHold" + ProvisioningStateSplit ProvisioningState = "Split" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateBillingFailed, + ProvisioningStateCancelled, + ProvisioningStateConfirmedBilling, + ProvisioningStateConfirmedResourceHold, + ProvisioningStateCreated, + ProvisioningStateCreating, + ProvisioningStateExpired, + ProvisioningStateFailed, + ProvisioningStateMerged, + ProvisioningStatePendingBilling, + ProvisioningStatePendingResourceHold, + ProvisioningStateSplit, + ProvisioningStateSucceeded, + } +} + +// ToPtr returns a *ProvisioningState pointing to the current value. +func (c ProvisioningState) ToPtr() *ProvisioningState { + return &c +} + +// QuotaRequestState - The quota request status. +type QuotaRequestState string + +const ( + QuotaRequestStateAccepted QuotaRequestState = "Accepted" + QuotaRequestStateFailed QuotaRequestState = "Failed" + QuotaRequestStateInProgress QuotaRequestState = "InProgress" + QuotaRequestStateInvalid QuotaRequestState = "Invalid" + QuotaRequestStateSucceeded QuotaRequestState = "Succeeded" +) + +// PossibleQuotaRequestStateValues returns the possible values for the QuotaRequestState const type. +func PossibleQuotaRequestStateValues() []QuotaRequestState { + return []QuotaRequestState{ + QuotaRequestStateAccepted, + QuotaRequestStateFailed, + QuotaRequestStateInProgress, + QuotaRequestStateInvalid, + QuotaRequestStateSucceeded, + } +} + +// ToPtr returns a *QuotaRequestState pointing to the current value. +func (c QuotaRequestState) ToPtr() *QuotaRequestState { + return &c +} + +// ReservationBillingPlan - Represent the billing plans. +type ReservationBillingPlan string + +const ( + ReservationBillingPlanMonthly ReservationBillingPlan = "Monthly" + ReservationBillingPlanUpfront ReservationBillingPlan = "Upfront" +) + +// PossibleReservationBillingPlanValues returns the possible values for the ReservationBillingPlan const type. +func PossibleReservationBillingPlanValues() []ReservationBillingPlan { + return []ReservationBillingPlan{ + ReservationBillingPlanMonthly, + ReservationBillingPlanUpfront, + } +} + +// ToPtr returns a *ReservationBillingPlan pointing to the current value. +func (c ReservationBillingPlan) ToPtr() *ReservationBillingPlan { + return &c +} + +type ReservationStatusCode string + +const ( + ReservationStatusCodeActive ReservationStatusCode = "Active" + ReservationStatusCodeExpired ReservationStatusCode = "Expired" + ReservationStatusCodeMerged ReservationStatusCode = "Merged" + ReservationStatusCodeNone ReservationStatusCode = "None" + ReservationStatusCodePaymentInstrumentError ReservationStatusCode = "PaymentInstrumentError" + ReservationStatusCodePending ReservationStatusCode = "Pending" + ReservationStatusCodePurchaseError ReservationStatusCode = "PurchaseError" + ReservationStatusCodeSplit ReservationStatusCode = "Split" + ReservationStatusCodeSucceeded ReservationStatusCode = "Succeeded" +) + +// PossibleReservationStatusCodeValues returns the possible values for the ReservationStatusCode const type. +func PossibleReservationStatusCodeValues() []ReservationStatusCode { + return []ReservationStatusCode{ + ReservationStatusCodeActive, + ReservationStatusCodeExpired, + ReservationStatusCodeMerged, + ReservationStatusCodeNone, + ReservationStatusCodePaymentInstrumentError, + ReservationStatusCodePending, + ReservationStatusCodePurchaseError, + ReservationStatusCodeSplit, + ReservationStatusCodeSucceeded, + } +} + +// ToPtr returns a *ReservationStatusCode pointing to the current value. +func (c ReservationStatusCode) ToPtr() *ReservationStatusCode { + return &c +} + +// ReservationTerm - Represent the term of Reservation. +type ReservationTerm string + +const ( + ReservationTermP1Y ReservationTerm = "P1Y" + ReservationTermP3Y ReservationTerm = "P3Y" + ReservationTermP5Y ReservationTerm = "P5Y" +) + +// PossibleReservationTermValues returns the possible values for the ReservationTerm const type. +func PossibleReservationTermValues() []ReservationTerm { + return []ReservationTerm{ + ReservationTermP1Y, + ReservationTermP3Y, + ReservationTermP5Y, + } +} + +// ToPtr returns a *ReservationTerm pointing to the current value. +func (c ReservationTerm) ToPtr() *ReservationTerm { + return &c +} + +// 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" + 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, + ReservedResourceTypeVirtualMachines, + } +} + +// ToPtr returns a *ReservedResourceType pointing to the current value. +func (c ReservedResourceType) ToPtr() *ReservedResourceType { + return &c +} + +// ResourceType - The resource types. +type ResourceType string + +const ( + ResourceTypeDedicated ResourceType = "dedicated" + ResourceTypeLowPriority ResourceType = "lowPriority" + ResourceTypeServiceSpecific ResourceType = "serviceSpecific" + ResourceTypeShared ResourceType = "shared" + ResourceTypeStandard ResourceType = "standard" +) + +// PossibleResourceTypeValues returns the possible values for the ResourceType const type. +func PossibleResourceTypeValues() []ResourceType { + return []ResourceType{ + ResourceTypeDedicated, + ResourceTypeLowPriority, + ResourceTypeServiceSpecific, + ResourceTypeShared, + ResourceTypeStandard, + } +} + +// ToPtr returns a *ResourceType pointing to the current value. +func (c ResourceType) ToPtr() *ResourceType { + return &c +} + +// UserFriendlyAppliedScopeType - The applied scope type +type UserFriendlyAppliedScopeType string + +const ( + UserFriendlyAppliedScopeTypeManagementGroup UserFriendlyAppliedScopeType = "ManagementGroup" + UserFriendlyAppliedScopeTypeNone UserFriendlyAppliedScopeType = "None" + UserFriendlyAppliedScopeTypeResourceGroup UserFriendlyAppliedScopeType = "ResourceGroup" + UserFriendlyAppliedScopeTypeShared UserFriendlyAppliedScopeType = "Shared" + UserFriendlyAppliedScopeTypeSingle UserFriendlyAppliedScopeType = "Single" +) + +// PossibleUserFriendlyAppliedScopeTypeValues returns the possible values for the UserFriendlyAppliedScopeType const type. +func PossibleUserFriendlyAppliedScopeTypeValues() []UserFriendlyAppliedScopeType { + return []UserFriendlyAppliedScopeType{ + UserFriendlyAppliedScopeTypeManagementGroup, + UserFriendlyAppliedScopeTypeNone, + UserFriendlyAppliedScopeTypeResourceGroup, + UserFriendlyAppliedScopeTypeShared, + UserFriendlyAppliedScopeTypeSingle, + } +} + +// ToPtr returns a *UserFriendlyAppliedScopeType pointing to the current value. +func (c UserFriendlyAppliedScopeType) ToPtr() *UserFriendlyAppliedScopeType { + return &c +} + +// UserFriendlyRenewState - The renew state of the reservation +type UserFriendlyRenewState string + +const ( + UserFriendlyRenewStateNotApplicable UserFriendlyRenewState = "NotApplicable" + UserFriendlyRenewStateNotRenewed UserFriendlyRenewState = "NotRenewed" + UserFriendlyRenewStateOff UserFriendlyRenewState = "Off" + UserFriendlyRenewStateOn UserFriendlyRenewState = "On" + UserFriendlyRenewStateRenewed UserFriendlyRenewState = "Renewed" +) + +// PossibleUserFriendlyRenewStateValues returns the possible values for the UserFriendlyRenewState const type. +func PossibleUserFriendlyRenewStateValues() []UserFriendlyRenewState { + return []UserFriendlyRenewState{ + UserFriendlyRenewStateNotApplicable, + UserFriendlyRenewStateNotRenewed, + UserFriendlyRenewStateOff, + UserFriendlyRenewStateOn, + UserFriendlyRenewStateRenewed, + } +} + +// ToPtr returns a *UserFriendlyRenewState pointing to the current value. +func (c UserFriendlyRenewState) ToPtr() *UserFriendlyRenewState { + return &c +} diff --git a/sdk/resourcemanager/reservations/armreservations/zz_generated_date_type.go b/sdk/resourcemanager/reservations/armreservations/zz_generated_date_type.go new file mode 100644 index 000000000000..726ccd86b19c --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/zz_generated_date_type.go @@ -0,0 +1,59 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armreservations + +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, 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 err + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/reservations/armreservations/zz_generated_exchange_client.go b/sdk/resourcemanager/reservations/armreservations/zz_generated_exchange_client.go new file mode 100644 index 000000000000..af889f369c0a --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/zz_generated_exchange_client.go @@ -0,0 +1,103 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armreservations + +import ( + "context" + "fmt" + "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/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// ExchangeClient contains the methods for the Exchange group. +// Don't use this type directly, use NewExchangeClient() instead. +type ExchangeClient struct { + ep string + pl runtime.Pipeline +} + +// NewExchangeClient creates a new instance of ExchangeClient with the specified values. +func NewExchangeClient(credential azcore.TokenCredential, options *arm.ClientOptions) *ExchangeClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ExchangeClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginPost - Returns one or more Reservations in exchange for one or more Reservation purchases. +// If the operation fails it returns the *Error error type. +func (client *ExchangeClient) BeginPost(ctx context.Context, body ExchangeRequest, options *ExchangeBeginPostOptions) (ExchangePostPollerResponse, error) { + resp, err := client.post(ctx, body, options) + if err != nil { + return ExchangePostPollerResponse{}, err + } + result := ExchangePostPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ExchangeClient.Post", "azure-async-operation", resp, client.pl, client.postHandleError) + if err != nil { + return ExchangePostPollerResponse{}, err + } + result.Poller = &ExchangePostPoller{ + pt: pt, + } + return result, nil +} + +// Post - Returns one or more Reservations in exchange for one or more Reservation purchases. +// If the operation fails it returns the *Error error type. +func (client *ExchangeClient) post(ctx context.Context, body ExchangeRequest, options *ExchangeBeginPostOptions) (*http.Response, error) { + req, err := client.postCreateRequest(ctx, 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.StatusAccepted) { + return nil, client.postHandleError(resp) + } + return resp, nil +} + +// postCreateRequest creates the Post request. +func (client *ExchangeClient) postCreateRequest(ctx context.Context, body ExchangeRequest, options *ExchangeBeginPostOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/exchange" + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// postHandleError handles the Post error response. +func (client *ExchangeClient) postHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := Error{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/reservations/armreservations/zz_generated_models.go b/sdk/resourcemanager/reservations/armreservations/zz_generated_models.go new file mode 100644 index 000000000000..281673a0782c --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/zz_generated_models.go @@ -0,0 +1,2004 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armreservations + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +type AppliedReservationList struct { + // Url to get the next page of reservations + NextLink *string `json:"nextLink,omitempty"` + Value []*string `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AppliedReservationList. +func (a AppliedReservationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +type AppliedReservations struct { + Properties *AppliedReservationsProperties `json:"properties,omitempty"` + + // READ-ONLY; Identifier of the applied reservations + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Name of resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Type of resource. "Microsoft.Capacity/AppliedReservations" + Type *string `json:"type,omitempty" azure:"ro"` +} + +type AppliedReservationsProperties struct { + ReservationOrderIDs *AppliedReservationList `json:"reservationOrderIds,omitempty"` +} + +type AvailableScopeProperties struct { + Properties *SubscriptionScopeProperties `json:"properties,omitempty"` +} + +// AvailableScopeRequest - Available scope +type AvailableScopeRequest struct { + // Available scope request properties + Properties *AvailableScopeRequestProperties `json:"properties,omitempty"` +} + +// AvailableScopeRequestProperties - Available scope request properties +type AvailableScopeRequestProperties struct { + Scopes []*string `json:"scopes,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AvailableScopeRequestProperties. +func (a AvailableScopeRequestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "scopes", a.Scopes) + return json.Marshal(objectMap) +} + +// AzureReservationAPIGetAppliedReservationListOptions contains the optional parameters for the AzureReservationAPI.GetAppliedReservationList method. +type AzureReservationAPIGetAppliedReservationListOptions struct { + // placeholder for future optional parameters +} + +// AzureReservationAPIGetCatalogOptions contains the optional parameters for the AzureReservationAPI.GetCatalog method. +type AzureReservationAPIGetCatalogOptions struct { + // Filters the skus based on the location specified in this parameter. This can be an azure region or global + Location *string + // The type of the resource for which the skus should be provided. + ReservedResourceType *string +} + +// BillingInformation - billing information +type BillingInformation struct { + BillingCurrencyProratedAmount *Price `json:"billingCurrencyProratedAmount,omitempty"` + BillingCurrencyRemainingCommitmentAmount *Price `json:"billingCurrencyRemainingCommitmentAmount,omitempty"` + BillingCurrencyTotalPaidAmount *Price `json:"billingCurrencyTotalPaidAmount,omitempty"` +} + +// CalculateExchangeBeginPostOptions contains the optional parameters for the CalculateExchange.BeginPost method. +type CalculateExchangeBeginPostOptions struct { + // placeholder for future optional parameters +} + +// CalculateExchangeOperationResultResponse - CalculateExchange operation result +type CalculateExchangeOperationResultResponse struct { + // Required if status == failed or status == canceled. + Error *OperationResultError `json:"error,omitempty"` + + // It should match what is used to GET the operation result. + ID *string `json:"id,omitempty"` + + // It must match the last segment of the id field, and will typically be a GUID / system generated value. + Name *string `json:"name,omitempty"` + + // CalculateExchange response properties + Properties *CalculateExchangeResponseProperties `json:"properties,omitempty"` + + // Status of the operation. + Status *CalculateExchangeOperationResultStatus `json:"status,omitempty"` +} + +// CalculateExchangeRequest - Calculate exchange request +type CalculateExchangeRequest struct { + // Calculate exchange request properties + Properties *CalculateExchangeRequestProperties `json:"properties,omitempty"` +} + +// CalculateExchangeRequestProperties - Calculate exchange request properties +type CalculateExchangeRequestProperties struct { + // List of reservations that are being returned in this exchange. + ReservationsToExchange []*ReservationToReturn `json:"reservationsToExchange,omitempty"` + + // List of reservations that are being purchased in this exchange. + ReservationsToPurchase []*PurchaseRequest `json:"reservationsToPurchase,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CalculateExchangeRequestProperties. +func (c CalculateExchangeRequestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "reservationsToExchange", c.ReservationsToExchange) + populate(objectMap, "reservationsToPurchase", c.ReservationsToPurchase) + return json.Marshal(objectMap) +} + +// CalculateExchangeResponseProperties - CalculateExchange response properties +type CalculateExchangeResponseProperties struct { + NetPayable *Price `json:"netPayable,omitempty"` + + // Exchange policy errors + PolicyResult *ExchangePolicyErrors `json:"policyResult,omitempty"` + PurchasesTotal *Price `json:"purchasesTotal,omitempty"` + RefundsTotal *Price `json:"refundsTotal,omitempty"` + + // Details of the reservations being returned + ReservationsToExchange []*ReservationToExchange `json:"reservationsToExchange,omitempty"` + + // Details of the reservations being purchased + ReservationsToPurchase []*ReservationToPurchaseCalculateExchange `json:"reservationsToPurchase,omitempty"` + + // Exchange session identifier + SessionID *string `json:"sessionId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CalculateExchangeResponseProperties. +func (c CalculateExchangeResponseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "netPayable", c.NetPayable) + populate(objectMap, "policyResult", c.PolicyResult) + populate(objectMap, "purchasesTotal", c.PurchasesTotal) + populate(objectMap, "refundsTotal", c.RefundsTotal) + populate(objectMap, "reservationsToExchange", c.ReservationsToExchange) + populate(objectMap, "reservationsToPurchase", c.ReservationsToPurchase) + populate(objectMap, "sessionId", c.SessionID) + return json.Marshal(objectMap) +} + +type CalculatePriceResponse struct { + Properties *CalculatePriceResponseProperties `json:"properties,omitempty"` +} + +type CalculatePriceResponseProperties struct { + // Currency and amount that customer will be charged in customer's local currency. Tax is not included. + BillingCurrencyTotal *CalculatePriceResponsePropertiesBillingCurrencyTotal `json:"billingCurrencyTotal,omitempty"` + + // Total amount in pricing currency. + GrandTotal *float64 `json:"grandTotal,omitempty"` + + // True if billing is managed by Microsoft Partner. Used only for CSP accounts. + IsBillingPartnerManaged *bool `json:"isBillingPartnerManaged,omitempty"` + + // Whether or not tax is included in grand total + IsTaxIncluded *bool `json:"isTaxIncluded,omitempty"` + + // Net total amount in pricing currency. + NetTotal *float64 `json:"netTotal,omitempty"` + PaymentSchedule []*PaymentDetail `json:"paymentSchedule,omitempty"` + + // Amount that Microsoft uses for record. Used during refund for calculating refund limit. Tax is not included. + PricingCurrencyTotal *CalculatePriceResponsePropertiesPricingCurrencyTotal `json:"pricingCurrencyTotal,omitempty"` + + // GUID that represents reservation order that can be placed after calculating price. + ReservationOrderID *string `json:"reservationOrderId,omitempty"` + + // Description of SKU that is being purchased. + SKUDescription *string `json:"skuDescription,omitempty"` + + // Title of SKU that is being purchased. + SKUTitle *string `json:"skuTitle,omitempty"` + + // Tax amount in pricing currency. + TaxTotal *float64 `json:"taxTotal,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CalculatePriceResponseProperties. +func (c CalculatePriceResponseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "billingCurrencyTotal", c.BillingCurrencyTotal) + populate(objectMap, "grandTotal", c.GrandTotal) + populate(objectMap, "isBillingPartnerManaged", c.IsBillingPartnerManaged) + populate(objectMap, "isTaxIncluded", c.IsTaxIncluded) + populate(objectMap, "netTotal", c.NetTotal) + populate(objectMap, "paymentSchedule", c.PaymentSchedule) + populate(objectMap, "pricingCurrencyTotal", c.PricingCurrencyTotal) + populate(objectMap, "reservationOrderId", c.ReservationOrderID) + populate(objectMap, "skuDescription", c.SKUDescription) + populate(objectMap, "skuTitle", c.SKUTitle) + populate(objectMap, "taxTotal", c.TaxTotal) + return json.Marshal(objectMap) +} + +// CalculatePriceResponsePropertiesBillingCurrencyTotal - Currency and amount that customer will be charged in customer's local currency. Tax is not included. +type CalculatePriceResponsePropertiesBillingCurrencyTotal struct { + // Amount in pricing currency. Tax is not included. + 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"` +} + +// CalculatePriceResponsePropertiesPricingCurrencyTotal - Amount that Microsoft uses for record. Used during refund for calculating refund limit. Tax is +// not included. +type CalculatePriceResponsePropertiesPricingCurrencyTotal struct { + Amount *float32 `json:"amount,omitempty"` + + // The ISO 4217 3-letter currency code for the currency used by this purchase record. + CurrencyCode *string `json:"currencyCode,omitempty"` +} + +type Catalog struct { + // The billing plan options available for this SKU. + BillingPlans map[string][]*ReservationBillingPlan `json:"billingPlans,omitempty"` + + // READ-ONLY + Capabilities []*SKUCapability `json:"capabilities,omitempty" azure:"ro"` + + // READ-ONLY + Locations []*string `json:"locations,omitempty" azure:"ro"` + + // READ-ONLY; Pricing information about the SKU + Msrp *CatalogMsrp `json:"msrp,omitempty" azure:"ro"` + + // READ-ONLY; The name of SKU + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of resource the SKU applies to. + ResourceType *string `json:"resourceType,omitempty" azure:"ro"` + + // READ-ONLY + Restrictions []*SKURestriction `json:"restrictions,omitempty" azure:"ro"` + + // READ-ONLY + SKUProperties []*SKUProperty `json:"skuProperties,omitempty" azure:"ro"` + + // READ-ONLY; The size of this SKU + Size *string `json:"size,omitempty" azure:"ro"` + + // READ-ONLY; Available reservation terms for this resource + Terms []*ReservationTerm `json:"terms,omitempty" azure:"ro"` + + // READ-ONLY; The tier of this SKU + Tier *string `json:"tier,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Catalog. +func (c Catalog) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "billingPlans", c.BillingPlans) + populate(objectMap, "capabilities", c.Capabilities) + populate(objectMap, "locations", c.Locations) + populate(objectMap, "msrp", c.Msrp) + populate(objectMap, "name", c.Name) + populate(objectMap, "resourceType", c.ResourceType) + populate(objectMap, "restrictions", c.Restrictions) + populate(objectMap, "skuProperties", c.SKUProperties) + populate(objectMap, "size", c.Size) + populate(objectMap, "terms", c.Terms) + populate(objectMap, "tier", c.Tier) + return json.Marshal(objectMap) +} + +// CatalogMsrp - Pricing information about the SKU +type CatalogMsrp struct { + // Amount in pricing currency. Tax not included. + P1Y *Price `json:"p1Y,omitempty"` +} + +type ChangeDirectoryRequest struct { + // Tenant id GUID that reservation order is to be transferred to + DestinationTenantID *string `json:"destinationTenantId,omitempty"` +} + +// ChangeDirectoryResponse - Change directory response +type ChangeDirectoryResponse struct { + // Change directory result for reservation order or reservation + ReservationOrder *ChangeDirectoryResult `json:"reservationOrder,omitempty"` + Reservations []*ChangeDirectoryResult `json:"reservations,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ChangeDirectoryResponse. +func (c ChangeDirectoryResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "reservationOrder", c.ReservationOrder) + populate(objectMap, "reservations", c.Reservations) + return json.Marshal(objectMap) +} + +// ChangeDirectoryResult - Change directory result for reservation order or reservation +type ChangeDirectoryResult struct { + // Error reason if operation failed. Null otherwise + Error *string `json:"error,omitempty"` + + // Identifier of the reservation order or reservation + ID *string `json:"id,omitempty"` + + // True if change directory operation succeeded on this reservation order or reservation + IsSucceeded *bool `json:"isSucceeded,omitempty"` + + // Name of the reservation order or reservation + Name *string `json:"name,omitempty"` +} + +// CreateGenericQuotaRequestParameters - Quota change requests information. +type CreateGenericQuotaRequestParameters struct { + // Quota change requests. + Value []*CurrentQuotaLimitBase `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CreateGenericQuotaRequestParameters. +func (c CreateGenericQuotaRequestParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// CurrentQuotaLimit - Current quota limits. +type CurrentQuotaLimit struct { + // Additional properties for the quota status for the resource. + Properties *QuotaRequestStatusDetails `json:"properties,omitempty"` + + // Quota details. + QuotaInformation *CurrentQuotaLimitBase `json:"quotaInformation,omitempty"` +} + +// CurrentQuotaLimitBase - Quota properties. +type CurrentQuotaLimitBase struct { + // Quota properties for the resource. + Properties *QuotaProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CurrentQuotaLimitBase. +func (c CurrentQuotaLimitBase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", c.Properties) + return json.Marshal(objectMap) +} + +// Implements the error and azcore.HTTPResponse interfaces. +type Error struct { + raw string + InnerError *ExtendedErrorInfo `json:"error,omitempty"` +} + +// Error implements the error interface for type Error. +// The contents of the error text are not contractual and subject to change. +func (e Error) Error() string { + return e.raw +} + +// ErrorDetails - The details of the error. +type ErrorDetails struct { + // READ-ONLY; Error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; Error message indicating why the operation failed. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The target of the particular error. + Target *string `json:"target,omitempty" azure:"ro"` +} + +// ErrorResponse - Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorResponse struct { + raw string + // The details of the error. + InnerError *ErrorDetails `json:"error,omitempty"` +} + +// Error implements the error interface for type ErrorResponse. +// The contents of the error text are not contractual and subject to change. +func (e ErrorResponse) Error() string { + return e.raw +} + +// ExceptionResponse - The API error. +// Implements the error and azcore.HTTPResponse interfaces. +type ExceptionResponse struct { + raw string + // The API error details. + InnerError *ServiceError `json:"error,omitempty"` +} + +// Error implements the error interface for type ExceptionResponse. +// The contents of the error text are not contractual and subject to change. +func (e ExceptionResponse) Error() string { + return e.raw +} + +// ExchangeBeginPostOptions contains the optional parameters for the Exchange.BeginPost method. +type ExchangeBeginPostOptions struct { + // placeholder for future optional parameters +} + +// ExchangeOperationResultResponse - Exchange operation result +type ExchangeOperationResultResponse struct { + // Required if status == failed or status == canceled. + Error *OperationResultError `json:"error,omitempty"` + + // It should match what is used to GET the operation result. + ID *string `json:"id,omitempty"` + + // It must match the last segment of the id field, and will typically be a GUID / system generated value. + Name *string `json:"name,omitempty"` + + // Exchange response properties + Properties *ExchangeResponseProperties `json:"properties,omitempty"` + + // Status of the operation. + Status *ExchangeOperationResultStatus `json:"status,omitempty"` +} + +// ExchangePolicyError - error details +type ExchangePolicyError struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} + +// ExchangePolicyErrors - Exchange policy errors +type ExchangePolicyErrors struct { + // Exchange Policy errors + PolicyErrors []*ExchangePolicyError `json:"policyErrors,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ExchangePolicyErrors. +func (e ExchangePolicyErrors) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "policyErrors", e.PolicyErrors) + return json.Marshal(objectMap) +} + +// ExchangeRequest - Exchange request +type ExchangeRequest struct { + // Exchange request properties + Properties *ExchangeRequestProperties `json:"properties,omitempty"` +} + +// ExchangeRequestProperties - Exchange request properties +type ExchangeRequestProperties struct { + // SessionId that was returned by CalculateExchange API. + SessionID *string `json:"sessionId,omitempty"` +} + +// ExchangeResponseProperties - Exchange response properties +type ExchangeResponseProperties struct { + NetPayable *Price `json:"netPayable,omitempty"` + + // Exchange policy errors + PolicyResult *ExchangePolicyErrors `json:"policyResult,omitempty"` + PurchasesTotal *Price `json:"purchasesTotal,omitempty"` + RefundsTotal *Price `json:"refundsTotal,omitempty"` + + // Details of the reservations being returned + ReservationsToExchange []*ReservationToReturnForExchange `json:"reservationsToExchange,omitempty"` + + // Details of the reservations being purchased + ReservationsToPurchase []*ReservationToPurchaseExchange `json:"reservationsToPurchase,omitempty"` + + // Exchange session identifier + SessionID *string `json:"sessionId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ExchangeResponseProperties. +func (e ExchangeResponseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "netPayable", e.NetPayable) + populate(objectMap, "policyResult", e.PolicyResult) + populate(objectMap, "purchasesTotal", e.PurchasesTotal) + populate(objectMap, "refundsTotal", e.RefundsTotal) + populate(objectMap, "reservationsToExchange", e.ReservationsToExchange) + populate(objectMap, "reservationsToPurchase", e.ReservationsToPurchase) + populate(objectMap, "sessionId", e.SessionID) + return json.Marshal(objectMap) +} + +type ExtendedErrorInfo struct { + Code *ErrorResponseCode `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} + +type ExtendedStatusInfo struct { + // The message giving detailed information about the status code. + Message *string `json:"message,omitempty"` + StatusCode *ReservationStatusCode `json:"statusCode,omitempty"` +} + +type MergeProperties struct { + // Format of the resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + Sources []*string `json:"sources,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MergeProperties. +func (m MergeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "sources", m.Sources) + return json.Marshal(objectMap) +} + +type MergeRequest struct { + Properties *MergeProperties `json:"properties,omitempty"` +} + +type OperationDisplay struct { + Description *string `json:"description,omitempty"` + Operation *string `json:"operation,omitempty"` + Provider *string `json:"provider,omitempty"` + Resource *string `json:"resource,omitempty"` +} + +type OperationList struct { + // Url to get the next page of items. + NextLink *string `json:"nextLink,omitempty"` + Value []*OperationResponse `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationList. +func (o OperationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationListOptions contains the optional parameters for the Operation.List method. +type OperationListOptions struct { + // placeholder for future optional parameters +} + +type OperationResponse struct { + // Display of the operation + Display *OperationDisplay `json:"display,omitempty"` + + // Indicates whether the operation is a data action + IsDataAction *bool `json:"isDataAction,omitempty"` + + // Name of the operation + Name *string `json:"name,omitempty"` + + // Origin of the operation + Origin *string `json:"origin,omitempty"` + + // Properties of the operation + Properties map[string]interface{} `json:"properties,omitempty"` +} + +// OperationResultError - Required if status == failed or status == canceled. +type OperationResultError struct { + // Required if status == failed or status == cancelled. If status == failed, provide an invariant error code used for error troubleshooting, aggregation, + // and analysis. + Code *string `json:"code,omitempty"` + + // Required if status == failed. Localized. If status == failed, provide an actionable error message indicating what error occurred, and what the user can + // do to address the issue. + Message *string `json:"message,omitempty"` +} + +type Patch struct { + Properties *PatchProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Patch. +func (p Patch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +type PatchProperties struct { + // Type of the Applied Scope. + AppliedScopeType *AppliedScopeType `json:"appliedScopeType,omitempty"` + + // List of the subscriptions that the benefit will be applied. Do not specify if AppliedScopeType is Shared. + AppliedScopes []*string `json:"appliedScopes,omitempty"` + + // Turning this on will apply the reservation discount to other VMs in the same VM size group. Only specify for VirtualMachines reserved resource type. + InstanceFlexibility *InstanceFlexibility `json:"instanceFlexibility,omitempty"` + + // Name of the Reservation + Name *string `json:"name,omitempty"` + + // Setting this to true will automatically purchase a new reservation on the expiration date time. + Renew *bool `json:"renew,omitempty"` + RenewProperties *PatchPropertiesRenewProperties `json:"renewProperties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PatchProperties. +func (p PatchProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "appliedScopeType", p.AppliedScopeType) + populate(objectMap, "appliedScopes", p.AppliedScopes) + populate(objectMap, "instanceFlexibility", p.InstanceFlexibility) + populate(objectMap, "name", p.Name) + populate(objectMap, "renew", p.Renew) + populate(objectMap, "renewProperties", p.RenewProperties) + return json.Marshal(objectMap) +} + +type PatchPropertiesRenewProperties struct { + PurchaseProperties *PurchaseRequest `json:"purchaseProperties,omitempty"` +} + +// PaymentDetail - Information about payment related to a reservation order. +type PaymentDetail struct { + // Shows the Account that is charged for this payment. + 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"` + ExtendedStatusInfo *ExtendedStatusInfo `json:"extendedStatusInfo,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"` +} + +// 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 err + } + for key, val := range rawMsg { + var err error + switch key { + case "billingAccount": + err = unpopulate(val, &p.BillingAccount) + delete(rawMsg, key) + case "billingCurrencyTotal": + err = unpopulate(val, &p.BillingCurrencyTotal) + delete(rawMsg, key) + case "dueDate": + err = unpopulateDateType(val, &p.DueDate) + delete(rawMsg, key) + case "extendedStatusInfo": + err = unpopulate(val, &p.ExtendedStatusInfo) + delete(rawMsg, key) + case "paymentDate": + err = unpopulateDateType(val, &p.PaymentDate) + delete(rawMsg, key) + case "pricingCurrencyTotal": + err = unpopulate(val, &p.PricingCurrencyTotal) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &p.Status) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +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 { + // The Azure Region where the reserved resource lives. + Location *string `json:"location,omitempty"` + Properties *PurchaseRequestProperties `json:"properties,omitempty"` + SKU *SKUName `json:"sku,omitempty"` +} + +type PurchaseRequestProperties struct { + // Type of the Applied Scope. + AppliedScopeType *AppliedScopeType `json:"appliedScopeType,omitempty"` + + // List of the subscriptions that the benefit will be applied. Do not specify if AppliedScopeType is Shared. + AppliedScopes []*string `json:"appliedScopes,omitempty"` + + // Represent the billing plans. + BillingPlan *ReservationBillingPlan `json:"billingPlan,omitempty"` + + // Subscription that will be charged for purchasing Reservation + BillingScopeID *string `json:"billingScopeId,omitempty"` + + // Friendly name of the Reservation + DisplayName *string `json:"displayName,omitempty"` + + // Quantity of the SKUs that are part of the Reservation. + Quantity *int32 `json:"quantity,omitempty"` + + // Setting this to true will automatically purchase a new reservation on the expiration date time. + Renew *bool `json:"renew,omitempty"` + + // Properties specific to each reserved resource type. Not required if not applicable. + ReservedResourceProperties *PurchaseRequestPropertiesReservedResourceProperties `json:"reservedResourceProperties,omitempty"` + + // The type of the resource that is being reserved. + ReservedResourceType *ReservedResourceType `json:"reservedResourceType,omitempty"` + + // Represent the term of Reservation. + Term *ReservationTerm `json:"term,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PurchaseRequestProperties. +func (p PurchaseRequestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "appliedScopeType", p.AppliedScopeType) + populate(objectMap, "appliedScopes", p.AppliedScopes) + populate(objectMap, "billingPlan", p.BillingPlan) + populate(objectMap, "billingScopeId", p.BillingScopeID) + populate(objectMap, "displayName", p.DisplayName) + populate(objectMap, "quantity", p.Quantity) + populate(objectMap, "renew", p.Renew) + populate(objectMap, "reservedResourceProperties", p.ReservedResourceProperties) + populate(objectMap, "reservedResourceType", p.ReservedResourceType) + populate(objectMap, "term", p.Term) + return json.Marshal(objectMap) +} + +// PurchaseRequestPropertiesReservedResourceProperties - Properties specific to each reserved resource type. Not required if not applicable. +type PurchaseRequestPropertiesReservedResourceProperties struct { + // Turning this on will apply the reservation discount to other VMs in the same VM size group. Only specify for VirtualMachines reserved resource type. + InstanceFlexibility *InstanceFlexibility `json:"instanceFlexibility,omitempty"` +} + +// QuotaBeginCreateOrUpdateOptions contains the optional parameters for the Quota.BeginCreateOrUpdate method. +type QuotaBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// QuotaBeginUpdateOptions contains the optional parameters for the Quota.BeginUpdate method. +type QuotaBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// QuotaGetOptions contains the optional parameters for the Quota.Get method. +type QuotaGetOptions struct { + // placeholder for future optional parameters +} + +// QuotaLimits - Quota limits. +type QuotaLimits struct { + // The URI for fetching the next page of quotas (service limits). When no more pages exist, the value is null. + NextLink *string `json:"nextLink,omitempty"` + + // List of quotas (service limits). + Value []*CurrentQuotaLimitBase `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type QuotaLimits. +func (q QuotaLimits) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", q.NextLink) + populate(objectMap, "value", q.Value) + return json.Marshal(objectMap) +} + +// QuotaLimitsResponse - Quotas (service limits) in the request response. +type QuotaLimitsResponse struct { + // The URI for fetching the next page of quota limits. When no more pages exist, the value is null. + NextLink *string `json:"nextLink,omitempty"` + + // List of quotas with the quota request status. + Value []*CurrentQuotaLimit `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type QuotaLimitsResponse. +func (q QuotaLimitsResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", q.NextLink) + populate(objectMap, "value", q.Value) + return json.Marshal(objectMap) +} + +// QuotaListOptions contains the optional parameters for the Quota.List method. +type QuotaListOptions struct { + // placeholder for future optional parameters +} + +// QuotaProperties - Quota properties for the resource. +type QuotaProperties struct { + // Quota properties. + Limit *int32 `json:"limit,omitempty"` + + // Name of the resource provide by the resource provider. Use this property for quotaRequests resource operations. + Name *ResourceName `json:"name,omitempty"` + + // Additional properties for the specified resource provider. + Properties map[string]interface{} `json:"properties,omitempty"` + + // The name of the resource type. + ResourceType *ResourceType `json:"resourceType,omitempty"` + + // The limit units, such as count and bytes. Use the unit field provided in the response of the GET quota operation. + Unit *string `json:"unit,omitempty"` + + // READ-ONLY; Current usage value for the resource. + CurrentValue *int32 `json:"currentValue,omitempty" azure:"ro"` + + // READ-ONLY; The time period over which the quota usage values are summarized. For example, P1D (per one day), PT1M (per one minute), and PT1S (per one + // second). This parameter is optional because, for some + // resources such as compute, the time period is irrelevant. + QuotaPeriod *string `json:"quotaPeriod,omitempty" azure:"ro"` +} + +// QuotaRequestDetails - Quota request details. +type QuotaRequestDetails struct { + // Quota request details. + Properties *QuotaRequestProperties `json:"properties,omitempty"` + + // READ-ONLY; Quota request ID. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Quota request name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Resource type + Type *string `json:"type,omitempty" azure:"ro"` +} + +// QuotaRequestDetailsList - Quota request details. +type QuotaRequestDetailsList struct { + // The URI to fetch the next page of quota limits. When there are no more pages, this is null. + NextLink *string `json:"nextLink,omitempty"` + + // The quota requests. + Value []*QuotaRequestDetails `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type QuotaRequestDetailsList. +func (q QuotaRequestDetailsList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", q.NextLink) + populate(objectMap, "value", q.Value) + return json.Marshal(objectMap) +} + +// QuotaRequestOneResourceProperties - The details of quota request. +type QuotaRequestOneResourceProperties struct { + // The quota request addition properties. + Properties *CurrentQuotaLimitBase `json:"properties,omitempty"` + + // READ-ONLY; User friendly status message. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The quota request status. + ProvisioningState *QuotaRequestState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The time when the quota request was submitted using format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + RequestSubmitTime *time.Time `json:"requestSubmitTime,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type QuotaRequestOneResourceProperties. +func (q QuotaRequestOneResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "message", q.Message) + populate(objectMap, "properties", q.Properties) + populate(objectMap, "provisioningState", q.ProvisioningState) + populateTimeRFC3339(objectMap, "requestSubmitTime", q.RequestSubmitTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QuotaRequestOneResourceProperties. +func (q *QuotaRequestOneResourceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, &q.Message) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, &q.Properties) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &q.ProvisioningState) + delete(rawMsg, key) + case "requestSubmitTime": + err = unpopulateTimeRFC3339(val, &q.RequestSubmitTime) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// QuotaRequestOneResourceSubmitResponse - Response for the quota submission request. +type QuotaRequestOneResourceSubmitResponse struct { + // The details for quota request. + Properties *QuotaRequestOneResourceProperties `json:"properties,omitempty"` + + // READ-ONLY; The quota request ID. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the quota request. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Type of resource. "Microsoft.Capacity/ServiceLimits" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// QuotaRequestProperties - The details of quota request. +type QuotaRequestProperties struct { + // The quota request status. + ProvisioningState *QuotaRequestState `json:"provisioningState,omitempty"` + + // The quotaRequests. + Value []*SubRequest `json:"value,omitempty"` + + // READ-ONLY; User friendly status message. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The time when the quota request was submitted using format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + RequestSubmitTime *time.Time `json:"requestSubmitTime,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type QuotaRequestProperties. +func (q QuotaRequestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "message", q.Message) + populate(objectMap, "provisioningState", q.ProvisioningState) + populateTimeRFC3339(objectMap, "requestSubmitTime", q.RequestSubmitTime) + populate(objectMap, "value", q.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QuotaRequestProperties. +func (q *QuotaRequestProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, &q.Message) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &q.ProvisioningState) + delete(rawMsg, key) + case "requestSubmitTime": + err = unpopulateTimeRFC3339(val, &q.RequestSubmitTime) + delete(rawMsg, key) + case "value": + err = unpopulate(val, &q.Value) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// QuotaRequestStatusDetails - Quota request status details. +type QuotaRequestStatusDetails struct { + // READ-ONLY; A user friendly message. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The details of the quota request status. + ProvisioningState *QuotaRequestState `json:"provisioningState,omitempty" azure:"ro"` +} + +// QuotaRequestStatusGetOptions contains the optional parameters for the QuotaRequestStatus.Get method. +type QuotaRequestStatusGetOptions struct { + // placeholder for future optional parameters +} + +// QuotaRequestStatusListOptions contains the optional parameters for the QuotaRequestStatus.List method. +type QuotaRequestStatusListOptions struct { + // | Field | Supported operators + // |---------------------|------------------------ + // + // |requestSubmitTime | ge, le, eq, gt, lt + Filter *string + // Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink + // element includes a skiptoken parameter that specifies a starting point to use for subsequent calls. + Skiptoken *string + // Number of records to return. + Top *int32 +} + +// QuotaRequestSubmitResponse - Response for the quota submission request. +type QuotaRequestSubmitResponse struct { + // The quota request details. + Properties *QuotaRequestProperties `json:"properties,omitempty"` + + // READ-ONLY; The quota request ID. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the quota request. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Type of resource. "Microsoft.Capacity/serviceLimits" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// QuotaRequestSubmitResponse201 - Response with request ID that the quota request was accepted. +type QuotaRequestSubmitResponse201 struct { + // Quota request status. + Properties *QuotaRequestStatusDetails `json:"properties,omitempty"` + + // READ-ONLY; The quota request ID. Use the requestId parameter to check the request status. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Operation ID + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Resource type + Type *string `json:"type,omitempty" azure:"ro"` +} + +type RenewPropertiesResponse struct { + // Currency and amount that customer will be charged in customer's local currency for renewal purchase. Tax is not included. + BillingCurrencyTotal *RenewPropertiesResponseBillingCurrencyTotal `json:"billingCurrencyTotal,omitempty"` + + // Amount that Microsoft uses for record. Used during refund for calculating refund limit. Tax is not included. This is locked price 30 days before expiry. + PricingCurrencyTotal *RenewPropertiesResponsePricingCurrencyTotal `json:"pricingCurrencyTotal,omitempty"` + PurchaseProperties *PurchaseRequest `json:"purchaseProperties,omitempty"` +} + +// RenewPropertiesResponseBillingCurrencyTotal - Currency and amount that customer will be charged in customer's local currency for renewal purchase. Tax +// is not included. +type RenewPropertiesResponseBillingCurrencyTotal struct { + Amount *float32 `json:"amount,omitempty"` + + // The ISO 4217 3-letter currency code for the currency used by this purchase record. + CurrencyCode *string `json:"currencyCode,omitempty"` +} + +// RenewPropertiesResponsePricingCurrencyTotal - Amount that Microsoft uses for record. Used during refund for calculating refund limit. Tax is not included. +// This is locked price 30 days before expiry. +type RenewPropertiesResponsePricingCurrencyTotal struct { + Amount *float32 `json:"amount,omitempty"` + + // The ISO 4217 3-letter currency code for the currency used by this purchase record. + CurrencyCode *string `json:"currencyCode,omitempty"` +} + +// ReservationBeginAvailableScopesOptions contains the optional parameters for the Reservation.BeginAvailableScopes method. +type ReservationBeginAvailableScopesOptions struct { + // placeholder for future optional parameters +} + +// ReservationBeginMergeOptions contains the optional parameters for the Reservation.BeginMerge method. +type ReservationBeginMergeOptions struct { + // placeholder for future optional parameters +} + +// ReservationBeginSplitOptions contains the optional parameters for the Reservation.BeginSplit method. +type ReservationBeginSplitOptions struct { + // placeholder for future optional parameters +} + +// ReservationBeginUpdateOptions contains the optional parameters for the Reservation.BeginUpdate method. +type ReservationBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// ReservationGetOptions contains the optional parameters for the Reservation.Get method. +type ReservationGetOptions struct { + // Supported value of this query is renewProperties + Expand *string +} + +type ReservationList struct { + // Url to get the next page of reservations. + NextLink *string `json:"nextLink,omitempty"` + Value []*ReservationResponse `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationList. +func (r ReservationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// ReservationListAllOptions contains the optional parameters for the Reservation.ListAll method. +type ReservationListAllOptions 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 reservations group by provisioning states + RefreshSummary *string + // The selected provisioning state + SelectedState *string + // The number of reservations to skip from the list before returning results + Skiptoken *float32 + // To number of reservations to return + Take *float32 +} + +// ReservationListOptions contains the optional parameters for the Reservation.List method. +type ReservationListOptions struct { + // placeholder for future optional parameters +} + +// ReservationListRevisionsOptions contains the optional parameters for the Reservation.ListRevisions method. +type ReservationListRevisionsOptions struct { + // placeholder for future optional parameters +} + +type ReservationMergeProperties struct { + // Reservation Resource Id Created due to the merge. Format of the resource Id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + MergeDestination *string `json:"mergeDestination,omitempty"` + + // Resource Ids of the Source Reservation's merged to form this Reservation. Format of the resource Id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + MergeSources []*string `json:"mergeSources,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationMergeProperties. +func (r ReservationMergeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "mergeDestination", r.MergeDestination) + populate(objectMap, "mergeSources", r.MergeSources) + return json.Marshal(objectMap) +} + +// ReservationOrderBeginPurchaseOptions contains the optional parameters for the ReservationOrder.BeginPurchase method. +type ReservationOrderBeginPurchaseOptions struct { + // placeholder for future optional parameters +} + +// ReservationOrderBillingPlanInformation - Information describing the type of billing plan for this reservation. +type ReservationOrderBillingPlanInformation struct { + // For recurring billing plans, indicates the date when next payment will be processed. Null when total is paid off. + NextPaymentDueDate *time.Time `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"` +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationOrderBillingPlanInformation. +func (r ReservationOrderBillingPlanInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateDateType(objectMap, "nextPaymentDueDate", r.NextPaymentDueDate) + populate(objectMap, "pricingCurrencyTotal", r.PricingCurrencyTotal) + populateDateType(objectMap, "startDate", r.StartDate) + populate(objectMap, "transactions", r.Transactions) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationOrderBillingPlanInformation. +func (r *ReservationOrderBillingPlanInformation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "nextPaymentDueDate": + err = unpopulateDateType(val, &r.NextPaymentDueDate) + delete(rawMsg, key) + case "pricingCurrencyTotal": + err = unpopulate(val, &r.PricingCurrencyTotal) + delete(rawMsg, key) + case "startDate": + err = unpopulateDateType(val, &r.StartDate) + delete(rawMsg, key) + case "transactions": + err = unpopulate(val, &r.Transactions) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ReservationOrderCalculateOptions contains the optional parameters for the ReservationOrder.Calculate method. +type ReservationOrderCalculateOptions struct { + // placeholder for future optional parameters +} + +// ReservationOrderChangeDirectoryOptions contains the optional parameters for the ReservationOrder.ChangeDirectory method. +type ReservationOrderChangeDirectoryOptions struct { + // placeholder for future optional parameters +} + +// ReservationOrderGetOptions contains the optional parameters for the ReservationOrder.Get method. +type ReservationOrderGetOptions struct { + // May be used to expand the planInformation. + Expand *string +} + +type ReservationOrderList struct { + // Url to get the next page of reservationOrders. + NextLink *string `json:"nextLink,omitempty"` + Value []*ReservationOrderResponse `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationOrderList. +func (r ReservationOrderList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// ReservationOrderListOptions contains the optional parameters for the ReservationOrder.List method. +type ReservationOrderListOptions struct { + // placeholder for future optional parameters +} + +type ReservationOrderProperties struct { + // Represent the billing plans. + BillingPlan *ReservationBillingPlan `json:"billingPlan,omitempty"` + + // This is the DateTime when the reservation was created. + CreatedDateTime *time.Time `json:"createdDateTime,omitempty"` + + // Friendly name for user to easily identified the reservation. + DisplayName *string `json:"displayName,omitempty"` + + // This is the date when the Reservation will expire. + ExpiryDate *time.Time `json:"expiryDate,omitempty"` + + // Total Quantity of the SKUs purchased in the Reservation. + OriginalQuantity *int32 `json:"originalQuantity,omitempty"` + + // Information describing the type of billing plan for this reservation. + PlanInformation *ReservationOrderBillingPlanInformation `json:"planInformation,omitempty"` + + // Current state of the reservation. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + + // This is the DateTime when the reservation was initially requested for purchase. + RequestDateTime *time.Time `json:"requestDateTime,omitempty"` + Reservations []*ReservationResponse `json:"reservations,omitempty"` + + // Represent the term of Reservation. + Term *ReservationTerm `json:"term,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationOrderProperties. +func (r ReservationOrderProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "billingPlan", r.BillingPlan) + populateTimeRFC3339(objectMap, "createdDateTime", r.CreatedDateTime) + populate(objectMap, "displayName", r.DisplayName) + populateDateType(objectMap, "expiryDate", r.ExpiryDate) + populate(objectMap, "originalQuantity", r.OriginalQuantity) + populate(objectMap, "planInformation", r.PlanInformation) + populate(objectMap, "provisioningState", r.ProvisioningState) + populateTimeRFC3339(objectMap, "requestDateTime", r.RequestDateTime) + populate(objectMap, "reservations", r.Reservations) + populate(objectMap, "term", r.Term) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationOrderProperties. +func (r *ReservationOrderProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "billingPlan": + err = unpopulate(val, &r.BillingPlan) + delete(rawMsg, key) + case "createdDateTime": + err = unpopulateTimeRFC3339(val, &r.CreatedDateTime) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, &r.DisplayName) + delete(rawMsg, key) + case "expiryDate": + err = unpopulateDateType(val, &r.ExpiryDate) + delete(rawMsg, key) + case "originalQuantity": + err = unpopulate(val, &r.OriginalQuantity) + delete(rawMsg, key) + case "planInformation": + err = unpopulate(val, &r.PlanInformation) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &r.ProvisioningState) + delete(rawMsg, key) + case "requestDateTime": + err = unpopulateTimeRFC3339(val, &r.RequestDateTime) + delete(rawMsg, key) + case "reservations": + err = unpopulate(val, &r.Reservations) + delete(rawMsg, key) + case "term": + err = unpopulate(val, &r.Term) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +type ReservationOrderResponse struct { + Etag *int32 `json:"etag,omitempty"` + Properties *ReservationOrderProperties `json:"properties,omitempty"` + + // READ-ONLY; Identifier of the reservation + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Name of the reservation + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; Type of resource. "Microsoft.Capacity/reservations" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ReservationResponse - The definition of the reservation. +type ReservationResponse struct { + Etag *int32 `json:"etag,omitempty"` + + // Resource Provider type to be reserved. + Kind *string `json:"kind,omitempty"` + + // The Azure Region where the reserved resource lives. + Location *string `json:"location,omitempty"` + + // The properties associated to this reservation + Properties *ReservationsProperties `json:"properties,omitempty"` + + // The sku information associated to this reservation + SKU *SKUName `json:"sku,omitempty"` + + // READ-ONLY; Identifier of the reservation + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Name of the reservation + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; Type of resource. "Microsoft.Capacity/reservationOrders/reservations" + Type *string `json:"type,omitempty" azure:"ro"` +} + +type ReservationSplitProperties struct { + // List of destination Resource Id that are created due to split. Format of the resource Id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + SplitDestinations []*string `json:"splitDestinations,omitempty"` + + // Resource Id of the Reservation from which this is split. Format of the resource Id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + SplitSource *string `json:"splitSource,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationSplitProperties. +func (r ReservationSplitProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "splitDestinations", r.SplitDestinations) + populate(objectMap, "splitSource", r.SplitSource) + return json.Marshal(objectMap) +} + +// ReservationSummary - The roll up count summary of reservations in each state +type ReservationSummary struct { + // READ-ONLY; The number of reservation in Cancelled state + CancelledCount *float32 `json:"cancelledCount,omitempty" azure:"ro"` + + // READ-ONLY; The number of reservation in Expired state + ExpiredCount *float32 `json:"expiredCount,omitempty" azure:"ro"` + + // READ-ONLY; The number of reservation in Expiring state + ExpiringCount *float32 `json:"expiringCount,omitempty" azure:"ro"` + + // READ-ONLY; The number of reservation in Failed state + FailedCount *float32 `json:"failedCount,omitempty" azure:"ro"` + + // READ-ONLY; The number of reservation in Pending state + PendingCount *float32 `json:"pendingCount,omitempty" azure:"ro"` + + // READ-ONLY; The number of reservation in Succeeded state + SucceededCount *float32 `json:"succeededCount,omitempty" azure:"ro"` +} + +// ReservationToExchange - Reservation refund details +type ReservationToExchange struct { + // billing information + BillingInformation *BillingInformation `json:"billingInformation,omitempty"` + BillingRefundAmount *Price `json:"billingRefundAmount,omitempty"` + + // Quantity to be returned + Quantity *int32 `json:"quantity,omitempty"` + + // Fully qualified id of the Reservation being returned. + ReservationID *string `json:"reservationId,omitempty"` +} + +// ReservationToPurchaseCalculateExchange - Reservation purchase details +type ReservationToPurchaseCalculateExchange struct { + BillingCurrencyTotal *Price `json:"billingCurrencyTotal,omitempty"` + Properties *PurchaseRequest `json:"properties,omitempty"` +} + +// ReservationToPurchaseExchange - Reservation purchase details +type ReservationToPurchaseExchange struct { + BillingCurrencyTotal *Price `json:"billingCurrencyTotal,omitempty"` + Properties *PurchaseRequest `json:"properties,omitempty"` + + // Fully qualified id of the Reservation being purchased. This value is only guaranteed to be non-null if the purchase is successful. + ReservationID *string `json:"reservationId,omitempty"` + + // Fully qualified id of the ReservationOrder being purchased + ReservationOrderID *string `json:"reservationOrderId,omitempty"` + + // Status of the individual operation. + Status *OperationStatus `json:"status,omitempty"` +} + +// ReservationToReturn - Reservation to return +type ReservationToReturn struct { + // Quantity to be returned. Must be greater than zero. + Quantity *int32 `json:"quantity,omitempty"` + + // Fully qualified identifier of the Reservation being returned + ReservationID *string `json:"reservationId,omitempty"` +} + +// ReservationToReturnForExchange - Reservation refund details +type ReservationToReturnForExchange struct { + // billing information + BillingInformation *BillingInformation `json:"billingInformation,omitempty"` + BillingRefundAmount *Price `json:"billingRefundAmount,omitempty"` + + // Quantity to be returned + Quantity *int32 `json:"quantity,omitempty"` + + // Fully qualified id of the Reservation being returned. + ReservationID *string `json:"reservationId,omitempty"` + + // Status of the individual operation. + Status *OperationStatus `json:"status,omitempty"` +} + +// ReservationUtilizationAggregates - The aggregate values of reservation utilization +type ReservationUtilizationAggregates 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"` +} + +// ReservationsListResult - The list of reservations and summary of roll out count of reservations in each state. +type ReservationsListResult struct { + // The roll out count summary of the reservations + Summary *ReservationSummary `json:"summary,omitempty"` + + // READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The list of reservations. + Value []*ReservationResponse `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationsListResult. +func (r ReservationsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "summary", r.Summary) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// ReservationsProperties - The properties of the reservations +type ReservationsProperties struct { + // The applied scope type + AppliedScopeType *AppliedScopeType `json:"appliedScopeType,omitempty"` + + // The list of applied scopes + AppliedScopes []*string `json:"appliedScopes,omitempty"` + + // Indicates if the reservation is archived + Archived *bool `json:"archived,omitempty"` + + // The billing plan options available for this SKU. + BillingPlan *ReservationBillingPlan `json:"billingPlan,omitempty"` + + // Subscription that will be charged for purchasing Reservation + BillingScopeID *string `json:"billingScopeId,omitempty"` + + // Capabilities of the reservation + Capabilities *string `json:"capabilities,omitempty"` + + // Friendly name for user to easily identify the reservation + DisplayName *string `json:"displayName,omitempty"` + + // DateTime of the Reservation starting when this version is effective from. + EffectiveDateTime *time.Time `json:"effectiveDateTime,omitempty"` + + // This is the date when the Reservation will expire. + ExpiryDate *time.Time `json:"expiryDate,omitempty"` + + // The message giving detailed information about the status code. + ExtendedStatusInfo *ExtendedStatusInfo `json:"extendedStatusInfo,omitempty"` + + // Allows reservation discount to be applied across skus within the same Autofit group. Not all skus support instance size flexibility. + InstanceFlexibility *InstanceFlexibility `json:"instanceFlexibility,omitempty"` + MergeProperties *ReservationMergeProperties `json:"mergeProperties,omitempty"` + + // Current state of the reservation. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + + // This is the date when the Reservation was purchased. + PurchaseDate *time.Time `json:"purchaseDate,omitempty"` + + // Quantity of the SKUs that are part of the Reservation. + Quantity *int32 `json:"quantity,omitempty"` + + // Setting this to true will automatically purchase a new reservation on the expiration date time. + Renew *bool `json:"renew,omitempty"` + + // Reservation Id of the reservation which is purchased because of renew. Format of the resource Id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + RenewDestination *string `json:"renewDestination,omitempty"` + RenewProperties *RenewPropertiesResponse `json:"renewProperties,omitempty"` + + // Reservation Id of the reservation from which this reservation is renewed. Format of the resource Id is + // /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + RenewSource *string `json:"renewSource,omitempty"` + + // The type of the resource that is being reserved. + ReservedResourceType *ReservedResourceType `json:"reservedResourceType,omitempty"` + + // Description of the SKU in english. + SKUDescription *string `json:"skuDescription,omitempty"` + SplitProperties *ReservationSplitProperties `json:"splitProperties,omitempty"` + + // Represent the term of Reservation. + Term *ReservationTerm `json:"term,omitempty"` + + // READ-ONLY; The provisioning state of the reservation for display, e.g. Succeeded + DisplayProvisioningState *string `json:"displayProvisioningState,omitempty" azure:"ro"` + + // READ-ONLY; DateTime of the last time the Reservation was updated. + LastUpdatedDateTime *time.Time `json:"lastUpdatedDateTime,omitempty" azure:"ro"` + + // READ-ONLY; The provisioning state of the reservation, e.g. Succeeded + ProvisioningSubState *string `json:"provisioningSubState,omitempty" azure:"ro"` + + // READ-ONLY; The applied scope type of the reservation for display, e.g. Shared + UserFriendlyAppliedScopeType *string `json:"userFriendlyAppliedScopeType,omitempty" azure:"ro"` + + // READ-ONLY; The renew state of the reservation for display, e.g. On + UserFriendlyRenewState *string `json:"userFriendlyRenewState,omitempty" azure:"ro"` + + // READ-ONLY; Reservation utilization + Utilization *ReservationsPropertiesUtilization `json:"utilization,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationsProperties. +func (r ReservationsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "appliedScopeType", r.AppliedScopeType) + populate(objectMap, "appliedScopes", r.AppliedScopes) + populate(objectMap, "archived", r.Archived) + populate(objectMap, "billingPlan", r.BillingPlan) + populate(objectMap, "billingScopeId", r.BillingScopeID) + populate(objectMap, "capabilities", r.Capabilities) + populate(objectMap, "displayName", r.DisplayName) + populate(objectMap, "displayProvisioningState", r.DisplayProvisioningState) + populateTimeRFC3339(objectMap, "effectiveDateTime", r.EffectiveDateTime) + populateDateType(objectMap, "expiryDate", r.ExpiryDate) + populate(objectMap, "extendedStatusInfo", r.ExtendedStatusInfo) + populate(objectMap, "instanceFlexibility", r.InstanceFlexibility) + populateTimeRFC3339(objectMap, "lastUpdatedDateTime", r.LastUpdatedDateTime) + populate(objectMap, "mergeProperties", r.MergeProperties) + populate(objectMap, "provisioningState", r.ProvisioningState) + populate(objectMap, "provisioningSubState", r.ProvisioningSubState) + populateDateType(objectMap, "purchaseDate", r.PurchaseDate) + populate(objectMap, "quantity", r.Quantity) + populate(objectMap, "renew", r.Renew) + populate(objectMap, "renewDestination", r.RenewDestination) + populate(objectMap, "renewProperties", r.RenewProperties) + populate(objectMap, "renewSource", r.RenewSource) + populate(objectMap, "reservedResourceType", r.ReservedResourceType) + populate(objectMap, "skuDescription", r.SKUDescription) + populate(objectMap, "splitProperties", r.SplitProperties) + populate(objectMap, "term", r.Term) + populate(objectMap, "userFriendlyAppliedScopeType", r.UserFriendlyAppliedScopeType) + populate(objectMap, "userFriendlyRenewState", r.UserFriendlyRenewState) + populate(objectMap, "utilization", r.Utilization) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationsProperties. +func (r *ReservationsProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "appliedScopeType": + err = unpopulate(val, &r.AppliedScopeType) + delete(rawMsg, key) + case "appliedScopes": + err = unpopulate(val, &r.AppliedScopes) + delete(rawMsg, key) + case "archived": + err = unpopulate(val, &r.Archived) + delete(rawMsg, key) + case "billingPlan": + err = unpopulate(val, &r.BillingPlan) + delete(rawMsg, key) + case "billingScopeId": + err = unpopulate(val, &r.BillingScopeID) + delete(rawMsg, key) + case "capabilities": + err = unpopulate(val, &r.Capabilities) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, &r.DisplayName) + delete(rawMsg, key) + case "displayProvisioningState": + err = unpopulate(val, &r.DisplayProvisioningState) + delete(rawMsg, key) + case "effectiveDateTime": + err = unpopulateTimeRFC3339(val, &r.EffectiveDateTime) + delete(rawMsg, key) + case "expiryDate": + err = unpopulateDateType(val, &r.ExpiryDate) + delete(rawMsg, key) + case "extendedStatusInfo": + err = unpopulate(val, &r.ExtendedStatusInfo) + delete(rawMsg, key) + case "instanceFlexibility": + err = unpopulate(val, &r.InstanceFlexibility) + delete(rawMsg, key) + case "lastUpdatedDateTime": + err = unpopulateTimeRFC3339(val, &r.LastUpdatedDateTime) + delete(rawMsg, key) + case "mergeProperties": + err = unpopulate(val, &r.MergeProperties) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &r.ProvisioningState) + delete(rawMsg, key) + case "provisioningSubState": + err = unpopulate(val, &r.ProvisioningSubState) + delete(rawMsg, key) + case "purchaseDate": + err = unpopulateDateType(val, &r.PurchaseDate) + delete(rawMsg, key) + case "quantity": + err = unpopulate(val, &r.Quantity) + delete(rawMsg, key) + case "renew": + err = unpopulate(val, &r.Renew) + delete(rawMsg, key) + case "renewDestination": + err = unpopulate(val, &r.RenewDestination) + delete(rawMsg, key) + case "renewProperties": + err = unpopulate(val, &r.RenewProperties) + delete(rawMsg, key) + case "renewSource": + err = unpopulate(val, &r.RenewSource) + delete(rawMsg, key) + case "reservedResourceType": + err = unpopulate(val, &r.ReservedResourceType) + delete(rawMsg, key) + case "skuDescription": + err = unpopulate(val, &r.SKUDescription) + delete(rawMsg, key) + case "splitProperties": + err = unpopulate(val, &r.SplitProperties) + delete(rawMsg, key) + case "term": + err = unpopulate(val, &r.Term) + delete(rawMsg, key) + case "userFriendlyAppliedScopeType": + err = unpopulate(val, &r.UserFriendlyAppliedScopeType) + delete(rawMsg, key) + case "userFriendlyRenewState": + err = unpopulate(val, &r.UserFriendlyRenewState) + delete(rawMsg, key) + case "utilization": + err = unpopulate(val, &r.Utilization) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ReservationsPropertiesUtilization - Reservation utilization +type ReservationsPropertiesUtilization struct { + // The array of aggregates of a reservation's utilization + Aggregates []*ReservationUtilizationAggregates `json:"aggregates,omitempty"` + + // READ-ONLY; The number of days trend for a reservation + Trend *string `json:"trend,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationsPropertiesUtilization. +func (r ReservationsPropertiesUtilization) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "aggregates", r.Aggregates) + populate(objectMap, "trend", r.Trend) + return json.Marshal(objectMap) +} + +// ResourceName - Resource name provided by the resource provider. Use this property for quotaRequest parameter. +type ResourceName struct { + // Resource name. + Value *string `json:"value,omitempty"` + + // READ-ONLY; Resource display localized name. + LocalizedValue *string `json:"localizedValue,omitempty" azure:"ro"` +} + +type SKUCapability struct { + // An invariant to describe the feature. + Name *string `json:"name,omitempty"` + + // An invariant if the feature is measured by quantity. + Value *string `json:"value,omitempty"` +} + +type SKUName struct { + Name *string `json:"name,omitempty"` +} + +type SKUProperty struct { + // An invariant to describe the feature. + Name *string `json:"name,omitempty"` + + // An invariant if the feature is measured by quantity. + Value *string `json:"value,omitempty"` +} + +type SKURestriction struct { + // The reason for restriction. + ReasonCode *string `json:"reasonCode,omitempty"` + + // The type of restrictions. + Type *string `json:"type,omitempty"` + + // The value of restrictions. If the restriction type is set to location. This would be different locations where the SKU is restricted. + Values []*string `json:"values,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SKURestriction. +func (s SKURestriction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "reasonCode", s.ReasonCode) + populate(objectMap, "type", s.Type) + populate(objectMap, "values", s.Values) + return json.Marshal(objectMap) +} + +type ScopeProperties struct { + Scope *string `json:"scope,omitempty"` + Valid *bool `json:"valid,omitempty"` +} + +// ServiceError - The API error details. +type ServiceError struct { + // The error code. + Code *string `json:"code,omitempty"` + + // The error message text. + Message *string `json:"message,omitempty"` + + // READ-ONLY; The list of error details. + Details []*ServiceErrorDetail `json:"details,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceError. +func (s ServiceError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", s.Code) + populate(objectMap, "details", s.Details) + populate(objectMap, "message", s.Message) + return json.Marshal(objectMap) +} + +// ServiceErrorDetail - The error details. +type ServiceErrorDetail struct { + // READ-ONLY; The error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The error message. + Message *string `json:"message,omitempty" azure:"ro"` +} + +type SplitProperties struct { + // List of the quantities in the new reservations to create. + Quantities []*int32 `json:"quantities,omitempty"` + + // Resource id of the reservation to be split. Format of the resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + ReservationID *string `json:"reservationId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SplitProperties. +func (s SplitProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "quantities", s.Quantities) + populate(objectMap, "reservationId", s.ReservationID) + return json.Marshal(objectMap) +} + +type SplitRequest struct { + Properties *SplitProperties `json:"properties,omitempty"` +} + +// SubRequest - The sub-request submitted with the quota request. +type SubRequest struct { + // The resource name. + Name *ResourceName `json:"name,omitempty"` + + // The quota request status. + ProvisioningState *QuotaRequestState `json:"provisioningState,omitempty"` + + // The limit units, such as count and bytes. Use the unit field provided in the response of the GET quota operation. + Unit *string `json:"unit,omitempty"` + + // READ-ONLY; Quota (resource limit). + Limit *int32 `json:"limit,omitempty" azure:"ro"` + + // READ-ONLY; User-friendly status message. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; Resource type for which the quota check was made. + ResourceType *string `json:"resourceType,omitempty" azure:"ro"` + + // READ-ONLY; Sub request ID for individual request. + SubRequestID *string `json:"subRequestId,omitempty" azure:"ro"` +} + +type SubscriptionScopeProperties struct { + Scopes []*ScopeProperties `json:"scopes,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionScopeProperties. +func (s SubscriptionScopeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "scopes", s.Scopes) + return json.Marshal(objectMap) +} + +// 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"` +} + +// 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 err + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return 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, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/resourcemanager/reservations/armreservations/zz_generated_operation_client.go b/sdk/resourcemanager/reservations/armreservations/zz_generated_operation_client.go new file mode 100644 index 000000000000..4ebb1a31cd1b --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/zz_generated_operation_client.go @@ -0,0 +1,89 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armreservations + +import ( + "context" + "fmt" + "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/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationClient contains the methods for the Operation group. +// Don't use this type directly, use NewOperationClient() instead. +type OperationClient struct { + ep string + pl runtime.Pipeline +} + +// NewOperationClient creates a new instance of OperationClient with the specified values. +func NewOperationClient(credential azcore.TokenCredential, options *arm.ClientOptions) *OperationClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &OperationClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - List all the operations. +// If the operation fails it returns the *Error error type. +func (client *OperationClient) List(options *OperationListOptions) *OperationListPager { + return &OperationListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp OperationListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.OperationList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *OperationClient) listCreateRequest(ctx context.Context, options *OperationListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationClient) listHandleResponse(resp *http.Response) (OperationListResponse, error) { + result := OperationListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationList); err != nil { + return OperationListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *OperationClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := Error{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/reservations/armreservations/zz_generated_pagers.go b/sdk/resourcemanager/reservations/armreservations/zz_generated_pagers.go new file mode 100644 index 000000000000..811b44c8059a --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/zz_generated_pagers.go @@ -0,0 +1,395 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armreservations + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "reflect" +) + +// OperationListPager provides operations for iterating over paged responses. +type OperationListPager struct { + client *OperationClient + current OperationListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, OperationListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *OperationListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *OperationListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.OperationList.NextLink == nil || len(*p.current.OperationList.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current OperationListResponse page. +func (p *OperationListPager) PageResponse() OperationListResponse { + return p.current +} + +// QuotaListPager provides operations for iterating over paged responses. +type QuotaListPager struct { + client *QuotaClient + current QuotaListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, QuotaListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *QuotaListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *QuotaListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.QuotaLimits.NextLink == nil || len(*p.current.QuotaLimits.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current QuotaListResponse page. +func (p *QuotaListPager) PageResponse() QuotaListResponse { + return p.current +} + +// QuotaRequestStatusListPager provides operations for iterating over paged responses. +type QuotaRequestStatusListPager struct { + client *QuotaRequestStatusClient + current QuotaRequestStatusListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, QuotaRequestStatusListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *QuotaRequestStatusListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *QuotaRequestStatusListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.QuotaRequestDetailsList.NextLink == nil || len(*p.current.QuotaRequestDetailsList.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current QuotaRequestStatusListResponse page. +func (p *QuotaRequestStatusListPager) PageResponse() QuotaRequestStatusListResponse { + return p.current +} + +// ReservationListAllPager provides operations for iterating over paged responses. +type ReservationListAllPager struct { + client *ReservationClient + current ReservationListAllResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ReservationListAllResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ReservationListAllPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *ReservationListAllPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ReservationsListResult.NextLink == nil || len(*p.current.ReservationsListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listAllHandleError(resp) + return false + } + result, err := p.client.listAllHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ReservationListAllResponse page. +func (p *ReservationListAllPager) PageResponse() ReservationListAllResponse { + return p.current +} + +// ReservationListPager provides operations for iterating over paged responses. +type ReservationListPager struct { + client *ReservationClient + current ReservationListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ReservationListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ReservationListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *ReservationListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ReservationList.NextLink == nil || len(*p.current.ReservationList.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ReservationListResponse page. +func (p *ReservationListPager) PageResponse() ReservationListResponse { + return p.current +} + +// ReservationListRevisionsPager provides operations for iterating over paged responses. +type ReservationListRevisionsPager struct { + client *ReservationClient + current ReservationListRevisionsResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ReservationListRevisionsResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ReservationListRevisionsPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *ReservationListRevisionsPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ReservationList.NextLink == nil || len(*p.current.ReservationList.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listRevisionsHandleError(resp) + return false + } + result, err := p.client.listRevisionsHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ReservationListRevisionsResponse page. +func (p *ReservationListRevisionsPager) PageResponse() ReservationListRevisionsResponse { + return p.current +} + +// ReservationOrderListPager provides operations for iterating over paged responses. +type ReservationOrderListPager struct { + client *ReservationOrderClient + current ReservationOrderListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ReservationOrderListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ReservationOrderListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *ReservationOrderListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ReservationOrderList.NextLink == nil || len(*p.current.ReservationOrderList.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ReservationOrderListResponse page. +func (p *ReservationOrderListPager) PageResponse() ReservationOrderListResponse { + return p.current +} diff --git a/sdk/resourcemanager/reservations/armreservations/zz_generated_pollers.go b/sdk/resourcemanager/reservations/armreservations/zz_generated_pollers.go new file mode 100644 index 000000000000..cd04d88ae4eb --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/zz_generated_pollers.go @@ -0,0 +1,402 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armreservations + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// CalculateExchangePostPoller provides polling facilities until the operation reaches a terminal state. +type CalculateExchangePostPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *CalculateExchangePostPoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *CalculateExchangePostPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final CalculateExchangePostResponse will be returned. +func (p *CalculateExchangePostPoller) FinalResponse(ctx context.Context) (CalculateExchangePostResponse, error) { + respType := CalculateExchangePostResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.CalculateExchangeOperationResultResponse) + if err != nil { + return CalculateExchangePostResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *CalculateExchangePostPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ExchangePostPoller provides polling facilities until the operation reaches a terminal state. +type ExchangePostPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ExchangePostPoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *ExchangePostPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final ExchangePostResponse will be returned. +func (p *ExchangePostPoller) FinalResponse(ctx context.Context) (ExchangePostResponse, error) { + respType := ExchangePostResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.ExchangeOperationResultResponse) + if err != nil { + return ExchangePostResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *ExchangePostPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// QuotaCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type QuotaCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *QuotaCreateOrUpdatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *QuotaCreateOrUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final QuotaCreateOrUpdateResponse will be returned. +func (p *QuotaCreateOrUpdatePoller) FinalResponse(ctx context.Context) (QuotaCreateOrUpdateResponse, error) { + respType := QuotaCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.QuotaRequestOneResourceSubmitResponse) + if err != nil { + return QuotaCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *QuotaCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// QuotaUpdatePoller provides polling facilities until the operation reaches a terminal state. +type QuotaUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *QuotaUpdatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *QuotaUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final QuotaUpdateResponse will be returned. +func (p *QuotaUpdatePoller) FinalResponse(ctx context.Context) (QuotaUpdateResponse, error) { + respType := QuotaUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.QuotaRequestOneResourceSubmitResponse) + if err != nil { + return QuotaUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *QuotaUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ReservationAvailableScopesPoller provides polling facilities until the operation reaches a terminal state. +type ReservationAvailableScopesPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ReservationAvailableScopesPoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *ReservationAvailableScopesPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final ReservationAvailableScopesResponse will be returned. +func (p *ReservationAvailableScopesPoller) FinalResponse(ctx context.Context) (ReservationAvailableScopesResponse, error) { + respType := ReservationAvailableScopesResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.AvailableScopeProperties) + if err != nil { + return ReservationAvailableScopesResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *ReservationAvailableScopesPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ReservationMergePoller provides polling facilities until the operation reaches a terminal state. +type ReservationMergePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ReservationMergePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *ReservationMergePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final ReservationMergeResponse will be returned. +func (p *ReservationMergePoller) FinalResponse(ctx context.Context) (ReservationMergeResponse, error) { + respType := ReservationMergeResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.ReservationResponseArray) + if err != nil { + return ReservationMergeResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *ReservationMergePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ReservationOrderPurchasePoller provides polling facilities until the operation reaches a terminal state. +type ReservationOrderPurchasePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ReservationOrderPurchasePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *ReservationOrderPurchasePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final ReservationOrderPurchaseResponse will be returned. +func (p *ReservationOrderPurchasePoller) FinalResponse(ctx context.Context) (ReservationOrderPurchaseResponse, error) { + respType := ReservationOrderPurchaseResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.ReservationOrderResponse) + if err != nil { + return ReservationOrderPurchaseResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *ReservationOrderPurchasePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ReservationSplitPoller provides polling facilities until the operation reaches a terminal state. +type ReservationSplitPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ReservationSplitPoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *ReservationSplitPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final ReservationSplitResponse will be returned. +func (p *ReservationSplitPoller) FinalResponse(ctx context.Context) (ReservationSplitResponse, error) { + respType := ReservationSplitResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.ReservationResponseArray) + if err != nil { + return ReservationSplitResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *ReservationSplitPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ReservationUpdatePoller provides polling facilities until the operation reaches a terminal state. +type ReservationUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ReservationUpdatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *ReservationUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final ReservationUpdateResponse will be returned. +func (p *ReservationUpdatePoller) FinalResponse(ctx context.Context) (ReservationUpdateResponse, error) { + respType := ReservationUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.ReservationResponse) + if err != nil { + return ReservationUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *ReservationUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} diff --git a/sdk/resourcemanager/reservations/armreservations/zz_generated_quota_client.go b/sdk/resourcemanager/reservations/armreservations/zz_generated_quota_client.go new file mode 100644 index 000000000000..0384608eeac2 --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/zz_generated_quota_client.go @@ -0,0 +1,362 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armreservations + +import ( + "context" + "errors" + "fmt" + "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/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// QuotaClient contains the methods for the Quota group. +// Don't use this type directly, use NewQuotaClient() instead. +type QuotaClient struct { + ep string + pl runtime.Pipeline +} + +// NewQuotaClient creates a new instance of QuotaClient with the specified values. +func NewQuotaClient(credential azcore.TokenCredential, options *arm.ClientOptions) *QuotaClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &QuotaClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Create or update the quota (service limits) of a resource to the requested value. Steps: +// 1. Make the Get request to get the quota information for specific resource. +// +// +// 2. To increase the quota, update the limit field in the response from Get request to new value. +// +// +// 3. Submit the JSON to the quota request API to update the quota. The Create quota request may be constructed as follows. The PUT operation can be used +// to update the quota. +// If the operation fails it returns the *ExceptionResponse error type. +func (client *QuotaClient) BeginCreateOrUpdate(ctx context.Context, subscriptionID string, providerID string, location string, resourceName string, createQuotaRequest CurrentQuotaLimitBase, options *QuotaBeginCreateOrUpdateOptions) (QuotaCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, subscriptionID, providerID, location, resourceName, createQuotaRequest, options) + if err != nil { + return QuotaCreateOrUpdatePollerResponse{}, err + } + result := QuotaCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("QuotaClient.CreateOrUpdate", "location", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return QuotaCreateOrUpdatePollerResponse{}, err + } + result.Poller = &QuotaCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Create or update the quota (service limits) of a resource to the requested value. Steps: +// 1. Make the Get request to get the quota information for specific resource. +// +// +// 2. To increase the quota, update the limit field in the response from Get request to new value. +// +// +// 3. Submit the JSON to the quota request API to update the quota. The Create quota request may be constructed as follows. The PUT operation can be used +// to update the quota. +// If the operation fails it returns the *ExceptionResponse error type. +func (client *QuotaClient) createOrUpdate(ctx context.Context, subscriptionID string, providerID string, location string, resourceName string, createQuotaRequest CurrentQuotaLimitBase, options *QuotaBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, subscriptionID, providerID, location, resourceName, createQuotaRequest, 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, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *QuotaClient) createOrUpdateCreateRequest(ctx context.Context, subscriptionID string, providerID string, location string, resourceName string, createQuotaRequest CurrentQuotaLimitBase, options *QuotaBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits/{resourceName}" + if subscriptionID == "" { + return nil, errors.New("parameter subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + if providerID == "" { + return nil, errors.New("parameter providerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{providerId}", url.PathEscape(providerID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-10-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, createQuotaRequest) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *QuotaClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ExceptionResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Get the current quota (service limit) and usage of a resource. You can use the response from the GET operation to submit quota update request. +// If the operation fails it returns the *ExceptionResponse error type. +func (client *QuotaClient) Get(ctx context.Context, subscriptionID string, providerID string, location string, resourceName string, options *QuotaGetOptions) (QuotaGetResponse, error) { + req, err := client.getCreateRequest(ctx, subscriptionID, providerID, location, resourceName, options) + if err != nil { + return QuotaGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return QuotaGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return QuotaGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *QuotaClient) getCreateRequest(ctx context.Context, subscriptionID string, providerID string, location string, resourceName string, options *QuotaGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits/{resourceName}" + if subscriptionID == "" { + return nil, errors.New("parameter subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + if providerID == "" { + return nil, errors.New("parameter providerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{providerId}", url.PathEscape(providerID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-10-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *QuotaClient) getHandleResponse(resp *http.Response) (QuotaGetResponse, error) { + result := QuotaGetResponse{RawResponse: resp} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.CurrentQuotaLimitBase); err != nil { + return QuotaGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *QuotaClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ExceptionResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - Gets a list of current quotas (service limits) and usage for all resources. The response from the list quota operation can be leveraged to request +// quota updates. +// If the operation fails it returns the *ExceptionResponse error type. +func (client *QuotaClient) List(subscriptionID string, providerID string, location string, options *QuotaListOptions) *QuotaListPager { + return &QuotaListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, subscriptionID, providerID, location, options) + }, + advancer: func(ctx context.Context, resp QuotaListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.QuotaLimits.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *QuotaClient) listCreateRequest(ctx context.Context, subscriptionID string, providerID string, location string, options *QuotaListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits" + if subscriptionID == "" { + return nil, errors.New("parameter subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + if providerID == "" { + return nil, errors.New("parameter providerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{providerId}", url.PathEscape(providerID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-10-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *QuotaClient) listHandleResponse(resp *http.Response) (QuotaListResponse, error) { + result := QuotaListResponse{RawResponse: resp} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.QuotaLimits); err != nil { + return QuotaListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *QuotaClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ExceptionResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginUpdate - Update the quota (service limits) of this resource to the requested value. +// • To get the quota information for specific resource, send a GET request. +// • To increase the quota, update the limit field from the GET response to a new value. +// • To update the quota value, submit the JSON response to the quota request API to update the quota. • To update the quota. use the PATCH operation. +// If the operation fails it returns the *ExceptionResponse error type. +func (client *QuotaClient) BeginUpdate(ctx context.Context, subscriptionID string, providerID string, location string, resourceName string, createQuotaRequest CurrentQuotaLimitBase, options *QuotaBeginUpdateOptions) (QuotaUpdatePollerResponse, error) { + resp, err := client.update(ctx, subscriptionID, providerID, location, resourceName, createQuotaRequest, options) + if err != nil { + return QuotaUpdatePollerResponse{}, err + } + result := QuotaUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("QuotaClient.Update", "location", resp, client.pl, client.updateHandleError) + if err != nil { + return QuotaUpdatePollerResponse{}, err + } + result.Poller = &QuotaUpdatePoller{ + pt: pt, + } + return result, nil +} + +// Update - Update the quota (service limits) of this resource to the requested value. +// • To get the quota information for specific resource, send a GET request. +// • To increase the quota, update the limit field from the GET response to a new value. +// • To update the quota value, submit the JSON response to the quota request API to update the quota. • To update the quota. use the PATCH operation. +// If the operation fails it returns the *ExceptionResponse error type. +func (client *QuotaClient) update(ctx context.Context, subscriptionID string, providerID string, location string, resourceName string, createQuotaRequest CurrentQuotaLimitBase, options *QuotaBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, subscriptionID, providerID, location, resourceName, createQuotaRequest, 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, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *QuotaClient) updateCreateRequest(ctx context.Context, subscriptionID string, providerID string, location string, resourceName string, createQuotaRequest CurrentQuotaLimitBase, options *QuotaBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits/{resourceName}" + if subscriptionID == "" { + return nil, errors.New("parameter subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + if providerID == "" { + return nil, errors.New("parameter providerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{providerId}", url.PathEscape(providerID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-10-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, createQuotaRequest) +} + +// updateHandleError handles the Update error response. +func (client *QuotaClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ExceptionResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/reservations/armreservations/zz_generated_quotarequeststatus_client.go b/sdk/resourcemanager/reservations/armreservations/zz_generated_quotarequeststatus_client.go new file mode 100644 index 000000000000..7f2588b3dce2 --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/zz_generated_quotarequeststatus_client.go @@ -0,0 +1,186 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armreservations + +import ( + "context" + "errors" + "fmt" + "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/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// QuotaRequestStatusClient contains the methods for the QuotaRequestStatus group. +// Don't use this type directly, use NewQuotaRequestStatusClient() instead. +type QuotaRequestStatusClient struct { + ep string + pl runtime.Pipeline +} + +// NewQuotaRequestStatusClient creates a new instance of QuotaRequestStatusClient with the specified values. +func NewQuotaRequestStatusClient(credential azcore.TokenCredential, options *arm.ClientOptions) *QuotaRequestStatusClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &QuotaRequestStatusClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - For the specified Azure region (location), get the details and status of the quota request by the quota request ID for the resources of the resource +// provider. The PUT request for the quota (service +// limit) returns a response with the requestId parameter. +// If the operation fails it returns the *ExceptionResponse error type. +func (client *QuotaRequestStatusClient) Get(ctx context.Context, subscriptionID string, providerID string, location string, id string, options *QuotaRequestStatusGetOptions) (QuotaRequestStatusGetResponse, error) { + req, err := client.getCreateRequest(ctx, subscriptionID, providerID, location, id, options) + if err != nil { + return QuotaRequestStatusGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return QuotaRequestStatusGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return QuotaRequestStatusGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *QuotaRequestStatusClient) getCreateRequest(ctx context.Context, subscriptionID string, providerID string, location string, id string, options *QuotaRequestStatusGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimitsRequests/{id}" + if subscriptionID == "" { + return nil, errors.New("parameter subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + if providerID == "" { + return nil, errors.New("parameter providerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{providerId}", url.PathEscape(providerID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + if id == "" { + return nil, errors.New("parameter id cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{id}", url.PathEscape(id)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-10-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *QuotaRequestStatusClient) getHandleResponse(resp *http.Response) (QuotaRequestStatusGetResponse, error) { + result := QuotaRequestStatusGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.QuotaRequestDetails); err != nil { + return QuotaRequestStatusGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *QuotaRequestStatusClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ExceptionResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - For the specified Azure region (location), subscription, and resource provider, get the history of the quota requests for the past year. To select +// specific quota requests, use the oData filter. +// If the operation fails it returns the *ExceptionResponse error type. +func (client *QuotaRequestStatusClient) List(subscriptionID string, providerID string, location string, options *QuotaRequestStatusListOptions) *QuotaRequestStatusListPager { + return &QuotaRequestStatusListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, subscriptionID, providerID, location, options) + }, + advancer: func(ctx context.Context, resp QuotaRequestStatusListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.QuotaRequestDetailsList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *QuotaRequestStatusClient) listCreateRequest(ctx context.Context, subscriptionID string, providerID string, location string, options *QuotaRequestStatusListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimitsRequests" + if subscriptionID == "" { + return nil, errors.New("parameter subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + if providerID == "" { + return nil, errors.New("parameter providerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{providerId}", url.PathEscape(providerID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-10-25") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.Skiptoken != nil { + reqQP.Set("$skiptoken", *options.Skiptoken) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *QuotaRequestStatusClient) listHandleResponse(resp *http.Response) (QuotaRequestStatusListResponse, error) { + result := QuotaRequestStatusListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.QuotaRequestDetailsList); err != nil { + return QuotaRequestStatusListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *QuotaRequestStatusClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ExceptionResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/reservations/armreservations/zz_generated_reservation_client.go b/sdk/resourcemanager/reservations/armreservations/zz_generated_reservation_client.go new file mode 100644 index 000000000000..07e62bcba86d --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/zz_generated_reservation_client.go @@ -0,0 +1,567 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armreservations + +import ( + "context" + "errors" + "fmt" + "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/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// ReservationClient contains the methods for the Reservation group. +// Don't use this type directly, use NewReservationClient() instead. +type ReservationClient struct { + ep string + pl runtime.Pipeline +} + +// NewReservationClient creates a new instance of ReservationClient with the specified values. +func NewReservationClient(credential azcore.TokenCredential, options *arm.ClientOptions) *ReservationClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ReservationClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginAvailableScopes - Get Available Scopes for Reservation. +// If the operation fails it returns the *Error error type. +func (client *ReservationClient) BeginAvailableScopes(ctx context.Context, reservationOrderID string, reservationID string, body AvailableScopeRequest, options *ReservationBeginAvailableScopesOptions) (ReservationAvailableScopesPollerResponse, error) { + resp, err := client.availableScopes(ctx, reservationOrderID, reservationID, body, options) + if err != nil { + return ReservationAvailableScopesPollerResponse{}, err + } + result := ReservationAvailableScopesPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ReservationClient.AvailableScopes", "", resp, client.pl, client.availableScopesHandleError) + if err != nil { + return ReservationAvailableScopesPollerResponse{}, err + } + result.Poller = &ReservationAvailableScopesPoller{ + pt: pt, + } + return result, nil +} + +// AvailableScopes - Get Available Scopes for Reservation. +// If the operation fails it returns the *Error error type. +func (client *ReservationClient) availableScopes(ctx context.Context, reservationOrderID string, reservationID string, body AvailableScopeRequest, options *ReservationBeginAvailableScopesOptions) (*http.Response, error) { + req, err := client.availableScopesCreateRequest(ctx, reservationOrderID, reservationID, 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) { + return nil, client.availableScopesHandleError(resp) + } + return resp, nil +} + +// availableScopesCreateRequest creates the AvailableScopes request. +func (client *ReservationClient) availableScopesCreateRequest(ctx context.Context, reservationOrderID string, reservationID string, body AvailableScopeRequest, options *ReservationBeginAvailableScopesOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}/availableScopes" + if reservationOrderID == "" { + return nil, errors.New("parameter reservationOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationOrderId}", url.PathEscape(reservationOrderID)) + if reservationID == "" { + return nil, errors.New("parameter reservationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationId}", url.PathEscape(reservationID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// availableScopesHandleError handles the AvailableScopes error response. +func (client *ReservationClient) availableScopesHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := Error{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Get specific Reservation details. +// If the operation fails it returns the *Error error type. +func (client *ReservationClient) Get(ctx context.Context, reservationID string, reservationOrderID string, options *ReservationGetOptions) (ReservationGetResponse, error) { + req, err := client.getCreateRequest(ctx, reservationID, reservationOrderID, options) + if err != nil { + return ReservationGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ReservationGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ReservationGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ReservationClient) getCreateRequest(ctx context.Context, reservationID string, reservationOrderID string, options *ReservationGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}" + if reservationID == "" { + return nil, errors.New("parameter reservationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationId}", url.PathEscape(reservationID)) + if reservationOrderID == "" { + return nil, errors.New("parameter reservationOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationOrderId}", url.PathEscape(reservationOrderID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + if options != nil && options.Expand != nil { + reqQP.Set("expand", *options.Expand) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ReservationClient) getHandleResponse(resp *http.Response) (ReservationGetResponse, error) { + result := ReservationGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ReservationResponse); err != nil { + return ReservationGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ReservationClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := Error{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - List Reservations within a single ReservationOrder. +// If the operation fails it returns the *Error error type. +func (client *ReservationClient) List(reservationOrderID string, options *ReservationListOptions) *ReservationListPager { + return &ReservationListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, reservationOrderID, options) + }, + advancer: func(ctx context.Context, resp ReservationListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ReservationList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *ReservationClient) listCreateRequest(ctx context.Context, reservationOrderID string, options *ReservationListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations" + if reservationOrderID == "" { + return nil, errors.New("parameter reservationOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationOrderId}", url.PathEscape(reservationOrderID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ReservationClient) listHandleResponse(resp *http.Response) (ReservationListResponse, error) { + result := ReservationListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ReservationList); err != nil { + return ReservationListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *ReservationClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := Error{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListAll - List the reservations and the roll up counts of reservations group by provisioning states that the user has access to in the current tenant. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ReservationClient) ListAll(options *ReservationListAllOptions) *ReservationListAllPager { + return &ReservationListAllPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listAllCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp ReservationListAllResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ReservationsListResult.NextLink) + }, + } +} + +// listAllCreateRequest creates the ListAll request. +func (client *ReservationClient) listAllCreateRequest(ctx context.Context, options *ReservationListAllOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/reservations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-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.Set("Accept", "application/json") + return req, nil +} + +// listAllHandleResponse handles the ListAll response. +func (client *ReservationClient) listAllHandleResponse(resp *http.Response) (ReservationListAllResponse, error) { + result := ReservationListAllResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ReservationsListResult); err != nil { + return ReservationListAllResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listAllHandleError handles the ListAll error response. +func (client *ReservationClient) listAllHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListRevisions - List of all the revisions for the Reservation. +// If the operation fails it returns the *Error error type. +func (client *ReservationClient) ListRevisions(reservationID string, reservationOrderID string, options *ReservationListRevisionsOptions) *ReservationListRevisionsPager { + return &ReservationListRevisionsPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listRevisionsCreateRequest(ctx, reservationID, reservationOrderID, options) + }, + advancer: func(ctx context.Context, resp ReservationListRevisionsResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ReservationList.NextLink) + }, + } +} + +// listRevisionsCreateRequest creates the ListRevisions request. +func (client *ReservationClient) listRevisionsCreateRequest(ctx context.Context, reservationID string, reservationOrderID string, options *ReservationListRevisionsOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}/revisions" + if reservationID == "" { + return nil, errors.New("parameter reservationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationId}", url.PathEscape(reservationID)) + if reservationOrderID == "" { + return nil, errors.New("parameter reservationOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationOrderId}", url.PathEscape(reservationOrderID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listRevisionsHandleResponse handles the ListRevisions response. +func (client *ReservationClient) listRevisionsHandleResponse(resp *http.Response) (ReservationListRevisionsResponse, error) { + result := ReservationListRevisionsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ReservationList); err != nil { + return ReservationListRevisionsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listRevisionsHandleError handles the ListRevisions error response. +func (client *ReservationClient) listRevisionsHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := Error{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginMerge - Merge the specified Reservations into a new Reservation. The two Reservations being merged must have same properties. +// If the operation fails it returns the *Error error type. +func (client *ReservationClient) BeginMerge(ctx context.Context, reservationOrderID string, body MergeRequest, options *ReservationBeginMergeOptions) (ReservationMergePollerResponse, error) { + resp, err := client.merge(ctx, reservationOrderID, body, options) + if err != nil { + return ReservationMergePollerResponse{}, err + } + result := ReservationMergePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ReservationClient.Merge", "location", resp, client.pl, client.mergeHandleError) + if err != nil { + return ReservationMergePollerResponse{}, err + } + result.Poller = &ReservationMergePoller{ + pt: pt, + } + return result, nil +} + +// Merge - Merge the specified Reservations into a new Reservation. The two Reservations being merged must have same properties. +// If the operation fails it returns the *Error error type. +func (client *ReservationClient) merge(ctx context.Context, reservationOrderID string, body MergeRequest, options *ReservationBeginMergeOptions) (*http.Response, error) { + req, err := client.mergeCreateRequest(ctx, reservationOrderID, 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.StatusAccepted) { + return nil, client.mergeHandleError(resp) + } + return resp, nil +} + +// mergeCreateRequest creates the Merge request. +func (client *ReservationClient) mergeCreateRequest(ctx context.Context, reservationOrderID string, body MergeRequest, options *ReservationBeginMergeOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/merge" + if reservationOrderID == "" { + return nil, errors.New("parameter reservationOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationOrderId}", url.PathEscape(reservationOrderID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// mergeHandleError handles the Merge error response. +func (client *ReservationClient) mergeHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := Error{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginSplit - Split a Reservation into two Reservations with specified quantity distribution. +// If the operation fails it returns the *Error error type. +func (client *ReservationClient) BeginSplit(ctx context.Context, reservationOrderID string, body SplitRequest, options *ReservationBeginSplitOptions) (ReservationSplitPollerResponse, error) { + resp, err := client.split(ctx, reservationOrderID, body, options) + if err != nil { + return ReservationSplitPollerResponse{}, err + } + result := ReservationSplitPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ReservationClient.Split", "location", resp, client.pl, client.splitHandleError) + if err != nil { + return ReservationSplitPollerResponse{}, err + } + result.Poller = &ReservationSplitPoller{ + pt: pt, + } + return result, nil +} + +// Split - Split a Reservation into two Reservations with specified quantity distribution. +// If the operation fails it returns the *Error error type. +func (client *ReservationClient) split(ctx context.Context, reservationOrderID string, body SplitRequest, options *ReservationBeginSplitOptions) (*http.Response, error) { + req, err := client.splitCreateRequest(ctx, reservationOrderID, 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.StatusAccepted) { + return nil, client.splitHandleError(resp) + } + return resp, nil +} + +// splitCreateRequest creates the Split request. +func (client *ReservationClient) splitCreateRequest(ctx context.Context, reservationOrderID string, body SplitRequest, options *ReservationBeginSplitOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/split" + if reservationOrderID == "" { + return nil, errors.New("parameter reservationOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationOrderId}", url.PathEscape(reservationOrderID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// splitHandleError handles the Split error response. +func (client *ReservationClient) splitHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := Error{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginUpdate - Updates the applied scopes of the Reservation. +// If the operation fails it returns the *Error error type. +func (client *ReservationClient) BeginUpdate(ctx context.Context, reservationOrderID string, reservationID string, parameters Patch, options *ReservationBeginUpdateOptions) (ReservationUpdatePollerResponse, error) { + resp, err := client.update(ctx, reservationOrderID, reservationID, parameters, options) + if err != nil { + return ReservationUpdatePollerResponse{}, err + } + result := ReservationUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ReservationClient.Update", "", resp, client.pl, client.updateHandleError) + if err != nil { + return ReservationUpdatePollerResponse{}, err + } + result.Poller = &ReservationUpdatePoller{ + pt: pt, + } + return result, nil +} + +// Update - Updates the applied scopes of the Reservation. +// If the operation fails it returns the *Error error type. +func (client *ReservationClient) update(ctx context.Context, reservationOrderID string, reservationID string, parameters Patch, options *ReservationBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, reservationOrderID, reservationID, parameters, 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.StatusAccepted) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *ReservationClient) updateCreateRequest(ctx context.Context, reservationOrderID string, reservationID string, parameters Patch, options *ReservationBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}" + if reservationOrderID == "" { + return nil, errors.New("parameter reservationOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationOrderId}", url.PathEscape(reservationOrderID)) + if reservationID == "" { + return nil, errors.New("parameter reservationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationId}", url.PathEscape(reservationID)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// updateHandleError handles the Update error response. +func (client *ReservationClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := Error{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/reservations/armreservations/zz_generated_reservationorder_client.go b/sdk/resourcemanager/reservations/armreservations/zz_generated_reservationorder_client.go new file mode 100644 index 000000000000..57119d321806 --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/zz_generated_reservationorder_client.go @@ -0,0 +1,330 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armreservations + +import ( + "context" + "errors" + "fmt" + "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/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ReservationOrderClient contains the methods for the ReservationOrder group. +// Don't use this type directly, use NewReservationOrderClient() instead. +type ReservationOrderClient struct { + ep string + pl runtime.Pipeline +} + +// NewReservationOrderClient creates a new instance of ReservationOrderClient with the specified values. +func NewReservationOrderClient(credential azcore.TokenCredential, options *arm.ClientOptions) *ReservationOrderClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ReservationOrderClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Calculate - Calculate price for placing a ReservationOrder. +// If the operation fails it returns the *Error error type. +func (client *ReservationOrderClient) Calculate(ctx context.Context, body PurchaseRequest, options *ReservationOrderCalculateOptions) (ReservationOrderCalculateResponse, error) { + req, err := client.calculateCreateRequest(ctx, body, options) + if err != nil { + return ReservationOrderCalculateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ReservationOrderCalculateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ReservationOrderCalculateResponse{}, client.calculateHandleError(resp) + } + return client.calculateHandleResponse(resp) +} + +// calculateCreateRequest creates the Calculate request. +func (client *ReservationOrderClient) calculateCreateRequest(ctx context.Context, body PurchaseRequest, options *ReservationOrderCalculateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/calculatePrice" + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// calculateHandleResponse handles the Calculate response. +func (client *ReservationOrderClient) calculateHandleResponse(resp *http.Response) (ReservationOrderCalculateResponse, error) { + result := ReservationOrderCalculateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CalculatePriceResponse); err != nil { + return ReservationOrderCalculateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// calculateHandleError handles the Calculate error response. +func (client *ReservationOrderClient) calculateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := Error{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ChangeDirectory - Change directory (tenant) of ReservationOrder and all Reservation under it to specified tenant id +// If the operation fails it returns the *Error error type. +func (client *ReservationOrderClient) ChangeDirectory(ctx context.Context, reservationOrderID string, body ChangeDirectoryRequest, options *ReservationOrderChangeDirectoryOptions) (ReservationOrderChangeDirectoryResponse, error) { + req, err := client.changeDirectoryCreateRequest(ctx, reservationOrderID, body, options) + if err != nil { + return ReservationOrderChangeDirectoryResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ReservationOrderChangeDirectoryResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ReservationOrderChangeDirectoryResponse{}, client.changeDirectoryHandleError(resp) + } + return client.changeDirectoryHandleResponse(resp) +} + +// changeDirectoryCreateRequest creates the ChangeDirectory request. +func (client *ReservationOrderClient) changeDirectoryCreateRequest(ctx context.Context, reservationOrderID string, body ChangeDirectoryRequest, options *ReservationOrderChangeDirectoryOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/changeDirectory" + if reservationOrderID == "" { + return nil, errors.New("parameter reservationOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationOrderId}", url.PathEscape(reservationOrderID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// changeDirectoryHandleResponse handles the ChangeDirectory response. +func (client *ReservationOrderClient) changeDirectoryHandleResponse(resp *http.Response) (ReservationOrderChangeDirectoryResponse, error) { + result := ReservationOrderChangeDirectoryResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ChangeDirectoryResponse); err != nil { + return ReservationOrderChangeDirectoryResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// changeDirectoryHandleError handles the ChangeDirectory error response. +func (client *ReservationOrderClient) changeDirectoryHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := Error{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Get the details of the ReservationOrder. +// If the operation fails it returns the *Error error type. +func (client *ReservationOrderClient) Get(ctx context.Context, reservationOrderID string, options *ReservationOrderGetOptions) (ReservationOrderGetResponse, error) { + req, err := client.getCreateRequest(ctx, reservationOrderID, options) + if err != nil { + return ReservationOrderGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ReservationOrderGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ReservationOrderGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ReservationOrderClient) getCreateRequest(ctx context.Context, reservationOrderID string, options *ReservationOrderGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}" + if reservationOrderID == "" { + return nil, errors.New("parameter reservationOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationOrderId}", url.PathEscape(reservationOrderID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ReservationOrderClient) getHandleResponse(resp *http.Response) (ReservationOrderGetResponse, error) { + result := ReservationOrderGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ReservationOrderResponse); err != nil { + return ReservationOrderGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ReservationOrderClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := Error{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - List of all the ReservationOrders that the user has access to in the current tenant. +// If the operation fails it returns the *Error error type. +func (client *ReservationOrderClient) List(options *ReservationOrderListOptions) *ReservationOrderListPager { + return &ReservationOrderListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp ReservationOrderListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ReservationOrderList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *ReservationOrderClient) listCreateRequest(ctx context.Context, options *ReservationOrderListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/reservationOrders" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ReservationOrderClient) listHandleResponse(resp *http.Response) (ReservationOrderListResponse, error) { + result := ReservationOrderListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ReservationOrderList); err != nil { + return ReservationOrderListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *ReservationOrderClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := Error{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginPurchase - Purchase ReservationOrder and create resource under the specified URI. +// If the operation fails it returns the *Error error type. +func (client *ReservationOrderClient) BeginPurchase(ctx context.Context, reservationOrderID string, body PurchaseRequest, options *ReservationOrderBeginPurchaseOptions) (ReservationOrderPurchasePollerResponse, error) { + resp, err := client.purchase(ctx, reservationOrderID, body, options) + if err != nil { + return ReservationOrderPurchasePollerResponse{}, err + } + result := ReservationOrderPurchasePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ReservationOrderClient.Purchase", "location", resp, client.pl, client.purchaseHandleError) + if err != nil { + return ReservationOrderPurchasePollerResponse{}, err + } + result.Poller = &ReservationOrderPurchasePoller{ + pt: pt, + } + return result, nil +} + +// Purchase - Purchase ReservationOrder and create resource under the specified URI. +// If the operation fails it returns the *Error error type. +func (client *ReservationOrderClient) purchase(ctx context.Context, reservationOrderID string, body PurchaseRequest, options *ReservationOrderBeginPurchaseOptions) (*http.Response, error) { + req, err := client.purchaseCreateRequest(ctx, reservationOrderID, 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.StatusAccepted) { + return nil, client.purchaseHandleError(resp) + } + return resp, nil +} + +// purchaseCreateRequest creates the Purchase request. +func (client *ReservationOrderClient) purchaseCreateRequest(ctx context.Context, reservationOrderID string, body PurchaseRequest, options *ReservationOrderBeginPurchaseOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}" + if reservationOrderID == "" { + return nil, errors.New("parameter reservationOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationOrderId}", url.PathEscape(reservationOrderID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// purchaseHandleError handles the Purchase error response. +func (client *ReservationOrderClient) purchaseHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := Error{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/reservations/armreservations/zz_generated_response_types.go b/sdk/resourcemanager/reservations/armreservations/zz_generated_response_types.go new file mode 100644 index 000000000000..8b996e25a916 --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/zz_generated_response_types.go @@ -0,0 +1,671 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armreservations + +import ( + "context" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "net/http" + "time" +) + +// AzureReservationAPIGetAppliedReservationListResponse contains the response from method AzureReservationAPI.GetAppliedReservationList. +type AzureReservationAPIGetAppliedReservationListResponse struct { + AzureReservationAPIGetAppliedReservationListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AzureReservationAPIGetAppliedReservationListResult contains the result from method AzureReservationAPI.GetAppliedReservationList. +type AzureReservationAPIGetAppliedReservationListResult struct { + AppliedReservations +} + +// AzureReservationAPIGetCatalogResponse contains the response from method AzureReservationAPI.GetCatalog. +type AzureReservationAPIGetCatalogResponse struct { + AzureReservationAPIGetCatalogResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AzureReservationAPIGetCatalogResult contains the result from method AzureReservationAPI.GetCatalog. +type AzureReservationAPIGetCatalogResult struct { + // Array of Catalog + CatalogArray []*Catalog +} + +// CalculateExchangePostPollerResponse contains the response from method CalculateExchange.Post. +type CalculateExchangePostPollerResponse struct { + // Poller contains an initialized poller. + Poller *CalculateExchangePostPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l CalculateExchangePostPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (CalculateExchangePostResponse, error) { + respType := CalculateExchangePostResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.CalculateExchangeOperationResultResponse) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a CalculateExchangePostPollerResponse from the provided client and resume token. +func (l *CalculateExchangePostPollerResponse) Resume(ctx context.Context, client *CalculateExchangeClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("CalculateExchangeClient.Post", token, client.pl, client.postHandleError) + if err != nil { + return err + } + poller := &CalculateExchangePostPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// CalculateExchangePostResponse contains the response from method CalculateExchange.Post. +type CalculateExchangePostResponse struct { + CalculateExchangePostResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CalculateExchangePostResult contains the result from method CalculateExchange.Post. +type CalculateExchangePostResult struct { + CalculateExchangeOperationResultResponse +} + +// ExchangePostPollerResponse contains the response from method Exchange.Post. +type ExchangePostPollerResponse struct { + // Poller contains an initialized poller. + Poller *ExchangePostPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ExchangePostPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ExchangePostResponse, error) { + respType := ExchangePostResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.ExchangeOperationResultResponse) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ExchangePostPollerResponse from the provided client and resume token. +func (l *ExchangePostPollerResponse) Resume(ctx context.Context, client *ExchangeClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ExchangeClient.Post", token, client.pl, client.postHandleError) + if err != nil { + return err + } + poller := &ExchangePostPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ExchangePostResponse contains the response from method Exchange.Post. +type ExchangePostResponse struct { + ExchangePostResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ExchangePostResult contains the result from method Exchange.Post. +type ExchangePostResult struct { + ExchangeOperationResultResponse +} + +// OperationListResponse contains the response from method Operation.List. +type OperationListResponse struct { + OperationListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationListResult contains the result from method Operation.List. +type OperationListResult struct { + OperationList +} + +// QuotaCreateOrUpdatePollerResponse contains the response from method Quota.CreateOrUpdate. +type QuotaCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *QuotaCreateOrUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l QuotaCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (QuotaCreateOrUpdateResponse, error) { + respType := QuotaCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.QuotaRequestOneResourceSubmitResponse) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a QuotaCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *QuotaCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *QuotaClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("QuotaClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &QuotaCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// QuotaCreateOrUpdateResponse contains the response from method Quota.CreateOrUpdate. +type QuotaCreateOrUpdateResponse struct { + QuotaCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// QuotaCreateOrUpdateResult contains the result from method Quota.CreateOrUpdate. +type QuotaCreateOrUpdateResult struct { + QuotaRequestOneResourceSubmitResponse +} + +// QuotaGetResponse contains the response from method Quota.Get. +type QuotaGetResponse struct { + QuotaGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// QuotaGetResult contains the result from method Quota.Get. +type QuotaGetResult struct { + CurrentQuotaLimitBase + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// QuotaListResponse contains the response from method Quota.List. +type QuotaListResponse struct { + QuotaListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// QuotaListResult contains the result from method Quota.List. +type QuotaListResult struct { + QuotaLimits + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// QuotaRequestStatusGetResponse contains the response from method QuotaRequestStatus.Get. +type QuotaRequestStatusGetResponse struct { + QuotaRequestStatusGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// QuotaRequestStatusGetResult contains the result from method QuotaRequestStatus.Get. +type QuotaRequestStatusGetResult struct { + QuotaRequestDetails +} + +// QuotaRequestStatusListResponse contains the response from method QuotaRequestStatus.List. +type QuotaRequestStatusListResponse struct { + QuotaRequestStatusListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// QuotaRequestStatusListResult contains the result from method QuotaRequestStatus.List. +type QuotaRequestStatusListResult struct { + QuotaRequestDetailsList +} + +// QuotaUpdatePollerResponse contains the response from method Quota.Update. +type QuotaUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *QuotaUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l QuotaUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (QuotaUpdateResponse, error) { + respType := QuotaUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.QuotaRequestOneResourceSubmitResponse) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a QuotaUpdatePollerResponse from the provided client and resume token. +func (l *QuotaUpdatePollerResponse) Resume(ctx context.Context, client *QuotaClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("QuotaClient.Update", token, client.pl, client.updateHandleError) + if err != nil { + return err + } + poller := &QuotaUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// QuotaUpdateResponse contains the response from method Quota.Update. +type QuotaUpdateResponse struct { + QuotaUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// QuotaUpdateResult contains the result from method Quota.Update. +type QuotaUpdateResult struct { + QuotaRequestOneResourceSubmitResponse +} + +// ReservationAvailableScopesPollerResponse contains the response from method Reservation.AvailableScopes. +type ReservationAvailableScopesPollerResponse struct { + // Poller contains an initialized poller. + Poller *ReservationAvailableScopesPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ReservationAvailableScopesPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ReservationAvailableScopesResponse, error) { + respType := ReservationAvailableScopesResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.AvailableScopeProperties) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ReservationAvailableScopesPollerResponse from the provided client and resume token. +func (l *ReservationAvailableScopesPollerResponse) Resume(ctx context.Context, client *ReservationClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ReservationClient.AvailableScopes", token, client.pl, client.availableScopesHandleError) + if err != nil { + return err + } + poller := &ReservationAvailableScopesPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ReservationAvailableScopesResponse contains the response from method Reservation.AvailableScopes. +type ReservationAvailableScopesResponse struct { + ReservationAvailableScopesResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ReservationAvailableScopesResult contains the result from method Reservation.AvailableScopes. +type ReservationAvailableScopesResult struct { + AvailableScopeProperties +} + +// ReservationGetResponse contains the response from method Reservation.Get. +type ReservationGetResponse struct { + ReservationGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ReservationGetResult contains the result from method Reservation.Get. +type ReservationGetResult struct { + ReservationResponse +} + +// ReservationListAllResponse contains the response from method Reservation.ListAll. +type ReservationListAllResponse struct { + ReservationListAllResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ReservationListAllResult contains the result from method Reservation.ListAll. +type ReservationListAllResult struct { + ReservationsListResult +} + +// ReservationListResponse contains the response from method Reservation.List. +type ReservationListResponse struct { + ReservationListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ReservationListResult contains the result from method Reservation.List. +type ReservationListResult struct { + ReservationList +} + +// ReservationListRevisionsResponse contains the response from method Reservation.ListRevisions. +type ReservationListRevisionsResponse struct { + ReservationListRevisionsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ReservationListRevisionsResult contains the result from method Reservation.ListRevisions. +type ReservationListRevisionsResult struct { + ReservationList +} + +// ReservationMergePollerResponse contains the response from method Reservation.Merge. +type ReservationMergePollerResponse struct { + // Poller contains an initialized poller. + Poller *ReservationMergePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ReservationMergePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ReservationMergeResponse, error) { + respType := ReservationMergeResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.ReservationResponseArray) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ReservationMergePollerResponse from the provided client and resume token. +func (l *ReservationMergePollerResponse) Resume(ctx context.Context, client *ReservationClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ReservationClient.Merge", token, client.pl, client.mergeHandleError) + if err != nil { + return err + } + poller := &ReservationMergePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ReservationMergeResponse contains the response from method Reservation.Merge. +type ReservationMergeResponse struct { + ReservationMergeResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ReservationMergeResult contains the result from method Reservation.Merge. +type ReservationMergeResult struct { + // Array of ReservationResponse + ReservationResponseArray []*ReservationResponse +} + +// ReservationOrderCalculateResponse contains the response from method ReservationOrder.Calculate. +type ReservationOrderCalculateResponse struct { + ReservationOrderCalculateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ReservationOrderCalculateResult contains the result from method ReservationOrder.Calculate. +type ReservationOrderCalculateResult struct { + CalculatePriceResponse +} + +// ReservationOrderChangeDirectoryResponse contains the response from method ReservationOrder.ChangeDirectory. +type ReservationOrderChangeDirectoryResponse struct { + ReservationOrderChangeDirectoryResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ReservationOrderChangeDirectoryResult contains the result from method ReservationOrder.ChangeDirectory. +type ReservationOrderChangeDirectoryResult struct { + ChangeDirectoryResponse +} + +// ReservationOrderGetResponse contains the response from method ReservationOrder.Get. +type ReservationOrderGetResponse struct { + ReservationOrderGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ReservationOrderGetResult contains the result from method ReservationOrder.Get. +type ReservationOrderGetResult struct { + ReservationOrderResponse +} + +// ReservationOrderListResponse contains the response from method ReservationOrder.List. +type ReservationOrderListResponse struct { + ReservationOrderListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ReservationOrderListResult contains the result from method ReservationOrder.List. +type ReservationOrderListResult struct { + ReservationOrderList +} + +// ReservationOrderPurchasePollerResponse contains the response from method ReservationOrder.Purchase. +type ReservationOrderPurchasePollerResponse struct { + // Poller contains an initialized poller. + Poller *ReservationOrderPurchasePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ReservationOrderPurchasePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ReservationOrderPurchaseResponse, error) { + respType := ReservationOrderPurchaseResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.ReservationOrderResponse) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ReservationOrderPurchasePollerResponse from the provided client and resume token. +func (l *ReservationOrderPurchasePollerResponse) Resume(ctx context.Context, client *ReservationOrderClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ReservationOrderClient.Purchase", token, client.pl, client.purchaseHandleError) + if err != nil { + return err + } + poller := &ReservationOrderPurchasePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ReservationOrderPurchaseResponse contains the response from method ReservationOrder.Purchase. +type ReservationOrderPurchaseResponse struct { + ReservationOrderPurchaseResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ReservationOrderPurchaseResult contains the result from method ReservationOrder.Purchase. +type ReservationOrderPurchaseResult struct { + ReservationOrderResponse +} + +// ReservationSplitPollerResponse contains the response from method Reservation.Split. +type ReservationSplitPollerResponse struct { + // Poller contains an initialized poller. + Poller *ReservationSplitPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ReservationSplitPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ReservationSplitResponse, error) { + respType := ReservationSplitResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.ReservationResponseArray) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ReservationSplitPollerResponse from the provided client and resume token. +func (l *ReservationSplitPollerResponse) Resume(ctx context.Context, client *ReservationClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ReservationClient.Split", token, client.pl, client.splitHandleError) + if err != nil { + return err + } + poller := &ReservationSplitPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ReservationSplitResponse contains the response from method Reservation.Split. +type ReservationSplitResponse struct { + ReservationSplitResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ReservationSplitResult contains the result from method Reservation.Split. +type ReservationSplitResult struct { + // Array of ReservationResponse + ReservationResponseArray []*ReservationResponse +} + +// ReservationUpdatePollerResponse contains the response from method Reservation.Update. +type ReservationUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *ReservationUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ReservationUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ReservationUpdateResponse, error) { + respType := ReservationUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.ReservationResponse) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ReservationUpdatePollerResponse from the provided client and resume token. +func (l *ReservationUpdatePollerResponse) Resume(ctx context.Context, client *ReservationClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ReservationClient.Update", token, client.pl, client.updateHandleError) + if err != nil { + return err + } + poller := &ReservationUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ReservationUpdateResponse contains the response from method Reservation.Update. +type ReservationUpdateResponse struct { + ReservationUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ReservationUpdateResult contains the result from method Reservation.Update. +type ReservationUpdateResult struct { + ReservationResponse +} diff --git a/sdk/resourcemanager/reservations/armreservations/zz_generated_time_rfc3339.go b/sdk/resourcemanager/reservations/armreservations/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..2a9953a21f8b --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/zz_generated_time_rfc3339.go @@ -0,0 +1,85 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armreservations + +import ( + "encoding/json" + "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, 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 err + } + *t = (*time.Time)(&aux) + return nil +}