From b7f6afed6d55862d2aacd40f538e6ce59b4bdc07 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 19 Nov 2020 05:35:29 +0000 Subject: [PATCH] CodeGen from PR 11668 in Azure/azure-rest-api-specs Microsoft.Capacity 2020-10-01-preview update (#11668) --- .../mgmt/2019-04-01/reservations/enums.go | 26 ++- .../mgmt/2019-04-01/reservations/models.go | 62 ++++--- .../2019-04-01/reservations/reservation.go | 158 +++++++++++++++++- .../reservationsapi/interfaces.go | 5 +- 4 files changed, 220 insertions(+), 31 deletions(-) diff --git a/services/preview/reservations/mgmt/2019-04-01/reservations/enums.go b/services/preview/reservations/mgmt/2019-04-01/reservations/enums.go index b49afdc63d5d..318a02d28b5e 100644 --- a/services/preview/reservations/mgmt/2019-04-01/reservations/enums.go +++ b/services/preview/reservations/mgmt/2019-04-01/reservations/enums.go @@ -221,12 +221,36 @@ func PossibleReservationTermValues() []ReservationTerm { type ReservedResourceType string const ( + // AppService ... + AppService ReservedResourceType = "AppService" + // AzureDataExplorer ... + AzureDataExplorer ReservedResourceType = "AzureDataExplorer" + // BlockBlob ... + BlockBlob ReservedResourceType = "BlockBlob" // CosmosDb ... CosmosDb ReservedResourceType = "CosmosDb" + // Databricks ... + Databricks ReservedResourceType = "Databricks" + // DedicatedHost ... + DedicatedHost ReservedResourceType = "DedicatedHost" + // ManagedDisk ... + ManagedDisk ReservedResourceType = "ManagedDisk" + // MariaDb ... + MariaDb ReservedResourceType = "MariaDb" + // MySQL ... + MySQL ReservedResourceType = "MySql" + // PostgreSQL ... + PostgreSQL ReservedResourceType = "PostgreSql" // RedHat ... RedHat ReservedResourceType = "RedHat" // RedHatOsa ... RedHatOsa ReservedResourceType = "RedHatOsa" + // RedisCache ... + RedisCache ReservedResourceType = "RedisCache" + // SapHana ... + SapHana ReservedResourceType = "SapHana" + // SQLAzureHybridBenefit ... + SQLAzureHybridBenefit ReservedResourceType = "SqlAzureHybridBenefit" // SQLDatabases ... SQLDatabases ReservedResourceType = "SqlDatabases" // SQLDataWarehouse ... @@ -241,7 +265,7 @@ const ( // PossibleReservedResourceTypeValues returns an array of possible values for the ReservedResourceType const type. func PossibleReservedResourceTypeValues() []ReservedResourceType { - return []ReservedResourceType{CosmosDb, RedHat, RedHatOsa, SQLDatabases, SQLDataWarehouse, SuseLinux, VirtualMachines, VMwareCloudSimple} + return []ReservedResourceType{AppService, AzureDataExplorer, BlockBlob, CosmosDb, Databricks, DedicatedHost, ManagedDisk, MariaDb, MySQL, PostgreSQL, RedHat, RedHatOsa, RedisCache, SapHana, SQLAzureHybridBenefit, SQLDatabases, SQLDataWarehouse, SuseLinux, VirtualMachines, VMwareCloudSimple} } // StatusCode enumerates the values for status code. diff --git a/services/preview/reservations/mgmt/2019-04-01/reservations/models.go b/services/preview/reservations/mgmt/2019-04-01/reservations/models.go index 267375c23601..7795160e2494 100644 --- a/services/preview/reservations/mgmt/2019-04-01/reservations/models.go +++ b/services/preview/reservations/mgmt/2019-04-01/reservations/models.go @@ -115,6 +115,17 @@ type AppliedReservationsProperties struct { ReservationOrderIds *AppliedReservationList `json:"reservationOrderIds,omitempty"` } +// AvailableScopeRequest ... +type AvailableScopeRequest struct { + Properties *AvailableScopeRequestProperties `json:"properties,omitempty"` +} + +// AvailableScopeRequestProperties list of scopes for which availability should be checked +type AvailableScopeRequestProperties struct { + // Scopes - Scopes to be checked for availability + Scopes *[]string `json:"scopes,omitempty"` +} + // CalculatePriceResponse ... type CalculatePriceResponse struct { autorest.Response `json:"-"` @@ -138,8 +149,8 @@ type CalculatePriceResponseProperties struct { PaymentSchedule *[]PaymentDetail `json:"paymentSchedule,omitempty"` } -// CalculatePriceResponsePropertiesBillingCurrencyTotal currency and amount that customer will be charged in -// customer's local currency. Tax is not included. +// CalculatePriceResponsePropertiesBillingCurrencyTotal currency and amount that customer will be charged +// in customer's local currency. Tax is not included. type CalculatePriceResponsePropertiesBillingCurrencyTotal struct { CurrencyCode *string `json:"currencyCode,omitempty"` Amount *float64 `json:"amount,omitempty"` @@ -356,8 +367,11 @@ func (page ListPage) Values() []Response { } // Creates a new instance of the ListPage type. -func NewListPage(getNextPage func(context.Context, List) (List, error)) ListPage { - return ListPage{fn: getNextPage} +func NewListPage(cur List, getNextPage func(context.Context, List) (List, error)) ListPage { + return ListPage{ + fn: getNextPage, + l: cur, + } } // ListResponse ... @@ -577,8 +591,11 @@ func (page OperationListPage) Values() []OperationResponse { } // Creates a new instance of the OperationListPage type. -func NewOperationListPage(getNextPage func(context.Context, OperationList) (OperationList, error)) OperationListPage { - return OperationListPage{fn: getNextPage} +func NewOperationListPage(cur OperationList, getNextPage func(context.Context, OperationList) (OperationList, error)) OperationListPage { + return OperationListPage{ + fn: getNextPage, + ol: cur, + } } // OperationResponse ... @@ -750,8 +767,11 @@ func (page OrderListPage) Values() []OrderResponse { } // Creates a new instance of the OrderListPage type. -func NewOrderListPage(getNextPage func(context.Context, OrderList) (OrderList, error)) OrderListPage { - return OrderListPage{fn: getNextPage} +func NewOrderListPage(cur OrderList, getNextPage func(context.Context, OrderList) (OrderList, error)) OrderListPage { + return OrderListPage{ + fn: getNextPage, + ol: cur, + } } // OrderProperties ... @@ -775,7 +795,8 @@ type OrderProperties struct { ReservationsProperty *[]Response `json:"reservations,omitempty"` } -// OrderPurchaseFuture an abstraction for monitoring and retrieving the results of a long-running operation. +// OrderPurchaseFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. type OrderPurchaseFuture struct { azure.Future } @@ -976,7 +997,7 @@ type Properties struct { // PropertiesType ... type PropertiesType struct { - // ReservedResourceType - Possible values include: 'VirtualMachines', 'SQLDatabases', 'SuseLinux', 'CosmosDb', 'RedHat', 'SQLDataWarehouse', 'VMwareCloudSimple', 'RedHatOsa' + // ReservedResourceType - Possible values include: 'VirtualMachines', 'SQLDatabases', 'SuseLinux', 'CosmosDb', 'RedHat', 'SQLDataWarehouse', 'VMwareCloudSimple', 'RedHatOsa', 'Databricks', 'AppService', 'ManagedDisk', 'BlockBlob', 'RedisCache', 'AzureDataExplorer', 'MySQL', 'MariaDb', 'PostgreSQL', 'DedicatedHost', 'SapHana', 'SQLAzureHybridBenefit' ReservedResourceType ReservedResourceType `json:"reservedResourceType,omitempty"` // InstanceFlexibility - Possible values include: 'On', 'Off' InstanceFlexibility InstanceFlexibility `json:"instanceFlexibility,omitempty"` @@ -1145,7 +1166,7 @@ func (pr *PurchaseRequest) UnmarshalJSON(body []byte) error { // PurchaseRequestProperties ... type PurchaseRequestProperties struct { - // ReservedResourceType - Possible values include: 'VirtualMachines', 'SQLDatabases', 'SuseLinux', 'CosmosDb', 'RedHat', 'SQLDataWarehouse', 'VMwareCloudSimple', 'RedHatOsa' + // ReservedResourceType - Possible values include: 'VirtualMachines', 'SQLDatabases', 'SuseLinux', 'CosmosDb', 'RedHat', 'SQLDataWarehouse', 'VMwareCloudSimple', 'RedHatOsa', 'Databricks', 'AppService', 'ManagedDisk', 'BlockBlob', 'RedisCache', 'AzureDataExplorer', 'MySQL', 'MariaDb', 'PostgreSQL', 'DedicatedHost', 'SapHana', 'SQLAzureHybridBenefit' ReservedResourceType ReservedResourceType `json:"reservedResourceType,omitempty"` BillingScopeID *string `json:"billingScopeId,omitempty"` // Term - Possible values include: 'P1Y', 'P3Y' @@ -1163,8 +1184,8 @@ type PurchaseRequestProperties struct { ReservedResourceProperties *PurchaseRequestPropertiesReservedResourceProperties `json:"reservedResourceProperties,omitempty"` } -// PurchaseRequestPropertiesReservedResourceProperties properties specific to each reserved resource type. Not -// required if not applicable. +// PurchaseRequestPropertiesReservedResourceProperties properties specific to each reserved resource type. +// Not required if not applicable. type PurchaseRequestPropertiesReservedResourceProperties struct { // InstanceFlexibility - Possible values include: 'On', 'Off' InstanceFlexibility InstanceFlexibility `json:"instanceFlexibility,omitempty"` @@ -1179,22 +1200,22 @@ type RenewPropertiesResponse struct { BillingCurrencyTotal *RenewPropertiesResponseBillingCurrencyTotal `json:"billingCurrencyTotal,omitempty"` } -// RenewPropertiesResponseBillingCurrencyTotal currency and amount that customer will be charged in customer's -// local currency for renewal purchase. Tax is not included. +// RenewPropertiesResponseBillingCurrencyTotal currency and amount that customer will be charged in +// customer's local currency for renewal purchase. Tax is not included. type RenewPropertiesResponseBillingCurrencyTotal struct { CurrencyCode *string `json:"currencyCode,omitempty"` Amount *float64 `json:"amount,omitempty"` } -// RenewPropertiesResponsePricingCurrencyTotal amount that Microsoft uses for record. Used during refund for -// calculating refund limit. Tax is not included. This is locked price 30 days before expiry. +// RenewPropertiesResponsePricingCurrencyTotal amount that Microsoft uses for record. Used during refund +// for calculating refund limit. Tax is not included. This is locked price 30 days before expiry. type RenewPropertiesResponsePricingCurrencyTotal struct { CurrencyCode *string `json:"currencyCode,omitempty"` Amount *float64 `json:"amount,omitempty"` } -// ReservationAvailableScopesFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. +// ReservationAvailableScopesFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. type ReservationAvailableScopesFuture struct { azure.Future } @@ -1222,7 +1243,8 @@ func (future *ReservationAvailableScopesFuture) Result(client Client) (p Propert return } -// ReservationMergeFuture an abstraction for monitoring and retrieving the results of a long-running operation. +// ReservationMergeFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. type ReservationMergeFuture struct { azure.Future } diff --git a/services/preview/reservations/mgmt/2019-04-01/reservations/reservation.go b/services/preview/reservations/mgmt/2019-04-01/reservations/reservation.go index 37934f50f37a..355f5b9f1deb 100644 --- a/services/preview/reservations/mgmt/2019-04-01/reservations/reservation.go +++ b/services/preview/reservations/mgmt/2019-04-01/reservations/reservation.go @@ -21,7 +21,6 @@ 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" ) @@ -42,11 +41,85 @@ func NewClientWithBaseURI(baseURI string) Client { return Client{NewWithBaseURI(baseURI)} } +// Archive archiving a `Reservation` moves it to `Archived` state. +// Parameters: +// reservationOrderID - order Id of the reservation +// reservationID - id of the Reservation Item +func (client Client) Archive(ctx context.Context, reservationOrderID string, reservationID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Archive") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ArchivePreparer(ctx, reservationOrderID, reservationID) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.Client", "Archive", nil, "Failure preparing request") + return + } + + resp, err := client.ArchiveSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "reservations.Client", "Archive", resp, "Failure sending request") + return + } + + result, err = client.ArchiveResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.Client", "Archive", resp, "Failure responding to request") + } + + return +} + +// ArchivePreparer prepares the Archive request. +func (client Client) ArchivePreparer(ctx context.Context, reservationOrderID string, reservationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "reservationId": autorest.Encode("path", reservationID), + "reservationOrderId": autorest.Encode("path", reservationOrderID), + } + + const APIVersion = "2019-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}/archive", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ArchiveSender sends the Archive request. The method will close the +// http.Response Body if it receives an error. +func (client Client) ArchiveSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ArchiveResponder handles the response to the Archive request. The method always +// closes the http.Response Body. +func (client Client) ArchiveResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + // AvailableScopes get Available Scopes for `Reservation`. // Parameters: // reservationOrderID - order Id of the reservation // reservationID - id of the Reservation Item -func (client Client) AvailableScopes(ctx context.Context, reservationOrderID string, reservationID string, body []string) (result ReservationAvailableScopesFuture, err error) { +// body - parameter for listing the available scopes +func (client Client) AvailableScopes(ctx context.Context, reservationOrderID string, reservationID string, body AvailableScopeRequest) (result ReservationAvailableScopesFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/Client.AvailableScopes") defer func() { @@ -57,12 +130,6 @@ func (client Client) AvailableScopes(ctx context.Context, reservationOrderID str tracing.EndSpan(ctx, sc, err) }() } - if err := validation.Validate([]validation.Validation{ - {TargetValue: body, - Constraints: []validation.Constraint{{Target: "body", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewError("reservations.Client", "AvailableScopes", err.Error()) - } - req, err := client.AvailableScopesPreparer(ctx, reservationOrderID, reservationID, body) if err != nil { err = autorest.NewErrorWithError(err, "reservations.Client", "AvailableScopes", nil, "Failure preparing request") @@ -79,7 +146,7 @@ func (client Client) AvailableScopes(ctx context.Context, reservationOrderID str } // AvailableScopesPreparer prepares the AvailableScopes request. -func (client Client) AvailableScopesPreparer(ctx context.Context, reservationOrderID string, reservationID string, body []string) (*http.Request, error) { +func (client Client) AvailableScopesPreparer(ctx context.Context, reservationOrderID string, reservationID string, body AvailableScopeRequest) (*http.Request, error) { pathParameters := map[string]interface{}{ "reservationId": autorest.Encode("path", reservationID), "reservationOrderId": autorest.Encode("path", reservationOrderID), @@ -581,6 +648,79 @@ func (client Client) SplitResponder(resp *http.Response) (result ListResponse, e return } +// Unarchive unarchiving a `Reservation` moves it to the state it was before archiving. +// Parameters: +// reservationOrderID - order Id of the reservation +// reservationID - id of the Reservation Item +func (client Client) Unarchive(ctx context.Context, reservationOrderID string, reservationID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Unarchive") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UnarchivePreparer(ctx, reservationOrderID, reservationID) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.Client", "Unarchive", nil, "Failure preparing request") + return + } + + resp, err := client.UnarchiveSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "reservations.Client", "Unarchive", resp, "Failure sending request") + return + } + + result, err = client.UnarchiveResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "reservations.Client", "Unarchive", resp, "Failure responding to request") + } + + return +} + +// UnarchivePreparer prepares the Unarchive request. +func (client Client) UnarchivePreparer(ctx context.Context, reservationOrderID string, reservationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "reservationId": autorest.Encode("path", reservationID), + "reservationOrderId": autorest.Encode("path", reservationOrderID), + } + + const APIVersion = "2019-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}/unarchive", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UnarchiveSender sends the Unarchive request. The method will close the +// http.Response Body if it receives an error. +func (client Client) UnarchiveSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// UnarchiveResponder handles the response to the Unarchive request. The method always +// closes the http.Response Body. +func (client Client) UnarchiveResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + // Update updates the applied scopes of the `Reservation`. // Parameters: // reservationOrderID - order Id of the reservation diff --git a/services/preview/reservations/mgmt/2019-04-01/reservations/reservationsapi/interfaces.go b/services/preview/reservations/mgmt/2019-04-01/reservations/reservationsapi/interfaces.go index 2780bb18ecb7..edcc3104ecb1 100644 --- a/services/preview/reservations/mgmt/2019-04-01/reservations/reservationsapi/interfaces.go +++ b/services/preview/reservations/mgmt/2019-04-01/reservations/reservationsapi/interfaces.go @@ -20,6 +20,7 @@ package reservationsapi import ( "context" "github.com/Azure/azure-sdk-for-go/services/preview/reservations/mgmt/2019-04-01/reservations" + "github.com/Azure/go-autorest/autorest" ) // BaseClientAPI contains the set of methods on the BaseClient type. @@ -32,7 +33,8 @@ var _ BaseClientAPI = (*reservations.BaseClient)(nil) // ClientAPI contains the set of methods on the Client type. type ClientAPI interface { - AvailableScopes(ctx context.Context, reservationOrderID string, reservationID string, body []string) (result reservations.ReservationAvailableScopesFuture, err error) + Archive(ctx context.Context, reservationOrderID string, reservationID string) (result autorest.Response, err error) + AvailableScopes(ctx context.Context, reservationOrderID string, reservationID string, body reservations.AvailableScopeRequest) (result reservations.ReservationAvailableScopesFuture, err error) Get(ctx context.Context, reservationID string, reservationOrderID string, expand 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) @@ -40,6 +42,7 @@ type ClientAPI interface { 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) + Unarchive(ctx context.Context, reservationOrderID string, reservationID string) (result autorest.Response, err error) Update(ctx context.Context, reservationOrderID string, reservationID string, parameters reservations.Patch) (result reservations.ReservationUpdateFuture, err error) }