From 8bd9f7b45ea1be64052f02903e90d387b67020a1 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Wed, 14 Nov 2018 20:22:50 +0000 Subject: [PATCH 1/2] Generated from e8183a03edd1178ade3f773ba48e88a45609d705 added example --- .../mgmt/apimanagement/models.go | 24 +++ .../mgmt/apimanagement/models.go | 33 +++- .../mgmt/2018-01-01/apimanagement/models.go | 181 +++++++++++++++++ .../2018-01-01/apimanagement/serviceskus.go | 165 ++++++++++++++++ .../apimanagement/models.go | 187 +++++++++++++++++- .../apimanagement/serviceskus.go | 165 ++++++++++++++++ 6 files changed, 749 insertions(+), 6 deletions(-) create mode 100644 services/apimanagement/mgmt/2018-01-01/apimanagement/serviceskus.go create mode 100644 services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/serviceskus.go diff --git a/profiles/preview/apimanagement/mgmt/apimanagement/models.go b/profiles/preview/apimanagement/mgmt/apimanagement/models.go index cd1e1ffa35dd..cd976b74b6df 100644 --- a/profiles/preview/apimanagement/mgmt/apimanagement/models.go +++ b/profiles/preview/apimanagement/mgmt/apimanagement/models.go @@ -248,6 +248,14 @@ const ( ProtocolHTTPS Protocol = original.ProtocolHTTPS ) +type ResourceSkuCapacityScaleType = original.ResourceSkuCapacityScaleType + +const ( + Automatic ResourceSkuCapacityScaleType = original.Automatic + Manual ResourceSkuCapacityScaleType = original.Manual + None ResourceSkuCapacityScaleType = original.None +) + type SkuType = original.SkuType const ( @@ -565,6 +573,12 @@ type RequestContract = original.RequestContract type RequestReportCollection = original.RequestReportCollection type RequestReportRecordContract = original.RequestReportRecordContract type Resource = original.Resource +type ResourceSku = original.ResourceSku +type ResourceSkuCapacity = original.ResourceSkuCapacity +type ResourceSkuResult = original.ResourceSkuResult +type ResourceSkuResults = original.ResourceSkuResults +type ResourceSkuResultsIterator = original.ResourceSkuResultsIterator +type ResourceSkuResultsPage = original.ResourceSkuResultsPage type ResponseContract = original.ResponseContract type SaveConfigurationParameter = original.SaveConfigurationParameter type SchemaCollection = original.SchemaCollection @@ -669,6 +683,7 @@ type QuotaByPeriodKeysClient = original.QuotaByPeriodKeysClient type RegionsClient = original.RegionsClient type ReportsClient = original.ReportsClient type ServiceClient = original.ServiceClient +type ServiceSkusClient = original.ServiceSkusClient type SignInSettingsClient = original.SignInSettingsClient type SignUpSettingsClient = original.SignUpSettingsClient type SubscriptionClient = original.SubscriptionClient @@ -914,6 +929,9 @@ func PossibleProductStateValues() []ProductState { func PossibleProtocolValues() []Protocol { return original.PossibleProtocolValues() } +func PossibleResourceSkuCapacityScaleTypeValues() []ResourceSkuCapacityScaleType { + return original.PossibleResourceSkuCapacityScaleTypeValues() +} func PossibleSkuTypeValues() []SkuType { return original.PossibleSkuTypeValues() } @@ -1064,6 +1082,12 @@ func NewServiceClient(subscriptionID string) ServiceClient { func NewServiceClientWithBaseURI(baseURI string, subscriptionID string) ServiceClient { return original.NewServiceClientWithBaseURI(baseURI, subscriptionID) } +func NewServiceSkusClient(subscriptionID string) ServiceSkusClient { + return original.NewServiceSkusClient(subscriptionID) +} +func NewServiceSkusClientWithBaseURI(baseURI string, subscriptionID string) ServiceSkusClient { + return original.NewServiceSkusClientWithBaseURI(baseURI, subscriptionID) +} func NewSignInSettingsClient(subscriptionID string) SignInSettingsClient { return original.NewSignInSettingsClient(subscriptionID) } diff --git a/profiles/preview/preview/apimanagement/mgmt/apimanagement/models.go b/profiles/preview/preview/apimanagement/mgmt/apimanagement/models.go index b0b4561d8e84..32c6a63e7451 100644 --- a/profiles/preview/preview/apimanagement/mgmt/apimanagement/models.go +++ b/profiles/preview/preview/apimanagement/mgmt/apimanagement/models.go @@ -252,6 +252,14 @@ const ( ProtocolHTTPS Protocol = original.ProtocolHTTPS ) +type ResourceSkuCapacityScaleType = original.ResourceSkuCapacityScaleType + +const ( + Automatic ResourceSkuCapacityScaleType = original.Automatic + Manual ResourceSkuCapacityScaleType = original.Manual + None ResourceSkuCapacityScaleType = original.None +) + type SamplingType = original.SamplingType const ( @@ -261,10 +269,11 @@ const ( type SkuType = original.SkuType const ( - SkuTypeBasic SkuType = original.SkuTypeBasic - SkuTypeDeveloper SkuType = original.SkuTypeDeveloper - SkuTypePremium SkuType = original.SkuTypePremium - SkuTypeStandard SkuType = original.SkuTypeStandard + SkuTypeBasic SkuType = original.SkuTypeBasic + SkuTypeConsumption SkuType = original.SkuTypeConsumption + SkuTypeDeveloper SkuType = original.SkuTypeDeveloper + SkuTypePremium SkuType = original.SkuTypePremium + SkuTypeStandard SkuType = original.SkuTypeStandard ) type SoapAPIType = original.SoapAPIType @@ -578,6 +587,12 @@ type RequestContract = original.RequestContract type RequestReportCollection = original.RequestReportCollection type RequestReportRecordContract = original.RequestReportRecordContract type Resource = original.Resource +type ResourceSku = original.ResourceSku +type ResourceSkuCapacity = original.ResourceSkuCapacity +type ResourceSkuResult = original.ResourceSkuResult +type ResourceSkuResults = original.ResourceSkuResults +type ResourceSkuResultsIterator = original.ResourceSkuResultsIterator +type ResourceSkuResultsPage = original.ResourceSkuResultsPage type ResponseContract = original.ResponseContract type SamplingSettings = original.SamplingSettings type SaveConfigurationParameter = original.SaveConfigurationParameter @@ -683,6 +698,7 @@ type QuotaByPeriodKeysClient = original.QuotaByPeriodKeysClient type RegionsClient = original.RegionsClient type ReportsClient = original.ReportsClient type ServiceClient = original.ServiceClient +type ServiceSkusClient = original.ServiceSkusClient type SignInSettingsClient = original.SignInSettingsClient type SignUpSettingsClient = original.SignUpSettingsClient type SubscriptionClient = original.SubscriptionClient @@ -919,6 +935,9 @@ func PossibleProductStateValues() []ProductState { func PossibleProtocolValues() []Protocol { return original.PossibleProtocolValues() } +func PossibleResourceSkuCapacityScaleTypeValues() []ResourceSkuCapacityScaleType { + return original.PossibleResourceSkuCapacityScaleTypeValues() +} func PossibleSamplingTypeValues() []SamplingType { return original.PossibleSamplingTypeValues() } @@ -1072,6 +1091,12 @@ func NewServiceClient(subscriptionID string) ServiceClient { func NewServiceClientWithBaseURI(baseURI string, subscriptionID string) ServiceClient { return original.NewServiceClientWithBaseURI(baseURI, subscriptionID) } +func NewServiceSkusClient(subscriptionID string) ServiceSkusClient { + return original.NewServiceSkusClient(subscriptionID) +} +func NewServiceSkusClientWithBaseURI(baseURI string, subscriptionID string) ServiceSkusClient { + return original.NewServiceSkusClientWithBaseURI(baseURI, subscriptionID) +} func NewSignInSettingsClient(subscriptionID string) SignInSettingsClient { return original.NewSignInSettingsClient(subscriptionID) } diff --git a/services/apimanagement/mgmt/2018-01-01/apimanagement/models.go b/services/apimanagement/mgmt/2018-01-01/apimanagement/models.go index c8aa2bd0b038..7dc266929c5b 100644 --- a/services/apimanagement/mgmt/2018-01-01/apimanagement/models.go +++ b/services/apimanagement/mgmt/2018-01-01/apimanagement/models.go @@ -457,6 +457,23 @@ func PossibleProtocolValues() []Protocol { return []Protocol{ProtocolHTTP, ProtocolHTTPS} } +// ResourceSkuCapacityScaleType enumerates the values for resource sku capacity scale type. +type ResourceSkuCapacityScaleType string + +const ( + // Automatic ... + Automatic ResourceSkuCapacityScaleType = "Automatic" + // Manual ... + Manual ResourceSkuCapacityScaleType = "Manual" + // None ... + None ResourceSkuCapacityScaleType = "None" +) + +// PossibleResourceSkuCapacityScaleTypeValues returns an array of possible values for the ResourceSkuCapacityScaleType const type. +func PossibleResourceSkuCapacityScaleTypeValues() []ResourceSkuCapacityScaleType { + return []ResourceSkuCapacityScaleType{Automatic, Manual, None} +} + // SkuType enumerates the values for sku type. type SkuType string @@ -8294,6 +8311,170 @@ type Resource struct { Type *string `json:"type,omitempty"` } +// ResourceSku describes an available API Management SKU. +type ResourceSku struct { + // Name - Name of the Sku. Possible values include: 'SkuTypeDeveloper', 'SkuTypeStandard', 'SkuTypePremium', 'SkuTypeBasic' + Name SkuType `json:"name,omitempty"` +} + +// ResourceSkuCapacity describes scaling information of a SKU. +type ResourceSkuCapacity struct { + // Minimum - The minimum capacity. + Minimum *int64 `json:"minimum,omitempty"` + // Maximum - The maximum capacity that can be set. + Maximum *int64 `json:"maximum,omitempty"` + // Default - The default capacity. + Default *int64 `json:"default,omitempty"` + // ScaleType - The scale type applicable to the sku. Possible values include: 'Automatic', 'Manual', 'None' + ScaleType ResourceSkuCapacityScaleType `json:"scaleType,omitempty"` +} + +// ResourceSkuResult describes an available API Management service SKU. +type ResourceSkuResult struct { + // ResourceType - The type of resource the SKU applies to. + ResourceType *string `json:"resourceType,omitempty"` + // Sku - Specifies API Management SKU. + Sku *ResourceSku `json:"sku,omitempty"` + // Capacity - Specifies the number of API Management units. + Capacity *ResourceSkuCapacity `json:"capacity,omitempty"` +} + +// ResourceSkuResults the API Management service SKUs operation response. +type ResourceSkuResults struct { + autorest.Response `json:"-"` + // Value - The list of skus available for the service. + Value *[]ResourceSkuResult `json:"value,omitempty"` + // NextLink - The uri to fetch the next page of API Management service Skus. + NextLink *string `json:"nextLink,omitempty"` +} + +// ResourceSkuResultsIterator provides access to a complete listing of ResourceSkuResult values. +type ResourceSkuResultsIterator struct { + i int + page ResourceSkuResultsPage +} + +// 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 *ResourceSkuResultsIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceSkuResultsIterator.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 *ResourceSkuResultsIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ResourceSkuResultsIterator) 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 ResourceSkuResultsIterator) Response() ResourceSkuResults { + 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 ResourceSkuResultsIterator) Value() ResourceSkuResult { + if !iter.page.NotDone() { + return ResourceSkuResult{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (rsr ResourceSkuResults) IsEmpty() bool { + return rsr.Value == nil || len(*rsr.Value) == 0 +} + +// resourceSkuResultsPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rsr ResourceSkuResults) resourceSkuResultsPreparer(ctx context.Context) (*http.Request, error) { + if rsr.NextLink == nil || len(to.String(rsr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rsr.NextLink))) +} + +// ResourceSkuResultsPage contains a page of ResourceSkuResult values. +type ResourceSkuResultsPage struct { + fn func(context.Context, ResourceSkuResults) (ResourceSkuResults, error) + rsr ResourceSkuResults +} + +// 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 *ResourceSkuResultsPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceSkuResultsPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.rsr) + if err != nil { + return err + } + page.rsr = next + 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 *ResourceSkuResultsPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ResourceSkuResultsPage) NotDone() bool { + return !page.rsr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ResourceSkuResultsPage) Response() ResourceSkuResults { + return page.rsr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ResourceSkuResultsPage) Values() []ResourceSkuResult { + if page.rsr.IsEmpty() { + return nil + } + return *page.rsr.Value +} + // ResponseContract operation response details. type ResponseContract struct { // StatusCode - Operation response HTTP status code. diff --git a/services/apimanagement/mgmt/2018-01-01/apimanagement/serviceskus.go b/services/apimanagement/mgmt/2018-01-01/apimanagement/serviceskus.go new file mode 100644 index 000000000000..d7a6c2ae8778 --- /dev/null +++ b/services/apimanagement/mgmt/2018-01-01/apimanagement/serviceskus.go @@ -0,0 +1,165 @@ +package apimanagement + +// 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" +) + +// ServiceSkusClient is the apiManagement Client +type ServiceSkusClient struct { + BaseClient +} + +// NewServiceSkusClient creates an instance of the ServiceSkusClient client. +func NewServiceSkusClient(subscriptionID string) ServiceSkusClient { + return NewServiceSkusClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServiceSkusClientWithBaseURI creates an instance of the ServiceSkusClient client. +func NewServiceSkusClientWithBaseURI(baseURI string, subscriptionID string) ServiceSkusClient { + return ServiceSkusClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListAvailableServiceSkus gets all available SKU for a given API Management service +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client ServiceSkusClient) ListAvailableServiceSkus(ctx context.Context, resourceGroupName string, serviceName string) (result ResourceSkuResultsPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceSkusClient.ListAvailableServiceSkus") + defer func() { + sc := -1 + if result.rsr.Response.Response != nil { + sc = result.rsr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ServiceSkusClient", "ListAvailableServiceSkus", err.Error()) + } + + result.fn = client.listAvailableServiceSkusNextResults + req, err := client.ListAvailableServiceSkusPreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceSkusClient", "ListAvailableServiceSkus", nil, "Failure preparing request") + return + } + + resp, err := client.ListAvailableServiceSkusSender(req) + if err != nil { + result.rsr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ServiceSkusClient", "ListAvailableServiceSkus", resp, "Failure sending request") + return + } + + result.rsr, err = client.ListAvailableServiceSkusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceSkusClient", "ListAvailableServiceSkus", resp, "Failure responding to request") + } + + return +} + +// ListAvailableServiceSkusPreparer prepares the ListAvailableServiceSkus request. +func (client ServiceSkusClient) ListAvailableServiceSkusPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/skus", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListAvailableServiceSkusSender sends the ListAvailableServiceSkus request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceSkusClient) ListAvailableServiceSkusSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListAvailableServiceSkusResponder handles the response to the ListAvailableServiceSkus request. The method always +// closes the http.Response Body. +func (client ServiceSkusClient) ListAvailableServiceSkusResponder(resp *http.Response) (result ResourceSkuResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listAvailableServiceSkusNextResults retrieves the next set of results, if any. +func (client ServiceSkusClient) listAvailableServiceSkusNextResults(ctx context.Context, lastResults ResourceSkuResults) (result ResourceSkuResults, err error) { + req, err := lastResults.resourceSkuResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ServiceSkusClient", "listAvailableServiceSkusNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListAvailableServiceSkusSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ServiceSkusClient", "listAvailableServiceSkusNextResults", resp, "Failure sending next results request") + } + result, err = client.ListAvailableServiceSkusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceSkusClient", "listAvailableServiceSkusNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListAvailableServiceSkusComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServiceSkusClient) ListAvailableServiceSkusComplete(ctx context.Context, resourceGroupName string, serviceName string) (result ResourceSkuResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceSkusClient.ListAvailableServiceSkus") + 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.ListAvailableServiceSkus(ctx, resourceGroupName, serviceName) + return +} diff --git a/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/models.go b/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/models.go index 75d5b1b42ae8..01537986719f 100644 --- a/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/models.go +++ b/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/models.go @@ -470,6 +470,23 @@ func PossibleProtocolValues() []Protocol { return []Protocol{ProtocolHTTP, ProtocolHTTPS} } +// ResourceSkuCapacityScaleType enumerates the values for resource sku capacity scale type. +type ResourceSkuCapacityScaleType string + +const ( + // Automatic ... + Automatic ResourceSkuCapacityScaleType = "Automatic" + // Manual ... + Manual ResourceSkuCapacityScaleType = "Manual" + // None ... + None ResourceSkuCapacityScaleType = "None" +) + +// PossibleResourceSkuCapacityScaleTypeValues returns an array of possible values for the ResourceSkuCapacityScaleType const type. +func PossibleResourceSkuCapacityScaleTypeValues() []ResourceSkuCapacityScaleType { + return []ResourceSkuCapacityScaleType{Automatic, Manual, None} +} + // SamplingType enumerates the values for sampling type. type SamplingType string @@ -489,6 +506,8 @@ type SkuType string const ( // SkuTypeBasic Basic SKU of Api Management. SkuTypeBasic SkuType = "Basic" + // SkuTypeConsumption Consumption SKU of Api Management. + SkuTypeConsumption SkuType = "Consumption" // SkuTypeDeveloper Developer SKU of Api Management. SkuTypeDeveloper SkuType = "Developer" // SkuTypePremium Premium SKU of Api Management. @@ -499,7 +518,7 @@ const ( // PossibleSkuTypeValues returns an array of possible values for the SkuType const type. func PossibleSkuTypeValues() []SkuType { - return []SkuType{SkuTypeBasic, SkuTypeDeveloper, SkuTypePremium, SkuTypeStandard} + return []SkuType{SkuTypeBasic, SkuTypeConsumption, SkuTypeDeveloper, SkuTypePremium, SkuTypeStandard} } // SoapAPIType enumerates the values for soap api type. @@ -8367,6 +8386,170 @@ type Resource struct { Type *string `json:"type,omitempty"` } +// ResourceSku describes an available API Management SKU. +type ResourceSku struct { + // Name - Name of the Sku. Possible values include: 'SkuTypeDeveloper', 'SkuTypeStandard', 'SkuTypePremium', 'SkuTypeBasic', 'SkuTypeConsumption' + Name SkuType `json:"name,omitempty"` +} + +// ResourceSkuCapacity describes scaling information of a SKU. +type ResourceSkuCapacity struct { + // Minimum - The minimum capacity. + Minimum *int64 `json:"minimum,omitempty"` + // Maximum - The maximum capacity that can be set. + Maximum *int64 `json:"maximum,omitempty"` + // Default - The default capacity. + Default *int64 `json:"default,omitempty"` + // ScaleType - The scale type applicable to the sku. Possible values include: 'Automatic', 'Manual', 'None' + ScaleType ResourceSkuCapacityScaleType `json:"scaleType,omitempty"` +} + +// ResourceSkuResult describes an available API Management service SKU. +type ResourceSkuResult struct { + // ResourceType - The type of resource the SKU applies to. + ResourceType *string `json:"resourceType,omitempty"` + // Sku - Specifies API Management SKU. + Sku *ResourceSku `json:"sku,omitempty"` + // Capacity - Specifies the number of API Management units. + Capacity *ResourceSkuCapacity `json:"capacity,omitempty"` +} + +// ResourceSkuResults the API Management service SKUs operation response. +type ResourceSkuResults struct { + autorest.Response `json:"-"` + // Value - The list of skus available for the service. + Value *[]ResourceSkuResult `json:"value,omitempty"` + // NextLink - The uri to fetch the next page of API Management service Skus. + NextLink *string `json:"nextLink,omitempty"` +} + +// ResourceSkuResultsIterator provides access to a complete listing of ResourceSkuResult values. +type ResourceSkuResultsIterator struct { + i int + page ResourceSkuResultsPage +} + +// 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 *ResourceSkuResultsIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceSkuResultsIterator.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 *ResourceSkuResultsIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ResourceSkuResultsIterator) 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 ResourceSkuResultsIterator) Response() ResourceSkuResults { + 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 ResourceSkuResultsIterator) Value() ResourceSkuResult { + if !iter.page.NotDone() { + return ResourceSkuResult{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (rsr ResourceSkuResults) IsEmpty() bool { + return rsr.Value == nil || len(*rsr.Value) == 0 +} + +// resourceSkuResultsPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rsr ResourceSkuResults) resourceSkuResultsPreparer(ctx context.Context) (*http.Request, error) { + if rsr.NextLink == nil || len(to.String(rsr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rsr.NextLink))) +} + +// ResourceSkuResultsPage contains a page of ResourceSkuResult values. +type ResourceSkuResultsPage struct { + fn func(context.Context, ResourceSkuResults) (ResourceSkuResults, error) + rsr ResourceSkuResults +} + +// 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 *ResourceSkuResultsPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceSkuResultsPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.rsr) + if err != nil { + return err + } + page.rsr = next + 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 *ResourceSkuResultsPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ResourceSkuResultsPage) NotDone() bool { + return !page.rsr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ResourceSkuResultsPage) Response() ResourceSkuResults { + return page.rsr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ResourceSkuResultsPage) Values() []ResourceSkuResult { + if page.rsr.IsEmpty() { + return nil + } + return *page.rsr.Value +} + // ResponseContract operation response details. type ResponseContract struct { // StatusCode - Operation response HTTP status code. @@ -9332,7 +9515,7 @@ func (future *ServiceRestoreFuture) Result(client ServiceClient) (sr ServiceReso // ServiceSkuProperties API Management service resource SKU properties. type ServiceSkuProperties struct { - // Name - Name of the Sku. Possible values include: 'SkuTypeDeveloper', 'SkuTypeStandard', 'SkuTypePremium', 'SkuTypeBasic' + // Name - Name of the Sku. Possible values include: 'SkuTypeDeveloper', 'SkuTypeStandard', 'SkuTypePremium', 'SkuTypeBasic', 'SkuTypeConsumption' Name SkuType `json:"name,omitempty"` // Capacity - Capacity of the SKU (number of deployed units of the SKU). The default value is 1. Capacity *int32 `json:"capacity,omitempty"` diff --git a/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/serviceskus.go b/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/serviceskus.go new file mode 100644 index 000000000000..346249aa265f --- /dev/null +++ b/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/serviceskus.go @@ -0,0 +1,165 @@ +package apimanagement + +// 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" +) + +// ServiceSkusClient is the apiManagement Client +type ServiceSkusClient struct { + BaseClient +} + +// NewServiceSkusClient creates an instance of the ServiceSkusClient client. +func NewServiceSkusClient(subscriptionID string) ServiceSkusClient { + return NewServiceSkusClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServiceSkusClientWithBaseURI creates an instance of the ServiceSkusClient client. +func NewServiceSkusClientWithBaseURI(baseURI string, subscriptionID string) ServiceSkusClient { + return ServiceSkusClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListAvailableServiceSkus gets all available SKU for a given API Management service +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client ServiceSkusClient) ListAvailableServiceSkus(ctx context.Context, resourceGroupName string, serviceName string) (result ResourceSkuResultsPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceSkusClient.ListAvailableServiceSkus") + defer func() { + sc := -1 + if result.rsr.Response.Response != nil { + sc = result.rsr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ServiceSkusClient", "ListAvailableServiceSkus", err.Error()) + } + + result.fn = client.listAvailableServiceSkusNextResults + req, err := client.ListAvailableServiceSkusPreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceSkusClient", "ListAvailableServiceSkus", nil, "Failure preparing request") + return + } + + resp, err := client.ListAvailableServiceSkusSender(req) + if err != nil { + result.rsr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ServiceSkusClient", "ListAvailableServiceSkus", resp, "Failure sending request") + return + } + + result.rsr, err = client.ListAvailableServiceSkusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceSkusClient", "ListAvailableServiceSkus", resp, "Failure responding to request") + } + + return +} + +// ListAvailableServiceSkusPreparer prepares the ListAvailableServiceSkus request. +func (client ServiceSkusClient) ListAvailableServiceSkusPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/skus", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListAvailableServiceSkusSender sends the ListAvailableServiceSkus request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceSkusClient) ListAvailableServiceSkusSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListAvailableServiceSkusResponder handles the response to the ListAvailableServiceSkus request. The method always +// closes the http.Response Body. +func (client ServiceSkusClient) ListAvailableServiceSkusResponder(resp *http.Response) (result ResourceSkuResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listAvailableServiceSkusNextResults retrieves the next set of results, if any. +func (client ServiceSkusClient) listAvailableServiceSkusNextResults(ctx context.Context, lastResults ResourceSkuResults) (result ResourceSkuResults, err error) { + req, err := lastResults.resourceSkuResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ServiceSkusClient", "listAvailableServiceSkusNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListAvailableServiceSkusSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ServiceSkusClient", "listAvailableServiceSkusNextResults", resp, "Failure sending next results request") + } + result, err = client.ListAvailableServiceSkusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceSkusClient", "listAvailableServiceSkusNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListAvailableServiceSkusComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServiceSkusClient) ListAvailableServiceSkusComplete(ctx context.Context, resourceGroupName string, serviceName string) (result ResourceSkuResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceSkusClient.ListAvailableServiceSkus") + 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.ListAvailableServiceSkus(ctx, resourceGroupName, serviceName) + return +} From 5640bc238d4a99226b2391aafec56570ad07432e Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Thu, 15 Nov 2018 00:13:06 +0000 Subject: [PATCH 2/2] Generated from 6f7dd127dd96f0607dc0e9ed851a66af33e7ba36 PR comments addressed --- .../mgmt/2018-06-01-preview/apimanagement/models.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/models.go b/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/models.go index 01537986719f..0ea00a704f28 100644 --- a/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/models.go +++ b/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/models.go @@ -474,11 +474,11 @@ func PossibleProtocolValues() []Protocol { type ResourceSkuCapacityScaleType string const ( - // Automatic ... + // Automatic Supported scale type automatic. Automatic ResourceSkuCapacityScaleType = "Automatic" - // Manual ... + // Manual Supported scale type manual. Manual ResourceSkuCapacityScaleType = "Manual" - // None ... + // None Scaling not supported. None ResourceSkuCapacityScaleType = "None" ) @@ -8395,11 +8395,11 @@ type ResourceSku struct { // ResourceSkuCapacity describes scaling information of a SKU. type ResourceSkuCapacity struct { // Minimum - The minimum capacity. - Minimum *int64 `json:"minimum,omitempty"` + Minimum *int32 `json:"minimum,omitempty"` // Maximum - The maximum capacity that can be set. - Maximum *int64 `json:"maximum,omitempty"` + Maximum *int32 `json:"maximum,omitempty"` // Default - The default capacity. - Default *int64 `json:"default,omitempty"` + Default *int32 `json:"default,omitempty"` // ScaleType - The scale type applicable to the sku. Possible values include: 'Automatic', 'Manual', 'None' ScaleType ResourceSkuCapacityScaleType `json:"scaleType,omitempty"` }