diff --git a/.teamcity/components/generated/services.kt b/.teamcity/components/generated/services.kt index 1f98d158e478..30fb775e5d0c 100644 --- a/.teamcity/components/generated/services.kt +++ b/.teamcity/components/generated/services.kt @@ -1,6 +1,7 @@ // NOTE: this is Generated from the Service Definitions - manual changes will be lost // to re-generate this file, run 'make generate' in the root of the repository var services = mapOf( + "advisor" to "Advisor", "analysisservices" to "Analysis Services", "apimanagement" to "API Management", "appconfiguration" to "App Configuration", diff --git a/azurerm/helpers/azure/resource_group.go b/azurerm/helpers/azure/resource_group.go index 7967f69f7bf8..9e171683fb14 100644 --- a/azurerm/helpers/azure/resource_group.go +++ b/azurerm/helpers/azure/resource_group.go @@ -46,6 +46,17 @@ func SchemaResourceGroupNameOptionalComputed() *schema.Schema { } } +func SchemaResourceGroupNameSetOptional() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validateResourceGroupName, + }, + } +} + func validateResourceGroupName(v interface{}, k string) (warnings []string, errors []error) { value := v.(string) diff --git a/azurerm/internal/clients/client.go b/azurerm/internal/clients/client.go index 9ff95f3f34de..305e8b78c514 100644 --- a/azurerm/internal/clients/client.go +++ b/azurerm/internal/clients/client.go @@ -6,6 +6,7 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" + advisor "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/advisor/client" analysisServices "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/analysisservices/client" apiManagement "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/apimanagement/client" appConfiguration "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/appconfiguration/client" @@ -87,6 +88,7 @@ type Client struct { Account *ResourceManagerAccount Features features.UserFeatures + Advisor *advisor.Client AnalysisServices *analysisServices.Client ApiManagement *apiManagement.Client AppConfiguration *appConfiguration.Client @@ -169,6 +171,7 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error client.Features = o.Features client.StopContext = ctx + client.Advisor = advisor.NewClient(o) client.AnalysisServices = analysisServices.NewClient(o) client.ApiManagement = apiManagement.NewClient(o) client.AppConfiguration = appConfiguration.NewClient(o) diff --git a/azurerm/internal/provider/services.go b/azurerm/internal/provider/services.go index 28d564713f85..b95deb04e9ef 100644 --- a/azurerm/internal/provider/services.go +++ b/azurerm/internal/provider/services.go @@ -1,6 +1,7 @@ package provider import ( + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/advisor" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/analysisservices" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/apimanagement" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/appconfiguration" @@ -80,6 +81,7 @@ import ( func SupportedServices() []common.ServiceRegistration { return []common.ServiceRegistration{ + advisor.Registration{}, analysisservices.Registration{}, apimanagement.Registration{}, appconfiguration.Registration{}, diff --git a/azurerm/internal/services/advisor/client/client.go b/azurerm/internal/services/advisor/client/client.go new file mode 100644 index 000000000000..320fd0750d37 --- /dev/null +++ b/azurerm/internal/services/advisor/client/client.go @@ -0,0 +1,19 @@ +package client + +import ( + "github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common" +) + +type Client struct { + RecommendationsClient *advisor.RecommendationsClient +} + +func NewClient(o *common.ClientOptions) *Client { + recommendationsClient := advisor.NewRecommendationsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + o.ConfigureClient(&recommendationsClient.Client, o.ResourceManagerAuthorizer) + + return &Client{ + RecommendationsClient: &recommendationsClient, + } +} diff --git a/azurerm/internal/services/advisor/data_source_advisor_recommendations.go b/azurerm/internal/services/advisor/data_source_advisor_recommendations.go new file mode 100644 index 000000000000..8e8e3d2df081 --- /dev/null +++ b/azurerm/internal/services/advisor/data_source_advisor_recommendations.go @@ -0,0 +1,212 @@ +package advisor + +import ( + "fmt" + "strings" + "time" + + "github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + uuid "github.com/satori/go.uuid" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" +) + +func dataSourceArmAdvisorRecommendations() *schema.Resource { + return &schema.Resource{ + Read: dataSourceArmAdvisorRecommendationsRead, + + Timeouts: &schema.ResourceTimeout{ + Read: schema.DefaultTimeout(10 * time.Minute), + }, + + Schema: map[string]*schema.Schema{ + "filter_by_category": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringInSlice([]string{ + string(advisor.HighAvailability), + string(advisor.Security), + string(advisor.Performance), + string(advisor.Cost), + string(advisor.OperationalExcellence)}, true), + }, + }, + + "filter_by_resource_groups": azure.SchemaResourceGroupNameSetOptional(), + + "recommendations": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "category": { + Type: schema.TypeString, + Computed: true, + }, + + "description": { + Type: schema.TypeString, + Computed: true, + }, + + "impact": { + Type: schema.TypeString, + Computed: true, + }, + + "recommendation_name": { + Type: schema.TypeString, + Computed: true, + }, + + "recommendation_type_id": { + Type: schema.TypeString, + Computed: true, + }, + + "resource_name": { + Type: schema.TypeString, + Computed: true, + }, + + "resource_type": { + Type: schema.TypeString, + Computed: true, + }, + + "suppression_names": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + + "updated_time": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + }, + } +} + +func dataSourceArmAdvisorRecommendationsRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Advisor.RecommendationsClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) + defer cancel() + + filterList := make([]string, 0) + if categories := expandAzureRmAdvisorRecommendationsMapString("Category", d.Get("filter_by_category").(*schema.Set).List()); categories != "" { + filterList = append(filterList, categories) + } + if resGroups := expandAzureRmAdvisorRecommendationsMapString("ResourceGroup", d.Get("filter_by_resource_groups").(*schema.Set).List()); resGroups != "" { + filterList = append(filterList, resGroups) + } + + var recommends []advisor.ResourceRecommendationBase + for recommendationIterator, err := client.ListComplete(ctx, strings.Join(filterList, " and "), nil, ""); recommendationIterator.NotDone(); err = recommendationIterator.NextWithContext(ctx) { + if err != nil { + return fmt.Errorf("loading Advisor Recommendation List: %+v", err) + } + + if recommendationIterator.Value().Name == nil || *recommendationIterator.Value().Name == "" { + return fmt.Errorf("advisor Recommendation Name was nil or empty") + } + + recommends = append(recommends, recommendationIterator.Value()) + } + + if err := d.Set("recommendations", flattenAzureRmAdvisorRecommendations(recommends)); err != nil { + return fmt.Errorf("setting `recommendations`: %+v", err) + } + + d.SetId(fmt.Sprintf("avdisor/recommendations/%s", time.Now().UTC().String())) + + return nil +} + +func flattenAzureRmAdvisorRecommendations(recommends []advisor.ResourceRecommendationBase) []interface{} { + result := make([]interface{}, 0) + + if len(recommends) == 0 { + return result + } + + for _, v := range recommends { + var category, description, impact, recTypeId, resourceName, resourceType, updatedTime string + var suppressionIds []interface{} + if v.Category != "" { + category = string(v.Category) + } + + if v.ShortDescription != nil && v.ShortDescription.Problem != nil { + description = *v.ShortDescription.Problem + } + + if v.Impact != "" { + impact = string(v.Impact) + } + + if v.RecommendationTypeID != nil { + recTypeId = *v.RecommendationTypeID + } + + if v.ImpactedValue != nil { + resourceName = *v.ImpactedValue + } + + if v.ImpactedField != nil { + resourceType = *v.ImpactedField + } + + if v.SuppressionIds != nil { + suppressionIds = flattenSuppressionSlice(v.SuppressionIds) + } + if v.LastUpdated != nil && !v.LastUpdated.IsZero() { + updatedTime = v.LastUpdated.Format(time.RFC3339) + } + + result = append(result, map[string]interface{}{ + "category": category, + "description": description, + "impact": impact, + "recommendation_name": *v.Name, + "recommendation_type_id": recTypeId, + "resource_name": resourceName, + "resource_type": resourceType, + "suppression_names": suppressionIds, + "updated_time": updatedTime, + }) + } + + return result +} + +func expandAzureRmAdvisorRecommendationsMapString(t string, input []interface{}) string { + if len(input) == 0 { + return "" + } + result := make([]string, 0) + for _, v := range input { + result = append(result, fmt.Sprintf("%s eq '%s'", t, v.(string))) + } + return "(" + strings.Join(result, " or ") + ")" +} + +func flattenSuppressionSlice(input *[]uuid.UUID) []interface{} { + result := make([]interface{}, 0) + if input != nil { + for _, item := range *input { + result = append(result, item.String()) + } + } + return result +} diff --git a/azurerm/internal/services/advisor/registration.go b/azurerm/internal/services/advisor/registration.go new file mode 100644 index 000000000000..c342faee6b35 --- /dev/null +++ b/azurerm/internal/services/advisor/registration.go @@ -0,0 +1,31 @@ +package advisor + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" +) + +type Registration struct{} + +// Name is the name of this Service +func (r Registration) Name() string { + return "Advisor" +} + +// WebsiteCategories returns a list of categories which can be used for the sidebar +func (r Registration) WebsiteCategories() []string { + return []string{ + "Advisor", + } +} + +// SupportedDataSources returns the supported Data Sources supported by this Service +func (r Registration) SupportedDataSources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "azurerm_advisor_recommendations": dataSourceArmAdvisorRecommendations(), + } +} + +// SupportedResources returns the supported Resources supported by this Service +func (r Registration) SupportedResources() map[string]*schema.Resource { + return map[string]*schema.Resource{} +} diff --git a/azurerm/internal/services/advisor/tests/data_source_advisor_recommendations_test.go b/azurerm/internal/services/advisor/tests/data_source_advisor_recommendations_test.go new file mode 100644 index 000000000000..b0c34990b247 --- /dev/null +++ b/azurerm/internal/services/advisor/tests/data_source_advisor_recommendations_test.go @@ -0,0 +1,117 @@ +package tests + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" +) + +func TestAccDataSourceAzureRMAdvisorRecommendations_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "data.azurerm_advisor_recommendations", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + Steps: []resource.TestStep{ + { + Config: testAccCheckArmAdvisorRecommendations_basic, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet(data.ResourceName, "recommendations.#"), + resource.TestCheckResourceAttrSet(data.ResourceName, "recommendations.0.category"), + resource.TestCheckResourceAttrSet(data.ResourceName, "recommendations.0.description"), + resource.TestCheckResourceAttrSet(data.ResourceName, "recommendations.0.impact"), + resource.TestCheckResourceAttrSet(data.ResourceName, "recommendations.0.recommendation_name"), + resource.TestCheckResourceAttrSet(data.ResourceName, "recommendations.0.recommendation_type_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "recommendations.0.resource_name"), + resource.TestCheckResourceAttrSet(data.ResourceName, "recommendations.0.resource_type"), + resource.TestCheckResourceAttrSet(data.ResourceName, "recommendations.0.updated_time"), + ), + }, + }, + }) +} + +func TestAccDataSourceAzureRMAdvisorRecommendations_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "data.azurerm_advisor_recommendations", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + Steps: []resource.TestStep{ + { + Config: testAccCheckArmAdvisorRecommendations_complete(data), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet(data.ResourceName, "recommendations.#"), + ), + }, + }, + }) +} + +func TestAccDataSourceAzureRMAdvisorRecommendations_categoriesFilter(t *testing.T) { + data := acceptance.BuildTestData(t, "data.azurerm_advisor_recommendations", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + Steps: []resource.TestStep{ + { + Config: testAccCheckArmAdvisorRecommendations_categoriesFilter, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet(data.ResourceName, "recommendations.#"), + resource.TestCheckResourceAttr(data.ResourceName, "recommendations.0.category", "Cost"), + ), + }, + }, + }) +} + +const testAccCheckArmAdvisorRecommendations_basic = ` +provider "azurerm" { + features {} +} + +data "azurerm_advisor_recommendations" "test" { } +` + +//Advisor genereate recommendations needs long time to take effects, sometimes up to one day or more, +//Please refer to the issue https://github.com/Azure/azure-rest-api-specs/issues/9284 +//So here we get an empty list of recommendations +func testAccCheckArmAdvisorRecommendations_complete(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-advisor-%d" + location = "%s" +} + +resource "azurerm_storage_account" "test" { + name = "accteststr%s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + enable_https_traffic_only = false + account_tier = "Standard" + account_replication_type = "LRS" +} + +data "azurerm_advisor_recommendations" "test" { + filter_by_category = ["security"] + filter_by_resource_groups = [azurerm_resource_group.test.name] +} +`, data.RandomInteger, data.Locations.Primary, data.RandomString) +} + +const testAccCheckArmAdvisorRecommendations_categoriesFilter = ` +provider "azurerm" { + features {} +} + +data "azurerm_advisor_recommendations" "test" { + filter_by_category = ["cost"] +} +` diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/client.go new file mode 100644 index 000000000000..8a901d441592 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/client.go @@ -0,0 +1,52 @@ +// Package advisor implements the Azure ARM Advisor service API version 2020-01-01. +// +// REST APIs for Azure Advisor +package advisor + +// 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 ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Advisor + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Advisor. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// 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, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/configurations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/configurations.go new file mode 100644 index 000000000000..acbc2b0efd5c --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/configurations.go @@ -0,0 +1,381 @@ +package advisor + +// 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" +) + +// ConfigurationsClient is the REST APIs for Azure Advisor +type ConfigurationsClient struct { + BaseClient +} + +// NewConfigurationsClient creates an instance of the ConfigurationsClient client. +func NewConfigurationsClient(subscriptionID string) ConfigurationsClient { + return NewConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConfigurationsClientWithBaseURI creates an instance of the ConfigurationsClient 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 NewConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) ConfigurationsClient { + return ConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateInResourceGroup sends the create in resource group request. +// Parameters: +// configContract - the Azure Advisor configuration data structure. +// resourceGroup - the name of the Azure resource group. +func (client ConfigurationsClient) CreateInResourceGroup(ctx context.Context, configContract ConfigData, resourceGroup string) (result ConfigData, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.CreateInResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateInResourceGroupPreparer(ctx, configContract, resourceGroup) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.ConfigurationsClient", "CreateInResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.CreateInResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "advisor.ConfigurationsClient", "CreateInResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.CreateInResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.ConfigurationsClient", "CreateInResourceGroup", resp, "Failure responding to request") + } + + return +} + +// CreateInResourceGroupPreparer prepares the CreateInResourceGroup request. +func (client ConfigurationsClient) CreateInResourceGroupPreparer(ctx context.Context, configContract ConfigData, resourceGroup string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationName": autorest.Encode("path", "default"), + "resourceGroup": autorest.Encode("path", resourceGroup), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + 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}/resourceGroups/{resourceGroup}/providers/Microsoft.Advisor/configurations/{configurationName}", pathParameters), + autorest.WithJSON(configContract), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateInResourceGroupSender sends the CreateInResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationsClient) CreateInResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateInResourceGroupResponder handles the response to the CreateInResourceGroup request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) CreateInResourceGroupResponder(resp *http.Response) (result ConfigData, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateInSubscription create/Overwrite Azure Advisor configuration and also delete all configurations of contained +// resource groups. +// Parameters: +// configContract - the Azure Advisor configuration data structure. +func (client ConfigurationsClient) CreateInSubscription(ctx context.Context, configContract ConfigData) (result ConfigData, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.CreateInSubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateInSubscriptionPreparer(ctx, configContract) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.ConfigurationsClient", "CreateInSubscription", nil, "Failure preparing request") + return + } + + resp, err := client.CreateInSubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "advisor.ConfigurationsClient", "CreateInSubscription", resp, "Failure sending request") + return + } + + result, err = client.CreateInSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.ConfigurationsClient", "CreateInSubscription", resp, "Failure responding to request") + } + + return +} + +// CreateInSubscriptionPreparer prepares the CreateInSubscription request. +func (client ConfigurationsClient) CreateInSubscriptionPreparer(ctx context.Context, configContract ConfigData) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationName": autorest.Encode("path", "default"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + 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.Advisor/configurations/{configurationName}", pathParameters), + autorest.WithJSON(configContract), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateInSubscriptionSender sends the CreateInSubscription request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationsClient) CreateInSubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateInSubscriptionResponder handles the response to the CreateInSubscription request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) CreateInSubscriptionResponder(resp *http.Response) (result ConfigData, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup sends the list by resource group request. +// Parameters: +// resourceGroup - the name of the Azure resource group. +func (client ConfigurationsClient) ListByResourceGroup(ctx context.Context, resourceGroup string) (result ConfigurationListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroup) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.ConfigurationsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "advisor.ConfigurationsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.ConfigurationsClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ConfigurationsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroup string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroup": autorest.Encode("path", resourceGroup), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Advisor/configurations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) ListByResourceGroupResponder(resp *http.Response) (result ConfigurationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscription retrieve Azure Advisor configurations and also retrieve configurations of contained resource +// groups. +func (client ConfigurationsClient) ListBySubscription(ctx context.Context) (result ConfigurationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.ListBySubscription") + defer func() { + sc := -1 + if result.clr.Response.Response != nil { + sc = result.clr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.ConfigurationsClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.clr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "advisor.ConfigurationsClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.clr, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.ConfigurationsClient", "ListBySubscription", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client ConfigurationsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/configurations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) ListBySubscriptionResponder(resp *http.Response) (result ConfigurationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client ConfigurationsClient) listBySubscriptionNextResults(ctx context.Context, lastResults ConfigurationListResult) (result ConfigurationListResult, err error) { + req, err := lastResults.configurationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "advisor.ConfigurationsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "advisor.ConfigurationsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.ConfigurationsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client ConfigurationsClient) ListBySubscriptionComplete(ctx context.Context) (result ConfigurationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.ListBySubscription") + 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.ListBySubscription(ctx) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/models.go new file mode 100644 index 000000000000..5a7e0be43769 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/models.go @@ -0,0 +1,1356 @@ +package advisor + +// 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/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "github.com/satori/go.uuid" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor" + +// Category enumerates the values for category. +type Category string + +const ( + // Cost ... + Cost Category = "Cost" + // HighAvailability ... + HighAvailability Category = "HighAvailability" + // OperationalExcellence ... + OperationalExcellence Category = "OperationalExcellence" + // Performance ... + Performance Category = "Performance" + // Security ... + Security Category = "Security" +) + +// PossibleCategoryValues returns an array of possible values for the Category const type. +func PossibleCategoryValues() []Category { + return []Category{Cost, HighAvailability, OperationalExcellence, Performance, Security} +} + +// CPUThreshold enumerates the values for cpu threshold. +type CPUThreshold string + +const ( + // Five ... + Five CPUThreshold = "5" + // OneFive ... + OneFive CPUThreshold = "15" + // OneZero ... + OneZero CPUThreshold = "10" + // TwoZero ... + TwoZero CPUThreshold = "20" +) + +// PossibleCPUThresholdValues returns an array of possible values for the CPUThreshold const type. +func PossibleCPUThresholdValues() []CPUThreshold { + return []CPUThreshold{Five, OneFive, OneZero, TwoZero} +} + +// DigestConfigState enumerates the values for digest config state. +type DigestConfigState string + +const ( + // Active ... + Active DigestConfigState = "Active" + // Disabled ... + Disabled DigestConfigState = "Disabled" +) + +// PossibleDigestConfigStateValues returns an array of possible values for the DigestConfigState const type. +func PossibleDigestConfigStateValues() []DigestConfigState { + return []DigestConfigState{Active, Disabled} +} + +// Impact enumerates the values for impact. +type Impact string + +const ( + // High ... + High Impact = "High" + // Low ... + Low Impact = "Low" + // Medium ... + Medium Impact = "Medium" +) + +// PossibleImpactValues returns an array of possible values for the Impact const type. +func PossibleImpactValues() []Impact { + return []Impact{High, Low, Medium} +} + +// Risk enumerates the values for risk. +type Risk string + +const ( + // Error ... + Error Risk = "Error" + // None ... + None Risk = "None" + // Warning ... + Warning Risk = "Warning" +) + +// PossibleRiskValues returns an array of possible values for the Risk const type. +func PossibleRiskValues() []Risk { + return []Risk{Error, None, Warning} +} + +// Scenario enumerates the values for scenario. +type Scenario string + +const ( + // Alerts ... + Alerts Scenario = "Alerts" +) + +// PossibleScenarioValues returns an array of possible values for the Scenario const type. +func PossibleScenarioValues() []Scenario { + return []Scenario{Alerts} +} + +// ArmErrorResponse ... +type ArmErrorResponse struct { + Error *ARMErrorResponseBody `json:"error,omitempty"` +} + +// ARMErrorResponseBody ARM error response body. +type ARMErrorResponseBody struct { + // Message - Gets or sets the string that describes the error in detail and provides debugging information. + Message *string `json:"message,omitempty"` + // Code - Gets or sets the string that can be used to programmatically identify the error. + Code *string `json:"code,omitempty"` +} + +// ConfigData the Advisor configuration data structure. +type ConfigData struct { + autorest.Response `json:"-"` + // ConfigDataProperties - The Advisor configuration data structure. + *ConfigDataProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConfigData. +func (cd ConfigData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cd.ConfigDataProperties != nil { + objectMap["properties"] = cd.ConfigDataProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ConfigData struct. +func (cd *ConfigData) 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 configDataProperties ConfigDataProperties + err = json.Unmarshal(*v, &configDataProperties) + if err != nil { + return err + } + cd.ConfigDataProperties = &configDataProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + cd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + cd.Type = &typeVar + } + } + } + + return nil +} + +// ConfigDataProperties configuration data properties +type ConfigDataProperties struct { + // Exclude - Exclude the resource from Advisor evaluations. Valid values: False (default) or True. + Exclude *bool `json:"exclude,omitempty"` + // LowCPUThreshold - Minimum percentage threshold for Advisor low CPU utilization evaluation. Valid only for subscriptions. Valid values: 5 (default), 10, 15 or 20. Possible values include: 'Five', 'OneZero', 'OneFive', 'TwoZero' + LowCPUThreshold CPUThreshold `json:"lowCpuThreshold,omitempty"` + // Digests - Advisor digest configuration. Valid only for subscriptions + Digests *[]DigestConfig `json:"digests,omitempty"` +} + +// ConfigurationListResult the list of Advisor configurations. +type ConfigurationListResult struct { + autorest.Response `json:"-"` + // Value - The list of configurations. + Value *[]ConfigData `json:"value,omitempty"` + // NextLink - The link used to get the next page of configurations. + NextLink *string `json:"nextLink,omitempty"` +} + +// ConfigurationListResultIterator provides access to a complete listing of ConfigData values. +type ConfigurationListResultIterator struct { + i int + page ConfigurationListResultPage +} + +// 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 *ConfigurationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationListResultIterator.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 *ConfigurationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ConfigurationListResultIterator) 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 ConfigurationListResultIterator) Response() ConfigurationListResult { + 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 ConfigurationListResultIterator) Value() ConfigData { + if !iter.page.NotDone() { + return ConfigData{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ConfigurationListResultIterator type. +func NewConfigurationListResultIterator(page ConfigurationListResultPage) ConfigurationListResultIterator { + return ConfigurationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (clr ConfigurationListResult) IsEmpty() bool { + return clr.Value == nil || len(*clr.Value) == 0 +} + +// configurationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (clr ConfigurationListResult) configurationListResultPreparer(ctx context.Context) (*http.Request, error) { + if clr.NextLink == nil || len(to.String(clr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(clr.NextLink))) +} + +// ConfigurationListResultPage contains a page of ConfigData values. +type ConfigurationListResultPage struct { + fn func(context.Context, ConfigurationListResult) (ConfigurationListResult, error) + clr ConfigurationListResult +} + +// 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 *ConfigurationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationListResultPage.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.clr) + if err != nil { + return err + } + page.clr = 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 *ConfigurationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ConfigurationListResultPage) NotDone() bool { + return !page.clr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ConfigurationListResultPage) Response() ConfigurationListResult { + return page.clr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ConfigurationListResultPage) Values() []ConfigData { + if page.clr.IsEmpty() { + return nil + } + return *page.clr.Value +} + +// Creates a new instance of the ConfigurationListResultPage type. +func NewConfigurationListResultPage(getNextPage func(context.Context, ConfigurationListResult) (ConfigurationListResult, error)) ConfigurationListResultPage { + return ConfigurationListResultPage{fn: getNextPage} +} + +// DigestConfig advisor Digest configuration entity +type DigestConfig struct { + // Name - Name of digest configuration. Value is case-insensitive and must be unique within a subscription. + Name *string `json:"name,omitempty"` + // ActionGroupResourceID - Action group resource id used by digest. + ActionGroupResourceID *string `json:"actionGroupResourceId,omitempty"` + // Frequency - Frequency that digest will be triggered, in days. Value must be between 7 and 30 days inclusive. + Frequency *int32 `json:"frequency,omitempty"` + // Categories - Categories to send digest for. If categories are not provided, then digest will be sent for all categories. + Categories *[]Category `json:"categories,omitempty"` + // Language - Language for digest content body. Value must be ISO 639-1 code for one of Azure portal supported languages. Otherwise, it will be converted into one. Default value is English (en). + Language *string `json:"language,omitempty"` + // State - State of digest configuration. Possible values include: 'Active', 'Disabled' + State DigestConfigState `json:"state,omitempty"` +} + +// MetadataEntity the metadata entity contract. +type MetadataEntity struct { + // ID - The resource Id of the metadata entity. + ID *string `json:"id,omitempty"` + // Type - The type of the metadata entity. + Type *string `json:"type,omitempty"` + // Name - The name of the metadata entity. + Name *string `json:"name,omitempty"` + // MetadataEntityProperties - The metadata entity properties. + *MetadataEntityProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetadataEntity. +func (me MetadataEntity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if me.ID != nil { + objectMap["id"] = me.ID + } + if me.Type != nil { + objectMap["type"] = me.Type + } + if me.Name != nil { + objectMap["name"] = me.Name + } + if me.MetadataEntityProperties != nil { + objectMap["properties"] = me.MetadataEntityProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MetadataEntity struct. +func (me *MetadataEntity) 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 + } + me.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + me.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + me.Name = &name + } + case "properties": + if v != nil { + var metadataEntityProperties MetadataEntityProperties + err = json.Unmarshal(*v, &metadataEntityProperties) + if err != nil { + return err + } + me.MetadataEntityProperties = &metadataEntityProperties + } + } + } + + return nil +} + +// MetadataEntityListResult the list of metadata entities +type MetadataEntityListResult struct { + autorest.Response `json:"-"` + // Value - The list of metadata entities. + Value *[]MetadataEntity `json:"value,omitempty"` + // NextLink - The link used to get the next page of metadata. + NextLink *string `json:"nextLink,omitempty"` +} + +// MetadataEntityListResultIterator provides access to a complete listing of MetadataEntity values. +type MetadataEntityListResultIterator struct { + i int + page MetadataEntityListResultPage +} + +// 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 *MetadataEntityListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetadataEntityListResultIterator.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 *MetadataEntityListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter MetadataEntityListResultIterator) 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 MetadataEntityListResultIterator) Response() MetadataEntityListResult { + 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 MetadataEntityListResultIterator) Value() MetadataEntity { + if !iter.page.NotDone() { + return MetadataEntity{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the MetadataEntityListResultIterator type. +func NewMetadataEntityListResultIterator(page MetadataEntityListResultPage) MetadataEntityListResultIterator { + return MetadataEntityListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (melr MetadataEntityListResult) IsEmpty() bool { + return melr.Value == nil || len(*melr.Value) == 0 +} + +// metadataEntityListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (melr MetadataEntityListResult) metadataEntityListResultPreparer(ctx context.Context) (*http.Request, error) { + if melr.NextLink == nil || len(to.String(melr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(melr.NextLink))) +} + +// MetadataEntityListResultPage contains a page of MetadataEntity values. +type MetadataEntityListResultPage struct { + fn func(context.Context, MetadataEntityListResult) (MetadataEntityListResult, error) + melr MetadataEntityListResult +} + +// 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 *MetadataEntityListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetadataEntityListResultPage.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.melr) + if err != nil { + return err + } + page.melr = 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 *MetadataEntityListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page MetadataEntityListResultPage) NotDone() bool { + return !page.melr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page MetadataEntityListResultPage) Response() MetadataEntityListResult { + return page.melr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page MetadataEntityListResultPage) Values() []MetadataEntity { + if page.melr.IsEmpty() { + return nil + } + return *page.melr.Value +} + +// Creates a new instance of the MetadataEntityListResultPage type. +func NewMetadataEntityListResultPage(getNextPage func(context.Context, MetadataEntityListResult) (MetadataEntityListResult, error)) MetadataEntityListResultPage { + return MetadataEntityListResultPage{fn: getNextPage} +} + +// MetadataEntityProperties the metadata entity properties +type MetadataEntityProperties struct { + // DisplayName - The display name. + DisplayName *string `json:"displayName,omitempty"` + // DependsOn - The list of keys on which this entity depends on. + DependsOn *[]string `json:"dependsOn,omitempty"` + // ApplicableScenarios - The list of scenarios applicable to this metadata entity. + ApplicableScenarios *[]Scenario `json:"applicableScenarios,omitempty"` + // SupportedValues - The list of supported values. + SupportedValues *[]MetadataSupportedValueDetail `json:"supportedValues,omitempty"` +} + +// MetadataSupportedValueDetail the metadata supported value detail. +type MetadataSupportedValueDetail struct { + // ID - The id. + ID *string `json:"id,omitempty"` + // DisplayName - The display name. + DisplayName *string `json:"displayName,omitempty"` +} + +// OperationDisplayInfo the operation supported by Advisor. +type OperationDisplayInfo struct { + // Description - The description of the operation. + Description *string `json:"description,omitempty"` + // Operation - The action that users can perform, based on their permission level. + Operation *string `json:"operation,omitempty"` + // Provider - Service provider: Microsoft Advisor. + Provider *string `json:"provider,omitempty"` + // Resource - Resource on which the operation is performed. + Resource *string `json:"resource,omitempty"` +} + +// OperationEntity the operation supported by Advisor. +type OperationEntity struct { + // Name - Operation name: {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty"` + // Display - The operation supported by Advisor. + Display *OperationDisplayInfo `json:"display,omitempty"` +} + +// OperationEntityListResult the list of Advisor operations. +type OperationEntityListResult struct { + autorest.Response `json:"-"` + // NextLink - The link used to get the next page of operations. + NextLink *string `json:"nextLink,omitempty"` + // Value - The list of operations. + Value *[]OperationEntity `json:"value,omitempty"` +} + +// OperationEntityListResultIterator provides access to a complete listing of OperationEntity values. +type OperationEntityListResultIterator struct { + i int + page OperationEntityListResultPage +} + +// 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 *OperationEntityListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationEntityListResultIterator.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 *OperationEntityListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationEntityListResultIterator) 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 OperationEntityListResultIterator) Response() OperationEntityListResult { + 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 OperationEntityListResultIterator) Value() OperationEntity { + if !iter.page.NotDone() { + return OperationEntity{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationEntityListResultIterator type. +func NewOperationEntityListResultIterator(page OperationEntityListResultPage) OperationEntityListResultIterator { + return OperationEntityListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (oelr OperationEntityListResult) IsEmpty() bool { + return oelr.Value == nil || len(*oelr.Value) == 0 +} + +// operationEntityListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (oelr OperationEntityListResult) operationEntityListResultPreparer(ctx context.Context) (*http.Request, error) { + if oelr.NextLink == nil || len(to.String(oelr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(oelr.NextLink))) +} + +// OperationEntityListResultPage contains a page of OperationEntity values. +type OperationEntityListResultPage struct { + fn func(context.Context, OperationEntityListResult) (OperationEntityListResult, error) + oelr OperationEntityListResult +} + +// 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 *OperationEntityListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationEntityListResultPage.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.oelr) + if err != nil { + return err + } + page.oelr = 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 *OperationEntityListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationEntityListResultPage) NotDone() bool { + return !page.oelr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationEntityListResultPage) Response() OperationEntityListResult { + return page.oelr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationEntityListResultPage) Values() []OperationEntity { + if page.oelr.IsEmpty() { + return nil + } + return *page.oelr.Value +} + +// Creates a new instance of the OperationEntityListResultPage type. +func NewOperationEntityListResultPage(getNextPage func(context.Context, OperationEntityListResult) (OperationEntityListResult, error)) OperationEntityListResultPage { + return OperationEntityListResultPage{fn: getNextPage} +} + +// RecommendationProperties the properties of the recommendation. +type RecommendationProperties struct { + // Category - The category of the recommendation. Possible values include: 'HighAvailability', 'Security', 'Performance', 'Cost', 'OperationalExcellence' + Category Category `json:"category,omitempty"` + // Impact - The business impact of the recommendation. Possible values include: 'High', 'Medium', 'Low' + Impact Impact `json:"impact,omitempty"` + // ImpactedField - The resource type identified by Advisor. + ImpactedField *string `json:"impactedField,omitempty"` + // ImpactedValue - The resource identified by Advisor. + ImpactedValue *string `json:"impactedValue,omitempty"` + // LastUpdated - The most recent time that Advisor checked the validity of the recommendation. + LastUpdated *date.Time `json:"lastUpdated,omitempty"` + // Metadata - The recommendation metadata. + Metadata map[string]interface{} `json:"metadata"` + // RecommendationTypeID - The recommendation-type GUID. + RecommendationTypeID *string `json:"recommendationTypeId,omitempty"` + // Risk - The potential risk of not implementing the recommendation. Possible values include: 'Error', 'Warning', 'None' + Risk Risk `json:"risk,omitempty"` + // ShortDescription - A summary of the recommendation. + ShortDescription *ShortDescription `json:"shortDescription,omitempty"` + // SuppressionIds - The list of snoozed and dismissed rules for the recommendation. + SuppressionIds *[]uuid.UUID `json:"suppressionIds,omitempty"` + // ExtendedProperties - Extended properties + ExtendedProperties map[string]*string `json:"extendedProperties"` + // ResourceMetadata - Metadata of resource that was assessed + ResourceMetadata *ResourceMetadata `json:"resourceMetadata,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecommendationProperties. +func (rp RecommendationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rp.Category != "" { + objectMap["category"] = rp.Category + } + if rp.Impact != "" { + objectMap["impact"] = rp.Impact + } + if rp.ImpactedField != nil { + objectMap["impactedField"] = rp.ImpactedField + } + if rp.ImpactedValue != nil { + objectMap["impactedValue"] = rp.ImpactedValue + } + if rp.LastUpdated != nil { + objectMap["lastUpdated"] = rp.LastUpdated + } + if rp.Metadata != nil { + objectMap["metadata"] = rp.Metadata + } + if rp.RecommendationTypeID != nil { + objectMap["recommendationTypeId"] = rp.RecommendationTypeID + } + if rp.Risk != "" { + objectMap["risk"] = rp.Risk + } + if rp.ShortDescription != nil { + objectMap["shortDescription"] = rp.ShortDescription + } + if rp.SuppressionIds != nil { + objectMap["suppressionIds"] = rp.SuppressionIds + } + if rp.ExtendedProperties != nil { + objectMap["extendedProperties"] = rp.ExtendedProperties + } + if rp.ResourceMetadata != nil { + objectMap["resourceMetadata"] = rp.ResourceMetadata + } + return json.Marshal(objectMap) +} + +// Resource an Azure resource. +type Resource struct { + // ID - READ-ONLY; The resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` +} + +// ResourceMetadata recommendation resource metadata +type ResourceMetadata struct { + // ResourceID - Azure resource Id of the assessed resource + ResourceID *string `json:"resourceId,omitempty"` + // Source - Source from which recommendation is generated + Source *string `json:"source,omitempty"` +} + +// ResourceRecommendationBase advisor Recommendation. +type ResourceRecommendationBase struct { + autorest.Response `json:"-"` + // RecommendationProperties - The properties of the recommendation. + *RecommendationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceRecommendationBase. +func (rrb ResourceRecommendationBase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rrb.RecommendationProperties != nil { + objectMap["properties"] = rrb.RecommendationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ResourceRecommendationBase struct. +func (rrb *ResourceRecommendationBase) 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 recommendationProperties RecommendationProperties + err = json.Unmarshal(*v, &recommendationProperties) + if err != nil { + return err + } + rrb.RecommendationProperties = &recommendationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rrb.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rrb.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rrb.Type = &typeVar + } + } + } + + return nil +} + +// ResourceRecommendationBaseListResult the list of Advisor recommendations. +type ResourceRecommendationBaseListResult struct { + autorest.Response `json:"-"` + // NextLink - The link used to get the next page of recommendations. + NextLink *string `json:"nextLink,omitempty"` + // Value - The list of recommendations. + Value *[]ResourceRecommendationBase `json:"value,omitempty"` +} + +// ResourceRecommendationBaseListResultIterator provides access to a complete listing of +// ResourceRecommendationBase values. +type ResourceRecommendationBaseListResultIterator struct { + i int + page ResourceRecommendationBaseListResultPage +} + +// 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 *ResourceRecommendationBaseListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceRecommendationBaseListResultIterator.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 *ResourceRecommendationBaseListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ResourceRecommendationBaseListResultIterator) 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 ResourceRecommendationBaseListResultIterator) Response() ResourceRecommendationBaseListResult { + 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 ResourceRecommendationBaseListResultIterator) Value() ResourceRecommendationBase { + if !iter.page.NotDone() { + return ResourceRecommendationBase{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ResourceRecommendationBaseListResultIterator type. +func NewResourceRecommendationBaseListResultIterator(page ResourceRecommendationBaseListResultPage) ResourceRecommendationBaseListResultIterator { + return ResourceRecommendationBaseListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rrblr ResourceRecommendationBaseListResult) IsEmpty() bool { + return rrblr.Value == nil || len(*rrblr.Value) == 0 +} + +// resourceRecommendationBaseListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rrblr ResourceRecommendationBaseListResult) resourceRecommendationBaseListResultPreparer(ctx context.Context) (*http.Request, error) { + if rrblr.NextLink == nil || len(to.String(rrblr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rrblr.NextLink))) +} + +// ResourceRecommendationBaseListResultPage contains a page of ResourceRecommendationBase values. +type ResourceRecommendationBaseListResultPage struct { + fn func(context.Context, ResourceRecommendationBaseListResult) (ResourceRecommendationBaseListResult, error) + rrblr ResourceRecommendationBaseListResult +} + +// 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 *ResourceRecommendationBaseListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceRecommendationBaseListResultPage.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.rrblr) + if err != nil { + return err + } + page.rrblr = 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 *ResourceRecommendationBaseListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ResourceRecommendationBaseListResultPage) NotDone() bool { + return !page.rrblr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ResourceRecommendationBaseListResultPage) Response() ResourceRecommendationBaseListResult { + return page.rrblr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ResourceRecommendationBaseListResultPage) Values() []ResourceRecommendationBase { + if page.rrblr.IsEmpty() { + return nil + } + return *page.rrblr.Value +} + +// Creates a new instance of the ResourceRecommendationBaseListResultPage type. +func NewResourceRecommendationBaseListResultPage(getNextPage func(context.Context, ResourceRecommendationBaseListResult) (ResourceRecommendationBaseListResult, error)) ResourceRecommendationBaseListResultPage { + return ResourceRecommendationBaseListResultPage{fn: getNextPage} +} + +// SetObject ... +type SetObject struct { + autorest.Response `json:"-"` + Value interface{} `json:"value,omitempty"` +} + +// ShortDescription a summary of the recommendation. +type ShortDescription struct { + // Problem - The issue or opportunity identified by the recommendation. + Problem *string `json:"problem,omitempty"` + // Solution - The remediation action suggested by the recommendation. + Solution *string `json:"solution,omitempty"` +} + +// SuppressionContract the details of the snoozed or dismissed rule; for example, the duration, name, and +// GUID associated with the rule. +type SuppressionContract struct { + autorest.Response `json:"-"` + // SuppressionProperties - The properties of the suppression. + *SuppressionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SuppressionContract. +func (sc SuppressionContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sc.SuppressionProperties != nil { + objectMap["properties"] = sc.SuppressionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SuppressionContract struct. +func (sc *SuppressionContract) 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 suppressionProperties SuppressionProperties + err = json.Unmarshal(*v, &suppressionProperties) + if err != nil { + return err + } + sc.SuppressionProperties = &suppressionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sc.Type = &typeVar + } + } + } + + return nil +} + +// SuppressionContractListResult the list of Advisor suppressions. +type SuppressionContractListResult struct { + autorest.Response `json:"-"` + // NextLink - The link used to get the next page of suppressions. + NextLink *string `json:"nextLink,omitempty"` + // Value - The list of suppressions. + Value *[]SuppressionContract `json:"value,omitempty"` +} + +// SuppressionContractListResultIterator provides access to a complete listing of SuppressionContract +// values. +type SuppressionContractListResultIterator struct { + i int + page SuppressionContractListResultPage +} + +// 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 *SuppressionContractListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SuppressionContractListResultIterator.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 *SuppressionContractListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SuppressionContractListResultIterator) 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 SuppressionContractListResultIterator) Response() SuppressionContractListResult { + 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 SuppressionContractListResultIterator) Value() SuppressionContract { + if !iter.page.NotDone() { + return SuppressionContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SuppressionContractListResultIterator type. +func NewSuppressionContractListResultIterator(page SuppressionContractListResultPage) SuppressionContractListResultIterator { + return SuppressionContractListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sclr SuppressionContractListResult) IsEmpty() bool { + return sclr.Value == nil || len(*sclr.Value) == 0 +} + +// suppressionContractListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sclr SuppressionContractListResult) suppressionContractListResultPreparer(ctx context.Context) (*http.Request, error) { + if sclr.NextLink == nil || len(to.String(sclr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sclr.NextLink))) +} + +// SuppressionContractListResultPage contains a page of SuppressionContract values. +type SuppressionContractListResultPage struct { + fn func(context.Context, SuppressionContractListResult) (SuppressionContractListResult, error) + sclr SuppressionContractListResult +} + +// 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 *SuppressionContractListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SuppressionContractListResultPage.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.sclr) + if err != nil { + return err + } + page.sclr = 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 *SuppressionContractListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SuppressionContractListResultPage) NotDone() bool { + return !page.sclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SuppressionContractListResultPage) Response() SuppressionContractListResult { + return page.sclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SuppressionContractListResultPage) Values() []SuppressionContract { + if page.sclr.IsEmpty() { + return nil + } + return *page.sclr.Value +} + +// Creates a new instance of the SuppressionContractListResultPage type. +func NewSuppressionContractListResultPage(getNextPage func(context.Context, SuppressionContractListResult) (SuppressionContractListResult, error)) SuppressionContractListResultPage { + return SuppressionContractListResultPage{fn: getNextPage} +} + +// SuppressionProperties the properties of the suppression. +type SuppressionProperties struct { + // SuppressionID - The GUID of the suppression. + SuppressionID *string `json:"suppressionId,omitempty"` + // TTL - The duration for which the suppression is valid. + TTL *string `json:"ttl,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/operations.go new file mode 100644 index 000000000000..7f05d76b6df6 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/operations.go @@ -0,0 +1,147 @@ +package advisor + +// 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" +) + +// OperationsClient is the REST APIs for Azure Advisor +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient 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 NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all the available Advisor REST API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationEntityListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.oelr.Response.Response != nil { + sc = result.oelr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.oelr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "advisor.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.oelr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Advisor/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 OperationsClient) 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 OperationsClient) ListResponder(resp *http.Response) (result OperationEntityListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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 OperationsClient) listNextResults(ctx context.Context, lastResults OperationEntityListResult) (result OperationEntityListResult, err error) { + req, err := lastResults.operationEntityListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "advisor.OperationsClient", "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, "advisor.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationEntityListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.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/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/recommendationmetadata.go b/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/recommendationmetadata.go new file mode 100644 index 000000000000..42443e927449 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/recommendationmetadata.go @@ -0,0 +1,221 @@ +package advisor + +// 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" +) + +// RecommendationMetadataClient is the REST APIs for Azure Advisor +type RecommendationMetadataClient struct { + BaseClient +} + +// NewRecommendationMetadataClient creates an instance of the RecommendationMetadataClient client. +func NewRecommendationMetadataClient(subscriptionID string) RecommendationMetadataClient { + return NewRecommendationMetadataClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRecommendationMetadataClientWithBaseURI creates an instance of the RecommendationMetadataClient 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 NewRecommendationMetadataClientWithBaseURI(baseURI string, subscriptionID string) RecommendationMetadataClient { + return RecommendationMetadataClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get sends the get request. +// Parameters: +// name - name of metadata entity. +func (client RecommendationMetadataClient) Get(ctx context.Context, name string) (result SetObject, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecommendationMetadataClient.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, name) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationMetadataClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "advisor.RecommendationMetadataClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationMetadataClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RecommendationMetadataClient) GetPreparer(ctx context.Context, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Advisor/metadata/{name}", 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 RecommendationMetadataClient) 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 RecommendationMetadataClient) GetResponder(resp *http.Response) (result SetObject, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +func (client RecommendationMetadataClient) List(ctx context.Context) (result MetadataEntityListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecommendationMetadataClient.List") + defer func() { + sc := -1 + if result.melr.Response.Response != nil { + sc = result.melr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationMetadataClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.melr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "advisor.RecommendationMetadataClient", "List", resp, "Failure sending request") + return + } + + result.melr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationMetadataClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client RecommendationMetadataClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Advisor/metadata"), + 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 RecommendationMetadataClient) 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 RecommendationMetadataClient) ListResponder(resp *http.Response) (result MetadataEntityListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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 RecommendationMetadataClient) listNextResults(ctx context.Context, lastResults MetadataEntityListResult) (result MetadataEntityListResult, err error) { + req, err := lastResults.metadataEntityListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "advisor.RecommendationMetadataClient", "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, "advisor.RecommendationMetadataClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationMetadataClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client RecommendationMetadataClient) ListComplete(ctx context.Context) (result MetadataEntityListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecommendationMetadataClient.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/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/recommendations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/recommendations.go new file mode 100644 index 000000000000..9d378761339b --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/recommendations.go @@ -0,0 +1,391 @@ +package advisor + +// 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" + "github.com/satori/go.uuid" + "net/http" +) + +// RecommendationsClient is the REST APIs for Azure Advisor +type RecommendationsClient struct { + BaseClient +} + +// NewRecommendationsClient creates an instance of the RecommendationsClient client. +func NewRecommendationsClient(subscriptionID string) RecommendationsClient { + return NewRecommendationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRecommendationsClientWithBaseURI creates an instance of the RecommendationsClient 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 NewRecommendationsClientWithBaseURI(baseURI string, subscriptionID string) RecommendationsClient { + return RecommendationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Generate initiates the recommendation generation or computation process for a subscription. This operation is +// asynchronous. The generated recommendations are stored in a cache in the Advisor service. +func (client RecommendationsClient) Generate(ctx context.Context) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecommendationsClient.Generate") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GeneratePreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "Generate", nil, "Failure preparing request") + return + } + + resp, err := client.GenerateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "Generate", resp, "Failure sending request") + return + } + + result, err = client.GenerateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "Generate", resp, "Failure responding to request") + } + + return +} + +// GeneratePreparer prepares the Generate request. +func (client RecommendationsClient) GeneratePreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/generateRecommendations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GenerateSender sends the Generate request. The method will close the +// http.Response Body if it receives an error. +func (client RecommendationsClient) GenerateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GenerateResponder handles the response to the Generate request. The method always +// closes the http.Response Body. +func (client RecommendationsClient) GenerateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get obtains details of a cached recommendation. +// Parameters: +// resourceURI - the fully qualified Azure Resource Manager identifier of the resource to which the +// recommendation applies. +// recommendationID - the recommendation ID. +func (client RecommendationsClient) Get(ctx context.Context, resourceURI string, recommendationID string) (result ResourceRecommendationBase, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecommendationsClient.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, resourceURI, recommendationID) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RecommendationsClient) GetPreparer(ctx context.Context, resourceURI string, recommendationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "recommendationId": autorest.Encode("path", recommendationID), + "resourceUri": autorest.Encode("path", resourceURI), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}", 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 RecommendationsClient) 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 RecommendationsClient) GetResponder(resp *http.Response) (result ResourceRecommendationBase, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetGenerateStatus retrieves the status of the recommendation computation or generation process. Invoke this API +// after calling the generation recommendation. The URI of this API is returned in the Location field of the response +// header. +// Parameters: +// operationID - the operation ID, which can be found from the Location field in the generate recommendation +// response header. +func (client RecommendationsClient) GetGenerateStatus(ctx context.Context, operationID uuid.UUID) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecommendationsClient.GetGenerateStatus") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetGenerateStatusPreparer(ctx, operationID) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "GetGenerateStatus", nil, "Failure preparing request") + return + } + + resp, err := client.GetGenerateStatusSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "GetGenerateStatus", resp, "Failure sending request") + return + } + + result, err = client.GetGenerateStatusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "GetGenerateStatus", resp, "Failure responding to request") + } + + return +} + +// GetGenerateStatusPreparer prepares the GetGenerateStatus request. +func (client RecommendationsClient) GetGenerateStatusPreparer(ctx context.Context, operationID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "operationId": autorest.Encode("path", operationID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/generateRecommendations/{operationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetGenerateStatusSender sends the GetGenerateStatus request. The method will close the +// http.Response Body if it receives an error. +func (client RecommendationsClient) GetGenerateStatusSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetGenerateStatusResponder handles the response to the GetGenerateStatus request. The method always +// closes the http.Response Body. +func (client RecommendationsClient) GetGenerateStatusResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// List obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking +// generateRecommendations. +// Parameters: +// filter - the filter to apply to the recommendations.
Filter can be applied to properties ['ResourceId', +// 'ResourceGroup', 'RecommendationTypeGuid', '[Category](#category)'] with operators ['eq', 'and', +// 'or'].
Example:
- $filter=Category eq 'Cost' and ResourceGroup eq 'MyResourceGroup' +// top - the number of recommendations per page if a paged version of this API is being used. +// skipToken - the page-continuation token to use with a paged version of this API. +func (client RecommendationsClient) List(ctx context.Context, filter string, top *int32, skipToken string) (result ResourceRecommendationBaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecommendationsClient.List") + defer func() { + sc := -1 + if result.rrblr.Response.Response != nil { + sc = result.rrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, filter, top, skipToken) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.rrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "List", resp, "Failure sending request") + return + } + + result.rrblr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client RecommendationsClient) ListPreparer(ctx context.Context, filter string, top *int32, skipToken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + 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.Advisor/recommendations", 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 RecommendationsClient) 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 RecommendationsClient) ListResponder(resp *http.Response) (result ResourceRecommendationBaseListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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 RecommendationsClient) listNextResults(ctx context.Context, lastResults ResourceRecommendationBaseListResult) (result ResourceRecommendationBaseListResult, err error) { + req, err := lastResults.resourceRecommendationBaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "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, "advisor.RecommendationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client RecommendationsClient) ListComplete(ctx context.Context, filter string, top *int32, skipToken string) (result ResourceRecommendationBaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecommendationsClient.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, filter, top, skipToken) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/suppressions.go b/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/suppressions.go new file mode 100644 index 000000000000..93f110e40ced --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/suppressions.go @@ -0,0 +1,399 @@ +package advisor + +// 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" +) + +// SuppressionsClient is the REST APIs for Azure Advisor +type SuppressionsClient struct { + BaseClient +} + +// NewSuppressionsClient creates an instance of the SuppressionsClient client. +func NewSuppressionsClient(subscriptionID string) SuppressionsClient { + return NewSuppressionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSuppressionsClientWithBaseURI creates an instance of the SuppressionsClient 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 NewSuppressionsClientWithBaseURI(baseURI string, subscriptionID string) SuppressionsClient { + return SuppressionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute is +// referred to as a suppression. Use this API to create or update the snoozed or dismissed status of a recommendation. +// Parameters: +// resourceURI - the fully qualified Azure Resource Manager identifier of the resource to which the +// recommendation applies. +// recommendationID - the recommendation ID. +// name - the name of the suppression. +// suppressionContract - the snoozed or dismissed attribute; for example, the snooze duration. +func (client SuppressionsClient) Create(ctx context.Context, resourceURI string, recommendationID string, name string, suppressionContract SuppressionContract) (result SuppressionContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SuppressionsClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreatePreparer(ctx, resourceURI, recommendationID, name, suppressionContract) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client SuppressionsClient) CreatePreparer(ctx context.Context, resourceURI string, recommendationID string, name string, suppressionContract SuppressionContract) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "recommendationId": autorest.Encode("path", recommendationID), + "resourceUri": autorest.Encode("path", resourceURI), + } + + const APIVersion = "2020-01-01" + 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("/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", pathParameters), + autorest.WithJSON(suppressionContract), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client SuppressionsClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client SuppressionsClient) CreateResponder(resp *http.Response) (result SuppressionContract, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute of a +// recommendation is referred to as a suppression. +// Parameters: +// resourceURI - the fully qualified Azure Resource Manager identifier of the resource to which the +// recommendation applies. +// recommendationID - the recommendation ID. +// name - the name of the suppression. +func (client SuppressionsClient) Delete(ctx context.Context, resourceURI string, recommendationID string, name string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SuppressionsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceURI, recommendationID, name) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SuppressionsClient) DeletePreparer(ctx context.Context, resourceURI string, recommendationID string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "recommendationId": autorest.Encode("path", recommendationID), + "resourceUri": autorest.Encode("path", resourceURI), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client SuppressionsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SuppressionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get obtains the details of a suppression. +// Parameters: +// resourceURI - the fully qualified Azure Resource Manager identifier of the resource to which the +// recommendation applies. +// recommendationID - the recommendation ID. +// name - the name of the suppression. +func (client SuppressionsClient) Get(ctx context.Context, resourceURI string, recommendationID string, name string) (result SuppressionContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SuppressionsClient.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, resourceURI, recommendationID, name) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SuppressionsClient) GetPreparer(ctx context.Context, resourceURI string, recommendationID string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "recommendationId": autorest.Encode("path", recommendationID), + "resourceUri": autorest.Encode("path", resourceURI), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", 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 SuppressionsClient) 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 SuppressionsClient) GetResponder(resp *http.Response) (result SuppressionContract, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute +// of a recommendation is referred to as a suppression. +// Parameters: +// top - the number of suppressions per page if a paged version of this API is being used. +// skipToken - the page-continuation token to use with a paged version of this API. +func (client SuppressionsClient) List(ctx context.Context, top *int32, skipToken string) (result SuppressionContractListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SuppressionsClient.List") + defer func() { + sc := -1 + if result.sclr.Response.Response != nil { + sc = result.sclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, top, skipToken) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.sclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "List", resp, "Failure sending request") + return + } + + result.sclr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client SuppressionsClient) ListPreparer(ctx context.Context, top *int32, skipToken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + 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.Advisor/suppressions", 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 SuppressionsClient) 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 SuppressionsClient) ListResponder(resp *http.Response) (result SuppressionContractListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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 SuppressionsClient) listNextResults(ctx context.Context, lastResults SuppressionContractListResult) (result SuppressionContractListResult, err error) { + req, err := lastResults.suppressionContractListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "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, "advisor.SuppressionsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client SuppressionsClient) ListComplete(ctx context.Context, top *int32, skipToken string) (result SuppressionContractListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SuppressionsClient.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, top, skipToken) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/version.go new file mode 100644 index 000000000000..e8cd05458c52 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor/version.go @@ -0,0 +1,30 @@ +package advisor + +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() + " advisor/2020-01-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/vendor/modules.txt b/vendor/modules.txt index af7dbaadc686..aedbbe98efe2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -8,6 +8,7 @@ cloud.google.com/go/internal/version cloud.google.com/go/storage # github.com/Azure/azure-sdk-for-go v42.1.0+incompatible github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources +github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor github.com/Azure/azure-sdk-for-go/services/analysisservices/mgmt/2017-08-01/analysisservices github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2019-12-01/apimanagement github.com/Azure/azure-sdk-for-go/services/appconfiguration/mgmt/2019-10-01/appconfiguration diff --git a/website/allowed-subcategories b/website/allowed-subcategories index 0646d0909edc..3846653eef4d 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -1,4 +1,5 @@ API Management +Advisor Analysis Services App Configuration App Service (Web Apps) diff --git a/website/azurerm.erb b/website/azurerm.erb index b8d309844bd7..6172c51d5537 100644 --- a/website/azurerm.erb +++ b/website/azurerm.erb @@ -54,6 +54,9 @@
  • Data Sources