From 4597aedb3809bba83eaf086e15558f3ad8ef4869 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 15 Dec 2020 03:14:13 +0000 Subject: [PATCH] CodeGen from PR 11930 in Azure/azure-rest-api-specs Capacity RP Quota APIs for GA (#11930) * Capacity RP Quota APIs for GA * Adding preview version to stable dir as base files. * Files from preview version, which will be removed. * Updating to GA Version. --- .../mgmt/2020-10-25/reservations/client.go | 200 ++ .../mgmt/2020-10-25/reservations/enums.go | 359 +++ .../mgmt/2020-10-25/reservations/models.go | 2041 +++++++++++++++++ .../mgmt/2020-10-25/reservations/operation.go | 151 ++ .../mgmt/2020-10-25/reservations/order.go | 224 ++ .../mgmt/2020-10-25/reservations/quota.go | 422 ++++ .../reservations/quotarequeststatus.go | 269 +++ .../2020-10-25/reservations/reservation.go | 577 +++++ .../reservationsapi/interfaces.go | 82 + .../mgmt/2020-10-25/reservations/version.go | 30 + 10 files changed, 4355 insertions(+) create mode 100644 services/reservations/mgmt/2020-10-25/reservations/client.go create mode 100644 services/reservations/mgmt/2020-10-25/reservations/enums.go create mode 100644 services/reservations/mgmt/2020-10-25/reservations/models.go create mode 100644 services/reservations/mgmt/2020-10-25/reservations/operation.go create mode 100644 services/reservations/mgmt/2020-10-25/reservations/order.go create mode 100644 services/reservations/mgmt/2020-10-25/reservations/quota.go create mode 100644 services/reservations/mgmt/2020-10-25/reservations/quotarequeststatus.go create mode 100644 services/reservations/mgmt/2020-10-25/reservations/reservation.go create mode 100644 services/reservations/mgmt/2020-10-25/reservations/reservationsapi/interfaces.go create mode 100644 services/reservations/mgmt/2020-10-25/reservations/version.go diff --git a/services/reservations/mgmt/2020-10-25/reservations/client.go b/services/reservations/mgmt/2020-10-25/reservations/client.go new file mode 100644 index 000000000000..1e999e6c4495 --- /dev/null +++ b/services/reservations/mgmt/2020-10-25/reservations/client.go @@ -0,0 +1,200 @@ +// Package reservations implements the Azure ARM Reservations service API version . +// +// +package reservations + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +const ( + // DefaultBaseURI is the default URI used for the service Reservations + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Reservations. +type BaseClient struct { + autorest.Client + BaseURI string +} + +// New creates an instance of the BaseClient client. +func New() BaseClient { + return NewWithBaseURI(DefaultBaseURI) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + } +} + +// GetAppliedReservationList get applicable `Reservation`s that are applied to this subscription. +// Parameters: +// subscriptionID - id of the subscription +func (client BaseClient) GetAppliedReservationList(ctx context.Context, subscriptionID string) (result AppliedReservations, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.GetAppliedReservationList") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetAppliedReservationListPreparer(ctx, subscriptionID) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.BaseClient", "GetAppliedReservationList", nil, "Failure preparing request") + return + } + + resp, err := client.GetAppliedReservationListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "reservations.BaseClient", "GetAppliedReservationList", resp, "Failure sending request") + return + } + + result, err = client.GetAppliedReservationListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.BaseClient", "GetAppliedReservationList", resp, "Failure responding to request") + return + } + + return +} + +// GetAppliedReservationListPreparer prepares the GetAppliedReservationList request. +func (client BaseClient) GetAppliedReservationListPreparer(ctx context.Context, subscriptionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2017-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/appliedReservations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetAppliedReservationListSender sends the GetAppliedReservationList request. The method will close the +// http.Response Body if it receives an error. +func (client BaseClient) GetAppliedReservationListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetAppliedReservationListResponder handles the response to the GetAppliedReservationList request. The method always +// closes the http.Response Body. +func (client BaseClient) GetAppliedReservationListResponder(resp *http.Response) (result AppliedReservations, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetCatalog sends the get catalog request. +// Parameters: +// subscriptionID - id of the subscription +func (client BaseClient) GetCatalog(ctx context.Context, subscriptionID string) (result ListCatalog, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.GetCatalog") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetCatalogPreparer(ctx, subscriptionID) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.BaseClient", "GetCatalog", nil, "Failure preparing request") + return + } + + resp, err := client.GetCatalogSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "reservations.BaseClient", "GetCatalog", resp, "Failure sending request") + return + } + + result, err = client.GetCatalogResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.BaseClient", "GetCatalog", resp, "Failure responding to request") + return + } + + return +} + +// GetCatalogPreparer prepares the GetCatalog request. +func (client BaseClient) GetCatalogPreparer(ctx context.Context, subscriptionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2017-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/catalogs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetCatalogSender sends the GetCatalog request. The method will close the +// http.Response Body if it receives an error. +func (client BaseClient) GetCatalogSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetCatalogResponder handles the response to the GetCatalog request. The method always +// closes the http.Response Body. +func (client BaseClient) GetCatalogResponder(resp *http.Response) (result ListCatalog, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/reservations/mgmt/2020-10-25/reservations/enums.go b/services/reservations/mgmt/2020-10-25/reservations/enums.go new file mode 100644 index 000000000000..e62b2a91ae1b --- /dev/null +++ b/services/reservations/mgmt/2020-10-25/reservations/enums.go @@ -0,0 +1,359 @@ +package reservations + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// AppliedScopeType enumerates the values for applied scope type. +type AppliedScopeType string + +const ( + // Shared ... + Shared AppliedScopeType = "Shared" + // Single ... + Single AppliedScopeType = "Single" +) + +// PossibleAppliedScopeTypeValues returns an array of possible values for the AppliedScopeType const type. +func PossibleAppliedScopeTypeValues() []AppliedScopeType { + return []AppliedScopeType{Shared, Single} +} + +// AppliedScopeType1 enumerates the values for applied scope type 1. +type AppliedScopeType1 string + +const ( + // AppliedScopeType1Shared ... + AppliedScopeType1Shared AppliedScopeType1 = "Shared" + // AppliedScopeType1Single ... + AppliedScopeType1Single AppliedScopeType1 = "Single" +) + +// PossibleAppliedScopeType1Values returns an array of possible values for the AppliedScopeType1 const type. +func PossibleAppliedScopeType1Values() []AppliedScopeType1 { + return []AppliedScopeType1{AppliedScopeType1Shared, AppliedScopeType1Single} +} + +// Code enumerates the values for code. +type Code string + +const ( + // ActivateQuoteFailed ... + ActivateQuoteFailed Code = "ActivateQuoteFailed" + // AppliedScopesNotAssociatedWithCommerceAccount ... + AppliedScopesNotAssociatedWithCommerceAccount Code = "AppliedScopesNotAssociatedWithCommerceAccount" + // AppliedScopesSameAsExisting ... + AppliedScopesSameAsExisting Code = "AppliedScopesSameAsExisting" + // AuthorizationFailed ... + AuthorizationFailed Code = "AuthorizationFailed" + // BadRequest ... + BadRequest Code = "BadRequest" + // BillingCustomerInputError ... + BillingCustomerInputError Code = "BillingCustomerInputError" + // BillingError ... + BillingError Code = "BillingError" + // BillingPaymentInstrumentHardError ... + BillingPaymentInstrumentHardError Code = "BillingPaymentInstrumentHardError" + // BillingPaymentInstrumentSoftError ... + BillingPaymentInstrumentSoftError Code = "BillingPaymentInstrumentSoftError" + // BillingScopeIDCannotBeChanged ... + BillingScopeIDCannotBeChanged Code = "BillingScopeIdCannotBeChanged" + // BillingTransientError ... + BillingTransientError Code = "BillingTransientError" + // CalculatePriceFailed ... + CalculatePriceFailed Code = "CalculatePriceFailed" + // CapacityUpdateScopesFailed ... + CapacityUpdateScopesFailed Code = "CapacityUpdateScopesFailed" + // ClientCertificateThumbprintNotSet ... + ClientCertificateThumbprintNotSet Code = "ClientCertificateThumbprintNotSet" + // CreateQuoteFailed ... + CreateQuoteFailed Code = "CreateQuoteFailed" + // Forbidden ... + Forbidden Code = "Forbidden" + // FulfillmentConfigurationError ... + FulfillmentConfigurationError Code = "FulfillmentConfigurationError" + // FulfillmentError ... + FulfillmentError Code = "FulfillmentError" + // FulfillmentOutOfStockError ... + FulfillmentOutOfStockError Code = "FulfillmentOutOfStockError" + // FulfillmentTransientError ... + FulfillmentTransientError Code = "FulfillmentTransientError" + // HTTPMethodNotSupported ... + HTTPMethodNotSupported Code = "HttpMethodNotSupported" + // InternalServerError ... + InternalServerError Code = "InternalServerError" + // InvalidAccessToken ... + InvalidAccessToken Code = "InvalidAccessToken" + // InvalidFulfillmentRequestParameters ... + InvalidFulfillmentRequestParameters Code = "InvalidFulfillmentRequestParameters" + // InvalidHealthCheckType ... + InvalidHealthCheckType Code = "InvalidHealthCheckType" + // InvalidLocationID ... + InvalidLocationID Code = "InvalidLocationId" + // InvalidRefundQuantity ... + InvalidRefundQuantity Code = "InvalidRefundQuantity" + // InvalidRequestContent ... + InvalidRequestContent Code = "InvalidRequestContent" + // InvalidRequestURI ... + InvalidRequestURI Code = "InvalidRequestUri" + // InvalidReservationID ... + InvalidReservationID Code = "InvalidReservationId" + // InvalidReservationOrderID ... + InvalidReservationOrderID Code = "InvalidReservationOrderId" + // InvalidSingleAppliedScopesCount ... + InvalidSingleAppliedScopesCount Code = "InvalidSingleAppliedScopesCount" + // InvalidSubscriptionID ... + InvalidSubscriptionID Code = "InvalidSubscriptionId" + // InvalidTenantID ... + InvalidTenantID Code = "InvalidTenantId" + // MissingAppliedScopesForSingle ... + MissingAppliedScopesForSingle Code = "MissingAppliedScopesForSingle" + // MissingTenantID ... + MissingTenantID Code = "MissingTenantId" + // NonsupportedAccountID ... + NonsupportedAccountID Code = "NonsupportedAccountId" + // NotSpecified ... + NotSpecified Code = "NotSpecified" + // NotSupportedCountry ... + NotSupportedCountry Code = "NotSupportedCountry" + // NoValidReservationsToReRate ... + NoValidReservationsToReRate Code = "NoValidReservationsToReRate" + // OperationCannotBePerformedInCurrentState ... + OperationCannotBePerformedInCurrentState Code = "OperationCannotBePerformedInCurrentState" + // OperationFailed ... + OperationFailed Code = "OperationFailed" + // PaymentInstrumentNotFound ... + PaymentInstrumentNotFound Code = "PaymentInstrumentNotFound" + // PurchaseError ... + PurchaseError Code = "PurchaseError" + // ReRateOnlyAllowedForEA ... + ReRateOnlyAllowedForEA Code = "ReRateOnlyAllowedForEA" + // ReservationIDNotInReservationOrder ... + ReservationIDNotInReservationOrder Code = "ReservationIdNotInReservationOrder" + // ReservationOrderCreationFailed ... + ReservationOrderCreationFailed Code = "ReservationOrderCreationFailed" + // ReservationOrderIDAlreadyExists ... + ReservationOrderIDAlreadyExists Code = "ReservationOrderIdAlreadyExists" + // ReservationOrderNotEnabled ... + ReservationOrderNotEnabled Code = "ReservationOrderNotEnabled" + // ReservationOrderNotFound ... + ReservationOrderNotFound Code = "ReservationOrderNotFound" + // RiskCheckFailed ... + RiskCheckFailed Code = "RiskCheckFailed" + // RoleAssignmentCreationFailed ... + RoleAssignmentCreationFailed Code = "RoleAssignmentCreationFailed" + // ServerTimeout ... + ServerTimeout Code = "ServerTimeout" + // UnauthenticatedRequestsThrottled ... + UnauthenticatedRequestsThrottled Code = "UnauthenticatedRequestsThrottled" + // UnsupportedReservationTerm ... + UnsupportedReservationTerm Code = "UnsupportedReservationTerm" +) + +// PossibleCodeValues returns an array of possible values for the Code const type. +func PossibleCodeValues() []Code { + return []Code{ActivateQuoteFailed, AppliedScopesNotAssociatedWithCommerceAccount, AppliedScopesSameAsExisting, AuthorizationFailed, BadRequest, BillingCustomerInputError, BillingError, BillingPaymentInstrumentHardError, BillingPaymentInstrumentSoftError, BillingScopeIDCannotBeChanged, BillingTransientError, CalculatePriceFailed, CapacityUpdateScopesFailed, ClientCertificateThumbprintNotSet, CreateQuoteFailed, Forbidden, FulfillmentConfigurationError, FulfillmentError, FulfillmentOutOfStockError, FulfillmentTransientError, HTTPMethodNotSupported, InternalServerError, InvalidAccessToken, InvalidFulfillmentRequestParameters, InvalidHealthCheckType, InvalidLocationID, InvalidRefundQuantity, InvalidRequestContent, InvalidRequestURI, InvalidReservationID, InvalidReservationOrderID, InvalidSingleAppliedScopesCount, InvalidSubscriptionID, InvalidTenantID, MissingAppliedScopesForSingle, MissingTenantID, NonsupportedAccountID, NotSpecified, NotSupportedCountry, NoValidReservationsToReRate, OperationCannotBePerformedInCurrentState, OperationFailed, PaymentInstrumentNotFound, PurchaseError, ReRateOnlyAllowedForEA, ReservationIDNotInReservationOrder, ReservationOrderCreationFailed, ReservationOrderIDAlreadyExists, ReservationOrderNotEnabled, ReservationOrderNotFound, RiskCheckFailed, RoleAssignmentCreationFailed, ServerTimeout, UnauthenticatedRequestsThrottled, UnsupportedReservationTerm} +} + +// Kind enumerates the values for kind. +type Kind string + +const ( + // MicrosoftCompute ... + MicrosoftCompute Kind = "Microsoft.Compute" +) + +// PossibleKindValues returns an array of possible values for the Kind const type. +func PossibleKindValues() []Kind { + return []Kind{MicrosoftCompute} +} + +// Location enumerates the values for location. +type Location string + +const ( + // Australiaeast ... + Australiaeast Location = "australiaeast" + // Australiasoutheast ... + Australiasoutheast Location = "australiasoutheast" + // Brazilsouth ... + Brazilsouth Location = "brazilsouth" + // Canadacentral ... + Canadacentral Location = "canadacentral" + // Canadaeast ... + Canadaeast Location = "canadaeast" + // Centralindia ... + Centralindia Location = "centralindia" + // Centralus ... + Centralus Location = "centralus" + // Eastasia ... + Eastasia Location = "eastasia" + // Eastus ... + Eastus Location = "eastus" + // Eastus2 ... + Eastus2 Location = "eastus2" + // Japaneast ... + Japaneast Location = "japaneast" + // Japanwest ... + Japanwest Location = "japanwest" + // Northcentralus ... + Northcentralus Location = "northcentralus" + // Northeurope ... + Northeurope Location = "northeurope" + // Southcentralus ... + Southcentralus Location = "southcentralus" + // Southeastasia ... + Southeastasia Location = "southeastasia" + // Southindia ... + Southindia Location = "southindia" + // Uksouth ... + Uksouth Location = "uksouth" + // Ukwest ... + Ukwest Location = "ukwest" + // Westcentralus ... + Westcentralus Location = "westcentralus" + // Westeurope ... + Westeurope Location = "westeurope" + // Westindia ... + Westindia Location = "westindia" + // Westus ... + Westus Location = "westus" + // Westus2 ... + Westus2 Location = "westus2" +) + +// PossibleLocationValues returns an array of possible values for the Location const type. +func PossibleLocationValues() []Location { + return []Location{Australiaeast, Australiasoutheast, Brazilsouth, Canadacentral, Canadaeast, Centralindia, Centralus, Eastasia, Eastus, Eastus2, Japaneast, Japanwest, Northcentralus, Northeurope, Southcentralus, Southeastasia, Southindia, Uksouth, Ukwest, Westcentralus, Westeurope, Westindia, Westus, Westus2} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // BillingFailed ... + BillingFailed ProvisioningState = "BillingFailed" + // Cancelled ... + Cancelled ProvisioningState = "Cancelled" + // ConfirmedBilling ... + ConfirmedBilling ProvisioningState = "ConfirmedBilling" + // ConfirmedResourceHold ... + ConfirmedResourceHold ProvisioningState = "ConfirmedResourceHold" + // Created ... + Created ProvisioningState = "Created" + // Creating ... + Creating ProvisioningState = "Creating" + // Expired ... + Expired ProvisioningState = "Expired" + // Failed ... + Failed ProvisioningState = "Failed" + // Merged ... + Merged ProvisioningState = "Merged" + // PendingBilling ... + PendingBilling ProvisioningState = "PendingBilling" + // PendingResourceHold ... + PendingResourceHold ProvisioningState = "PendingResourceHold" + // Split ... + Split ProvisioningState = "Split" + // Succeeded ... + Succeeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{BillingFailed, Cancelled, ConfirmedBilling, ConfirmedResourceHold, Created, Creating, Expired, Failed, Merged, PendingBilling, PendingResourceHold, Split, Succeeded} +} + +// ProvisioningState1 enumerates the values for provisioning state 1. +type ProvisioningState1 string + +const ( + // ProvisioningState1BillingFailed ... + ProvisioningState1BillingFailed ProvisioningState1 = "BillingFailed" + // ProvisioningState1Cancelled ... + ProvisioningState1Cancelled ProvisioningState1 = "Cancelled" + // ProvisioningState1ConfirmedBilling ... + ProvisioningState1ConfirmedBilling ProvisioningState1 = "ConfirmedBilling" + // ProvisioningState1ConfirmedResourceHold ... + ProvisioningState1ConfirmedResourceHold ProvisioningState1 = "ConfirmedResourceHold" + // ProvisioningState1Created ... + ProvisioningState1Created ProvisioningState1 = "Created" + // ProvisioningState1Creating ... + ProvisioningState1Creating ProvisioningState1 = "Creating" + // ProvisioningState1Expired ... + ProvisioningState1Expired ProvisioningState1 = "Expired" + // ProvisioningState1Failed ... + ProvisioningState1Failed ProvisioningState1 = "Failed" + // ProvisioningState1Merged ... + ProvisioningState1Merged ProvisioningState1 = "Merged" + // ProvisioningState1PendingBilling ... + ProvisioningState1PendingBilling ProvisioningState1 = "PendingBilling" + // ProvisioningState1PendingResourceHold ... + ProvisioningState1PendingResourceHold ProvisioningState1 = "PendingResourceHold" + // ProvisioningState1Split ... + ProvisioningState1Split ProvisioningState1 = "Split" + // ProvisioningState1Succeeded ... + ProvisioningState1Succeeded ProvisioningState1 = "Succeeded" +) + +// PossibleProvisioningState1Values returns an array of possible values for the ProvisioningState1 const type. +func PossibleProvisioningState1Values() []ProvisioningState1 { + return []ProvisioningState1{ProvisioningState1BillingFailed, ProvisioningState1Cancelled, ProvisioningState1ConfirmedBilling, ProvisioningState1ConfirmedResourceHold, ProvisioningState1Created, ProvisioningState1Creating, ProvisioningState1Expired, ProvisioningState1Failed, ProvisioningState1Merged, ProvisioningState1PendingBilling, ProvisioningState1PendingResourceHold, ProvisioningState1Split, ProvisioningState1Succeeded} +} + +// StatusCode enumerates the values for status code. +type StatusCode string + +const ( + // StatusCodeActive ... + StatusCodeActive StatusCode = "Active" + // StatusCodeExpired ... + StatusCodeExpired StatusCode = "Expired" + // StatusCodeMerged ... + StatusCodeMerged StatusCode = "Merged" + // StatusCodeNone ... + StatusCodeNone StatusCode = "None" + // StatusCodePaymentInstrumentError ... + StatusCodePaymentInstrumentError StatusCode = "PaymentInstrumentError" + // StatusCodePending ... + StatusCodePending StatusCode = "Pending" + // StatusCodePurchaseError ... + StatusCodePurchaseError StatusCode = "PurchaseError" + // StatusCodeSplit ... + StatusCodeSplit StatusCode = "Split" + // StatusCodeSucceeded ... + StatusCodeSucceeded StatusCode = "Succeeded" +) + +// PossibleStatusCodeValues returns an array of possible values for the StatusCode const type. +func PossibleStatusCodeValues() []StatusCode { + return []StatusCode{StatusCodeActive, StatusCodeExpired, StatusCodeMerged, StatusCodeNone, StatusCodePaymentInstrumentError, StatusCodePending, StatusCodePurchaseError, StatusCodeSplit, StatusCodeSucceeded} +} + +// Term enumerates the values for term. +type Term string + +const ( + // P1Y ... + P1Y Term = "P1Y" + // P3Y ... + P3Y Term = "P3Y" +) + +// PossibleTermValues returns an array of possible values for the Term const type. +func PossibleTermValues() []Term { + return []Term{P1Y, P3Y} +} diff --git a/services/reservations/mgmt/2020-10-25/reservations/models.go b/services/reservations/mgmt/2020-10-25/reservations/models.go new file mode 100644 index 000000000000..e627c3bbfb69 --- /dev/null +++ b/services/reservations/mgmt/2020-10-25/reservations/models.go @@ -0,0 +1,2041 @@ +package reservations + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/reservations/mgmt/2020-10-25/reservations" + +// AppliedReservationList ... +type AppliedReservationList struct { + Value *[]string `json:"value,omitempty"` + // NextLink - Url to get the next page of reservations + NextLink *string `json:"nextLink,omitempty"` +} + +// AppliedReservations ... +type AppliedReservations struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; Identifier of the applied reservations + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Name of resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Type of resource. "Microsoft.Capacity/AppliedReservations" + Type *string `json:"type,omitempty"` + *AppliedReservationsProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for AppliedReservations. +func (ar AppliedReservations) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ar.AppliedReservationsProperties != nil { + objectMap["properties"] = ar.AppliedReservationsProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AppliedReservations struct. +func (ar *AppliedReservations) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ar.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ar.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ar.Type = &typeVar + } + case "properties": + if v != nil { + var appliedReservationsProperties AppliedReservationsProperties + err = json.Unmarshal(*v, &appliedReservationsProperties) + if err != nil { + return err + } + ar.AppliedReservationsProperties = &appliedReservationsProperties + } + } + } + + return nil +} + +// AppliedReservationsProperties ... +type AppliedReservationsProperties struct { + ReservationOrderIds *AppliedReservationList `json:"reservationOrderIds,omitempty"` +} + +// Catalog ... +type Catalog struct { + // ResourceType - READ-ONLY; The type of resource the SKU applies to. + ResourceType *string `json:"resourceType,omitempty"` + // Name - READ-ONLY; The name of SKU + Name *string `json:"name,omitempty"` + // Tier - READ-ONLY; The tier of this SKU + Tier *string `json:"tier,omitempty"` + // Size - READ-ONLY; The size of this SKU + Size *string `json:"size,omitempty"` + // Terms - READ-ONLY; Available reservation terms for this resource + Terms *[]string `json:"terms,omitempty"` + // Locations - READ-ONLY + Locations *[]string `json:"locations,omitempty"` + // Capabilities - READ-ONLY + Capabilities *[]SkuCapability `json:"capabilities,omitempty"` + // Restrictions - READ-ONLY + Restrictions *[]SkuRestriction `json:"restrictions,omitempty"` +} + +// CreateGenericQuotaRequestParameters quota change requests information. +type CreateGenericQuotaRequestParameters struct { + // Value - Quota change requests. + Value *[]CurrentQuotaLimitBase `json:"value,omitempty"` +} + +// CurrentQuotaLimit current quota limits. +type CurrentQuotaLimit struct { + // CurrentQuotaLimitBase - Quota details. + *CurrentQuotaLimitBase `json:"quotaInformation,omitempty"` + // QuotaRequestStatusDetails - Additional properties for the quota status for the resource. + *QuotaRequestStatusDetails `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for CurrentQuotaLimit. +func (cql CurrentQuotaLimit) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cql.CurrentQuotaLimitBase != nil { + objectMap["quotaInformation"] = cql.CurrentQuotaLimitBase + } + if cql.QuotaRequestStatusDetails != nil { + objectMap["properties"] = cql.QuotaRequestStatusDetails + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CurrentQuotaLimit struct. +func (cql *CurrentQuotaLimit) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "quotaInformation": + if v != nil { + var currentQuotaLimitBase CurrentQuotaLimitBase + err = json.Unmarshal(*v, ¤tQuotaLimitBase) + if err != nil { + return err + } + cql.CurrentQuotaLimitBase = ¤tQuotaLimitBase + } + case "properties": + if v != nil { + var quotaRequestStatusDetails QuotaRequestStatusDetails + err = json.Unmarshal(*v, "aRequestStatusDetails) + if err != nil { + return err + } + cql.QuotaRequestStatusDetails = "aRequestStatusDetails + } + } + } + + return nil +} + +// CurrentQuotaLimitBase quota properties. +type CurrentQuotaLimitBase struct { + autorest.Response `json:"-"` + // Properties - Quota properties for the resource. + Properties *QuotaProperties `json:"properties,omitempty"` +} + +// Error ... +type Error struct { + Error *ExtendedErrorInfo `json:"error,omitempty"` +} + +// ExceptionResponse the API error. +type ExceptionResponse struct { + // Error - The API error details. + Error *ServiceError `json:"error,omitempty"` +} + +// ExtendedErrorInfo ... +type ExtendedErrorInfo struct { + // Code - Possible values include: 'NotSpecified', 'InternalServerError', 'ServerTimeout', 'AuthorizationFailed', 'BadRequest', 'ClientCertificateThumbprintNotSet', 'InvalidRequestContent', 'OperationFailed', 'HTTPMethodNotSupported', 'InvalidRequestURI', 'MissingTenantID', 'InvalidTenantID', 'InvalidReservationOrderID', 'InvalidReservationID', 'ReservationIDNotInReservationOrder', 'ReservationOrderNotFound', 'InvalidSubscriptionID', 'InvalidAccessToken', 'InvalidLocationID', 'UnauthenticatedRequestsThrottled', 'InvalidHealthCheckType', 'Forbidden', 'BillingScopeIDCannotBeChanged', 'AppliedScopesNotAssociatedWithCommerceAccount', 'AppliedScopesSameAsExisting', 'RoleAssignmentCreationFailed', 'ReservationOrderCreationFailed', 'ReservationOrderNotEnabled', 'CapacityUpdateScopesFailed', 'UnsupportedReservationTerm', 'ReservationOrderIDAlreadyExists', 'RiskCheckFailed', 'CreateQuoteFailed', 'ActivateQuoteFailed', 'NonsupportedAccountID', 'PaymentInstrumentNotFound', 'MissingAppliedScopesForSingle', 'NoValidReservationsToReRate', 'ReRateOnlyAllowedForEA', 'OperationCannotBePerformedInCurrentState', 'InvalidSingleAppliedScopesCount', 'InvalidFulfillmentRequestParameters', 'NotSupportedCountry', 'InvalidRefundQuantity', 'PurchaseError', 'BillingCustomerInputError', 'BillingPaymentInstrumentSoftError', 'BillingPaymentInstrumentHardError', 'BillingTransientError', 'BillingError', 'FulfillmentConfigurationError', 'FulfillmentOutOfStockError', 'FulfillmentTransientError', 'FulfillmentError', 'CalculatePriceFailed' + Code Code `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} + +// ExtendedStatusInfo ... +type ExtendedStatusInfo struct { + // StatusCode - Possible values include: 'StatusCodeNone', 'StatusCodePending', 'StatusCodeActive', 'StatusCodePurchaseError', 'StatusCodePaymentInstrumentError', 'StatusCodeSplit', 'StatusCodeMerged', 'StatusCodeExpired', 'StatusCodeSucceeded' + StatusCode StatusCode `json:"statusCode,omitempty"` + // Message - The message giving detailed information about the status code. + Message *string `json:"message,omitempty"` +} + +// List ... +type List struct { + autorest.Response `json:"-"` + Value *[]Response `json:"value,omitempty"` + // NextLink - Url to get the next page of reservations. + NextLink *string `json:"nextLink,omitempty"` +} + +// ListCatalog ... +type ListCatalog struct { + autorest.Response `json:"-"` + Value *[]Catalog `json:"value,omitempty"` +} + +// ListIterator provides access to a complete listing of Response values. +type ListIterator struct { + i int + page ListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ListIterator) Response() List { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ListIterator) Value() Response { + if !iter.page.NotDone() { + return Response{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ListIterator type. +func NewListIterator(page ListPage) ListIterator { + return ListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (l List) IsEmpty() bool { + return l.Value == nil || len(*l.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (l List) hasNextLink() bool { + return l.NextLink != nil && len(*l.NextLink) != 0 +} + +// listPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (l List) listPreparer(ctx context.Context) (*http.Request, error) { + if !l.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(l.NextLink))) +} + +// ListPage contains a page of Response values. +type ListPage struct { + fn func(context.Context, List) (List, error) + l List +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.l) + if err != nil { + return err + } + page.l = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ListPage) NotDone() bool { + return !page.l.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ListPage) Response() List { + return page.l +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ListPage) Values() []Response { + if page.l.IsEmpty() { + return nil + } + return *page.l.Value +} + +// Creates a new instance of the ListPage type. +func NewListPage(cur List, getNextPage func(context.Context, List) (List, error)) ListPage { + return ListPage{ + fn: getNextPage, + l: cur, + } +} + +// ListResponse ... +type ListResponse struct { + autorest.Response `json:"-"` + Value *[]Response `json:"value,omitempty"` +} + +// MergeProperties ... +type MergeProperties struct { + // Sources - Format of the resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + Sources *[]string `json:"sources,omitempty"` +} + +// MergePropertiesType ... +type MergePropertiesType struct { + // MergeDestination - 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"` + // MergeSources - 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"` +} + +// MergeRequest ... +type MergeRequest struct { + *MergeProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for MergeRequest. +func (mr MergeRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mr.MergeProperties != nil { + objectMap["properties"] = mr.MergeProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MergeRequest struct. +func (mr *MergeRequest) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var mergeProperties MergeProperties + err = json.Unmarshal(*v, &mergeProperties) + if err != nil { + return err + } + mr.MergeProperties = &mergeProperties + } + } + } + + return nil +} + +// OperationDisplay ... +type OperationDisplay struct { + Provider *string `json:"provider,omitempty"` + Resource *string `json:"resource,omitempty"` + Operation *string `json:"operation,omitempty"` + Description *string `json:"description,omitempty"` +} + +// OperationList ... +type OperationList struct { + autorest.Response `json:"-"` + Value *[]OperationResponse `json:"value,omitempty"` + // NextLink - Url to get the next page of items. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListIterator provides access to a complete listing of OperationResponse values. +type OperationListIterator struct { + i int + page OperationListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListIterator) Response() OperationList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListIterator) Value() OperationResponse { + if !iter.page.NotDone() { + return OperationResponse{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListIterator type. +func NewOperationListIterator(page OperationListPage) OperationListIterator { + return OperationListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ol OperationList) IsEmpty() bool { + return ol.Value == nil || len(*ol.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ol OperationList) hasNextLink() bool { + return ol.NextLink != nil && len(*ol.NextLink) != 0 +} + +// operationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ol OperationList) operationListPreparer(ctx context.Context) (*http.Request, error) { + if !ol.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ol.NextLink))) +} + +// OperationListPage contains a page of OperationResponse values. +type OperationListPage struct { + fn func(context.Context, OperationList) (OperationList, error) + ol OperationList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ol) + if err != nil { + return err + } + page.ol = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListPage) NotDone() bool { + return !page.ol.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListPage) Response() OperationList { + return page.ol +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListPage) Values() []OperationResponse { + if page.ol.IsEmpty() { + return nil + } + return *page.ol.Value +} + +// Creates a new instance of the OperationListPage type. +func NewOperationListPage(cur OperationList, getNextPage func(context.Context, OperationList) (OperationList, error)) OperationListPage { + return OperationListPage{ + fn: getNextPage, + ol: cur, + } +} + +// OperationResponse ... +type OperationResponse struct { + Name *string `json:"name,omitempty"` + Display *OperationDisplay `json:"display,omitempty"` + Origin *string `json:"origin,omitempty"` +} + +// OrderList ... +type OrderList struct { + autorest.Response `json:"-"` + Value *[]OrderResponse `json:"value,omitempty"` + // NextLink - Url to get the next page of reservationOrders. + NextLink *string `json:"nextLink,omitempty"` +} + +// OrderListIterator provides access to a complete listing of OrderResponse values. +type OrderListIterator struct { + i int + page OrderListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OrderListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OrderListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OrderListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OrderListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OrderListIterator) Response() OrderList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OrderListIterator) Value() OrderResponse { + if !iter.page.NotDone() { + return OrderResponse{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OrderListIterator type. +func NewOrderListIterator(page OrderListPage) OrderListIterator { + return OrderListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ol OrderList) IsEmpty() bool { + return ol.Value == nil || len(*ol.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ol OrderList) hasNextLink() bool { + return ol.NextLink != nil && len(*ol.NextLink) != 0 +} + +// orderListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ol OrderList) orderListPreparer(ctx context.Context) (*http.Request, error) { + if !ol.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ol.NextLink))) +} + +// OrderListPage contains a page of OrderResponse values. +type OrderListPage struct { + fn func(context.Context, OrderList) (OrderList, error) + ol OrderList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OrderListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OrderListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ol) + if err != nil { + return err + } + page.ol = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OrderListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OrderListPage) NotDone() bool { + return !page.ol.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OrderListPage) Response() OrderList { + return page.ol +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OrderListPage) Values() []OrderResponse { + if page.ol.IsEmpty() { + return nil + } + return *page.ol.Value +} + +// Creates a new instance of the OrderListPage type. +func NewOrderListPage(cur OrderList, getNextPage func(context.Context, OrderList) (OrderList, error)) OrderListPage { + return OrderListPage{ + fn: getNextPage, + ol: cur, + } +} + +// OrderProperties ... +type OrderProperties struct { + // DisplayName - Friendly name for user to easily identified the reservation. + DisplayName *string `json:"displayName,omitempty"` + // RequestDateTime - This is the DateTime when the reservation was initially requested for purchase. + RequestDateTime *date.Time `json:"requestDateTime,omitempty"` + // CreatedDateTime - This is the DateTime when the reservation was created. + CreatedDateTime *date.Time `json:"createdDateTime,omitempty"` + // ExpiryDate - This is the date when the Reservation will expire. + ExpiryDate *date.Date `json:"expiryDate,omitempty"` + // OriginalQuantity - Total Quantity of the SKUs purchased in the Reservation. + OriginalQuantity *int32 `json:"originalQuantity,omitempty"` + // Term - Possible values include: 'P1Y', 'P3Y' + Term Term `json:"term,omitempty"` + // ProvisioningState - Possible values include: 'ProvisioningState1Creating', 'ProvisioningState1PendingResourceHold', 'ProvisioningState1ConfirmedResourceHold', 'ProvisioningState1PendingBilling', 'ProvisioningState1ConfirmedBilling', 'ProvisioningState1Created', 'ProvisioningState1Succeeded', 'ProvisioningState1Cancelled', 'ProvisioningState1Expired', 'ProvisioningState1BillingFailed', 'ProvisioningState1Failed', 'ProvisioningState1Split', 'ProvisioningState1Merged' + ProvisioningState ProvisioningState1 `json:"provisioningState,omitempty"` + ReservationsProperty *[]Response `json:"reservations,omitempty"` +} + +// OrderResponse ... +type OrderResponse struct { + autorest.Response `json:"-"` + Etag *int32 `json:"etag,omitempty"` + // ID - READ-ONLY; Identifier of the reservation + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Name of the reservation + Name *string `json:"name,omitempty"` + *OrderProperties `json:"properties,omitempty"` + // Type - READ-ONLY; Type of resource. "Microsoft.Capacity/reservations" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for OrderResponse. +func (or OrderResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if or.Etag != nil { + objectMap["etag"] = or.Etag + } + if or.OrderProperties != nil { + objectMap["properties"] = or.OrderProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for OrderResponse struct. +func (or *OrderResponse) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "etag": + if v != nil { + var etag int32 + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + or.Etag = &etag + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + or.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + or.Name = &name + } + case "properties": + if v != nil { + var orderProperties OrderProperties + err = json.Unmarshal(*v, &orderProperties) + if err != nil { + return err + } + or.OrderProperties = &orderProperties + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + or.Type = &typeVar + } + } + } + + return nil +} + +// Patch ... +type Patch struct { + *PatchProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for Patch. +func (p Patch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if p.PatchProperties != nil { + objectMap["properties"] = p.PatchProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Patch struct. +func (p *Patch) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var patchProperties PatchProperties + err = json.Unmarshal(*v, &patchProperties) + if err != nil { + return err + } + p.PatchProperties = &patchProperties + } + } + } + + return nil +} + +// PatchProperties ... +type PatchProperties struct { + // AppliedScopeType - Possible values include: 'AppliedScopeType1Single', 'AppliedScopeType1Shared' + AppliedScopeType AppliedScopeType1 `json:"appliedScopeType,omitempty"` + AppliedScopes *[]string `json:"appliedScopes,omitempty"` +} + +// Properties ... +type Properties struct { + // DisplayName - Friendly name for user to easily identify the reservation + DisplayName *string `json:"displayName,omitempty"` + AppliedScopes *[]string `json:"appliedScopes,omitempty"` + // AppliedScopeType - Possible values include: 'Single', 'Shared' + AppliedScopeType AppliedScopeType `json:"appliedScopeType,omitempty"` + // Quantity - Quantity of the SKUs that are part of the Reservation. + Quantity *int32 `json:"quantity,omitempty"` + // ProvisioningState - Possible values include: 'Creating', 'PendingResourceHold', 'ConfirmedResourceHold', 'PendingBilling', 'ConfirmedBilling', 'Created', 'Succeeded', 'Cancelled', 'Expired', 'BillingFailed', 'Failed', 'Split', 'Merged' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // EffectiveDateTime - DateTime of the Reservation starting when this version is effective from. + EffectiveDateTime *date.Time `json:"effectiveDateTime,omitempty"` + // LastUpdatedDateTime - READ-ONLY; DateTime of the last time the Reservation was updated. + LastUpdatedDateTime *date.Time `json:"lastUpdatedDateTime,omitempty"` + // ExpiryDate - This is the date when the Reservation will expire. + ExpiryDate *date.Date `json:"expiryDate,omitempty"` + ExtendedStatusInfo *ExtendedStatusInfo `json:"extendedStatusInfo,omitempty"` + SplitProperties *SplitPropertiesType `json:"splitProperties,omitempty"` + MergeProperties *MergePropertiesType `json:"mergeProperties,omitempty"` +} + +// MarshalJSON is the custom marshaler for Properties. +func (p Properties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if p.DisplayName != nil { + objectMap["displayName"] = p.DisplayName + } + if p.AppliedScopes != nil { + objectMap["appliedScopes"] = p.AppliedScopes + } + if p.AppliedScopeType != "" { + objectMap["appliedScopeType"] = p.AppliedScopeType + } + if p.Quantity != nil { + objectMap["quantity"] = p.Quantity + } + if p.ProvisioningState != "" { + objectMap["provisioningState"] = p.ProvisioningState + } + if p.EffectiveDateTime != nil { + objectMap["effectiveDateTime"] = p.EffectiveDateTime + } + if p.ExpiryDate != nil { + objectMap["expiryDate"] = p.ExpiryDate + } + if p.ExtendedStatusInfo != nil { + objectMap["extendedStatusInfo"] = p.ExtendedStatusInfo + } + if p.SplitProperties != nil { + objectMap["splitProperties"] = p.SplitProperties + } + if p.MergeProperties != nil { + objectMap["mergeProperties"] = p.MergeProperties + } + return json.Marshal(objectMap) +} + +// QuotaCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type QuotaCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *QuotaCreateOrUpdateFuture) Result(client QuotaClient) (so SetObject, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.QuotaCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("reservations.QuotaCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if so.Response.Response, err = future.GetResult(sender); err == nil && so.Response.Response.StatusCode != http.StatusNoContent { + so, err = client.CreateOrUpdateResponder(so.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.QuotaCreateOrUpdateFuture", "Result", so.Response.Response, "Failure responding to request") + } + } + return +} + +// QuotaLimits quota limits. +type QuotaLimits struct { + autorest.Response `json:"-"` + // Value - List of quotas (service limits). + Value *[]CurrentQuotaLimitBase `json:"value,omitempty"` + // NextLink - 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"` +} + +// QuotaLimitsIterator provides access to a complete listing of CurrentQuotaLimitBase values. +type QuotaLimitsIterator struct { + i int + page QuotaLimitsPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *QuotaLimitsIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QuotaLimitsIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *QuotaLimitsIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter QuotaLimitsIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter QuotaLimitsIterator) Response() QuotaLimits { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter QuotaLimitsIterator) Value() CurrentQuotaLimitBase { + if !iter.page.NotDone() { + return CurrentQuotaLimitBase{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the QuotaLimitsIterator type. +func NewQuotaLimitsIterator(page QuotaLimitsPage) QuotaLimitsIterator { + return QuotaLimitsIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ql QuotaLimits) IsEmpty() bool { + return ql.Value == nil || len(*ql.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ql QuotaLimits) hasNextLink() bool { + return ql.NextLink != nil && len(*ql.NextLink) != 0 +} + +// quotaLimitsPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ql QuotaLimits) quotaLimitsPreparer(ctx context.Context) (*http.Request, error) { + if !ql.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ql.NextLink))) +} + +// QuotaLimitsPage contains a page of CurrentQuotaLimitBase values. +type QuotaLimitsPage struct { + fn func(context.Context, QuotaLimits) (QuotaLimits, error) + ql QuotaLimits +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *QuotaLimitsPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QuotaLimitsPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ql) + if err != nil { + return err + } + page.ql = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *QuotaLimitsPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page QuotaLimitsPage) NotDone() bool { + return !page.ql.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page QuotaLimitsPage) Response() QuotaLimits { + return page.ql +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page QuotaLimitsPage) Values() []CurrentQuotaLimitBase { + if page.ql.IsEmpty() { + return nil + } + return *page.ql.Value +} + +// Creates a new instance of the QuotaLimitsPage type. +func NewQuotaLimitsPage(cur QuotaLimits, getNextPage func(context.Context, QuotaLimits) (QuotaLimits, error)) QuotaLimitsPage { + return QuotaLimitsPage{ + fn: getNextPage, + ql: cur, + } +} + +// QuotaLimitsResponse quotas (service limits) in the request response. +type QuotaLimitsResponse struct { + // Value - List of quotas with the quota request status. + Value *[]CurrentQuotaLimit `json:"value,omitempty"` + // NextLink - The URI for fetching the next page of quota limits. When no more pages exist, the value is null. + NextLink *string `json:"nextLink,omitempty"` +} + +// QuotaProperties quota properties for the resource. +type QuotaProperties struct { + // Limit - Quota properties. + Limit *int32 `json:"limit,omitempty"` + // CurrentValue - READ-ONLY; Current usage value for the resource. + CurrentValue *int32 `json:"currentValue,omitempty"` + // Unit - 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"` + // Name - Name of the resource provide by the resource provider. Use this property for quotaRequests resource operations. + Name *ResourceName `json:"name,omitempty"` + // ResourceType - The name of the resource type. + ResourceType interface{} `json:"resourceType,omitempty"` + // QuotaPeriod - 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"` + // Properties - Additional properties for the specified resource provider. + Properties interface{} `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for QuotaProperties. +func (qp QuotaProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if qp.Limit != nil { + objectMap["limit"] = qp.Limit + } + if qp.Unit != nil { + objectMap["unit"] = qp.Unit + } + if qp.Name != nil { + objectMap["name"] = qp.Name + } + if qp.ResourceType != nil { + objectMap["resourceType"] = qp.ResourceType + } + if qp.Properties != nil { + objectMap["properties"] = qp.Properties + } + return json.Marshal(objectMap) +} + +// QuotaRequestDetails quota request details. +type QuotaRequestDetails struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; Quota request ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Quota request name. + Name *string `json:"name,omitempty"` + // QuotaRequestProperties - Quota request details. + *QuotaRequestProperties `json:"properties,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for QuotaRequestDetails. +func (qrd QuotaRequestDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if qrd.QuotaRequestProperties != nil { + objectMap["properties"] = qrd.QuotaRequestProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for QuotaRequestDetails struct. +func (qrd *QuotaRequestDetails) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + qrd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + qrd.Name = &name + } + case "properties": + if v != nil { + var quotaRequestProperties QuotaRequestProperties + err = json.Unmarshal(*v, "aRequestProperties) + if err != nil { + return err + } + qrd.QuotaRequestProperties = "aRequestProperties + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + qrd.Type = &typeVar + } + } + } + + return nil +} + +// QuotaRequestDetailsList quota request details. +type QuotaRequestDetailsList struct { + autorest.Response `json:"-"` + // Value - The quota requests. + Value *[]QuotaRequestDetails `json:"value,omitempty"` + // NextLink - The URI to fetch the next page of quota limits. When there are no more pages, this is null. + NextLink *string `json:"nextLink,omitempty"` +} + +// QuotaRequestDetailsListIterator provides access to a complete listing of QuotaRequestDetails values. +type QuotaRequestDetailsListIterator struct { + i int + page QuotaRequestDetailsListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *QuotaRequestDetailsListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QuotaRequestDetailsListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *QuotaRequestDetailsListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter QuotaRequestDetailsListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter QuotaRequestDetailsListIterator) Response() QuotaRequestDetailsList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter QuotaRequestDetailsListIterator) Value() QuotaRequestDetails { + if !iter.page.NotDone() { + return QuotaRequestDetails{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the QuotaRequestDetailsListIterator type. +func NewQuotaRequestDetailsListIterator(page QuotaRequestDetailsListPage) QuotaRequestDetailsListIterator { + return QuotaRequestDetailsListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (qrdl QuotaRequestDetailsList) IsEmpty() bool { + return qrdl.Value == nil || len(*qrdl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (qrdl QuotaRequestDetailsList) hasNextLink() bool { + return qrdl.NextLink != nil && len(*qrdl.NextLink) != 0 +} + +// quotaRequestDetailsListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (qrdl QuotaRequestDetailsList) quotaRequestDetailsListPreparer(ctx context.Context) (*http.Request, error) { + if !qrdl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(qrdl.NextLink))) +} + +// QuotaRequestDetailsListPage contains a page of QuotaRequestDetails values. +type QuotaRequestDetailsListPage struct { + fn func(context.Context, QuotaRequestDetailsList) (QuotaRequestDetailsList, error) + qrdl QuotaRequestDetailsList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *QuotaRequestDetailsListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QuotaRequestDetailsListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.qrdl) + if err != nil { + return err + } + page.qrdl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *QuotaRequestDetailsListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page QuotaRequestDetailsListPage) NotDone() bool { + return !page.qrdl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page QuotaRequestDetailsListPage) Response() QuotaRequestDetailsList { + return page.qrdl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page QuotaRequestDetailsListPage) Values() []QuotaRequestDetails { + if page.qrdl.IsEmpty() { + return nil + } + return *page.qrdl.Value +} + +// Creates a new instance of the QuotaRequestDetailsListPage type. +func NewQuotaRequestDetailsListPage(cur QuotaRequestDetailsList, getNextPage func(context.Context, QuotaRequestDetailsList) (QuotaRequestDetailsList, error)) QuotaRequestDetailsListPage { + return QuotaRequestDetailsListPage{ + fn: getNextPage, + qrdl: cur, + } +} + +// QuotaRequestOneResourceProperties the details of quota request. +type QuotaRequestOneResourceProperties struct { + // ProvisioningState - READ-ONLY; The quota request status. + ProvisioningState interface{} `json:"provisioningState,omitempty"` + // Message - READ-ONLY; User friendly status message. + Message *string `json:"message,omitempty"` + // RequestSubmitTime - 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 *date.Time `json:"requestSubmitTime,omitempty"` + // CurrentQuotaLimitBase - The quota request addition properties. + *CurrentQuotaLimitBase `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for QuotaRequestOneResourceProperties. +func (qrorp QuotaRequestOneResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if qrorp.CurrentQuotaLimitBase != nil { + objectMap["properties"] = qrorp.CurrentQuotaLimitBase + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for QuotaRequestOneResourceProperties struct. +func (qrorp *QuotaRequestOneResourceProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "provisioningState": + if v != nil { + var provisioningState interface{} + err = json.Unmarshal(*v, &provisioningState) + if err != nil { + return err + } + qrorp.ProvisioningState = provisioningState + } + case "message": + if v != nil { + var message string + err = json.Unmarshal(*v, &message) + if err != nil { + return err + } + qrorp.Message = &message + } + case "requestSubmitTime": + if v != nil { + var requestSubmitTime date.Time + err = json.Unmarshal(*v, &requestSubmitTime) + if err != nil { + return err + } + qrorp.RequestSubmitTime = &requestSubmitTime + } + case "properties": + if v != nil { + var currentQuotaLimitBase CurrentQuotaLimitBase + err = json.Unmarshal(*v, ¤tQuotaLimitBase) + if err != nil { + return err + } + qrorp.CurrentQuotaLimitBase = ¤tQuotaLimitBase + } + } + } + + return nil +} + +// QuotaRequestOneResourceSubmitResponse response for the quota submission request. +type QuotaRequestOneResourceSubmitResponse struct { + // ID - READ-ONLY; The quota request ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the quota request. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Type of resource. "Microsoft.Capacity/ServiceLimits" + Type *string `json:"type,omitempty"` + // QuotaRequestOneResourceProperties - The details for quota request. + *QuotaRequestOneResourceProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for QuotaRequestOneResourceSubmitResponse. +func (qrorsr QuotaRequestOneResourceSubmitResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if qrorsr.QuotaRequestOneResourceProperties != nil { + objectMap["properties"] = qrorsr.QuotaRequestOneResourceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for QuotaRequestOneResourceSubmitResponse struct. +func (qrorsr *QuotaRequestOneResourceSubmitResponse) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + qrorsr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + qrorsr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + qrorsr.Type = &typeVar + } + case "properties": + if v != nil { + var quotaRequestOneResourceProperties QuotaRequestOneResourceProperties + err = json.Unmarshal(*v, "aRequestOneResourceProperties) + if err != nil { + return err + } + qrorsr.QuotaRequestOneResourceProperties = "aRequestOneResourceProperties + } + } + } + + return nil +} + +// QuotaRequestProperties the details of quota request. +type QuotaRequestProperties struct { + // ProvisioningState - The quota request status. + ProvisioningState interface{} `json:"provisioningState,omitempty"` + // Message - READ-ONLY; User friendly status message. + Message *string `json:"message,omitempty"` + // RequestSubmitTime - 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 *date.Time `json:"requestSubmitTime,omitempty"` + // Value - The quotaRequests. + Value *[]SubRequest `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for QuotaRequestProperties. +func (qrp QuotaRequestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if qrp.ProvisioningState != nil { + objectMap["provisioningState"] = qrp.ProvisioningState + } + if qrp.Value != nil { + objectMap["value"] = qrp.Value + } + return json.Marshal(objectMap) +} + +// QuotaRequestStatusDetails quota request status details. +type QuotaRequestStatusDetails struct { + // ProvisioningState - READ-ONLY; The details of the quota request status. + ProvisioningState interface{} `json:"provisioningState,omitempty"` + // Message - READ-ONLY; A user friendly message. + Message *string `json:"message,omitempty"` +} + +// QuotaRequestSubmitResponse response for the quota submission request. +type QuotaRequestSubmitResponse struct { + // ID - READ-ONLY; The quota request ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the quota request. + Name *string `json:"name,omitempty"` + // Properties - The quota request details. + Properties *QuotaRequestProperties `json:"properties,omitempty"` + // Type - READ-ONLY; Type of resource. "Microsoft.Capacity/serviceLimits" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for QuotaRequestSubmitResponse. +func (qrsr QuotaRequestSubmitResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if qrsr.Properties != nil { + objectMap["properties"] = qrsr.Properties + } + return json.Marshal(objectMap) +} + +// QuotaRequestSubmitResponse201 response with request ID that the quota request was accepted. +type QuotaRequestSubmitResponse201 struct { + // ID - READ-ONLY; The quota request ID. Use the requestId parameter to check the request status. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Operation ID + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // QuotaRequestStatusDetails - Quota request status. + *QuotaRequestStatusDetails `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for QuotaRequestSubmitResponse201. +func (qrsr2 QuotaRequestSubmitResponse201) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if qrsr2.QuotaRequestStatusDetails != nil { + objectMap["properties"] = qrsr2.QuotaRequestStatusDetails + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for QuotaRequestSubmitResponse201 struct. +func (qrsr2 *QuotaRequestSubmitResponse201) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + qrsr2.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + qrsr2.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + qrsr2.Type = &typeVar + } + case "properties": + if v != nil { + var quotaRequestStatusDetails QuotaRequestStatusDetails + err = json.Unmarshal(*v, "aRequestStatusDetails) + if err != nil { + return err + } + qrsr2.QuotaRequestStatusDetails = "aRequestStatusDetails + } + } + } + + return nil +} + +// QuotaUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type QuotaUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *QuotaUpdateFuture) Result(client QuotaClient) (so SetObject, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.QuotaUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("reservations.QuotaUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if so.Response.Response, err = future.GetResult(sender); err == nil && so.Response.Response.StatusCode != http.StatusNoContent { + so, err = client.UpdateResponder(so.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.QuotaUpdateFuture", "Result", so.Response.Response, "Failure responding to request") + } + } + return +} + +// ReservationMergeFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ReservationMergeFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ReservationMergeFuture) Result(client Client) (lr ListResponse, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.ReservationMergeFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("reservations.ReservationMergeFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if lr.Response.Response, err = future.GetResult(sender); err == nil && lr.Response.Response.StatusCode != http.StatusNoContent { + lr, err = client.MergeResponder(lr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.ReservationMergeFuture", "Result", lr.Response.Response, "Failure responding to request") + } + } + return +} + +// ReservationUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ReservationUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ReservationUpdateFuture) Result(client Client) (r Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.ReservationUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("reservations.ReservationUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if r.Response.Response, err = future.GetResult(sender); err == nil && r.Response.Response.StatusCode != http.StatusNoContent { + r, err = client.UpdateResponder(r.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.ReservationUpdateFuture", "Result", r.Response.Response, "Failure responding to request") + } + } + return +} + +// ResourceName resource name provided by the resource provider. Use this property for quotaRequest +// parameter. +type ResourceName struct { + // Value - Resource name. + Value *string `json:"value,omitempty"` + // LocalizedValue - READ-ONLY; Resource display localized name. + LocalizedValue *string `json:"localizedValue,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceName. +func (rn ResourceName) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rn.Value != nil { + objectMap["value"] = rn.Value + } + return json.Marshal(objectMap) +} + +// Response ... +type Response struct { + autorest.Response `json:"-"` + // Location - Possible values include: 'Westus', 'Eastus', 'Eastus2', 'Northcentralus', 'Westus2', 'Southcentralus', 'Centralus', 'Westeurope', 'Northeurope', 'Eastasia', 'Southeastasia', 'Japaneast', 'Japanwest', 'Brazilsouth', 'Australiaeast', 'Australiasoutheast', 'Southindia', 'Westindia', 'Centralindia', 'Canadacentral', 'Canadaeast', 'Uksouth', 'Westcentralus', 'Ukwest' + Location Location `json:"location,omitempty"` + Etag *int32 `json:"etag,omitempty"` + // ID - READ-ONLY; Identifier of the reservation + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Name of the reservation + Name *string `json:"name,omitempty"` + // Kind - Resource Provider type to be reserved. Possible values include: 'MicrosoftCompute' + Kind Kind `json:"kind,omitempty"` + Sku *SkuName `json:"sku,omitempty"` + Properties *Properties `json:"properties,omitempty"` + // Type - READ-ONLY; Type of resource. "Microsoft.Capacity/reservationOrders/reservations" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Response. +func (r Response) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.Location != "" { + objectMap["location"] = r.Location + } + if r.Etag != nil { + objectMap["etag"] = r.Etag + } + if r.Kind != "" { + objectMap["kind"] = r.Kind + } + if r.Sku != nil { + objectMap["sku"] = r.Sku + } + if r.Properties != nil { + objectMap["properties"] = r.Properties + } + return json.Marshal(objectMap) +} + +// ServiceError the API error details. +type ServiceError struct { + // Code - The error code. + Code *string `json:"code,omitempty"` + // Message - The error message text. + Message *string `json:"message,omitempty"` + // Details - READ-ONLY; The list of error details. + Details *[]ServiceErrorDetail `json:"details,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceError. +func (se ServiceError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if se.Code != nil { + objectMap["code"] = se.Code + } + if se.Message != nil { + objectMap["message"] = se.Message + } + return json.Marshal(objectMap) +} + +// ServiceErrorDetail the error details. +type ServiceErrorDetail struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` +} + +// SetObject ... +type SetObject struct { + autorest.Response `json:"-"` + Value interface{} `json:"value,omitempty"` +} + +// SkuCapability ... +type SkuCapability struct { + // Name - An invariant to describe the feature. + Name *string `json:"name,omitempty"` + // Value - An invariant if the feature is measured by quantity. + Value *string `json:"value,omitempty"` +} + +// SkuName ... +type SkuName struct { + Name *string `json:"name,omitempty"` +} + +// SkuRestriction ... +type SkuRestriction struct { + // Type - The type of restrictions. + Type *string `json:"type,omitempty"` + // Values - 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"` + // ReasonCode - The reason for restriction. + ReasonCode *string `json:"reasonCode,omitempty"` +} + +// SplitFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type SplitFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *SplitFuture) Result(client Client) (lr ListResponse, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.SplitFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("reservations.SplitFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if lr.Response.Response, err = future.GetResult(sender); err == nil && lr.Response.Response.StatusCode != http.StatusNoContent { + lr, err = client.SplitResponder(lr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.SplitFuture", "Result", lr.Response.Response, "Failure responding to request") + } + } + return +} + +// SplitProperties ... +type SplitProperties struct { + // Quantities - List of the quantities in the new reservations to create. + Quantities *[]int32 `json:"quantities,omitempty"` + // ReservationID - 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"` +} + +// SplitPropertiesType ... +type SplitPropertiesType struct { + // SplitDestinations - 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"` + // SplitSource - 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"` +} + +// SplitRequest ... +type SplitRequest struct { + *SplitProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SplitRequest. +func (sr SplitRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sr.SplitProperties != nil { + objectMap["properties"] = sr.SplitProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SplitRequest struct. +func (sr *SplitRequest) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var splitProperties SplitProperties + err = json.Unmarshal(*v, &splitProperties) + if err != nil { + return err + } + sr.SplitProperties = &splitProperties + } + } + } + + return nil +} + +// SubRequest the sub-request submitted with the quota request. +type SubRequest struct { + // Limit - READ-ONLY; Quota (resource limit). + Limit *int32 `json:"limit,omitempty"` + // Name - The resource name. + Name *ResourceName `json:"name,omitempty"` + // ResourceType - READ-ONLY; Resource type for which the quota check was made. + ResourceType *string `json:"resourceType,omitempty"` + // Unit - 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"` + // ProvisioningState - The quota request status. + ProvisioningState interface{} `json:"provisioningState,omitempty"` + // Message - READ-ONLY; User-friendly status message. + Message *string `json:"message,omitempty"` + // SubRequestID - READ-ONLY; Sub request ID for individual request. + SubRequestID *string `json:"subRequestId,omitempty"` +} + +// MarshalJSON is the custom marshaler for SubRequest. +func (sr SubRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sr.Name != nil { + objectMap["name"] = sr.Name + } + if sr.Unit != nil { + objectMap["unit"] = sr.Unit + } + if sr.ProvisioningState != nil { + objectMap["provisioningState"] = sr.ProvisioningState + } + return json.Marshal(objectMap) +} diff --git a/services/reservations/mgmt/2020-10-25/reservations/operation.go b/services/reservations/mgmt/2020-10-25/reservations/operation.go new file mode 100644 index 000000000000..e2481ae28014 --- /dev/null +++ b/services/reservations/mgmt/2020-10-25/reservations/operation.go @@ -0,0 +1,151 @@ +package reservations + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationClient is the client for the Operation methods of the Reservations service. +type OperationClient struct { + BaseClient +} + +// NewOperationClient creates an instance of the OperationClient client. +func NewOperationClient() OperationClient { + return NewOperationClientWithBaseURI(DefaultBaseURI) +} + +// NewOperationClientWithBaseURI creates an instance of the OperationClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationClientWithBaseURI(baseURI string) OperationClient { + return OperationClient{NewWithBaseURI(baseURI)} +} + +// List list all the operations. +func (client OperationClient) List(ctx context.Context) (result OperationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationClient.List") + defer func() { + sc := -1 + if result.ol.Response.Response != nil { + sc = result.ol.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.OperationClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ol.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "reservations.OperationClient", "List", resp, "Failure sending request") + return + } + + result.ol, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.OperationClient", "List", resp, "Failure responding to request") + return + } + if result.ol.hasNextLink() && result.ol.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2017-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Capacity/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationClient) ListResponder(resp *http.Response) (result OperationList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationClient) listNextResults(ctx context.Context, lastResults OperationList) (result OperationList, err error) { + req, err := lastResults.operationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "reservations.OperationClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "reservations.OperationClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.OperationClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationClient) ListComplete(ctx context.Context) (result OperationListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/reservations/mgmt/2020-10-25/reservations/order.go b/services/reservations/mgmt/2020-10-25/reservations/order.go new file mode 100644 index 000000000000..fcb7d9ef97ce --- /dev/null +++ b/services/reservations/mgmt/2020-10-25/reservations/order.go @@ -0,0 +1,224 @@ +package reservations + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OrderClient is the client for the Order methods of the Reservations service. +type OrderClient struct { + BaseClient +} + +// NewOrderClient creates an instance of the OrderClient client. +func NewOrderClient() OrderClient { + return NewOrderClientWithBaseURI(DefaultBaseURI) +} + +// NewOrderClientWithBaseURI creates an instance of the OrderClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOrderClientWithBaseURI(baseURI string) OrderClient { + return OrderClient{NewWithBaseURI(baseURI)} +} + +// Get get the details of the `ReservationOrder`. +// Parameters: +// reservationOrderID - order Id of the reservation +func (client OrderClient) Get(ctx context.Context, reservationOrderID string) (result OrderResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OrderClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, reservationOrderID) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.OrderClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "reservations.OrderClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.OrderClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client OrderClient) GetPreparer(ctx context.Context, reservationOrderID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "reservationOrderId": autorest.Encode("path", reservationOrderID), + } + + const APIVersion = "2017-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client OrderClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client OrderClient) GetResponder(resp *http.Response) (result OrderResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list of all the `ReservationOrder`s that the user has access to in the current tenant. +func (client OrderClient) List(ctx context.Context) (result OrderListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OrderClient.List") + defer func() { + sc := -1 + if result.ol.Response.Response != nil { + sc = result.ol.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.OrderClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ol.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "reservations.OrderClient", "List", resp, "Failure sending request") + return + } + + result.ol, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.OrderClient", "List", resp, "Failure responding to request") + return + } + if result.ol.hasNextLink() && result.ol.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OrderClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2017-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Capacity/reservationOrders"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OrderClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OrderClient) ListResponder(resp *http.Response) (result OrderList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OrderClient) listNextResults(ctx context.Context, lastResults OrderList) (result OrderList, err error) { + req, err := lastResults.orderListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "reservations.OrderClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "reservations.OrderClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.OrderClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OrderClient) ListComplete(ctx context.Context) (result OrderListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OrderClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/reservations/mgmt/2020-10-25/reservations/quota.go b/services/reservations/mgmt/2020-10-25/reservations/quota.go new file mode 100644 index 000000000000..3164bde9aa0d --- /dev/null +++ b/services/reservations/mgmt/2020-10-25/reservations/quota.go @@ -0,0 +1,422 @@ +package reservations + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// QuotaClient is the client for the Quota methods of the Reservations service. +type QuotaClient struct { + BaseClient +} + +// NewQuotaClient creates an instance of the QuotaClient client. +func NewQuotaClient() QuotaClient { + return NewQuotaClientWithBaseURI(DefaultBaseURI) +} + +// NewQuotaClientWithBaseURI creates an instance of the QuotaClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewQuotaClientWithBaseURI(baseURI string) QuotaClient { + return QuotaClient{NewWithBaseURI(baseURI)} +} + +// CreateOrUpdate create or update the quotas (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. +// Parameters: +// subscriptionID - azure subscription ID. +// providerID - azure resource provider ID. +// location - azure region. +// resourceName - the resource name for a resource provider, such as SKU name for Microsoft.Compute, Sku or +// TotalLowPriorityCores for Microsoft.MachineLearningServices +// createQuotaRequest - quota requests payload. +func (client QuotaClient) CreateOrUpdate(ctx context.Context, subscriptionID string, providerID string, location string, resourceName string, createQuotaRequest CurrentQuotaLimitBase) (result QuotaCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QuotaClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, subscriptionID, providerID, location, resourceName, createQuotaRequest) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.QuotaClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.QuotaClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client QuotaClient) CreateOrUpdatePreparer(ctx context.Context, subscriptionID string, providerID string, location string, resourceName string, createQuotaRequest CurrentQuotaLimitBase) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "providerId": autorest.Encode("path", providerID), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2020-10-25" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits/{resourceName}", pathParameters), + autorest.WithJSON(createQuotaRequest), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client QuotaClient) CreateOrUpdateSender(req *http.Request) (future QuotaCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client QuotaClient) CreateOrUpdateResponder(resp *http.Response) (result SetObject, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get the current quotas (service limits) and usage of a resource. You can use the response from the GET operation +// to submit quota update requests. +// Parameters: +// subscriptionID - azure subscription ID. +// providerID - azure resource provider ID. +// location - azure region. +// resourceName - the resource name for a resource provider, such as SKU name for Microsoft.Compute, Sku or +// TotalLowPriorityCores for Microsoft.MachineLearningServices +func (client QuotaClient) Get(ctx context.Context, subscriptionID string, providerID string, location string, resourceName string) (result CurrentQuotaLimitBase, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QuotaClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, subscriptionID, providerID, location, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.QuotaClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "reservations.QuotaClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.QuotaClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client QuotaClient) GetPreparer(ctx context.Context, subscriptionID string, providerID string, location string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "providerId": autorest.Encode("path", providerID), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2020-10-25" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client QuotaClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client QuotaClient) GetResponder(resp *http.Response) (result CurrentQuotaLimitBase, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// 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. +// Parameters: +// subscriptionID - azure subscription ID. +// providerID - azure resource provider ID. +// location - azure region. +func (client QuotaClient) List(ctx context.Context, subscriptionID string, providerID string, location string) (result QuotaLimitsPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QuotaClient.List") + defer func() { + sc := -1 + if result.ql.Response.Response != nil { + sc = result.ql.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, subscriptionID, providerID, location) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.QuotaClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ql.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "reservations.QuotaClient", "List", resp, "Failure sending request") + return + } + + result.ql, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.QuotaClient", "List", resp, "Failure responding to request") + return + } + if result.ql.hasNextLink() && result.ql.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client QuotaClient) ListPreparer(ctx context.Context, subscriptionID string, providerID string, location string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "providerId": autorest.Encode("path", providerID), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2020-10-25" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client QuotaClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client QuotaClient) ListResponder(resp *http.Response) (result QuotaLimits, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client QuotaClient) listNextResults(ctx context.Context, lastResults QuotaLimits) (result QuotaLimits, err error) { + req, err := lastResults.quotaLimitsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "reservations.QuotaClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "reservations.QuotaClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.QuotaClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client QuotaClient) ListComplete(ctx context.Context, subscriptionID string, providerID string, location string) (result QuotaLimitsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QuotaClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, subscriptionID, providerID, location) + return +} + +// 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. +// Parameters: +// subscriptionID - azure subscription ID. +// providerID - azure resource provider ID. +// location - azure region. +// resourceName - the resource name for a resource provider, such as SKU name for Microsoft.Compute, Sku or +// TotalLowPriorityCores for Microsoft.MachineLearningServices +// createQuotaRequest - payload for the quota request. +func (client QuotaClient) Update(ctx context.Context, subscriptionID string, providerID string, location string, resourceName string, createQuotaRequest CurrentQuotaLimitBase) (result QuotaUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QuotaClient.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, subscriptionID, providerID, location, resourceName, createQuotaRequest) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.QuotaClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.QuotaClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client QuotaClient) UpdatePreparer(ctx context.Context, subscriptionID string, providerID string, location string, resourceName string, createQuotaRequest CurrentQuotaLimitBase) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "providerId": autorest.Encode("path", providerID), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2020-10-25" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits/{resourceName}", pathParameters), + autorest.WithJSON(createQuotaRequest), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client QuotaClient) UpdateSender(req *http.Request) (future QuotaUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client QuotaClient) UpdateResponder(resp *http.Response) (result SetObject, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/reservations/mgmt/2020-10-25/reservations/quotarequeststatus.go b/services/reservations/mgmt/2020-10-25/reservations/quotarequeststatus.go new file mode 100644 index 000000000000..03422391e5ac --- /dev/null +++ b/services/reservations/mgmt/2020-10-25/reservations/quotarequeststatus.go @@ -0,0 +1,269 @@ +package reservations + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// QuotaRequestStatusClient is the client for the QuotaRequestStatus methods of the Reservations service. +type QuotaRequestStatusClient struct { + BaseClient +} + +// NewQuotaRequestStatusClient creates an instance of the QuotaRequestStatusClient client. +func NewQuotaRequestStatusClient() QuotaRequestStatusClient { + return NewQuotaRequestStatusClientWithBaseURI(DefaultBaseURI) +} + +// NewQuotaRequestStatusClientWithBaseURI creates an instance of the QuotaRequestStatusClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewQuotaRequestStatusClientWithBaseURI(baseURI string) QuotaRequestStatusClient { + return QuotaRequestStatusClient{NewWithBaseURI(baseURI)} +} + +// 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 service limits returns a response with the +// requestId parameter. +// Parameters: +// subscriptionID - azure subscription ID. +// providerID - azure resource provider ID. +// location - azure region. +// ID - quota Request ID. +func (client QuotaRequestStatusClient) Get(ctx context.Context, subscriptionID string, providerID string, location string, ID string) (result QuotaRequestDetails, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QuotaRequestStatusClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, subscriptionID, providerID, location, ID) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.QuotaRequestStatusClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "reservations.QuotaRequestStatusClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.QuotaRequestStatusClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client QuotaRequestStatusClient) GetPreparer(ctx context.Context, subscriptionID string, providerID string, location string, ID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "id": autorest.Encode("path", ID), + "location": autorest.Encode("path", location), + "providerId": autorest.Encode("path", providerID), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2020-10-25" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimitsRequests/{id}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client QuotaRequestStatusClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client QuotaRequestStatusClient) GetResponder(resp *http.Response) (result QuotaRequestDetails, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// 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. +// Parameters: +// subscriptionID - azure subscription ID. +// providerID - azure resource provider ID. +// location - azure region. +// filter - | Field | Supported operators +// |---------------------|------------------------ +// +// |requestSubmitTime | ge, le, eq, gt, lt +// top - number of records to return. +// skiptoken - 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. +func (client QuotaRequestStatusClient) List(ctx context.Context, subscriptionID string, providerID string, location string, filter string, top *int32, skiptoken string) (result QuotaRequestDetailsListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QuotaRequestStatusClient.List") + defer func() { + sc := -1 + if result.qrdl.Response.Response != nil { + sc = result.qrdl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("reservations.QuotaRequestStatusClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, subscriptionID, providerID, location, filter, top, skiptoken) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.QuotaRequestStatusClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.qrdl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "reservations.QuotaRequestStatusClient", "List", resp, "Failure sending request") + return + } + + result.qrdl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.QuotaRequestStatusClient", "List", resp, "Failure responding to request") + return + } + if result.qrdl.hasNextLink() && result.qrdl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client QuotaRequestStatusClient) ListPreparer(ctx context.Context, subscriptionID string, providerID string, location string, filter string, top *int32, skiptoken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "providerId": autorest.Encode("path", providerID), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2020-10-25" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimitsRequests", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client QuotaRequestStatusClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client QuotaRequestStatusClient) ListResponder(resp *http.Response) (result QuotaRequestDetailsList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client QuotaRequestStatusClient) listNextResults(ctx context.Context, lastResults QuotaRequestDetailsList) (result QuotaRequestDetailsList, err error) { + req, err := lastResults.quotaRequestDetailsListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "reservations.QuotaRequestStatusClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "reservations.QuotaRequestStatusClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.QuotaRequestStatusClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client QuotaRequestStatusClient) ListComplete(ctx context.Context, subscriptionID string, providerID string, location string, filter string, top *int32, skiptoken string) (result QuotaRequestDetailsListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QuotaRequestStatusClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, subscriptionID, providerID, location, filter, top, skiptoken) + return +} diff --git a/services/reservations/mgmt/2020-10-25/reservations/reservation.go b/services/reservations/mgmt/2020-10-25/reservations/reservation.go new file mode 100644 index 000000000000..ad3ed59ccbf1 --- /dev/null +++ b/services/reservations/mgmt/2020-10-25/reservations/reservation.go @@ -0,0 +1,577 @@ +package reservations + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// Client is the client for the Reservation methods of the Reservations service. +type Client struct { + BaseClient +} + +// NewClient creates an instance of the Client client. +func NewClient() Client { + return NewClientWithBaseURI(DefaultBaseURI) +} + +// NewClientWithBaseURI creates an instance of the Client client using a custom endpoint. Use this when interacting +// with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewClientWithBaseURI(baseURI string) Client { + return Client{NewWithBaseURI(baseURI)} +} + +// Get get specific `Reservation` details. +// Parameters: +// reservationID - id of the Reservation Item +// reservationOrderID - order Id of the reservation +func (client Client) Get(ctx context.Context, reservationID string, reservationOrderID string) (result Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, reservationID, reservationOrderID) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.Client", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "reservations.Client", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.Client", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client Client) GetPreparer(ctx context.Context, reservationID string, reservationOrderID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "reservationId": autorest.Encode("path", reservationID), + "reservationOrderId": autorest.Encode("path", reservationOrderID), + } + + const APIVersion = "2017-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client Client) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client Client) GetResponder(resp *http.Response) (result Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list `Reservation`s within a single `ReservationOrder`. +// Parameters: +// reservationOrderID - order Id of the reservation +func (client Client) List(ctx context.Context, reservationOrderID string) (result ListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.List") + defer func() { + sc := -1 + if result.l.Response.Response != nil { + sc = result.l.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, reservationOrderID) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.Client", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.l.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "reservations.Client", "List", resp, "Failure sending request") + return + } + + result.l, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.Client", "List", resp, "Failure responding to request") + return + } + if result.l.hasNextLink() && result.l.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client Client) ListPreparer(ctx context.Context, reservationOrderID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "reservationOrderId": autorest.Encode("path", reservationOrderID), + } + + const APIVersion = "2017-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client Client) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client Client) ListResponder(resp *http.Response) (result List, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client Client) listNextResults(ctx context.Context, lastResults List) (result List, err error) { + req, err := lastResults.listPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "reservations.Client", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "reservations.Client", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.Client", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client Client) ListComplete(ctx context.Context, reservationOrderID string) (result ListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, reservationOrderID) + return +} + +// ListRevisions list of all the revisions for the `Reservation`. +// Parameters: +// reservationID - id of the Reservation Item +// reservationOrderID - order Id of the reservation +func (client Client) ListRevisions(ctx context.Context, reservationID string, reservationOrderID string) (result ListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListRevisions") + defer func() { + sc := -1 + if result.l.Response.Response != nil { + sc = result.l.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listRevisionsNextResults + req, err := client.ListRevisionsPreparer(ctx, reservationID, reservationOrderID) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.Client", "ListRevisions", nil, "Failure preparing request") + return + } + + resp, err := client.ListRevisionsSender(req) + if err != nil { + result.l.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "reservations.Client", "ListRevisions", resp, "Failure sending request") + return + } + + result.l, err = client.ListRevisionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.Client", "ListRevisions", resp, "Failure responding to request") + return + } + if result.l.hasNextLink() && result.l.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListRevisionsPreparer prepares the ListRevisions request. +func (client Client) ListRevisionsPreparer(ctx context.Context, reservationID string, reservationOrderID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "reservationId": autorest.Encode("path", reservationID), + "reservationOrderId": autorest.Encode("path", reservationOrderID), + } + + const APIVersion = "2017-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}/revisions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListRevisionsSender sends the ListRevisions request. The method will close the +// http.Response Body if it receives an error. +func (client Client) ListRevisionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListRevisionsResponder handles the response to the ListRevisions request. The method always +// closes the http.Response Body. +func (client Client) ListRevisionsResponder(resp *http.Response) (result List, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listRevisionsNextResults retrieves the next set of results, if any. +func (client Client) listRevisionsNextResults(ctx context.Context, lastResults List) (result List, err error) { + req, err := lastResults.listPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "reservations.Client", "listRevisionsNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListRevisionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "reservations.Client", "listRevisionsNextResults", resp, "Failure sending next results request") + } + result, err = client.ListRevisionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.Client", "listRevisionsNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListRevisionsComplete enumerates all values, automatically crossing page boundaries as required. +func (client Client) ListRevisionsComplete(ctx context.Context, reservationID string, reservationOrderID string) (result ListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListRevisions") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListRevisions(ctx, reservationID, reservationOrderID) + return +} + +// Merge merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged must have +// same properties. +// Parameters: +// reservationOrderID - order Id of the reservation +// body - information needed for commercial request for a reservation +func (client Client) Merge(ctx context.Context, reservationOrderID string, body MergeRequest) (result ReservationMergeFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Merge") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.MergePreparer(ctx, reservationOrderID, body) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.Client", "Merge", nil, "Failure preparing request") + return + } + + result, err = client.MergeSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.Client", "Merge", result.Response(), "Failure sending request") + return + } + + return +} + +// MergePreparer prepares the Merge request. +func (client Client) MergePreparer(ctx context.Context, reservationOrderID string, body MergeRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "reservationOrderId": autorest.Encode("path", reservationOrderID), + } + + const APIVersion = "2017-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/merge", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MergeSender sends the Merge request. The method will close the +// http.Response Body if it receives an error. +func (client Client) MergeSender(req *http.Request) (future ReservationMergeFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// MergeResponder handles the response to the Merge request. The method always +// closes the http.Response Body. +func (client Client) MergeResponder(resp *http.Response) (result ListResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Split split a `Reservation` into two `Reservation`s with specified quantity distribution. +// Parameters: +// reservationOrderID - order Id of the reservation +// body - information needed to Split a reservation item +func (client Client) Split(ctx context.Context, reservationOrderID string, body SplitRequest) (result SplitFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Split") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.SplitPreparer(ctx, reservationOrderID, body) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.Client", "Split", nil, "Failure preparing request") + return + } + + result, err = client.SplitSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.Client", "Split", result.Response(), "Failure sending request") + return + } + + return +} + +// SplitPreparer prepares the Split request. +func (client Client) SplitPreparer(ctx context.Context, reservationOrderID string, body SplitRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "reservationOrderId": autorest.Encode("path", reservationOrderID), + } + + const APIVersion = "2017-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/split", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// SplitSender sends the Split request. The method will close the +// http.Response Body if it receives an error. +func (client Client) SplitSender(req *http.Request) (future SplitFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// SplitResponder handles the response to the Split request. The method always +// closes the http.Response Body. +func (client Client) SplitResponder(resp *http.Response) (result ListResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates the applied scopes of the `Reservation`. +// Parameters: +// reservationOrderID - order Id of the reservation +// reservationID - id of the Reservation Item +// parameters - information needed to patch a reservation item +func (client Client) Update(ctx context.Context, reservationOrderID string, reservationID string, parameters Patch) (result ReservationUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, reservationOrderID, reservationID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.Client", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.Client", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client Client) UpdatePreparer(ctx context.Context, reservationOrderID string, reservationID string, parameters Patch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "reservationId": autorest.Encode("path", reservationID), + "reservationOrderId": autorest.Encode("path", reservationOrderID), + } + + const APIVersion = "2017-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client Client) UpdateSender(req *http.Request) (future ReservationUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client Client) UpdateResponder(resp *http.Response) (result Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/reservations/mgmt/2020-10-25/reservations/reservationsapi/interfaces.go b/services/reservations/mgmt/2020-10-25/reservations/reservationsapi/interfaces.go new file mode 100644 index 000000000000..c8a2378ed538 --- /dev/null +++ b/services/reservations/mgmt/2020-10-25/reservations/reservationsapi/interfaces.go @@ -0,0 +1,82 @@ +package reservationsapi + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/reservations/mgmt/2020-10-25/reservations" +) + +// BaseClientAPI contains the set of methods on the BaseClient type. +type BaseClientAPI interface { + GetAppliedReservationList(ctx context.Context, subscriptionID string) (result reservations.AppliedReservations, err error) + GetCatalog(ctx context.Context, subscriptionID string) (result reservations.ListCatalog, err error) +} + +var _ BaseClientAPI = (*reservations.BaseClient)(nil) + +// OrderClientAPI contains the set of methods on the OrderClient type. +type OrderClientAPI interface { + Get(ctx context.Context, reservationOrderID string) (result reservations.OrderResponse, err error) + List(ctx context.Context) (result reservations.OrderListPage, err error) + ListComplete(ctx context.Context) (result reservations.OrderListIterator, err error) +} + +var _ OrderClientAPI = (*reservations.OrderClient)(nil) + +// ClientAPI contains the set of methods on the Client type. +type ClientAPI interface { + Get(ctx context.Context, reservationID string, reservationOrderID string) (result reservations.Response, err error) + List(ctx context.Context, reservationOrderID string) (result reservations.ListPage, err error) + ListComplete(ctx context.Context, reservationOrderID string) (result reservations.ListIterator, err error) + ListRevisions(ctx context.Context, reservationID string, reservationOrderID string) (result reservations.ListPage, err error) + ListRevisionsComplete(ctx context.Context, reservationID string, reservationOrderID string) (result reservations.ListIterator, err error) + Merge(ctx context.Context, reservationOrderID string, body reservations.MergeRequest) (result reservations.ReservationMergeFuture, err error) + Split(ctx context.Context, reservationOrderID string, body reservations.SplitRequest) (result reservations.SplitFuture, err error) + Update(ctx context.Context, reservationOrderID string, reservationID string, parameters reservations.Patch) (result reservations.ReservationUpdateFuture, err error) +} + +var _ ClientAPI = (*reservations.Client)(nil) + +// OperationClientAPI contains the set of methods on the OperationClient type. +type OperationClientAPI interface { + List(ctx context.Context) (result reservations.OperationListPage, err error) + ListComplete(ctx context.Context) (result reservations.OperationListIterator, err error) +} + +var _ OperationClientAPI = (*reservations.OperationClient)(nil) + +// QuotaClientAPI contains the set of methods on the QuotaClient type. +type QuotaClientAPI interface { + CreateOrUpdate(ctx context.Context, subscriptionID string, providerID string, location string, resourceName string, createQuotaRequest reservations.CurrentQuotaLimitBase) (result reservations.QuotaCreateOrUpdateFuture, err error) + Get(ctx context.Context, subscriptionID string, providerID string, location string, resourceName string) (result reservations.CurrentQuotaLimitBase, err error) + List(ctx context.Context, subscriptionID string, providerID string, location string) (result reservations.QuotaLimitsPage, err error) + ListComplete(ctx context.Context, subscriptionID string, providerID string, location string) (result reservations.QuotaLimitsIterator, err error) + Update(ctx context.Context, subscriptionID string, providerID string, location string, resourceName string, createQuotaRequest reservations.CurrentQuotaLimitBase) (result reservations.QuotaUpdateFuture, err error) +} + +var _ QuotaClientAPI = (*reservations.QuotaClient)(nil) + +// QuotaRequestStatusClientAPI contains the set of methods on the QuotaRequestStatusClient type. +type QuotaRequestStatusClientAPI interface { + Get(ctx context.Context, subscriptionID string, providerID string, location string, ID string) (result reservations.QuotaRequestDetails, err error) + List(ctx context.Context, subscriptionID string, providerID string, location string, filter string, top *int32, skiptoken string) (result reservations.QuotaRequestDetailsListPage, err error) + ListComplete(ctx context.Context, subscriptionID string, providerID string, location string, filter string, top *int32, skiptoken string) (result reservations.QuotaRequestDetailsListIterator, err error) +} + +var _ QuotaRequestStatusClientAPI = (*reservations.QuotaRequestStatusClient)(nil) diff --git a/services/reservations/mgmt/2020-10-25/reservations/version.go b/services/reservations/mgmt/2020-10-25/reservations/version.go new file mode 100644 index 000000000000..6c75d1511268 --- /dev/null +++ b/services/reservations/mgmt/2020-10-25/reservations/version.go @@ -0,0 +1,30 @@ +package reservations + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " reservations/2020-10-25" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}