diff --git a/azurerm/config.go b/azurerm/config.go index ec9d54f61e1e..36ec6f46a5b9 100644 --- a/azurerm/config.go +++ b/azurerm/config.go @@ -26,6 +26,7 @@ import ( "github.com/Azure/azure-sdk-for-go/services/eventgrid/mgmt/2017-09-15-preview/eventgrid" "github.com/Azure/azure-sdk-for-go/services/eventhub/mgmt/2017-04-01/eventhub" "github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac" + "github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights" "github.com/Azure/azure-sdk-for-go/services/mysql/mgmt/2017-04-30-preview/mysql" "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network" "github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2015-11-01-preview/operationalinsights" @@ -125,6 +126,9 @@ type ArmClient struct { sqlFirewallRulesClient sql.FirewallRulesClient sqlServersClient sql.ServersClient + // Monitor + monitorAlertRulesClient insights.AlertRulesClient + // Networking applicationGatewayClient network.ApplicationGatewaysClient expressRouteCircuitClient network.ExpressRouteCircuitsClient @@ -400,6 +404,7 @@ func getArmClient(c *authentication.Config) (*ArmClient, error) { client.registerEventGridClients(endpoint, c.SubscriptionID, auth, sender) client.registerEventHubClients(endpoint, c.SubscriptionID, auth, sender) client.registerKeyVaultClients(endpoint, c.SubscriptionID, auth, keyVaultAuth, sender) + client.registerMonitorClients(endpoint, c.SubscriptionID, auth, sender) client.registerNetworkingClients(endpoint, c.SubscriptionID, auth, sender) client.registerOperationalInsightsClients(endpoint, c.SubscriptionID, auth, sender) client.registerRedisClients(endpoint, c.SubscriptionID, auth, sender) @@ -654,6 +659,14 @@ func (c *ArmClient) registerKeyVaultClients(endpoint, subscriptionId string, aut c.keyVaultManagementClient = keyVaultManagementClient } +func (c *ArmClient) registerMonitorClients(endpoint, subscriptionId string, auth autorest.Authorizer, sender autorest.Sender) { + arc := insights.NewAlertRulesClientWithBaseURI(endpoint, subscriptionId) + setUserAgent(&arc.Client) + arc.Authorizer = auth + arc.Sender = autorest.CreateSender(withRequestLogging()) + c.monitorAlertRulesClient = arc +} + func (c *ArmClient) registerNetworkingClients(endpoint, subscriptionId string, auth autorest.Authorizer, sender autorest.Sender) { applicationGatewaysClient := network.NewApplicationGatewaysClientWithBaseURI(endpoint, subscriptionId) c.configureClient(&applicationGatewaysClient.Client, auth) diff --git a/azurerm/import_arm_metric_alertrule_test.go b/azurerm/import_arm_metric_alertrule_test.go new file mode 100644 index 000000000000..61fa6fa29e3d --- /dev/null +++ b/azurerm/import_arm_metric_alertrule_test.go @@ -0,0 +1,31 @@ +package azurerm + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAzureRMMetricAlertRule_importVirtualMachineCpu(t *testing.T) { + resourceName := "azurerm_metric_alertrule.test" + + ri := acctest.RandInt() + config := testAccAzureRMMetricAlertRule_virtualMachineCpu(ri, testLocation(), true) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMMetricAlertRuleDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} diff --git a/azurerm/provider.go b/azurerm/provider.go index 04fb82360d00..339fa46b4f59 100644 --- a/azurerm/provider.go +++ b/azurerm/provider.go @@ -132,6 +132,7 @@ func Provider() terraform.ResourceProvider { "azurerm_log_analytics_workspace": resourceArmLogAnalyticsWorkspace(), "azurerm_managed_disk": resourceArmManagedDisk(), "azurerm_management_lock": resourceArmManagementLock(), + "azurerm_metric_alertrule": resourceArmMetricAlertRule(), "azurerm_mysql_configuration": resourceArmMySQLConfiguration(), "azurerm_mysql_database": resourceArmMySqlDatabase(), "azurerm_mysql_firewall_rule": resourceArmMySqlFirewallRule(), diff --git a/azurerm/resource_arm_metric_alertrule.go b/azurerm/resource_arm_metric_alertrule.go new file mode 100644 index 000000000000..33744120e9ec --- /dev/null +++ b/azurerm/resource_arm_metric_alertrule.go @@ -0,0 +1,417 @@ +package azurerm + +import ( + "fmt" + "log" + + "github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights" + "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func resourceArmMetricAlertRule() *schema.Resource { + return &schema.Resource{ + Create: resourceArmMetricAlertRuleCreateOrUpdate, + Read: resourceArmMetricAlertRuleRead, + Update: resourceArmMetricAlertRuleCreateOrUpdate, + Delete: resourceArmMetricAlertRuleDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "resource_group_name": resourceGroupNameSchema(), + + "location": locationSchema(), + + "description": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "enabled": { + Type: schema.TypeBool, + Optional: true, + Default: true, + }, + + "resource_id": { + Type: schema.TypeString, + Required: true, + }, + + "metric_name": { + Type: schema.TypeString, + Required: true, + }, + + "operator": { + Type: schema.TypeString, + Required: true, + DiffSuppressFunc: ignoreCaseDiffSuppressFunc, + ValidateFunc: validation.StringInSlice([]string{ + string(insights.ConditionOperatorGreaterThan), + string(insights.ConditionOperatorGreaterThanOrEqual), + string(insights.ConditionOperatorLessThan), + string(insights.ConditionOperatorLessThanOrEqual), + }, true), + }, + + "threshold": { + Type: schema.TypeFloat, + Required: true, + }, + + "period": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validateIso8601Duration(), + }, + + "aggregation": { + Type: schema.TypeString, + Required: true, + DiffSuppressFunc: ignoreCaseDiffSuppressFunc, + ValidateFunc: validation.StringInSlice([]string{ + string(insights.TimeAggregationOperatorAverage), + string(insights.TimeAggregationOperatorLast), + string(insights.TimeAggregationOperatorMaximum), + string(insights.TimeAggregationOperatorMinimum), + string(insights.TimeAggregationOperatorTotal), + }, true), + }, + + "email_action": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "send_to_service_owners": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + }, + + "custom_emails": { + Type: schema.TypeList, + Optional: true, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + + "webhook_action": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "service_uri": { + Type: schema.TypeString, + Required: true, + }, + + "properties": { + Type: schema.TypeMap, + Optional: true, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + + "tags": tagsSchema(), + }, + } +} + +func resourceArmMetricAlertRuleCreateOrUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).monitorAlertRulesClient + ctx := meta.(*ArmClient).StopContext + + log.Printf("[INFO] preparing arguments for AzureRM Alert Rule creation.") + + name := d.Get("name").(string) + resourceGroup := d.Get("resource_group_name").(string) + location := d.Get("location").(string) + tags := d.Get("tags").(map[string]interface{}) + + alertRule, err := expandAzureRmMetricThresholdAlertRule(d) + if err != nil { + return err + } + + alertRuleResource := insights.AlertRuleResource{ + Name: &name, + Location: &location, + Tags: expandTags(tags), + AlertRule: alertRule, + } + + _, err = client.CreateOrUpdate(ctx, resourceGroup, name, alertRuleResource) + if err != nil { + return err + } + + read, err := client.Get(ctx, resourceGroup, name) + if err != nil { + return err + } + if read.ID == nil { + return fmt.Errorf("Cannot read AzureRM Alert Rule %q (Resource Group %s) ID", name, resourceGroup) + } + + d.SetId(*read.ID) + + return resourceArmMetricAlertRuleRead(d, meta) +} + +func resourceArmMetricAlertRuleRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).monitorAlertRulesClient + ctx := meta.(*ArmClient).StopContext + + resourceGroup, name, err := resourceGroupAndAlertRuleNameFromId(d.Id()) + if err != nil { + return err + } + + resp, err := client.Get(ctx, resourceGroup, name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + log.Printf("[DEBUG] Metric Alert Rule %q (resource group %q) was not found - removing from state", name, resourceGroup) + d.SetId("") + return nil + } + + return fmt.Errorf("Error making Read request on AzureRM Metric Alert Rule %q: %+v", name, err) + } + + d.Set("name", name) + d.Set("resource_group_name", resourceGroup) + d.Set("location", azureRMNormalizeLocation(*resp.Location)) + + if alertRule := resp.AlertRule; alertRule != nil { + d.Set("description", alertRule.Description) + d.Set("enabled", alertRule.IsEnabled) + + ruleCondition := alertRule.Condition + + if ruleCondition != nil { + if thresholdRuleCondition, ok := ruleCondition.AsThresholdRuleCondition(); ok && thresholdRuleCondition != nil { + d.Set("operator", string(thresholdRuleCondition.Operator)) + d.Set("threshold", *thresholdRuleCondition.Threshold) + d.Set("period", thresholdRuleCondition.WindowSize) + d.Set("aggregation", string(thresholdRuleCondition.TimeAggregation)) + + dataSource := thresholdRuleCondition.DataSource + + if dataSource != nil { + if metricDataSource, ok := dataSource.AsRuleMetricDataSource(); ok && metricDataSource != nil { + d.Set("resource_id", metricDataSource.ResourceURI) + d.Set("metric_name", metricDataSource.MetricName) + } + } + } + } + + email_actions := make([]interface{}, 0) + webhook_actions := make([]interface{}, 0) + + for _, ruleAction := range *alertRule.Actions { + if emailAction, ok := ruleAction.AsRuleEmailAction(); ok && emailAction != nil { + email_action := make(map[string]interface{}, 1) + + if sendToOwners := emailAction.SendToServiceOwners; sendToOwners != nil { + email_action["send_to_service_owners"] = *sendToOwners + } + + custom_emails := []string{} + for _, custom_email := range *emailAction.CustomEmails { + custom_emails = append(custom_emails, custom_email) + } + + email_action["custom_emails"] = custom_emails + + email_actions = append(email_actions, email_action) + } else if webhookAction, ok := ruleAction.AsRuleWebhookAction(); ok && webhookAction != nil { + webhook_action := make(map[string]interface{}, 1) + + webhook_action["service_uri"] = *webhookAction.ServiceURI + + //var properties map[string]string; + + if webhookAction.Properties != nil { + properties := make(map[string]string, len(*webhookAction.Properties)) + + for k, v := range *webhookAction.Properties { + if k != "$type" { + properties[k] = *v + } + } + webhook_action["properties"] = properties + } + //else { + // properties = make(map[string]string, 0) + //} + + webhook_actions = append(webhook_actions, webhook_action) + } + } + + d.Set("email_action", email_actions) + d.Set("webhook_action", webhook_actions) + } + + flattenAndSetTags(d, resp.Tags) + + return nil +} + +func resourceArmMetricAlertRuleDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).monitorAlertRulesClient + ctx := meta.(*ArmClient).StopContext + + resourceGroup, name, err := resourceGroupAndAlertRuleNameFromId(d.Id()) + if err != nil { + return err + } + + resp, err := client.Delete(ctx, resourceGroup, name) + if err != nil { + if utils.ResponseWasNotFound(resp) { + return nil + } + + return fmt.Errorf("Error deleting Metric Alert Rule %q (resource group %q): %+v", name, resourceGroup, err) + } + + return err +} + +func expandAzureRmMetricThresholdAlertRule(d *schema.ResourceData) (*insights.AlertRule, error) { + name := d.Get("name").(string) + + resource := d.Get("resource_id").(string) + metric_name := d.Get("metric_name").(string) + + metricDataSource := insights.RuleMetricDataSource{ + ResourceURI: &resource, + MetricName: &metric_name, + } + + operator := d.Get("operator").(string) + threshold := d.Get("threshold").(float64) + period := d.Get("period").(string) + aggregation := d.Get("aggregation").(string) + + thresholdRuleCondition := insights.ThresholdRuleCondition{ + DataSource: metricDataSource, + Operator: insights.ConditionOperator(operator), + Threshold: &threshold, + TimeAggregation: insights.TimeAggregationOperator(aggregation), + WindowSize: &period, + } + + actions := make([]insights.BasicRuleAction, 0, 2) + + // Email action + + email_actions := d.Get("email_action").([]interface{}) + + if len(email_actions) > 0 { + email_action := email_actions[0].(map[string]interface{}) + emailAction := insights.RuleEmailAction{} + + if v, ok := email_action["custom_emails"]; ok { + custom_emails := v.([]interface{}) + + customEmails := make([]string, 0) + for _, customEmail := range custom_emails { + custom_email := customEmail.(string) + customEmails = append(customEmails, custom_email) + } + + emailAction.CustomEmails = &customEmails + } + + if v, ok := email_action["send_to_service_owners"]; ok { + sendToServiceOwners := v.(bool) + emailAction.SendToServiceOwners = &sendToServiceOwners + } + + actions = append(actions, emailAction) + } + + // Webhook action + + webhook_actions := d.Get("webhook_action").([]interface{}) + + if len(webhook_actions) > 0 { + webhook_action := webhook_actions[0].(map[string]interface{}) + + service_uri := webhook_action["service_uri"].(string) + + webhook_properties := make(map[string]*string) + + if v, ok := webhook_action["properties"]; ok { + properties := v.(map[string]interface{}) + + for property_key, property_value := range properties { + property_string := property_value.(string) + webhook_properties[property_key] = &property_string + } + } + + webhookAction := insights.RuleWebhookAction{ + ServiceURI: &service_uri, + Properties: &webhook_properties, + } + + actions = append(actions, webhookAction) + } + + enabled := d.Get("enabled").(bool) + + alertRule := insights.AlertRule{ + Name: &name, + Condition: &thresholdRuleCondition, + Actions: &actions, + IsEnabled: &enabled, + } + + if v, ok := d.GetOk("description"); ok { + description := v.(string) + alertRule.Description = &description + } + + return &alertRule, nil +} + +func resourceGroupAndAlertRuleNameFromId(alertRuleId string) (string, string, error) { + id, err := parseAzureResourceID(alertRuleId) + if err != nil { + return "", "", err + } + name := id.Path["alertrules"] + resourceGroup := id.ResourceGroup + + return resourceGroup, name, nil +} diff --git a/azurerm/resource_arm_metric_alertrule_test.go b/azurerm/resource_arm_metric_alertrule_test.go new file mode 100644 index 000000000000..d9fef0c28c21 --- /dev/null +++ b/azurerm/resource_arm_metric_alertrule_test.go @@ -0,0 +1,201 @@ +package azurerm + +import ( + "fmt" + "strconv" + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/terraform" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func TestAccAzureRMMetricAlertRule_virtualMachineCpu(t *testing.T) { + resourceName := "azurerm_metric_alertrule.test" + ri := acctest.RandInt() + preConfig := testAccAzureRMMetricAlertRule_virtualMachineCpu(ri, testLocation(), true) + postConfig := testAccAzureRMMetricAlertRule_virtualMachineCpu(ri, testLocation(), false) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMMetricAlertRuleDestroy, + Steps: []resource.TestStep{ + { + Config: preConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMMetricAlertRuleExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "enabled", "true"), + ), + }, + { + Config: postConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMMetricAlertRuleExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "enabled", "false"), + ), + }, + }, + }) +} + +func TestAccAzureRMMetricAlertRule_sqlDatabaseStorage(t *testing.T) { + resourceName := "azurerm_metric_alertrule.test" + ri := acctest.RandInt() + config := testAccAzureRMMetricAlertRule_sqlDatabaseStorage(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMMetricAlertRuleDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMMetricAlertRuleExists(resourceName), + ), + }, + }, + }) +} + +func testCheckAzureRMMetricAlertRuleExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + // Ensure we have enough information in state to look up in API + rs, ok := s.RootModule().Resources[name] + if !ok { + return fmt.Errorf("Not found: %s", name) + } + + name := rs.Primary.Attributes["name"] + resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] + if !hasResourceGroup { + return fmt.Errorf("Bad: no resource group found in state for Alert Rule: %s", name) + } + + client := testAccProvider.Meta().(*ArmClient).monitorAlertRulesClient + ctx := testAccProvider.Meta().(*ArmClient).StopContext + + resp, err := client.Get(ctx, resourceGroup, name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("Bad: Alert Rule %q (resource group: %q) does not exist", name, resourceGroup) + } + + return fmt.Errorf("Bad: Get on monitorAlertRulesClient: %+v", err) + } + + return nil + } +} + +func testCheckAzureRMMetricAlertRuleDestroy(s *terraform.State) error { + client := testAccProvider.Meta().(*ArmClient).monitorAlertRulesClient + ctx := testAccProvider.Meta().(*ArmClient).StopContext + + for _, rs := range s.RootModule().Resources { + if rs.Type != "azurerm_metric_alertrule" { + continue + } + + name := rs.Primary.Attributes["name"] + resourceGroup := rs.Primary.Attributes["resource_group_name"] + + resp, err := client.Get(ctx, resourceGroup, name) + + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return nil + } + + return err + } + + return fmt.Errorf("Alert Rule still exists:\n%#v", resp) + } + + return nil +} + +func testAccAzureRMMetricAlertRule_virtualMachineCpu(rInt int, location string, enabled bool) string { + basicLinuxMachine := testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_explicit(rInt, location) + + enabledString := strconv.FormatBool(enabled) + + return fmt.Sprintf(` +%s + +resource "azurerm_metric_alertrule" "test" { + name = "${azurerm_virtual_machine.test.name}-cpu" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + + description = "An alert rule to watch the metric Percentage CPU" + + enabled = %s + + resource_id = "${azurerm_virtual_machine.test.id}" + metric_name = "Percentage CPU" + operator = "GreaterThan" + threshold = 75 + aggregation = "Average" + period = "PT5M" + + email_action { + send_to_service_owners = false + custom_emails = [ + "support@azure.microsoft.com", + ] + } + + webhook_action { + service_uri = "https://requestb.in/18jamc41" + properties = { + severity = "incredible" + acceptance_test = "true" + } + } +} +`, basicLinuxMachine, enabledString) +} + +func testAccAzureRMMetricAlertRule_sqlDatabaseStorage(rInt int, location string) string { + basicSqlServerDatabase := testAccAzureRMSqlDatabase_basic(rInt, location) + + return fmt.Sprintf(` +%s + +resource "azurerm_metric_alertrule" "test" { + name = "${azurerm_sql_database.test.name}-storage" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + + description = "An alert rule to watch the metric Storage" + + enabled = true + + resource_id = "${azurerm_sql_database.test.id}" + metric_name = "storage" + operator = "GreaterThan" + threshold = 1073741824 + aggregation = "Maximum" + period = "PT10M" + + email_action { + send_to_service_owners = false + custom_emails = [ + "support@azure.microsoft.com", + ] + } + + webhook_action { + service_uri = "https://requestb.in/18jamc41" + properties = { + severity = "incredible" + acceptance_test = "true" + } + } +} +`, basicSqlServerDatabase) +} diff --git a/azurerm/validators.go b/azurerm/validators.go index a6405ed8ea6b..a55853cdba8c 100644 --- a/azurerm/validators.go +++ b/azurerm/validators.go @@ -74,3 +74,20 @@ func validateStringLength(maxLength int) schema.SchemaValidateFunc { return } } + +func validateIso8601Duration() schema.SchemaValidateFunc { + return func(i interface{}, k string) (s []string, es []error) { + v, ok := i.(string) + if !ok { + es = append(es, fmt.Errorf("expected type of %s to be string", k)) + return + } + + matched, _ := regexp.MatchString(`^P([0-9]+Y)?([0-9]+M)?([0-9]+W)?([0-9]+D)?(T([0-9]+H)?([0-9]+M)?([0-9]+(\.?[0-9]+)?S)?)?$`, v) + + if !matched { + es = append(es, fmt.Errorf("expected %s to be in ISO 8601 duration format, got %s", k, v)) + } + return + } +} diff --git a/azurerm/validators_test.go b/azurerm/validators_test.go index 7294ad2f821d..edf710546dcf 100644 --- a/azurerm/validators_test.go +++ b/azurerm/validators_test.go @@ -130,3 +130,44 @@ func TestDBAccountName_validation(t *testing.T) { } } } + +func TestValidateIso8601Duration(t *testing.T) { + cases := []struct { + Value string + Errors int + }{ + { + // Date components only + Value: "P1Y2M3D", + Errors: 0, + }, + { + // Time components only + Value: "PT7H42M3S", + Errors: 0, + }, + { + // Date and time components + Value: "P1Y2M3DT7H42M3S", + Errors: 0, + }, + { + // Invalid prefix + Value: "1Y2M3DT7H42M3S", + Errors: 1, + }, + { + // Wrong order of components, i.e. invalid format + Value: "PT7H42M3S1Y2M3D", + Errors: 1, + }, + } + + for _, tc := range cases { + _, errors := validateIso8601Duration()(tc.Value, "example") + + if len(errors) != tc.Errors { + t.Fatalf("Expected validateIso8601Duration to trigger '%d' errors for '%s' - got '%d'", tc.Errors, tc.Value, len(errors)) + } + } +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/actiongroups.go b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/actiongroups.go new file mode 100644 index 000000000000..94121c5eeb32 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/actiongroups.go @@ -0,0 +1,452 @@ +package insights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ActionGroupsClient is the monitor Management Client +type ActionGroupsClient struct { + BaseClient +} + +// NewActionGroupsClient creates an instance of the ActionGroupsClient client. +func NewActionGroupsClient(subscriptionID string) ActionGroupsClient { + return NewActionGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewActionGroupsClientWithBaseURI creates an instance of the ActionGroupsClient client. +func NewActionGroupsClientWithBaseURI(baseURI string, subscriptionID string) ActionGroupsClient { + return ActionGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create a new action group or update an existing one. +// +// resourceGroupName is the name of the resource group. actionGroupName is the name of the action group. actionGroup is +// the action group to create or use for the update. +func (client ActionGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroup ActionGroupResource) (result ActionGroupResource, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: actionGroup, + Constraints: []validation.Constraint{{Target: "actionGroup.ActionGroup", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "actionGroup.ActionGroup.GroupShortName", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "actionGroup.ActionGroup.GroupShortName", Name: validation.MaxLength, Rule: 15, Chain: nil}}}, + {Target: "actionGroup.ActionGroup.Enabled", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "insights.ActionGroupsClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, actionGroupName, actionGroup) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ActionGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroup ActionGroupResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "actionGroupName": autorest.Encode("path", actionGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", pathParameters), + autorest.WithJSON(actionGroup), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ActionGroupsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ActionGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result ActionGroupResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete an action group. +// +// resourceGroupName is the name of the resource group. actionGroupName is the name of the action group. +func (client ActionGroupsClient) Delete(ctx context.Context, resourceGroupName string, actionGroupName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, actionGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ActionGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, actionGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "actionGroupName": autorest.Encode("path", actionGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", 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 ActionGroupsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ActionGroupsClient) 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 +} + +// EnableReceiver enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. +// +// resourceGroupName is the name of the resource group. actionGroupName is the name of the action group. enableRequest +// is the receiver to re-enable. +func (client ActionGroupsClient) EnableReceiver(ctx context.Context, resourceGroupName string, actionGroupName string, enableRequest EnableRequest) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: enableRequest, + Constraints: []validation.Constraint{{Target: "enableRequest.ReceiverName", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "insights.ActionGroupsClient", "EnableReceiver") + } + + req, err := client.EnableReceiverPreparer(ctx, resourceGroupName, actionGroupName, enableRequest) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "EnableReceiver", nil, "Failure preparing request") + return + } + + resp, err := client.EnableReceiverSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "EnableReceiver", resp, "Failure sending request") + return + } + + result, err = client.EnableReceiverResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "EnableReceiver", resp, "Failure responding to request") + } + + return +} + +// EnableReceiverPreparer prepares the EnableReceiver request. +func (client ActionGroupsClient) EnableReceiverPreparer(ctx context.Context, resourceGroupName string, actionGroupName string, enableRequest EnableRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "actionGroupName": autorest.Encode("path", actionGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe", pathParameters), + autorest.WithJSON(enableRequest), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// EnableReceiverSender sends the EnableReceiver request. The method will close the +// http.Response Body if it receives an error. +func (client ActionGroupsClient) EnableReceiverSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// EnableReceiverResponder handles the response to the EnableReceiver request. The method always +// closes the http.Response Body. +func (client ActionGroupsClient) EnableReceiverResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusConflict), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get an action group. +// +// resourceGroupName is the name of the resource group. actionGroupName is the name of the action group. +func (client ActionGroupsClient) Get(ctx context.Context, resourceGroupName string, actionGroupName string) (result ActionGroupResource, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, actionGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ActionGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, actionGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "actionGroupName": autorest.Encode("path", actionGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", 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 ActionGroupsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ActionGroupsClient) GetResponder(resp *http.Response) (result ActionGroupResource, 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 get a list of all action groups in a resource group. +// +// resourceGroupName is the name of the resource group. +func (client ActionGroupsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ActionGroupList, err error) { + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ActionGroupsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups", 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 ActionGroupsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ActionGroupsClient) ListByResourceGroupResponder(resp *http.Response) (result ActionGroupList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscriptionID get a list of all action groups in a subscription. +func (client ActionGroupsClient) ListBySubscriptionID(ctx context.Context) (result ActionGroupList, err error) { + req, err := client.ListBySubscriptionIDPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListBySubscriptionID", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListBySubscriptionID", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListBySubscriptionID", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionIDPreparer prepares the ListBySubscriptionID request. +func (client ActionGroupsClient) ListBySubscriptionIDPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionIDSender sends the ListBySubscriptionID request. The method will close the +// http.Response Body if it receives an error. +func (client ActionGroupsClient) ListBySubscriptionIDSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionIDResponder handles the response to the ListBySubscriptionID request. The method always +// closes the http.Response Body. +func (client ActionGroupsClient) ListBySubscriptionIDResponder(resp *http.Response) (result ActionGroupList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/activitylogalerts.go b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/activitylogalerts.go new file mode 100644 index 000000000000..137bacfa340e --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/activitylogalerts.go @@ -0,0 +1,448 @@ +package insights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ActivityLogAlertsClient is the monitor Management Client +type ActivityLogAlertsClient struct { + BaseClient +} + +// NewActivityLogAlertsClient creates an instance of the ActivityLogAlertsClient client. +func NewActivityLogAlertsClient(subscriptionID string) ActivityLogAlertsClient { + return NewActivityLogAlertsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewActivityLogAlertsClientWithBaseURI creates an instance of the ActivityLogAlertsClient client. +func NewActivityLogAlertsClientWithBaseURI(baseURI string, subscriptionID string) ActivityLogAlertsClient { + return ActivityLogAlertsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create a new activity log alert or update an existing one. +// +// resourceGroupName is the name of the resource group. activityLogAlertName is the name of the activity log alert. +// activityLogAlert is the activity log alert to create or use for the update. +func (client ActivityLogAlertsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlert ActivityLogAlertResource) (result ActivityLogAlertResource, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: activityLogAlert, + Constraints: []validation.Constraint{{Target: "activityLogAlert.ActivityLogAlert", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "activityLogAlert.ActivityLogAlert.Scopes", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "activityLogAlert.ActivityLogAlert.Condition", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "activityLogAlert.ActivityLogAlert.Condition.AllOf", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "activityLogAlert.ActivityLogAlert.Actions", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "insights.ActivityLogAlertsClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, activityLogAlertName, activityLogAlert) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ActivityLogAlertsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlert ActivityLogAlertResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "activityLogAlertName": autorest.Encode("path", activityLogAlertName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", pathParameters), + autorest.WithJSON(activityLogAlert), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ActivityLogAlertsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ActivityLogAlertsClient) CreateOrUpdateResponder(resp *http.Response) (result ActivityLogAlertResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete an activity log alert. +// +// resourceGroupName is the name of the resource group. activityLogAlertName is the name of the activity log alert. +func (client ActivityLogAlertsClient) Delete(ctx context.Context, resourceGroupName string, activityLogAlertName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, activityLogAlertName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ActivityLogAlertsClient) DeletePreparer(ctx context.Context, resourceGroupName string, activityLogAlertName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "activityLogAlertName": autorest.Encode("path", activityLogAlertName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", 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 ActivityLogAlertsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ActivityLogAlertsClient) 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 get an activity log alert. +// +// resourceGroupName is the name of the resource group. activityLogAlertName is the name of the activity log alert. +func (client ActivityLogAlertsClient) Get(ctx context.Context, resourceGroupName string, activityLogAlertName string) (result ActivityLogAlertResource, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, activityLogAlertName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ActivityLogAlertsClient) GetPreparer(ctx context.Context, resourceGroupName string, activityLogAlertName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "activityLogAlertName": autorest.Encode("path", activityLogAlertName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", 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 ActivityLogAlertsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ActivityLogAlertsClient) GetResponder(resp *http.Response) (result ActivityLogAlertResource, 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 get a list of all activity log alerts in a resource group. +// +// resourceGroupName is the name of the resource group. +func (client ActivityLogAlertsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ActivityLogAlertList, err error) { + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ActivityLogAlertsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts", 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 ActivityLogAlertsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ActivityLogAlertsClient) ListByResourceGroupResponder(resp *http.Response) (result ActivityLogAlertList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscriptionID get a list of all activity log alerts in a subscription. +func (client ActivityLogAlertsClient) ListBySubscriptionID(ctx context.Context) (result ActivityLogAlertList, err error) { + req, err := client.ListBySubscriptionIDPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "ListBySubscriptionID", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "ListBySubscriptionID", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "ListBySubscriptionID", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionIDPreparer prepares the ListBySubscriptionID request. +func (client ActivityLogAlertsClient) ListBySubscriptionIDPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionIDSender sends the ListBySubscriptionID request. The method will close the +// http.Response Body if it receives an error. +func (client ActivityLogAlertsClient) ListBySubscriptionIDSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionIDResponder handles the response to the ListBySubscriptionID request. The method always +// closes the http.Response Body. +func (client ActivityLogAlertsClient) ListBySubscriptionIDResponder(resp *http.Response) (result ActivityLogAlertList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing ActivityLogAlertResource's tags. To update other fields use the CreateOrUpdate method. +// +// resourceGroupName is the name of the resource group. activityLogAlertName is the name of the activity log alert. +// activityLogAlertPatch is parameters supplied to the operation. +func (client ActivityLogAlertsClient) Update(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlertPatch ActivityLogAlertPatchBody) (result ActivityLogAlertResource, err error) { + req, err := client.UpdatePreparer(ctx, resourceGroupName, activityLogAlertName, activityLogAlertPatch) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ActivityLogAlertsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlertPatch ActivityLogAlertPatchBody) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "activityLogAlertName": autorest.Encode("path", activityLogAlertName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", pathParameters), + autorest.WithJSON(activityLogAlertPatch), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ActivityLogAlertsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ActivityLogAlertsClient) UpdateResponder(resp *http.Response) (result ActivityLogAlertResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/alertruleincidents.go b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/alertruleincidents.go new file mode 100644 index 000000000000..9d1508ec1bca --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/alertruleincidents.go @@ -0,0 +1,174 @@ +package insights + +// 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" + "net/http" +) + +// AlertRuleIncidentsClient is the monitor Management Client +type AlertRuleIncidentsClient struct { + BaseClient +} + +// NewAlertRuleIncidentsClient creates an instance of the AlertRuleIncidentsClient client. +func NewAlertRuleIncidentsClient(subscriptionID string) AlertRuleIncidentsClient { + return NewAlertRuleIncidentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAlertRuleIncidentsClientWithBaseURI creates an instance of the AlertRuleIncidentsClient client. +func NewAlertRuleIncidentsClientWithBaseURI(baseURI string, subscriptionID string) AlertRuleIncidentsClient { + return AlertRuleIncidentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets an incident associated to an alert rule +// +// resourceGroupName is the name of the resource group. ruleName is the name of the rule. incidentName is the name of +// the incident to retrieve. +func (client AlertRuleIncidentsClient) Get(ctx context.Context, resourceGroupName string, ruleName string, incidentName string) (result Incident, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, ruleName, incidentName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AlertRuleIncidentsClient) GetPreparer(ctx context.Context, resourceGroupName string, ruleName string, incidentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "incidentName": autorest.Encode("path", incidentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}", 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 AlertRuleIncidentsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AlertRuleIncidentsClient) GetResponder(resp *http.Response) (result Incident, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAlertRule gets a list of incidents associated to an alert rule +// +// resourceGroupName is the name of the resource group. ruleName is the name of the rule. +func (client AlertRuleIncidentsClient) ListByAlertRule(ctx context.Context, resourceGroupName string, ruleName string) (result IncidentListResult, err error) { + req, err := client.ListByAlertRulePreparer(ctx, resourceGroupName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "ListByAlertRule", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAlertRuleSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "ListByAlertRule", resp, "Failure sending request") + return + } + + result, err = client.ListByAlertRuleResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "ListByAlertRule", resp, "Failure responding to request") + } + + return +} + +// ListByAlertRulePreparer prepares the ListByAlertRule request. +func (client AlertRuleIncidentsClient) ListByAlertRulePreparer(ctx context.Context, resourceGroupName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByAlertRuleSender sends the ListByAlertRule request. The method will close the +// http.Response Body if it receives an error. +func (client AlertRuleIncidentsClient) ListByAlertRuleSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByAlertRuleResponder handles the response to the ListByAlertRule request. The method always +// closes the http.Response Body. +func (client AlertRuleIncidentsClient) ListByAlertRuleResponder(resp *http.Response) (result IncidentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/alertrules.go b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/alertrules.go new file mode 100644 index 000000000000..7d8a19dd6e20 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/alertrules.go @@ -0,0 +1,385 @@ +package insights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// AlertRulesClient is the monitor Management Client +type AlertRulesClient struct { + BaseClient +} + +// NewAlertRulesClient creates an instance of the AlertRulesClient client. +func NewAlertRulesClient(subscriptionID string) AlertRulesClient { + return NewAlertRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAlertRulesClientWithBaseURI creates an instance of the AlertRulesClient client. +func NewAlertRulesClientWithBaseURI(baseURI string, subscriptionID string) AlertRulesClient { + return AlertRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an alert rule. +// +// resourceGroupName is the name of the resource group. ruleName is the name of the rule. parameters is the parameters +// of the rule to create or update. +func (client AlertRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, ruleName string, parameters AlertRuleResource) (result AlertRuleResource, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.AlertRule", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.AlertRule.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AlertRule.IsEnabled", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AlertRule.Condition", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "insights.AlertRulesClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, ruleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AlertRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, ruleName string, parameters AlertRuleResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client AlertRulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) CreateOrUpdateResponder(resp *http.Response) (result AlertRuleResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an alert rule +// +// resourceGroupName is the name of the resource group. ruleName is the name of the rule. +func (client AlertRulesClient) Delete(ctx context.Context, resourceGroupName string, ruleName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AlertRulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}", 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 AlertRulesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) 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 gets an alert rule +// +// resourceGroupName is the name of the resource group. ruleName is the name of the rule. +func (client AlertRulesClient) Get(ctx context.Context, resourceGroupName string, ruleName string) (result AlertRuleResource, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AlertRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}", 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 AlertRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) GetResponder(resp *http.Response) (result AlertRuleResource, 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 list the alert rules within a resource group. +// +// resourceGroupName is the name of the resource group. +func (client AlertRulesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result AlertRuleResourceCollection, err error) { + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client AlertRulesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules", 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 AlertRulesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) ListByResourceGroupResponder(resp *http.Response) (result AlertRuleResourceCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing AlertRuleResource. To update other fields use the CreateOrUpdate method. +// +// resourceGroupName is the name of the resource group. ruleName is the name of the rule. alertRulesResource is +// parameters supplied to the operation. +func (client AlertRulesClient) Update(ctx context.Context, resourceGroupName string, ruleName string, alertRulesResource AlertRuleResourcePatch) (result AlertRuleResource, err error) { + req, err := client.UpdatePreparer(ctx, resourceGroupName, ruleName, alertRulesResource) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client AlertRulesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, ruleName string, alertRulesResource AlertRuleResourcePatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}", pathParameters), + autorest.WithJSON(alertRulesResource), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client AlertRulesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) UpdateResponder(resp *http.Response) (result AlertRuleResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/autoscalesettings.go b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/autoscalesettings.go new file mode 100644 index 000000000000..a3be3075a55f --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/autoscalesettings.go @@ -0,0 +1,412 @@ +package insights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// AutoscaleSettingsClient is the monitor Management Client +type AutoscaleSettingsClient struct { + BaseClient +} + +// NewAutoscaleSettingsClient creates an instance of the AutoscaleSettingsClient client. +func NewAutoscaleSettingsClient(subscriptionID string) AutoscaleSettingsClient { + return NewAutoscaleSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAutoscaleSettingsClientWithBaseURI creates an instance of the AutoscaleSettingsClient client. +func NewAutoscaleSettingsClientWithBaseURI(baseURI string, subscriptionID string) AutoscaleSettingsClient { + return AutoscaleSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an autoscale setting. +// +// resourceGroupName is the name of the resource group. autoscaleSettingName is the autoscale setting name. parameters +// is parameters supplied to the operation. +func (client AutoscaleSettingsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, autoscaleSettingName string, parameters AutoscaleSettingResource) (result AutoscaleSettingResource, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.AutoscaleSetting", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.AutoscaleSetting.Profiles", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.AutoscaleSetting.Profiles", Name: validation.MaxItems, Rule: 20, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "insights.AutoscaleSettingsClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, autoscaleSettingName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AutoscaleSettingsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, autoscaleSettingName string, parameters AutoscaleSettingResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "autoscaleSettingName": autorest.Encode("path", autoscaleSettingName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/autoscalesettings/{autoscaleSettingName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client AutoscaleSettingsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AutoscaleSettingsClient) CreateOrUpdateResponder(resp *http.Response) (result AutoscaleSettingResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes and autoscale setting +// +// resourceGroupName is the name of the resource group. autoscaleSettingName is the autoscale setting name. +func (client AutoscaleSettingsClient) Delete(ctx context.Context, resourceGroupName string, autoscaleSettingName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, autoscaleSettingName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AutoscaleSettingsClient) DeletePreparer(ctx context.Context, resourceGroupName string, autoscaleSettingName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "autoscaleSettingName": autorest.Encode("path", autoscaleSettingName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/autoscalesettings/{autoscaleSettingName}", 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 AutoscaleSettingsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AutoscaleSettingsClient) 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 gets an autoscale setting +// +// resourceGroupName is the name of the resource group. autoscaleSettingName is the autoscale setting name. +func (client AutoscaleSettingsClient) Get(ctx context.Context, resourceGroupName string, autoscaleSettingName string) (result AutoscaleSettingResource, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, autoscaleSettingName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AutoscaleSettingsClient) GetPreparer(ctx context.Context, resourceGroupName string, autoscaleSettingName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "autoscaleSettingName": autorest.Encode("path", autoscaleSettingName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/autoscalesettings/{autoscaleSettingName}", 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 AutoscaleSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AutoscaleSettingsClient) GetResponder(resp *http.Response) (result AutoscaleSettingResource, 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 lists the autoscale settings for a resource group +// +// resourceGroupName is the name of the resource group. +func (client AutoscaleSettingsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result AutoscaleSettingResourceCollectionPage, err error) { + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.asrc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.asrc, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client AutoscaleSettingsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/autoscalesettings", 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 AutoscaleSettingsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client AutoscaleSettingsClient) ListByResourceGroupResponder(resp *http.Response) (result AutoscaleSettingResourceCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client AutoscaleSettingsClient) listByResourceGroupNextResults(lastResults AutoscaleSettingResourceCollection) (result AutoscaleSettingResourceCollection, err error) { + req, err := lastResults.autoscaleSettingResourceCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client AutoscaleSettingsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result AutoscaleSettingResourceCollectionIterator, err error) { + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate method. +// +// resourceGroupName is the name of the resource group. autoscaleSettingName is the autoscale setting name. +// autoscaleSettingResource is parameters supplied to the operation. +func (client AutoscaleSettingsClient) Update(ctx context.Context, resourceGroupName string, autoscaleSettingName string, autoscaleSettingResource AutoscaleSettingResourcePatch) (result AutoscaleSettingResource, err error) { + req, err := client.UpdatePreparer(ctx, resourceGroupName, autoscaleSettingName, autoscaleSettingResource) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client AutoscaleSettingsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, autoscaleSettingName string, autoscaleSettingResource AutoscaleSettingResourcePatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "autoscaleSettingName": autorest.Encode("path", autoscaleSettingName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/autoscalesettings/{autoscaleSettingName}", pathParameters), + autorest.WithJSON(autoscaleSettingResource), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client AutoscaleSettingsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client AutoscaleSettingsClient) UpdateResponder(resp *http.Response) (result AutoscaleSettingResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/client.go new file mode 100644 index 000000000000..5ed388022a2b --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/client.go @@ -0,0 +1,51 @@ +// Package insights implements the Azure ARM Insights service API version . +// +// Monitor Management Client +package insights + +// 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 Insights + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Insights. +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. +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/monitor/mgmt/2017-05-01-preview/insights/diagnosticsettings.go b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/diagnosticsettings.go new file mode 100644 index 000000000000..c938435a013a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/diagnosticsettings.go @@ -0,0 +1,301 @@ +package insights + +// 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" + "net/http" +) + +// DiagnosticSettingsClient is the monitor Management Client +type DiagnosticSettingsClient struct { + BaseClient +} + +// NewDiagnosticSettingsClient creates an instance of the DiagnosticSettingsClient client. +func NewDiagnosticSettingsClient(subscriptionID string) DiagnosticSettingsClient { + return NewDiagnosticSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDiagnosticSettingsClientWithBaseURI creates an instance of the DiagnosticSettingsClient client. +func NewDiagnosticSettingsClientWithBaseURI(baseURI string, subscriptionID string) DiagnosticSettingsClient { + return DiagnosticSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates diagnostic settings for the specified resource. +// +// resourceURI is the identifier of the resource. parameters is parameters supplied to the operation. name is the name +// of the diagnostic setting. +func (client DiagnosticSettingsClient) CreateOrUpdate(ctx context.Context, resourceURI string, parameters DiagnosticSettingsResource, name string) (result DiagnosticSettingsResource, err error) { + req, err := client.CreateOrUpdatePreparer(ctx, resourceURI, parameters, name) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DiagnosticSettingsClient) CreateOrUpdatePreparer(ctx context.Context, resourceURI string, parameters DiagnosticSettingsResource, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceUri": autorest.Encode("path", resourceURI), + } + + const APIVersion = "2017-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/diagnosticSettings/{name}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DiagnosticSettingsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DiagnosticSettingsClient) CreateOrUpdateResponder(resp *http.Response) (result DiagnosticSettingsResource, 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 deletes existing diagnostic settings for the specified resource. +// +// resourceURI is the identifier of the resource. name is the name of the diagnostic setting. +func (client DiagnosticSettingsClient) Delete(ctx context.Context, resourceURI string, name string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(ctx, resourceURI, name) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DiagnosticSettingsClient) DeletePreparer(ctx context.Context, resourceURI string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceUri": autorest.Encode("path", resourceURI), + } + + const APIVersion = "2017-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/diagnosticSettings/{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 DiagnosticSettingsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 DiagnosticSettingsClient) 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 gets the active diagnostic settings for the specified resource. +// +// resourceURI is the identifier of the resource. name is the name of the diagnostic setting. +func (client DiagnosticSettingsClient) Get(ctx context.Context, resourceURI string, name string) (result DiagnosticSettingsResource, err error) { + req, err := client.GetPreparer(ctx, resourceURI, name) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DiagnosticSettingsClient) GetPreparer(ctx context.Context, resourceURI string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceUri": autorest.Encode("path", resourceURI), + } + + const APIVersion = "2017-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/diagnosticSettings/{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 DiagnosticSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 DiagnosticSettingsClient) GetResponder(resp *http.Response) (result DiagnosticSettingsResource, 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 gets the active diagnostic settings list for the specified resource. +// +// resourceURI is the identifier of the resource. +func (client DiagnosticSettingsClient) List(ctx context.Context, resourceURI string) (result DiagnosticSettingsResourceCollection, err error) { + req, err := client.ListPreparer(ctx, resourceURI) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client DiagnosticSettingsClient) ListPreparer(ctx context.Context, resourceURI string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceUri": autorest.Encode("path", resourceURI), + } + + const APIVersion = "2017-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/diagnosticSettings", 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 DiagnosticSettingsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 DiagnosticSettingsClient) ListResponder(resp *http.Response) (result DiagnosticSettingsResourceCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/diagnosticsettingscategory.go b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/diagnosticsettingscategory.go new file mode 100644 index 000000000000..8862f852c9c0 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/diagnosticsettingscategory.go @@ -0,0 +1,169 @@ +package insights + +// 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" + "net/http" +) + +// DiagnosticSettingsCategoryClient is the monitor Management Client +type DiagnosticSettingsCategoryClient struct { + BaseClient +} + +// NewDiagnosticSettingsCategoryClient creates an instance of the DiagnosticSettingsCategoryClient client. +func NewDiagnosticSettingsCategoryClient(subscriptionID string) DiagnosticSettingsCategoryClient { + return NewDiagnosticSettingsCategoryClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDiagnosticSettingsCategoryClientWithBaseURI creates an instance of the DiagnosticSettingsCategoryClient client. +func NewDiagnosticSettingsCategoryClientWithBaseURI(baseURI string, subscriptionID string) DiagnosticSettingsCategoryClient { + return DiagnosticSettingsCategoryClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets the diagnostic settings category for the specified resource. +// +// resourceURI is the identifier of the resource. name is the name of the diagnostic setting. +func (client DiagnosticSettingsCategoryClient) Get(ctx context.Context, resourceURI string, name string) (result DiagnosticSettingsCategoryResource, err error) { + req, err := client.GetPreparer(ctx, resourceURI, name) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsCategoryClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsCategoryClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsCategoryClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DiagnosticSettingsCategoryClient) GetPreparer(ctx context.Context, resourceURI string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceUri": autorest.Encode("path", resourceURI), + } + + const APIVersion = "2017-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/diagnosticSettingsCategories/{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 DiagnosticSettingsCategoryClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 DiagnosticSettingsCategoryClient) GetResponder(resp *http.Response) (result DiagnosticSettingsCategoryResource, 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 lists the diagnostic settings categories for the specified resource. +// +// resourceURI is the identifier of the resource. +func (client DiagnosticSettingsCategoryClient) List(ctx context.Context, resourceURI string) (result DiagnosticSettingsCategoryResourceCollection, err error) { + req, err := client.ListPreparer(ctx, resourceURI) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsCategoryClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsCategoryClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsCategoryClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client DiagnosticSettingsCategoryClient) ListPreparer(ctx context.Context, resourceURI string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceUri": autorest.Encode("path", resourceURI), + } + + const APIVersion = "2017-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/diagnosticSettingsCategories", 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 DiagnosticSettingsCategoryClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 DiagnosticSettingsCategoryClient) ListResponder(resp *http.Response) (result DiagnosticSettingsCategoryResourceCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/logprofiles.go b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/logprofiles.go new file mode 100644 index 000000000000..91342d2467a7 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/logprofiles.go @@ -0,0 +1,380 @@ +package insights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// LogProfilesClient is the monitor Management Client +type LogProfilesClient struct { + BaseClient +} + +// NewLogProfilesClient creates an instance of the LogProfilesClient client. +func NewLogProfilesClient(subscriptionID string) LogProfilesClient { + return NewLogProfilesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLogProfilesClientWithBaseURI creates an instance of the LogProfilesClient client. +func NewLogProfilesClientWithBaseURI(baseURI string, subscriptionID string) LogProfilesClient { + return LogProfilesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update a log profile in Azure Monitoring REST API. +// +// logProfileName is the name of the log profile. parameters is parameters supplied to the operation. +func (client LogProfilesClient) CreateOrUpdate(ctx context.Context, logProfileName string, parameters LogProfileResource) (result LogProfileResource, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.LogProfileProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.LogProfileProperties.Locations", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.LogProfileProperties.Categories", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.LogProfileProperties.RetentionPolicy", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.LogProfileProperties.RetentionPolicy.Enabled", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.LogProfileProperties.RetentionPolicy.Days", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.LogProfileProperties.RetentionPolicy.Days", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}, + }}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "insights.LogProfilesClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(ctx, logProfileName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client LogProfilesClient) CreateOrUpdatePreparer(ctx context.Context, logProfileName string, parameters LogProfileResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "logProfileName": autorest.Encode("path", logProfileName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client LogProfilesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client LogProfilesClient) CreateOrUpdateResponder(resp *http.Response) (result LogProfileResource, 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 deletes the log profile. +// +// logProfileName is the name of the log profile. +func (client LogProfilesClient) Delete(ctx context.Context, logProfileName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(ctx, logProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client LogProfilesClient) DeletePreparer(ctx context.Context, logProfileName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "logProfileName": autorest.Encode("path", logProfileName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}", 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 LogProfilesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client LogProfilesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the log profile. +// +// logProfileName is the name of the log profile. +func (client LogProfilesClient) Get(ctx context.Context, logProfileName string) (result LogProfileResource, err error) { + req, err := client.GetPreparer(ctx, logProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client LogProfilesClient) GetPreparer(ctx context.Context, logProfileName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "logProfileName": autorest.Encode("path", logProfileName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}", 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 LogProfilesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client LogProfilesClient) GetResponder(resp *http.Response) (result LogProfileResource, 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 list the log profiles. +func (client LogProfilesClient) List(ctx context.Context) (result LogProfileCollection, err error) { + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client LogProfilesClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles", 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 LogProfilesClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client LogProfilesClient) ListResponder(resp *http.Response) (result LogProfileCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. +// +// logProfileName is the name of the log profile. logProfilesResource is parameters supplied to the operation. +func (client LogProfilesClient) Update(ctx context.Context, logProfileName string, logProfilesResource LogProfileResourcePatch) (result LogProfileResource, err error) { + req, err := client.UpdatePreparer(ctx, logProfileName, logProfilesResource) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client LogProfilesClient) UpdatePreparer(ctx context.Context, logProfileName string, logProfilesResource LogProfileResourcePatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "logProfileName": autorest.Encode("path", logProfileName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}", pathParameters), + autorest.WithJSON(logProfilesResource), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client LogProfilesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client LogProfilesClient) UpdateResponder(resp *http.Response) (result LogProfileResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/models.go new file mode 100644 index 000000000000..b68ac83cf2ca --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/models.go @@ -0,0 +1,2370 @@ +package insights + +// 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 ( + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "net/http" +) + +// CategoryType enumerates the values for category type. +type CategoryType string + +const ( + // Logs ... + Logs CategoryType = "Logs" + // Metrics ... + Metrics CategoryType = "Metrics" +) + +// ComparisonOperationType enumerates the values for comparison operation type. +type ComparisonOperationType string + +const ( + // Equals ... + Equals ComparisonOperationType = "Equals" + // GreaterThan ... + GreaterThan ComparisonOperationType = "GreaterThan" + // GreaterThanOrEqual ... + GreaterThanOrEqual ComparisonOperationType = "GreaterThanOrEqual" + // LessThan ... + LessThan ComparisonOperationType = "LessThan" + // LessThanOrEqual ... + LessThanOrEqual ComparisonOperationType = "LessThanOrEqual" + // NotEquals ... + NotEquals ComparisonOperationType = "NotEquals" +) + +// ConditionOperator enumerates the values for condition operator. +type ConditionOperator string + +const ( + // ConditionOperatorGreaterThan ... + ConditionOperatorGreaterThan ConditionOperator = "GreaterThan" + // ConditionOperatorGreaterThanOrEqual ... + ConditionOperatorGreaterThanOrEqual ConditionOperator = "GreaterThanOrEqual" + // ConditionOperatorLessThan ... + ConditionOperatorLessThan ConditionOperator = "LessThan" + // ConditionOperatorLessThanOrEqual ... + ConditionOperatorLessThanOrEqual ConditionOperator = "LessThanOrEqual" +) + +// MetricStatisticType enumerates the values for metric statistic type. +type MetricStatisticType string + +const ( + // Average ... + Average MetricStatisticType = "Average" + // Max ... + Max MetricStatisticType = "Max" + // Min ... + Min MetricStatisticType = "Min" + // Sum ... + Sum MetricStatisticType = "Sum" +) + +// OdataType enumerates the values for odata type. +type OdataType string + +const ( + // OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource ... + OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource OdataType = "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource" + // OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource ... + OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource OdataType = "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource" + // OdataTypeRuleDataSource ... + OdataTypeRuleDataSource OdataType = "RuleDataSource" +) + +// OdataTypeBasicRuleAction enumerates the values for odata type basic rule action. +type OdataTypeBasicRuleAction string + +const ( + // OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction ... + OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction OdataTypeBasicRuleAction = "Microsoft.Azure.Management.Insights.Models.RuleEmailAction" + // OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction ... + OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction OdataTypeBasicRuleAction = "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction" + // OdataTypeRuleAction ... + OdataTypeRuleAction OdataTypeBasicRuleAction = "RuleAction" +) + +// OdataTypeBasicRuleCondition enumerates the values for odata type basic rule condition. +type OdataTypeBasicRuleCondition string + +const ( + // OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition ... + OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition OdataTypeBasicRuleCondition = "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition" + // OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition ... + OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition OdataTypeBasicRuleCondition = "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition" + // OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition ... + OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition OdataTypeBasicRuleCondition = "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition" + // OdataTypeRuleCondition ... + OdataTypeRuleCondition OdataTypeBasicRuleCondition = "RuleCondition" +) + +// ReceiverStatus enumerates the values for receiver status. +type ReceiverStatus string + +const ( + // Disabled ... + Disabled ReceiverStatus = "Disabled" + // Enabled ... + Enabled ReceiverStatus = "Enabled" + // NotSpecified ... + NotSpecified ReceiverStatus = "NotSpecified" +) + +// RecurrenceFrequency enumerates the values for recurrence frequency. +type RecurrenceFrequency string + +const ( + // Day ... + Day RecurrenceFrequency = "Day" + // Hour ... + Hour RecurrenceFrequency = "Hour" + // Minute ... + Minute RecurrenceFrequency = "Minute" + // Month ... + Month RecurrenceFrequency = "Month" + // None ... + None RecurrenceFrequency = "None" + // Second ... + Second RecurrenceFrequency = "Second" + // Week ... + Week RecurrenceFrequency = "Week" + // Year ... + Year RecurrenceFrequency = "Year" +) + +// ScaleDirection enumerates the values for scale direction. +type ScaleDirection string + +const ( + // ScaleDirectionDecrease ... + ScaleDirectionDecrease ScaleDirection = "Decrease" + // ScaleDirectionIncrease ... + ScaleDirectionIncrease ScaleDirection = "Increase" + // ScaleDirectionNone ... + ScaleDirectionNone ScaleDirection = "None" +) + +// ScaleType enumerates the values for scale type. +type ScaleType string + +const ( + // ChangeCount ... + ChangeCount ScaleType = "ChangeCount" + // ExactCount ... + ExactCount ScaleType = "ExactCount" + // PercentChangeCount ... + PercentChangeCount ScaleType = "PercentChangeCount" +) + +// TimeAggregationOperator enumerates the values for time aggregation operator. +type TimeAggregationOperator string + +const ( + // TimeAggregationOperatorAverage ... + TimeAggregationOperatorAverage TimeAggregationOperator = "Average" + // TimeAggregationOperatorLast ... + TimeAggregationOperatorLast TimeAggregationOperator = "Last" + // TimeAggregationOperatorMaximum ... + TimeAggregationOperatorMaximum TimeAggregationOperator = "Maximum" + // TimeAggregationOperatorMinimum ... + TimeAggregationOperatorMinimum TimeAggregationOperator = "Minimum" + // TimeAggregationOperatorTotal ... + TimeAggregationOperatorTotal TimeAggregationOperator = "Total" +) + +// TimeAggregationType enumerates the values for time aggregation type. +type TimeAggregationType string + +const ( + // TimeAggregationTypeAverage ... + TimeAggregationTypeAverage TimeAggregationType = "Average" + // TimeAggregationTypeCount ... + TimeAggregationTypeCount TimeAggregationType = "Count" + // TimeAggregationTypeMaximum ... + TimeAggregationTypeMaximum TimeAggregationType = "Maximum" + // TimeAggregationTypeMinimum ... + TimeAggregationTypeMinimum TimeAggregationType = "Minimum" + // TimeAggregationTypeTotal ... + TimeAggregationTypeTotal TimeAggregationType = "Total" +) + +// ActionGroup an Azure action group. +type ActionGroup struct { + // GroupShortName - The short name of the action group. This will be used in SMS messages. + GroupShortName *string `json:"groupShortName,omitempty"` + // Enabled - Indicates whether this action group is enabled. If an action group is not enabled, then none of its receivers will receive communications. + Enabled *bool `json:"enabled,omitempty"` + // EmailReceivers - The list of email receivers that are part of this action group. + EmailReceivers *[]EmailReceiver `json:"emailReceivers,omitempty"` + // SmsReceivers - The list of SMS receivers that are part of this action group. + SmsReceivers *[]SmsReceiver `json:"smsReceivers,omitempty"` + // WebhookReceivers - The list of webhook receivers that are part of this action group. + WebhookReceivers *[]WebhookReceiver `json:"webhookReceivers,omitempty"` +} + +// ActionGroupList a list of action groups. +type ActionGroupList struct { + autorest.Response `json:"-"` + // Value - The list of action groups. + Value *[]ActionGroupResource `json:"value,omitempty"` + // NextLink - Provides the link to retrieve the next set of elements. + NextLink *string `json:"nextLink,omitempty"` +} + +// ActionGroupResource an action group resource. +type ActionGroupResource struct { + autorest.Response `json:"-"` + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags *map[string]*string `json:"tags,omitempty"` + // ActionGroup - The action groups properties of the resource. + *ActionGroup `json:"properties,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for ActionGroupResource struct. +func (agr *ActionGroupResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["properties"] + if v != nil { + var properties ActionGroup + err = json.Unmarshal(*m["properties"], &properties) + if err != nil { + return err + } + agr.ActionGroup = &properties + } + + v = m["id"] + if v != nil { + var ID string + err = json.Unmarshal(*m["id"], &ID) + if err != nil { + return err + } + agr.ID = &ID + } + + v = m["name"] + if v != nil { + var name string + err = json.Unmarshal(*m["name"], &name) + if err != nil { + return err + } + agr.Name = &name + } + + v = m["type"] + if v != nil { + var typeVar string + err = json.Unmarshal(*m["type"], &typeVar) + if err != nil { + return err + } + agr.Type = &typeVar + } + + v = m["location"] + if v != nil { + var location string + err = json.Unmarshal(*m["location"], &location) + if err != nil { + return err + } + agr.Location = &location + } + + v = m["tags"] + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*m["tags"], &tags) + if err != nil { + return err + } + agr.Tags = &tags + } + + return nil +} + +// ActivityLogAlert an Azure activity log alert. +type ActivityLogAlert struct { + // Scopes - A list of resourceIds that will be used as prefixes. The alert will only apply to activityLogs with resourceIds that fall under one of these prefixes. This list must include at least one item. + Scopes *[]string `json:"scopes,omitempty"` + // Enabled - Indicates whether this activity log alert is enabled. If an activity log alert is not enabled, then none of its actions will be activated. + Enabled *bool `json:"enabled,omitempty"` + // Condition - The condition that will cause this alert to activate. + Condition *ActivityLogAlertAllOfCondition `json:"condition,omitempty"` + // Actions - The actions that will activate when the condition is met. + Actions *ActivityLogAlertActionList `json:"actions,omitempty"` + // Description - A description of this activity log alert. + Description *string `json:"description,omitempty"` +} + +// ActivityLogAlertActionGroup a pointer to an Azure Action Group. +type ActivityLogAlertActionGroup struct { + // ActionGroupID - The resourceId of the action group. This cannot be null or empty. + ActionGroupID *string `json:"actionGroupId,omitempty"` + // WebhookProperties - the dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. + WebhookProperties *map[string]*string `json:"webhookProperties,omitempty"` +} + +// ActivityLogAlertActionList a list of activity log alert actions. +type ActivityLogAlertActionList struct { + // ActionGroups - The list of activity log alerts. + ActionGroups *[]ActivityLogAlertActionGroup `json:"actionGroups,omitempty"` +} + +// ActivityLogAlertAllOfCondition an Activity Log alert condition that is met when all its member conditions are met. +type ActivityLogAlertAllOfCondition struct { + // AllOf - The list of activity log alert conditions. + AllOf *[]ActivityLogAlertLeafCondition `json:"allOf,omitempty"` +} + +// ActivityLogAlertLeafCondition an Activity Log alert condition that is met by comparing an activity log field and +// value. +type ActivityLogAlertLeafCondition struct { + // Field - The name of the field that this condition will examine. The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything beginning with 'properties.'. + Field *string `json:"field,omitempty"` + // Equals - The field value will be compared to this value (case-insensitive) to determine if the condition is met. + Equals *string `json:"equals,omitempty"` +} + +// ActivityLogAlertList a list of activity log alerts. +type ActivityLogAlertList struct { + autorest.Response `json:"-"` + // Value - The list of activity log alerts. + Value *[]ActivityLogAlertResource `json:"value,omitempty"` + // NextLink - Provides the link to retrieve the next set of elements. + NextLink *string `json:"nextLink,omitempty"` +} + +// ActivityLogAlertPatch an Azure activity log alert for patch operations. +type ActivityLogAlertPatch struct { + // Enabled - Indicates whether this activity log alert is enabled. If an activity log alert is not enabled, then none of its actions will be activated. + Enabled *bool `json:"enabled,omitempty"` +} + +// ActivityLogAlertPatchBody an activity log alert object for the body of patch operations. +type ActivityLogAlertPatchBody struct { + // Tags - Resource tags + Tags *map[string]*string `json:"tags,omitempty"` + // ActivityLogAlertPatch - The activity log alert settings for an update operation. + *ActivityLogAlertPatch `json:"properties,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for ActivityLogAlertPatchBody struct. +func (alapb *ActivityLogAlertPatchBody) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["tags"] + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*m["tags"], &tags) + if err != nil { + return err + } + alapb.Tags = &tags + } + + v = m["properties"] + if v != nil { + var properties ActivityLogAlertPatch + err = json.Unmarshal(*m["properties"], &properties) + if err != nil { + return err + } + alapb.ActivityLogAlertPatch = &properties + } + + return nil +} + +// ActivityLogAlertResource an activity log alert resource. +type ActivityLogAlertResource struct { + autorest.Response `json:"-"` + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags *map[string]*string `json:"tags,omitempty"` + // ActivityLogAlert - The activity log alert properties of the resource. + *ActivityLogAlert `json:"properties,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for ActivityLogAlertResource struct. +func (alar *ActivityLogAlertResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["properties"] + if v != nil { + var properties ActivityLogAlert + err = json.Unmarshal(*m["properties"], &properties) + if err != nil { + return err + } + alar.ActivityLogAlert = &properties + } + + v = m["id"] + if v != nil { + var ID string + err = json.Unmarshal(*m["id"], &ID) + if err != nil { + return err + } + alar.ID = &ID + } + + v = m["name"] + if v != nil { + var name string + err = json.Unmarshal(*m["name"], &name) + if err != nil { + return err + } + alar.Name = &name + } + + v = m["type"] + if v != nil { + var typeVar string + err = json.Unmarshal(*m["type"], &typeVar) + if err != nil { + return err + } + alar.Type = &typeVar + } + + v = m["location"] + if v != nil { + var location string + err = json.Unmarshal(*m["location"], &location) + if err != nil { + return err + } + alar.Location = &location + } + + v = m["tags"] + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*m["tags"], &tags) + if err != nil { + return err + } + alar.Tags = &tags + } + + return nil +} + +// AlertRule an alert rule. +type AlertRule struct { + // Name - the name of the alert rule. + Name *string `json:"name,omitempty"` + // Description - the description of the alert rule that will be included in the alert email. + Description *string `json:"description,omitempty"` + // IsEnabled - the flag that indicates whether the alert rule is enabled. + IsEnabled *bool `json:"isEnabled,omitempty"` + // Condition - the condition that results in the alert rule being activated. + Condition BasicRuleCondition `json:"condition,omitempty"` + // Actions - the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. + Actions *[]BasicRuleAction `json:"actions,omitempty"` + // LastUpdatedTime - Last time the rule was updated in ISO8601 format. + LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for AlertRule struct. +func (ar *AlertRule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["name"] + if v != nil { + var name string + err = json.Unmarshal(*m["name"], &name) + if err != nil { + return err + } + ar.Name = &name + } + + v = m["description"] + if v != nil { + var description string + err = json.Unmarshal(*m["description"], &description) + if err != nil { + return err + } + ar.Description = &description + } + + v = m["isEnabled"] + if v != nil { + var isEnabled bool + err = json.Unmarshal(*m["isEnabled"], &isEnabled) + if err != nil { + return err + } + ar.IsEnabled = &isEnabled + } + + v = m["condition"] + if v != nil { + condition, err := unmarshalBasicRuleCondition(*m["condition"]) + if err != nil { + return err + } + ar.Condition = condition + } + + v = m["actions"] + if v != nil { + actions, err := unmarshalBasicRuleActionArray(*m["actions"]) + if err != nil { + return err + } + ar.Actions = &actions + } + + v = m["lastUpdatedTime"] + if v != nil { + var lastUpdatedTime date.Time + err = json.Unmarshal(*m["lastUpdatedTime"], &lastUpdatedTime) + if err != nil { + return err + } + ar.LastUpdatedTime = &lastUpdatedTime + } + + return nil +} + +// AlertRuleResource the alert rule resource. +type AlertRuleResource struct { + autorest.Response `json:"-"` + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags *map[string]*string `json:"tags,omitempty"` + // AlertRule - The alert rule properties of the resource. + *AlertRule `json:"properties,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for AlertRuleResource struct. +func (arr *AlertRuleResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["properties"] + if v != nil { + var properties AlertRule + err = json.Unmarshal(*m["properties"], &properties) + if err != nil { + return err + } + arr.AlertRule = &properties + } + + v = m["id"] + if v != nil { + var ID string + err = json.Unmarshal(*m["id"], &ID) + if err != nil { + return err + } + arr.ID = &ID + } + + v = m["name"] + if v != nil { + var name string + err = json.Unmarshal(*m["name"], &name) + if err != nil { + return err + } + arr.Name = &name + } + + v = m["type"] + if v != nil { + var typeVar string + err = json.Unmarshal(*m["type"], &typeVar) + if err != nil { + return err + } + arr.Type = &typeVar + } + + v = m["location"] + if v != nil { + var location string + err = json.Unmarshal(*m["location"], &location) + if err != nil { + return err + } + arr.Location = &location + } + + v = m["tags"] + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*m["tags"], &tags) + if err != nil { + return err + } + arr.Tags = &tags + } + + return nil +} + +// AlertRuleResourceCollection represents a collection of alert rule resources. +type AlertRuleResourceCollection struct { + autorest.Response `json:"-"` + // Value - the values for the alert rule resources. + Value *[]AlertRuleResource `json:"value,omitempty"` +} + +// AlertRuleResourcePatch the alert rule object for patch operations. +type AlertRuleResourcePatch struct { + // Tags - Resource tags + Tags *map[string]*string `json:"tags,omitempty"` + // AlertRule - The properties of an alert rule. + *AlertRule `json:"properties,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for AlertRuleResourcePatch struct. +func (arrp *AlertRuleResourcePatch) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["tags"] + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*m["tags"], &tags) + if err != nil { + return err + } + arrp.Tags = &tags + } + + v = m["properties"] + if v != nil { + var properties AlertRule + err = json.Unmarshal(*m["properties"], &properties) + if err != nil { + return err + } + arrp.AlertRule = &properties + } + + return nil +} + +// AutoscaleNotification autoscale notification. +type AutoscaleNotification struct { + // Operation - the operation associated with the notification and its value must be "scale" + Operation *string `json:"operation,omitempty"` + // Email - the email notification. + Email *EmailNotification `json:"email,omitempty"` + // Webhooks - the collection of webhook notifications. + Webhooks *[]WebhookNotification `json:"webhooks,omitempty"` +} + +// AutoscaleProfile autoscale profile. +type AutoscaleProfile struct { + // Name - the name of the profile. + Name *string `json:"name,omitempty"` + // Capacity - the number of instances that can be used during this profile. + Capacity *ScaleCapacity `json:"capacity,omitempty"` + // Rules - the collection of rules that provide the triggers and parameters for the scaling action. A maximum of 10 rules can be specified. + Rules *[]ScaleRule `json:"rules,omitempty"` + // FixedDate - the specific date-time for the profile. This element is not used if the Recurrence element is used. + FixedDate *TimeWindow `json:"fixedDate,omitempty"` + // Recurrence - the repeating times at which this profile begins. This element is not used if the FixedDate element is used. + Recurrence *Recurrence `json:"recurrence,omitempty"` +} + +// AutoscaleSetting a setting that contains all of the configuration for the automatic scaling of a resource. +type AutoscaleSetting struct { + // Profiles - the collection of automatic scaling profiles that specify different scaling parameters for different time periods. A maximum of 20 profiles can be specified. + Profiles *[]AutoscaleProfile `json:"profiles,omitempty"` + // Notifications - the collection of notifications. + Notifications *[]AutoscaleNotification `json:"notifications,omitempty"` + // Enabled - the enabled flag. Specifies whether automatic scaling is enabled for the resource. The default value is 'true'. + Enabled *bool `json:"enabled,omitempty"` + // Name - the name of the autoscale setting. + Name *string `json:"name,omitempty"` + // TargetResourceURI - the resource identifier of the resource that the autoscale setting should be added to. + TargetResourceURI *string `json:"targetResourceUri,omitempty"` +} + +// AutoscaleSettingResource the autoscale setting resource. +type AutoscaleSettingResource struct { + autorest.Response `json:"-"` + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags *map[string]*string `json:"tags,omitempty"` + // AutoscaleSetting - The autoscale setting of the resource. + *AutoscaleSetting `json:"properties,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for AutoscaleSettingResource struct. +func (asr *AutoscaleSettingResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["properties"] + if v != nil { + var properties AutoscaleSetting + err = json.Unmarshal(*m["properties"], &properties) + if err != nil { + return err + } + asr.AutoscaleSetting = &properties + } + + v = m["id"] + if v != nil { + var ID string + err = json.Unmarshal(*m["id"], &ID) + if err != nil { + return err + } + asr.ID = &ID + } + + v = m["name"] + if v != nil { + var name string + err = json.Unmarshal(*m["name"], &name) + if err != nil { + return err + } + asr.Name = &name + } + + v = m["type"] + if v != nil { + var typeVar string + err = json.Unmarshal(*m["type"], &typeVar) + if err != nil { + return err + } + asr.Type = &typeVar + } + + v = m["location"] + if v != nil { + var location string + err = json.Unmarshal(*m["location"], &location) + if err != nil { + return err + } + asr.Location = &location + } + + v = m["tags"] + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*m["tags"], &tags) + if err != nil { + return err + } + asr.Tags = &tags + } + + return nil +} + +// AutoscaleSettingResourceCollection represents a collection of autoscale setting resources. +type AutoscaleSettingResourceCollection struct { + autorest.Response `json:"-"` + // Value - the values for the autoscale setting resources. + Value *[]AutoscaleSettingResource `json:"value,omitempty"` + // NextLink - URL to get the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// AutoscaleSettingResourceCollectionIterator provides access to a complete listing of AutoscaleSettingResource values. +type AutoscaleSettingResourceCollectionIterator struct { + i int + page AutoscaleSettingResourceCollectionPage +} + +// Next 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 *AutoscaleSettingResourceCollectionIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AutoscaleSettingResourceCollectionIterator) 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 AutoscaleSettingResourceCollectionIterator) Response() AutoscaleSettingResourceCollection { + 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 AutoscaleSettingResourceCollectionIterator) Value() AutoscaleSettingResource { + if !iter.page.NotDone() { + return AutoscaleSettingResource{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (asrc AutoscaleSettingResourceCollection) IsEmpty() bool { + return asrc.Value == nil || len(*asrc.Value) == 0 +} + +// autoscaleSettingResourceCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (asrc AutoscaleSettingResourceCollection) autoscaleSettingResourceCollectionPreparer() (*http.Request, error) { + if asrc.NextLink == nil || len(to.String(asrc.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(asrc.NextLink))) +} + +// AutoscaleSettingResourceCollectionPage contains a page of AutoscaleSettingResource values. +type AutoscaleSettingResourceCollectionPage struct { + fn func(AutoscaleSettingResourceCollection) (AutoscaleSettingResourceCollection, error) + asrc AutoscaleSettingResourceCollection +} + +// 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. +func (page *AutoscaleSettingResourceCollectionPage) Next() error { + next, err := page.fn(page.asrc) + if err != nil { + return err + } + page.asrc = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AutoscaleSettingResourceCollectionPage) NotDone() bool { + return !page.asrc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AutoscaleSettingResourceCollectionPage) Response() AutoscaleSettingResourceCollection { + return page.asrc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AutoscaleSettingResourceCollectionPage) Values() []AutoscaleSettingResource { + if page.asrc.IsEmpty() { + return nil + } + return *page.asrc.Value +} + +// AutoscaleSettingResourcePatch the autoscale setting object for patch operations. +type AutoscaleSettingResourcePatch struct { + // Tags - Resource tags + Tags *map[string]*string `json:"tags,omitempty"` + // AutoscaleSetting - The autoscale setting properties of the update operation. + *AutoscaleSetting `json:"properties,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for AutoscaleSettingResourcePatch struct. +func (asrp *AutoscaleSettingResourcePatch) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["tags"] + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*m["tags"], &tags) + if err != nil { + return err + } + asrp.Tags = &tags + } + + v = m["properties"] + if v != nil { + var properties AutoscaleSetting + err = json.Unmarshal(*m["properties"], &properties) + if err != nil { + return err + } + asrp.AutoscaleSetting = &properties + } + + return nil +} + +// DiagnosticSettings the diagnostic settings. +type DiagnosticSettings struct { + // StorageAccountID - The resource ID of the storage account to which you would like to send Diagnostic Logs. + StorageAccountID *string `json:"storageAccountId,omitempty"` + // EventHubAuthorizationRuleID - The resource Id for the event hub authorization rule. + EventHubAuthorizationRuleID *string `json:"eventHubAuthorizationRuleId,omitempty"` + // EventHubName - The name of the event hub. If none is specified, the default event hub will be selected. + EventHubName *string `json:"eventHubName,omitempty"` + // Metrics - the list of metric settings. + Metrics *[]MetricSettings `json:"metrics,omitempty"` + // Logs - the list of logs settings. + Logs *[]LogSettings `json:"logs,omitempty"` + // WorkspaceID - The workspace ID (resource ID of a Log Analytics workspace) for a Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2 + WorkspaceID *string `json:"workspaceId,omitempty"` +} + +// DiagnosticSettingsCategory the diagnostic settings Category. +type DiagnosticSettingsCategory struct { + // CategoryType - The type of the diagnostic settings category. Possible values include: 'Metrics', 'Logs' + CategoryType CategoryType `json:"categoryType,omitempty"` +} + +// DiagnosticSettingsCategoryResource the diagnostic settings category resource. +type DiagnosticSettingsCategoryResource struct { + autorest.Response `json:"-"` + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` + *DiagnosticSettingsCategory `json:"properties,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for DiagnosticSettingsCategoryResource struct. +func (dscr *DiagnosticSettingsCategoryResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["properties"] + if v != nil { + var properties DiagnosticSettingsCategory + err = json.Unmarshal(*m["properties"], &properties) + if err != nil { + return err + } + dscr.DiagnosticSettingsCategory = &properties + } + + v = m["id"] + if v != nil { + var ID string + err = json.Unmarshal(*m["id"], &ID) + if err != nil { + return err + } + dscr.ID = &ID + } + + v = m["name"] + if v != nil { + var name string + err = json.Unmarshal(*m["name"], &name) + if err != nil { + return err + } + dscr.Name = &name + } + + v = m["type"] + if v != nil { + var typeVar string + err = json.Unmarshal(*m["type"], &typeVar) + if err != nil { + return err + } + dscr.Type = &typeVar + } + + return nil +} + +// DiagnosticSettingsCategoryResourceCollection represents a collection of diagnostic setting category resources. +type DiagnosticSettingsCategoryResourceCollection struct { + autorest.Response `json:"-"` + // Value - The collection of diagnostic settings category resources. + Value *[]DiagnosticSettingsCategoryResource `json:"value,omitempty"` +} + +// DiagnosticSettingsResource the diagnostic setting resource. +type DiagnosticSettingsResource struct { + autorest.Response `json:"-"` + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` + *DiagnosticSettings `json:"properties,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for DiagnosticSettingsResource struct. +func (dsr *DiagnosticSettingsResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["properties"] + if v != nil { + var properties DiagnosticSettings + err = json.Unmarshal(*m["properties"], &properties) + if err != nil { + return err + } + dsr.DiagnosticSettings = &properties + } + + v = m["id"] + if v != nil { + var ID string + err = json.Unmarshal(*m["id"], &ID) + if err != nil { + return err + } + dsr.ID = &ID + } + + v = m["name"] + if v != nil { + var name string + err = json.Unmarshal(*m["name"], &name) + if err != nil { + return err + } + dsr.Name = &name + } + + v = m["type"] + if v != nil { + var typeVar string + err = json.Unmarshal(*m["type"], &typeVar) + if err != nil { + return err + } + dsr.Type = &typeVar + } + + return nil +} + +// DiagnosticSettingsResourceCollection represents a collection of alert rule resources. +type DiagnosticSettingsResourceCollection struct { + autorest.Response `json:"-"` + // Value - The collection of diagnostic settings resources;. + Value *[]DiagnosticSettingsResource `json:"value,omitempty"` +} + +// EmailNotification email notification of an autoscale event. +type EmailNotification struct { + // SendToSubscriptionAdministrator - a value indicating whether to send email to subscription administrator. + SendToSubscriptionAdministrator *bool `json:"sendToSubscriptionAdministrator,omitempty"` + // SendToSubscriptionCoAdministrators - a value indicating whether to send email to subscription co-administrators. + SendToSubscriptionCoAdministrators *bool `json:"sendToSubscriptionCoAdministrators,omitempty"` + // CustomEmails - the custom e-mails list. This value can be null or empty, in which case this attribute will be ignored. + CustomEmails *[]string `json:"customEmails,omitempty"` +} + +// EmailReceiver an email receiver. +type EmailReceiver struct { + // Name - The name of the email receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + // EmailAddress - The email address of this receiver. + EmailAddress *string `json:"emailAddress,omitempty"` + // Status - The receiver status of the e-mail. Possible values include: 'NotSpecified', 'Enabled', 'Disabled' + Status ReceiverStatus `json:"status,omitempty"` +} + +// EnableRequest describes a receiver that should be resubscribed. +type EnableRequest struct { + // ReceiverName - The name of the receiver to resubscribe. + ReceiverName *string `json:"receiverName,omitempty"` +} + +// ErrorResponse describes the format of Error response. +type ErrorResponse struct { + // Code - Error code + Code *string `json:"code,omitempty"` + // Message - Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// Incident an alert incident indicates the activation status of an alert rule. +type Incident struct { + autorest.Response `json:"-"` + // Name - Incident name. + Name *string `json:"name,omitempty"` + // RuleName - Rule name that is associated with the incident. + RuleName *string `json:"ruleName,omitempty"` + // IsActive - A boolean to indicate whether the incident is active or resolved. + IsActive *bool `json:"isActive,omitempty"` + // ActivatedTime - The time at which the incident was activated in ISO8601 format. + ActivatedTime *date.Time `json:"activatedTime,omitempty"` + // ResolvedTime - The time at which the incident was resolved in ISO8601 format. If null, it means the incident is still active. + ResolvedTime *date.Time `json:"resolvedTime,omitempty"` +} + +// IncidentListResult the List incidents operation response. +type IncidentListResult struct { + autorest.Response `json:"-"` + // Value - the incident collection. + Value *[]Incident `json:"value,omitempty"` +} + +// LocationThresholdRuleCondition a rule condition based on a certain number of locations failing. +type LocationThresholdRuleCondition struct { + // DataSource - the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. + DataSource BasicRuleDataSource `json:"dataSource,omitempty"` + // OdataType - Possible values include: 'OdataTypeRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition' + OdataType OdataTypeBasicRuleCondition `json:"odata.type,omitempty"` + // WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. + WindowSize *string `json:"windowSize,omitempty"` + // FailedLocationCount - the number of locations that must fail to activate the alert. + FailedLocationCount *int32 `json:"failedLocationCount,omitempty"` +} + +// MarshalJSON is the custom marshaler for LocationThresholdRuleCondition. +func (ltrc LocationThresholdRuleCondition) MarshalJSON() ([]byte, error) { + ltrc.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition + type Alias LocationThresholdRuleCondition + return json.Marshal(&struct { + Alias + }{ + Alias: (Alias)(ltrc), + }) +} + +// AsThresholdRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition. +func (ltrc LocationThresholdRuleCondition) AsThresholdRuleCondition() (*ThresholdRuleCondition, bool) { + return nil, false +} + +// AsLocationThresholdRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition. +func (ltrc LocationThresholdRuleCondition) AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool) { + return <rc, true +} + +// AsManagementEventRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition. +func (ltrc LocationThresholdRuleCondition) AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool) { + return nil, false +} + +// AsRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition. +func (ltrc LocationThresholdRuleCondition) AsRuleCondition() (*RuleCondition, bool) { + return nil, false +} + +// AsBasicRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition. +func (ltrc LocationThresholdRuleCondition) AsBasicRuleCondition() (BasicRuleCondition, bool) { + return <rc, true +} + +// UnmarshalJSON is the custom unmarshaler for LocationThresholdRuleCondition struct. +func (ltrc *LocationThresholdRuleCondition) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["windowSize"] + if v != nil { + var windowSize string + err = json.Unmarshal(*m["windowSize"], &windowSize) + if err != nil { + return err + } + ltrc.WindowSize = &windowSize + } + + v = m["failedLocationCount"] + if v != nil { + var failedLocationCount int32 + err = json.Unmarshal(*m["failedLocationCount"], &failedLocationCount) + if err != nil { + return err + } + ltrc.FailedLocationCount = &failedLocationCount + } + + v = m["dataSource"] + if v != nil { + dataSource, err := unmarshalBasicRuleDataSource(*m["dataSource"]) + if err != nil { + return err + } + ltrc.DataSource = dataSource + } + + v = m["odata.type"] + if v != nil { + var odatatype OdataTypeBasicRuleCondition + err = json.Unmarshal(*m["odata.type"], &odatatype) + if err != nil { + return err + } + ltrc.OdataType = odatatype + } + + return nil +} + +// LogProfileCollection represents a collection of log profiles. +type LogProfileCollection struct { + autorest.Response `json:"-"` + // Value - the values of the log profiles. + Value *[]LogProfileResource `json:"value,omitempty"` +} + +// LogProfileProperties the log profile properties. +type LogProfileProperties struct { + // StorageAccountID - the resource id of the storage account to which you would like to send the Activity Log. + StorageAccountID *string `json:"storageAccountId,omitempty"` + // ServiceBusRuleID - The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming the Activity Log. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'. + ServiceBusRuleID *string `json:"serviceBusRuleId,omitempty"` + // Locations - List of regions for which Activity Log events should be stored or streamed. It is a comma separated list of valid ARM locations including the 'global' location. + Locations *[]string `json:"locations,omitempty"` + // Categories - the categories of the logs. These categories are created as is convenient to the user. Some values are: 'Write', 'Delete', and/or 'Action.' + Categories *[]string `json:"categories,omitempty"` + // RetentionPolicy - the retention policy for the events in the log. + RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"` +} + +// LogProfileResource the log profile resource. +type LogProfileResource struct { + autorest.Response `json:"-"` + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags *map[string]*string `json:"tags,omitempty"` + // LogProfileProperties - The log profile properties of the resource. + *LogProfileProperties `json:"properties,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for LogProfileResource struct. +func (lpr *LogProfileResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["properties"] + if v != nil { + var properties LogProfileProperties + err = json.Unmarshal(*m["properties"], &properties) + if err != nil { + return err + } + lpr.LogProfileProperties = &properties + } + + v = m["id"] + if v != nil { + var ID string + err = json.Unmarshal(*m["id"], &ID) + if err != nil { + return err + } + lpr.ID = &ID + } + + v = m["name"] + if v != nil { + var name string + err = json.Unmarshal(*m["name"], &name) + if err != nil { + return err + } + lpr.Name = &name + } + + v = m["type"] + if v != nil { + var typeVar string + err = json.Unmarshal(*m["type"], &typeVar) + if err != nil { + return err + } + lpr.Type = &typeVar + } + + v = m["location"] + if v != nil { + var location string + err = json.Unmarshal(*m["location"], &location) + if err != nil { + return err + } + lpr.Location = &location + } + + v = m["tags"] + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*m["tags"], &tags) + if err != nil { + return err + } + lpr.Tags = &tags + } + + return nil +} + +// LogProfileResourcePatch the log profile resource for patch operations. +type LogProfileResourcePatch struct { + // Tags - Resource tags + Tags *map[string]*string `json:"tags,omitempty"` + // LogProfileProperties - The log profile properties for an update operation. + *LogProfileProperties `json:"properties,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for LogProfileResourcePatch struct. +func (lprp *LogProfileResourcePatch) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["tags"] + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*m["tags"], &tags) + if err != nil { + return err + } + lprp.Tags = &tags + } + + v = m["properties"] + if v != nil { + var properties LogProfileProperties + err = json.Unmarshal(*m["properties"], &properties) + if err != nil { + return err + } + lprp.LogProfileProperties = &properties + } + + return nil +} + +// LogSettings part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log. +type LogSettings struct { + // Category - Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. + Category *string `json:"category,omitempty"` + // Enabled - a value indicating whether this log is enabled. + Enabled *bool `json:"enabled,omitempty"` + // RetentionPolicy - the retention policy for this log. + RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"` +} + +// ManagementEventAggregationCondition how the data that is collected should be combined over time. +type ManagementEventAggregationCondition struct { + // Operator - the condition operator. Possible values include: 'ConditionOperatorGreaterThan', 'ConditionOperatorGreaterThanOrEqual', 'ConditionOperatorLessThan', 'ConditionOperatorLessThanOrEqual' + Operator ConditionOperator `json:"operator,omitempty"` + // Threshold - The threshold value that activates the alert. + Threshold *float64 `json:"threshold,omitempty"` + // WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. + WindowSize *string `json:"windowSize,omitempty"` +} + +// ManagementEventRuleCondition a management event rule condition. +type ManagementEventRuleCondition struct { + // DataSource - the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. + DataSource BasicRuleDataSource `json:"dataSource,omitempty"` + // OdataType - Possible values include: 'OdataTypeRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition' + OdataType OdataTypeBasicRuleCondition `json:"odata.type,omitempty"` + // Aggregation - How the data that is collected should be combined over time and when the alert is activated. Note that for management event alerts aggregation is optional – if it is not provided then any event will cause the alert to activate. + Aggregation *ManagementEventAggregationCondition `json:"aggregation,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagementEventRuleCondition. +func (merc ManagementEventRuleCondition) MarshalJSON() ([]byte, error) { + merc.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition + type Alias ManagementEventRuleCondition + return json.Marshal(&struct { + Alias + }{ + Alias: (Alias)(merc), + }) +} + +// AsThresholdRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition. +func (merc ManagementEventRuleCondition) AsThresholdRuleCondition() (*ThresholdRuleCondition, bool) { + return nil, false +} + +// AsLocationThresholdRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition. +func (merc ManagementEventRuleCondition) AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool) { + return nil, false +} + +// AsManagementEventRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition. +func (merc ManagementEventRuleCondition) AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool) { + return &merc, true +} + +// AsRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition. +func (merc ManagementEventRuleCondition) AsRuleCondition() (*RuleCondition, bool) { + return nil, false +} + +// AsBasicRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition. +func (merc ManagementEventRuleCondition) AsBasicRuleCondition() (BasicRuleCondition, bool) { + return &merc, true +} + +// UnmarshalJSON is the custom unmarshaler for ManagementEventRuleCondition struct. +func (merc *ManagementEventRuleCondition) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["aggregation"] + if v != nil { + var aggregation ManagementEventAggregationCondition + err = json.Unmarshal(*m["aggregation"], &aggregation) + if err != nil { + return err + } + merc.Aggregation = &aggregation + } + + v = m["dataSource"] + if v != nil { + dataSource, err := unmarshalBasicRuleDataSource(*m["dataSource"]) + if err != nil { + return err + } + merc.DataSource = dataSource + } + + v = m["odata.type"] + if v != nil { + var odatatype OdataTypeBasicRuleCondition + err = json.Unmarshal(*m["odata.type"], &odatatype) + if err != nil { + return err + } + merc.OdataType = odatatype + } + + return nil +} + +// MetricSettings part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric. +type MetricSettings struct { + // TimeGrain - the timegrain of the metric in ISO8601 format. + TimeGrain *string `json:"timeGrain,omitempty"` + // Category - Name of a Diagnostic Metric category for a resource type this setting is applied to. To obtain the list of Diagnostic metric categories for a resource, first perform a GET diagnostic settings operation. + Category *string `json:"category,omitempty"` + // Enabled - a value indicating whether this category is enabled. + Enabled *bool `json:"enabled,omitempty"` + // RetentionPolicy - the retention policy for this category. + RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"` +} + +// MetricTrigger the trigger that results in a scaling action. +type MetricTrigger struct { + // MetricName - the name of the metric that defines what the rule monitors. + MetricName *string `json:"metricName,omitempty"` + // MetricResourceURI - the resource identifier of the resource the rule monitors. + MetricResourceURI *string `json:"metricResourceUri,omitempty"` + // TimeGrain - the granularity of metrics the rule monitors. Must be one of the predefined values returned from metric definitions for the metric. Must be between 12 hours and 1 minute. + TimeGrain *string `json:"timeGrain,omitempty"` + // Statistic - the metric statistic type. How the metrics from multiple instances are combined. Possible values include: 'Average', 'Min', 'Max', 'Sum' + Statistic MetricStatisticType `json:"statistic,omitempty"` + // TimeWindow - the range of time in which instance data is collected. This value must be greater than the delay in metric collection, which can vary from resource-to-resource. Must be between 12 hours and 5 minutes. + TimeWindow *string `json:"timeWindow,omitempty"` + // TimeAggregation - time aggregation type. How the data that is collected should be combined over time. The default value is Average. Possible values include: 'TimeAggregationTypeAverage', 'TimeAggregationTypeMinimum', 'TimeAggregationTypeMaximum', 'TimeAggregationTypeTotal', 'TimeAggregationTypeCount' + TimeAggregation TimeAggregationType `json:"timeAggregation,omitempty"` + // Operator - the operator that is used to compare the metric data and the threshold. Possible values include: 'Equals', 'NotEquals', 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', 'LessThanOrEqual' + Operator ComparisonOperationType `json:"operator,omitempty"` + // Threshold - the threshold of the metric that triggers the scale action. + Threshold *float64 `json:"threshold,omitempty"` +} + +// Operation microsoft Insights API operation definition. +type Operation struct { + // Name - Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // Display - Display metadata associated with the operation. + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay display metadata associated with the operation. +type OperationDisplay struct { + // Provider - Service provider: Microsoft.Insights + Provider *string `json:"provider,omitempty"` + // Resource - Resource on which the operation is performed: AlertRules, Autoscale, etc. + Resource *string `json:"resource,omitempty"` + // Operation - Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` +} + +// OperationListResult result of the request to list Microsoft.Insights operations. It contains a list of operations +// and a URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - List of operations supported by the Microsoft.Insights provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// ProxyOnlyResource a proxy only azure resource object +type ProxyOnlyResource struct { + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` +} + +// Recurrence the repeating times at which this profile begins. This element is not used if the FixedDate element is +// used. +type Recurrence struct { + // Frequency - the recurrence frequency. How often the schedule profile should take effect. This value must be Week, meaning each week will have the same set of profiles. Possible values include: 'None', 'Second', 'Minute', 'Hour', 'Day', 'Week', 'Month', 'Year' + Frequency RecurrenceFrequency `json:"frequency,omitempty"` + // Schedule - the scheduling constraints for when the profile begins. + Schedule *RecurrentSchedule `json:"schedule,omitempty"` +} + +// RecurrentSchedule the scheduling constraints for when the profile begins. +type RecurrentSchedule struct { + // TimeZone - the timezone for the hours of the profile. Some examples of valid timezones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific Standard Time, Eastern Standard Time, US Eastern Standard Time, Venezuela Standard Time, Paraguay Standard Time, Atlantic Standard Time, Central Brazilian Standard Time, SA Western Standard Time, Pacific SA Standard Time, Newfoundland Standard Time, E. South America Standard Time, Argentina Standard Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo Standard Time, Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard Time, W. Europe Standard Time, Central Europe Standard Time, Romance Standard Time, Central European Standard Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard Time, GTB Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, E. Europe Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, Israel Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, Arab Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia Time Zone 3, Mauritius Standard Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, West Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, Bangladesh Standard Time, N. Central Asia Standard Time, Myanmar Standard Time, SE Asia Standard Time, North Asia Standard Time, China Standard Time, North Asia East Standard Time, Singapore Standard Time, W. Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo Standard Time, Korea Standard Time, Yakutsk Standard Time, Cen. Australia Standard Time, AUS Central Standard Time, E. Australia Standard Time, AUS Eastern Standard Time, West Pacific Standard Time, Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time + TimeZone *string `json:"timeZone,omitempty"` + // Days - the collection of days that the profile takes effect on. Possible values are Sunday through Saturday. + Days *[]string `json:"days,omitempty"` + // Hours - A collection of hours that the profile takes effect on. Values supported are 0 to 23 on the 24-hour clock (AM/PM times are not supported). + Hours *[]int32 `json:"hours,omitempty"` + // Minutes - A collection of minutes at which the profile takes effect at. + Minutes *[]int32 `json:"minutes,omitempty"` +} + +// Resource an azure resource object +type Resource struct { + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags *map[string]*string `json:"tags,omitempty"` +} + +// RetentionPolicy specifies the retention policy for the log. +type RetentionPolicy struct { + // Enabled - a value indicating whether the retention policy is enabled. + Enabled *bool `json:"enabled,omitempty"` + // Days - the number of days for the retention in days. A value of 0 will retain the events indefinitely. + Days *int32 `json:"days,omitempty"` +} + +// BasicRuleAction the action that is performed when the alert rule becomes active, and when an alert condition is +// resolved. +type BasicRuleAction interface { + AsRuleEmailAction() (*RuleEmailAction, bool) + AsRuleWebhookAction() (*RuleWebhookAction, bool) + AsRuleAction() (*RuleAction, bool) +} + +// RuleAction the action that is performed when the alert rule becomes active, and when an alert condition is resolved. +type RuleAction struct { + // OdataType - Possible values include: 'OdataTypeRuleAction', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction' + OdataType OdataTypeBasicRuleAction `json:"odata.type,omitempty"` +} + +func unmarshalBasicRuleAction(body []byte) (BasicRuleAction, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["odata.type"] { + case string(OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction): + var rea RuleEmailAction + err := json.Unmarshal(body, &rea) + return rea, err + case string(OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction): + var rwa RuleWebhookAction + err := json.Unmarshal(body, &rwa) + return rwa, err + default: + var ra RuleAction + err := json.Unmarshal(body, &ra) + return ra, err + } +} +func unmarshalBasicRuleActionArray(body []byte) ([]BasicRuleAction, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + raArray := make([]BasicRuleAction, len(rawMessages)) + + for index, rawMessage := range rawMessages { + ra, err := unmarshalBasicRuleAction(*rawMessage) + if err != nil { + return nil, err + } + raArray[index] = ra + } + return raArray, nil +} + +// MarshalJSON is the custom marshaler for RuleAction. +func (ra RuleAction) MarshalJSON() ([]byte, error) { + ra.OdataType = OdataTypeRuleAction + type Alias RuleAction + return json.Marshal(&struct { + Alias + }{ + Alias: (Alias)(ra), + }) +} + +// AsRuleEmailAction is the BasicRuleAction implementation for RuleAction. +func (ra RuleAction) AsRuleEmailAction() (*RuleEmailAction, bool) { + return nil, false +} + +// AsRuleWebhookAction is the BasicRuleAction implementation for RuleAction. +func (ra RuleAction) AsRuleWebhookAction() (*RuleWebhookAction, bool) { + return nil, false +} + +// AsRuleAction is the BasicRuleAction implementation for RuleAction. +func (ra RuleAction) AsRuleAction() (*RuleAction, bool) { + return &ra, true +} + +// AsBasicRuleAction is the BasicRuleAction implementation for RuleAction. +func (ra RuleAction) AsBasicRuleAction() (BasicRuleAction, bool) { + return &ra, true +} + +// BasicRuleCondition the condition that results in the alert rule being activated. +type BasicRuleCondition interface { + AsThresholdRuleCondition() (*ThresholdRuleCondition, bool) + AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool) + AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool) + AsRuleCondition() (*RuleCondition, bool) +} + +// RuleCondition the condition that results in the alert rule being activated. +type RuleCondition struct { + // DataSource - the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. + DataSource BasicRuleDataSource `json:"dataSource,omitempty"` + // OdataType - Possible values include: 'OdataTypeRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition' + OdataType OdataTypeBasicRuleCondition `json:"odata.type,omitempty"` +} + +func unmarshalBasicRuleCondition(body []byte) (BasicRuleCondition, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["odata.type"] { + case string(OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition): + var trc ThresholdRuleCondition + err := json.Unmarshal(body, &trc) + return trc, err + case string(OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition): + var ltrc LocationThresholdRuleCondition + err := json.Unmarshal(body, <rc) + return ltrc, err + case string(OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition): + var merc ManagementEventRuleCondition + err := json.Unmarshal(body, &merc) + return merc, err + default: + var rc RuleCondition + err := json.Unmarshal(body, &rc) + return rc, err + } +} +func unmarshalBasicRuleConditionArray(body []byte) ([]BasicRuleCondition, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + rcArray := make([]BasicRuleCondition, len(rawMessages)) + + for index, rawMessage := range rawMessages { + rc, err := unmarshalBasicRuleCondition(*rawMessage) + if err != nil { + return nil, err + } + rcArray[index] = rc + } + return rcArray, nil +} + +// MarshalJSON is the custom marshaler for RuleCondition. +func (rc RuleCondition) MarshalJSON() ([]byte, error) { + rc.OdataType = OdataTypeRuleCondition + type Alias RuleCondition + return json.Marshal(&struct { + Alias + }{ + Alias: (Alias)(rc), + }) +} + +// AsThresholdRuleCondition is the BasicRuleCondition implementation for RuleCondition. +func (rc RuleCondition) AsThresholdRuleCondition() (*ThresholdRuleCondition, bool) { + return nil, false +} + +// AsLocationThresholdRuleCondition is the BasicRuleCondition implementation for RuleCondition. +func (rc RuleCondition) AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool) { + return nil, false +} + +// AsManagementEventRuleCondition is the BasicRuleCondition implementation for RuleCondition. +func (rc RuleCondition) AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool) { + return nil, false +} + +// AsRuleCondition is the BasicRuleCondition implementation for RuleCondition. +func (rc RuleCondition) AsRuleCondition() (*RuleCondition, bool) { + return &rc, true +} + +// AsBasicRuleCondition is the BasicRuleCondition implementation for RuleCondition. +func (rc RuleCondition) AsBasicRuleCondition() (BasicRuleCondition, bool) { + return &rc, true +} + +// UnmarshalJSON is the custom unmarshaler for RuleCondition struct. +func (rc *RuleCondition) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["dataSource"] + if v != nil { + dataSource, err := unmarshalBasicRuleDataSource(*m["dataSource"]) + if err != nil { + return err + } + rc.DataSource = dataSource + } + + v = m["odata.type"] + if v != nil { + var odatatype OdataTypeBasicRuleCondition + err = json.Unmarshal(*m["odata.type"], &odatatype) + if err != nil { + return err + } + rc.OdataType = odatatype + } + + return nil +} + +// BasicRuleDataSource the resource from which the rule collects its data. +type BasicRuleDataSource interface { + AsRuleMetricDataSource() (*RuleMetricDataSource, bool) + AsRuleManagementEventDataSource() (*RuleManagementEventDataSource, bool) + AsRuleDataSource() (*RuleDataSource, bool) +} + +// RuleDataSource the resource from which the rule collects its data. +type RuleDataSource struct { + // ResourceURI - the resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule. + ResourceURI *string `json:"resourceUri,omitempty"` + // OdataType - Possible values include: 'OdataTypeRuleDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource' + OdataType OdataType `json:"odata.type,omitempty"` +} + +func unmarshalBasicRuleDataSource(body []byte) (BasicRuleDataSource, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["odata.type"] { + case string(OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource): + var rmds RuleMetricDataSource + err := json.Unmarshal(body, &rmds) + return rmds, err + case string(OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource): + var rmeds RuleManagementEventDataSource + err := json.Unmarshal(body, &rmeds) + return rmeds, err + default: + var rds RuleDataSource + err := json.Unmarshal(body, &rds) + return rds, err + } +} +func unmarshalBasicRuleDataSourceArray(body []byte) ([]BasicRuleDataSource, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + rdsArray := make([]BasicRuleDataSource, len(rawMessages)) + + for index, rawMessage := range rawMessages { + rds, err := unmarshalBasicRuleDataSource(*rawMessage) + if err != nil { + return nil, err + } + rdsArray[index] = rds + } + return rdsArray, nil +} + +// MarshalJSON is the custom marshaler for RuleDataSource. +func (rds RuleDataSource) MarshalJSON() ([]byte, error) { + rds.OdataType = OdataTypeRuleDataSource + type Alias RuleDataSource + return json.Marshal(&struct { + Alias + }{ + Alias: (Alias)(rds), + }) +} + +// AsRuleMetricDataSource is the BasicRuleDataSource implementation for RuleDataSource. +func (rds RuleDataSource) AsRuleMetricDataSource() (*RuleMetricDataSource, bool) { + return nil, false +} + +// AsRuleManagementEventDataSource is the BasicRuleDataSource implementation for RuleDataSource. +func (rds RuleDataSource) AsRuleManagementEventDataSource() (*RuleManagementEventDataSource, bool) { + return nil, false +} + +// AsRuleDataSource is the BasicRuleDataSource implementation for RuleDataSource. +func (rds RuleDataSource) AsRuleDataSource() (*RuleDataSource, bool) { + return &rds, true +} + +// AsBasicRuleDataSource is the BasicRuleDataSource implementation for RuleDataSource. +func (rds RuleDataSource) AsBasicRuleDataSource() (BasicRuleDataSource, bool) { + return &rds, true +} + +// RuleEmailAction specifies the action to send email when the rule condition is evaluated. The discriminator is always +// RuleEmailAction in this case. +type RuleEmailAction struct { + // OdataType - Possible values include: 'OdataTypeRuleAction', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction' + OdataType OdataTypeBasicRuleAction `json:"odata.type,omitempty"` + // SendToServiceOwners - Whether the administrators (service and co-administrators) of the service should be notified when the alert is activated. + SendToServiceOwners *bool `json:"sendToServiceOwners,omitempty"` + // CustomEmails - the list of administrator's custom email addresses to notify of the activation of the alert. + CustomEmails *[]string `json:"customEmails,omitempty"` +} + +// MarshalJSON is the custom marshaler for RuleEmailAction. +func (rea RuleEmailAction) MarshalJSON() ([]byte, error) { + rea.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction + type Alias RuleEmailAction + return json.Marshal(&struct { + Alias + }{ + Alias: (Alias)(rea), + }) +} + +// AsRuleEmailAction is the BasicRuleAction implementation for RuleEmailAction. +func (rea RuleEmailAction) AsRuleEmailAction() (*RuleEmailAction, bool) { + return &rea, true +} + +// AsRuleWebhookAction is the BasicRuleAction implementation for RuleEmailAction. +func (rea RuleEmailAction) AsRuleWebhookAction() (*RuleWebhookAction, bool) { + return nil, false +} + +// AsRuleAction is the BasicRuleAction implementation for RuleEmailAction. +func (rea RuleEmailAction) AsRuleAction() (*RuleAction, bool) { + return nil, false +} + +// AsBasicRuleAction is the BasicRuleAction implementation for RuleEmailAction. +func (rea RuleEmailAction) AsBasicRuleAction() (BasicRuleAction, bool) { + return &rea, true +} + +// RuleManagementEventClaimsDataSource the claims for a rule management event data source. +type RuleManagementEventClaimsDataSource struct { + // EmailAddress - the email address. + EmailAddress *string `json:"emailAddress,omitempty"` +} + +// RuleManagementEventDataSource a rule management event data source. The discriminator fields is always +// RuleManagementEventDataSource in this case. +type RuleManagementEventDataSource struct { + // ResourceURI - the resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule. + ResourceURI *string `json:"resourceUri,omitempty"` + // OdataType - Possible values include: 'OdataTypeRuleDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource' + OdataType OdataType `json:"odata.type,omitempty"` + // EventName - the event name. + EventName *string `json:"eventName,omitempty"` + // EventSource - the event source. + EventSource *string `json:"eventSource,omitempty"` + // Level - the level. + Level *string `json:"level,omitempty"` + // OperationName - The name of the operation that should be checked for. If no name is provided, any operation will match. + OperationName *string `json:"operationName,omitempty"` + // ResourceGroupName - the resource group name. + ResourceGroupName *string `json:"resourceGroupName,omitempty"` + // ResourceProviderName - the resource provider name. + ResourceProviderName *string `json:"resourceProviderName,omitempty"` + // Status - The status of the operation that should be checked for. If no status is provided, any status will match. + Status *string `json:"status,omitempty"` + // SubStatus - the substatus. + SubStatus *string `json:"subStatus,omitempty"` + // Claims - the claims. + Claims *RuleManagementEventClaimsDataSource `json:"claims,omitempty"` +} + +// MarshalJSON is the custom marshaler for RuleManagementEventDataSource. +func (rmeds RuleManagementEventDataSource) MarshalJSON() ([]byte, error) { + rmeds.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource + type Alias RuleManagementEventDataSource + return json.Marshal(&struct { + Alias + }{ + Alias: (Alias)(rmeds), + }) +} + +// AsRuleMetricDataSource is the BasicRuleDataSource implementation for RuleManagementEventDataSource. +func (rmeds RuleManagementEventDataSource) AsRuleMetricDataSource() (*RuleMetricDataSource, bool) { + return nil, false +} + +// AsRuleManagementEventDataSource is the BasicRuleDataSource implementation for RuleManagementEventDataSource. +func (rmeds RuleManagementEventDataSource) AsRuleManagementEventDataSource() (*RuleManagementEventDataSource, bool) { + return &rmeds, true +} + +// AsRuleDataSource is the BasicRuleDataSource implementation for RuleManagementEventDataSource. +func (rmeds RuleManagementEventDataSource) AsRuleDataSource() (*RuleDataSource, bool) { + return nil, false +} + +// AsBasicRuleDataSource is the BasicRuleDataSource implementation for RuleManagementEventDataSource. +func (rmeds RuleManagementEventDataSource) AsBasicRuleDataSource() (BasicRuleDataSource, bool) { + return &rmeds, true +} + +// RuleMetricDataSource a rule metric data source. The discriminator value is always RuleMetricDataSource in this case. +type RuleMetricDataSource struct { + // ResourceURI - the resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule. + ResourceURI *string `json:"resourceUri,omitempty"` + // OdataType - Possible values include: 'OdataTypeRuleDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource' + OdataType OdataType `json:"odata.type,omitempty"` + // MetricName - the name of the metric that defines what the rule monitors. + MetricName *string `json:"metricName,omitempty"` +} + +// MarshalJSON is the custom marshaler for RuleMetricDataSource. +func (rmds RuleMetricDataSource) MarshalJSON() ([]byte, error) { + rmds.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource + type Alias RuleMetricDataSource + return json.Marshal(&struct { + Alias + }{ + Alias: (Alias)(rmds), + }) +} + +// AsRuleMetricDataSource is the BasicRuleDataSource implementation for RuleMetricDataSource. +func (rmds RuleMetricDataSource) AsRuleMetricDataSource() (*RuleMetricDataSource, bool) { + return &rmds, true +} + +// AsRuleManagementEventDataSource is the BasicRuleDataSource implementation for RuleMetricDataSource. +func (rmds RuleMetricDataSource) AsRuleManagementEventDataSource() (*RuleManagementEventDataSource, bool) { + return nil, false +} + +// AsRuleDataSource is the BasicRuleDataSource implementation for RuleMetricDataSource. +func (rmds RuleMetricDataSource) AsRuleDataSource() (*RuleDataSource, bool) { + return nil, false +} + +// AsBasicRuleDataSource is the BasicRuleDataSource implementation for RuleMetricDataSource. +func (rmds RuleMetricDataSource) AsBasicRuleDataSource() (BasicRuleDataSource, bool) { + return &rmds, true +} + +// RuleWebhookAction specifies the action to post to service when the rule condition is evaluated. The discriminator is +// always RuleWebhookAction in this case. +type RuleWebhookAction struct { + // OdataType - Possible values include: 'OdataTypeRuleAction', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction' + OdataType OdataTypeBasicRuleAction `json:"odata.type,omitempty"` + // ServiceURI - the service uri to Post the notification when the alert activates or resolves. + ServiceURI *string `json:"serviceUri,omitempty"` + // Properties - the dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. + Properties *map[string]*string `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for RuleWebhookAction. +func (rwa RuleWebhookAction) MarshalJSON() ([]byte, error) { + rwa.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction + type Alias RuleWebhookAction + return json.Marshal(&struct { + Alias + }{ + Alias: (Alias)(rwa), + }) +} + +// AsRuleEmailAction is the BasicRuleAction implementation for RuleWebhookAction. +func (rwa RuleWebhookAction) AsRuleEmailAction() (*RuleEmailAction, bool) { + return nil, false +} + +// AsRuleWebhookAction is the BasicRuleAction implementation for RuleWebhookAction. +func (rwa RuleWebhookAction) AsRuleWebhookAction() (*RuleWebhookAction, bool) { + return &rwa, true +} + +// AsRuleAction is the BasicRuleAction implementation for RuleWebhookAction. +func (rwa RuleWebhookAction) AsRuleAction() (*RuleAction, bool) { + return nil, false +} + +// AsBasicRuleAction is the BasicRuleAction implementation for RuleWebhookAction. +func (rwa RuleWebhookAction) AsBasicRuleAction() (BasicRuleAction, bool) { + return &rwa, true +} + +// ScaleAction the parameters for the scaling action. +type ScaleAction struct { + // Direction - the scale direction. Whether the scaling action increases or decreases the number of instances. Possible values include: 'ScaleDirectionNone', 'ScaleDirectionIncrease', 'ScaleDirectionDecrease' + Direction ScaleDirection `json:"direction,omitempty"` + // Type - the type of action that should occur when the scale rule fires. Possible values include: 'ChangeCount', 'PercentChangeCount', 'ExactCount' + Type ScaleType `json:"type,omitempty"` + // Value - the number of instances that are involved in the scaling action. This value must be 1 or greater. The default value is 1. + Value *string `json:"value,omitempty"` + // Cooldown - the amount of time to wait since the last scaling action before this action occurs. It must be between 1 week and 1 minute in ISO 8601 format. + Cooldown *string `json:"cooldown,omitempty"` +} + +// ScaleCapacity the number of instances that can be used during this profile. +type ScaleCapacity struct { + // Minimum - the minimum number of instances for the resource. + Minimum *string `json:"minimum,omitempty"` + // Maximum - the maximum number of instances for the resource. The actual maximum number of instances is limited by the cores that are available in the subscription. + Maximum *string `json:"maximum,omitempty"` + // Default - the number of instances that will be set if metrics are not available for evaluation. The default is only used if the current instance count is lower than the default. + Default *string `json:"default,omitempty"` +} + +// ScaleRule a rule that provide the triggers and parameters for the scaling action. +type ScaleRule struct { + // MetricTrigger - the trigger that results in a scaling action. + MetricTrigger *MetricTrigger `json:"metricTrigger,omitempty"` + // ScaleAction - the parameters for the scaling action. + ScaleAction *ScaleAction `json:"scaleAction,omitempty"` +} + +// SmsReceiver an SMS receiver. +type SmsReceiver struct { + // Name - The name of the SMS receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + // CountryCode - The country code of the SMS receiver. + CountryCode *string `json:"countryCode,omitempty"` + // PhoneNumber - The phone number of the SMS receiver. + PhoneNumber *string `json:"phoneNumber,omitempty"` + // Status - The status of the receiver. Possible values include: 'NotSpecified', 'Enabled', 'Disabled' + Status ReceiverStatus `json:"status,omitempty"` +} + +// ThresholdRuleCondition a rule condition based on a metric crossing a threshold. +type ThresholdRuleCondition struct { + // DataSource - the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. + DataSource BasicRuleDataSource `json:"dataSource,omitempty"` + // OdataType - Possible values include: 'OdataTypeRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition' + OdataType OdataTypeBasicRuleCondition `json:"odata.type,omitempty"` + // Operator - the operator used to compare the data and the threshold. Possible values include: 'ConditionOperatorGreaterThan', 'ConditionOperatorGreaterThanOrEqual', 'ConditionOperatorLessThan', 'ConditionOperatorLessThanOrEqual' + Operator ConditionOperator `json:"operator,omitempty"` + // Threshold - the threshold value that activates the alert. + Threshold *float64 `json:"threshold,omitempty"` + // WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. + WindowSize *string `json:"windowSize,omitempty"` + // TimeAggregation - the time aggregation operator. How the data that are collected should be combined over time. The default value is the PrimaryAggregationType of the Metric. Possible values include: 'TimeAggregationOperatorAverage', 'TimeAggregationOperatorMinimum', 'TimeAggregationOperatorMaximum', 'TimeAggregationOperatorTotal', 'TimeAggregationOperatorLast' + TimeAggregation TimeAggregationOperator `json:"timeAggregation,omitempty"` +} + +// MarshalJSON is the custom marshaler for ThresholdRuleCondition. +func (trc ThresholdRuleCondition) MarshalJSON() ([]byte, error) { + trc.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition + type Alias ThresholdRuleCondition + return json.Marshal(&struct { + Alias + }{ + Alias: (Alias)(trc), + }) +} + +// AsThresholdRuleCondition is the BasicRuleCondition implementation for ThresholdRuleCondition. +func (trc ThresholdRuleCondition) AsThresholdRuleCondition() (*ThresholdRuleCondition, bool) { + return &trc, true +} + +// AsLocationThresholdRuleCondition is the BasicRuleCondition implementation for ThresholdRuleCondition. +func (trc ThresholdRuleCondition) AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool) { + return nil, false +} + +// AsManagementEventRuleCondition is the BasicRuleCondition implementation for ThresholdRuleCondition. +func (trc ThresholdRuleCondition) AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool) { + return nil, false +} + +// AsRuleCondition is the BasicRuleCondition implementation for ThresholdRuleCondition. +func (trc ThresholdRuleCondition) AsRuleCondition() (*RuleCondition, bool) { + return nil, false +} + +// AsBasicRuleCondition is the BasicRuleCondition implementation for ThresholdRuleCondition. +func (trc ThresholdRuleCondition) AsBasicRuleCondition() (BasicRuleCondition, bool) { + return &trc, true +} + +// UnmarshalJSON is the custom unmarshaler for ThresholdRuleCondition struct. +func (trc *ThresholdRuleCondition) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["operator"] + if v != nil { + var operator ConditionOperator + err = json.Unmarshal(*m["operator"], &operator) + if err != nil { + return err + } + trc.Operator = operator + } + + v = m["threshold"] + if v != nil { + var threshold float64 + err = json.Unmarshal(*m["threshold"], &threshold) + if err != nil { + return err + } + trc.Threshold = &threshold + } + + v = m["windowSize"] + if v != nil { + var windowSize string + err = json.Unmarshal(*m["windowSize"], &windowSize) + if err != nil { + return err + } + trc.WindowSize = &windowSize + } + + v = m["timeAggregation"] + if v != nil { + var timeAggregation TimeAggregationOperator + err = json.Unmarshal(*m["timeAggregation"], &timeAggregation) + if err != nil { + return err + } + trc.TimeAggregation = timeAggregation + } + + v = m["dataSource"] + if v != nil { + dataSource, err := unmarshalBasicRuleDataSource(*m["dataSource"]) + if err != nil { + return err + } + trc.DataSource = dataSource + } + + v = m["odata.type"] + if v != nil { + var odatatype OdataTypeBasicRuleCondition + err = json.Unmarshal(*m["odata.type"], &odatatype) + if err != nil { + return err + } + trc.OdataType = odatatype + } + + return nil +} + +// TimeWindow a specific date-time for the profile. +type TimeWindow struct { + // TimeZone - the timezone of the start and end times for the profile. Some examples of valid timezones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific Standard Time, Eastern Standard Time, US Eastern Standard Time, Venezuela Standard Time, Paraguay Standard Time, Atlantic Standard Time, Central Brazilian Standard Time, SA Western Standard Time, Pacific SA Standard Time, Newfoundland Standard Time, E. South America Standard Time, Argentina Standard Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo Standard Time, Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard Time, W. Europe Standard Time, Central Europe Standard Time, Romance Standard Time, Central European Standard Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard Time, GTB Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, E. Europe Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, Israel Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, Arab Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia Time Zone 3, Mauritius Standard Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, West Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, Bangladesh Standard Time, N. Central Asia Standard Time, Myanmar Standard Time, SE Asia Standard Time, North Asia Standard Time, China Standard Time, North Asia East Standard Time, Singapore Standard Time, W. Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo Standard Time, Korea Standard Time, Yakutsk Standard Time, Cen. Australia Standard Time, AUS Central Standard Time, E. Australia Standard Time, AUS Eastern Standard Time, West Pacific Standard Time, Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time + TimeZone *string `json:"timeZone,omitempty"` + // Start - the start time for the profile in ISO 8601 format. + Start *date.Time `json:"start,omitempty"` + // End - the end time for the profile in ISO 8601 format. + End *date.Time `json:"end,omitempty"` +} + +// WebhookNotification webhook notification of an autoscale event. +type WebhookNotification struct { + // ServiceURI - the service address to receive the notification. + ServiceURI *string `json:"serviceUri,omitempty"` + // Properties - a property bag of settings. This value can be empty. + Properties *map[string]*string `json:"properties,omitempty"` +} + +// WebhookReceiver a webhook receiver. +type WebhookReceiver struct { + // Name - The name of the webhook receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + // ServiceURI - The URI where webhooks should be sent. + ServiceURI *string `json:"serviceUri,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/operations.go new file mode 100644 index 000000000000..bcfbfcf93b3d --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/operations.go @@ -0,0 +1,98 @@ +package insights + +// 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" + "net/http" +) + +// OperationsClient is the monitor Management Client +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. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available operations from Microsoft.Insights provider. +func (client OperationsClient) List(ctx context.Context) (result OperationListResult, err error) { + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.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 = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/microsoft.insights/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 autorest.SendWithSender(client, 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 OperationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/version.go new file mode 100644 index 000000000000..b43f3dab0b6e --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights/version.go @@ -0,0 +1,28 @@ +package insights + +// 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/v12.2.0-beta services" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return "v12.2.0-beta" +} diff --git a/vendor/vendor.json b/vendor/vendor.json index 28542fba86cc..1c79ccfe7582 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -162,6 +162,14 @@ "version": "v12.2.0-beta", "versionExact": "v12.2.0-beta" }, + { + "checksumSHA1": "BIYVv8ZatuZvOoUoYH9xhI+p+zA=", + "path": "github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights", + "revision": "eae258195456be76b2ec9ad2ee2ab63cdda365d9", + "revisionTime": "2018-01-09T21:59:56Z", + "version": "=v12.2.0-beta", + "versionExact": "v12.2.0-beta" + }, { "checksumSHA1": "YfkdpUnZChrGOsllGtPCqvTPauo=", "path": "github.com/Azure/azure-sdk-for-go/services/mysql/mgmt/2017-04-30-preview/mysql", diff --git a/website/azurerm.erb b/website/azurerm.erb index 6006a5544f46..4cea2754e2f0 100644 --- a/website/azurerm.erb +++ b/website/azurerm.erb @@ -444,6 +444,15 @@ +