diff --git a/azurerm/internal/services/loganalytics/client/client.go b/azurerm/internal/services/loganalytics/client/client.go index c9ffc1f9cae3..1b2a48b4f80c 100644 --- a/azurerm/internal/services/loganalytics/client/client.go +++ b/azurerm/internal/services/loganalytics/client/client.go @@ -1,7 +1,7 @@ package client import ( - "github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights" + "github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights" "github.com/Azure/azure-sdk-for-go/services/preview/operationsmanagement/mgmt/2015-11-01-preview/operationsmanagement" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common" ) diff --git a/azurerm/internal/services/loganalytics/log_analytics_cluster.go b/azurerm/internal/services/loganalytics/log_analytics_cluster.go index fc5e6d21fae4..3575d1e94e68 100644 --- a/azurerm/internal/services/loganalytics/log_analytics_cluster.go +++ b/azurerm/internal/services/loganalytics/log_analytics_cluster.go @@ -6,7 +6,7 @@ import ( "log" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights" + "github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" ) diff --git a/azurerm/internal/services/loganalytics/log_analytics_cluster_customer_managed_key_resource.go b/azurerm/internal/services/loganalytics/log_analytics_cluster_customer_managed_key_resource.go index def010bce375..f73737030be8 100644 --- a/azurerm/internal/services/loganalytics/log_analytics_cluster_customer_managed_key_resource.go +++ b/azurerm/internal/services/loganalytics/log_analytics_cluster_customer_managed_key_resource.go @@ -6,7 +6,7 @@ import ( "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights" + "github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" @@ -40,7 +40,7 @@ func resourceArmLogAnalyticsClusterCustomerManagedKey() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.LogAnalyticsClusterId, + ValidateFunc: validate.LogAnalyticsClusterID, }, "key_vault_key_id": { @@ -63,12 +63,12 @@ func resourceArmLogAnalyticsClusterCustomerManagedKeyCreate(d *schema.ResourceDa return err } - resp, err := client.Get(ctx, clusterId.ResourceGroup, clusterId.Name) + resp, err := client.Get(ctx, clusterId.ResourceGroup, clusterId.ClusterName) if err != nil { if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("Log Analytics Cluster %q (resource group %q) was not found", clusterId.Name, clusterId.ResourceGroup) + return fmt.Errorf("Log Analytics Cluster %q (resource group %q) was not found", clusterId.ClusterName, clusterId.ResourceGroup) } - return fmt.Errorf("failed to get details of Log Analytics Cluster %q (resource group %q): %+v", clusterId.Name, clusterId.ResourceGroup, err) + return fmt.Errorf("failed to get details of Log Analytics Cluster %q (resource group %q): %+v", clusterId.ClusterName, clusterId.ResourceGroup, err) } if resp.ClusterProperties != nil && resp.ClusterProperties.KeyVaultProperties != nil { keyProps := *resp.ClusterProperties.KeyVaultProperties @@ -106,14 +106,14 @@ func resourceArmLogAnalyticsClusterCustomerManagedKeyUpdate(d *schema.ResourceDa }, } - if _, err := client.Update(ctx, clusterId.ResourceGroup, clusterId.Name, clusterPatch); err != nil { - return fmt.Errorf("updating Log Analytics Cluster %q (Resource Group %q): %+v", clusterId.Name, clusterId.ResourceGroup, err) + if _, err := client.Update(ctx, clusterId.ResourceGroup, clusterId.ClusterName, clusterPatch); err != nil { + return fmt.Errorf("updating Log Analytics Cluster %q (Resource Group %q): %+v", clusterId.ClusterName, clusterId.ResourceGroup, err) } - updateWait := logAnalyticsClusterWaitForState(ctx, meta, d.Timeout(schema.TimeoutUpdate), clusterId.ResourceGroup, clusterId.Name) + updateWait := logAnalyticsClusterWaitForState(ctx, meta, d.Timeout(schema.TimeoutUpdate), clusterId.ResourceGroup, clusterId.ClusterName) if _, err := updateWait.WaitForState(); err != nil { - return fmt.Errorf("waiting for Log Analytics Cluster to finish updating %q (Resource Group %q): %v", clusterId.Name, clusterId.ResourceGroup, err) + return fmt.Errorf("waiting for Log Analytics Cluster to finish updating %q (Resource Group %q): %v", clusterId.ClusterName, clusterId.ResourceGroup, err) } return resourceArmLogAnalyticsClusterCustomerManagedKeyRead(d, meta) @@ -133,14 +133,14 @@ func resourceArmLogAnalyticsClusterCustomerManagedKeyRead(d *schema.ResourceData d.Set("log_analytics_cluster_id", idRaw) - resp, err := client.Get(ctx, id.ResourceGroup, id.Name) + resp, err := client.Get(ctx, id.ResourceGroup, id.ClusterName) if err != nil { if utils.ResponseWasNotFound(resp.Response) { log.Printf("[INFO] Log Analytics %q does not exist - removing from state", d.Id()) d.SetId("") return nil } - return fmt.Errorf("retrieving Log Analytics Cluster %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + return fmt.Errorf("retrieving Log Analytics Cluster %q (Resource Group %q): %+v", id.ClusterName, id.ResourceGroup, err) } if props := resp.ClusterProperties; props != nil { @@ -190,14 +190,14 @@ func resourceArmLogAnalyticsClusterCustomerManagedKeyDelete(d *schema.ResourceDa }, } - if _, err = client.Update(ctx, clusterId.ResourceGroup, clusterId.Name, clusterPatch); err != nil { - return fmt.Errorf("removing Log Analytics Cluster Customer Managed Key from cluster %q (resource group %q)", clusterId.Name, clusterId.ResourceGroup) + if _, err = client.Update(ctx, clusterId.ResourceGroup, clusterId.ClusterName, clusterPatch); err != nil { + return fmt.Errorf("removing Log Analytics Cluster Customer Managed Key from cluster %q (resource group %q)", clusterId.ClusterName, clusterId.ResourceGroup) } - deleteWait := logAnalyticsClusterWaitForState(ctx, meta, d.Timeout(schema.TimeoutDelete), clusterId.ResourceGroup, clusterId.Name) + deleteWait := logAnalyticsClusterWaitForState(ctx, meta, d.Timeout(schema.TimeoutDelete), clusterId.ResourceGroup, clusterId.ClusterName) if _, err := deleteWait.WaitForState(); err != nil { - return fmt.Errorf("waiting for Log Analytics Cluster to finish updating %q (Resource Group %q): %v", clusterId.Name, clusterId.ResourceGroup, err) + return fmt.Errorf("waiting for Log Analytics Cluster to finish updating %q (Resource Group %q): %v", clusterId.ClusterName, clusterId.ResourceGroup, err) } return nil diff --git a/azurerm/internal/services/loganalytics/log_analytics_cluster_customer_managed_key_resource_test.go b/azurerm/internal/services/loganalytics/log_analytics_cluster_customer_managed_key_resource_test.go index 7ca20a58d5b2..cebee1d4f94c 100644 --- a/azurerm/internal/services/loganalytics/log_analytics_cluster_customer_managed_key_resource_test.go +++ b/azurerm/internal/services/loganalytics/log_analytics_cluster_customer_managed_key_resource_test.go @@ -45,7 +45,7 @@ func testCheckAzureRMLogAnalyticsClusterCustomerManagedKeyExists(resourceName st if err != nil { return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.Name) + resp, err := client.Get(ctx, id.ResourceGroup, id.ClusterName) if err != nil { if !utils.ResponseWasNotFound(resp.Response) { return fmt.Errorf("bad: get on Log Analytics Cluster for CMK: %+v", err) @@ -77,7 +77,7 @@ func testCheckAzureRMLogAnalyticsClusterCustomerManagedKeyDestroy(s *terraform.S if err != nil { return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.Name) + resp, err := client.Get(ctx, id.ResourceGroup, id.ClusterName) if err != nil { if !utils.ResponseWasNotFound(resp.Response) { return fmt.Errorf("bad: get on Log Analytics Cluster for CMK: %+v", err) diff --git a/azurerm/internal/services/loganalytics/log_analytics_cluster_resource.go b/azurerm/internal/services/loganalytics/log_analytics_cluster_resource.go index a25f01bbba87..eead0a652ca6 100644 --- a/azurerm/internal/services/loganalytics/log_analytics_cluster_resource.go +++ b/azurerm/internal/services/loganalytics/log_analytics_cluster_resource.go @@ -5,7 +5,7 @@ import ( "log" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights" + "github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" @@ -112,7 +112,7 @@ func resourceArmLogAnalyticsClusterCreate(d *schema.ResourceData, meta interface name := d.Get("name").(string) resourceGroup := d.Get("resource_group_name").(string) - id := parse.NewLogAnalyticsClusterId(name, resourceGroup) + id := parse.NewLogAnalyticsClusterID(subscriptionId, resourceGroup, name) existing, err := client.Get(ctx, resourceGroup, name) if err != nil { @@ -147,10 +147,10 @@ func resourceArmLogAnalyticsClusterCreate(d *schema.ResourceData, meta interface return fmt.Errorf("retrieving Log Analytics Cluster %q (Resource Group %q): %+v", name, resourceGroup, err) } - createWait := logAnalyticsClusterWaitForState(ctx, meta, d.Timeout(schema.TimeoutCreate), id.ResourceGroup, id.Name) + createWait := logAnalyticsClusterWaitForState(ctx, meta, d.Timeout(schema.TimeoutCreate), id.ResourceGroup, id.ClusterName) if _, err := createWait.WaitForState(); err != nil { - return fmt.Errorf("waiting for Log Analytics Cluster to finish updating %q (Resource Group %q): %v", id.Name, id.ResourceGroup, err) + return fmt.Errorf("waiting for Log Analytics Cluster to finish updating %q (Resource Group %q): %v", id.ClusterName, id.ResourceGroup, err) } d.SetId(id.ID(subscriptionId)) @@ -168,16 +168,16 @@ func resourceArmLogAnalyticsClusterRead(d *schema.ResourceData, meta interface{} return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.Name) + resp, err := client.Get(ctx, id.ResourceGroup, id.ClusterName) if err != nil { if utils.ResponseWasNotFound(resp.Response) { log.Printf("[INFO] Log Analytics %q does not exist - removing from state", d.Id()) d.SetId("") return nil } - return fmt.Errorf("retrieving Log Analytics Cluster %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + return fmt.Errorf("retrieving Log Analytics Cluster %q (Resource Group %q): %+v", id.ClusterName, id.ResourceGroup, err) } - d.Set("name", id.Name) + d.Set("name", id.ClusterName) d.Set("resource_group_name", id.ResourceGroup) d.Set("location", location.NormalizeNilable(resp.Location)) if err := d.Set("identity", flattenArmLogAnalyticsIdentity(resp.Identity)); err != nil { @@ -221,18 +221,18 @@ func resourceArmLogAnalyticsClusterUpdate(d *schema.ResourceData, meta interface parameters.Tags = tags.Expand(d.Get("tags").(map[string]interface{})) } - if _, err := client.Update(ctx, id.ResourceGroup, id.Name, parameters); err != nil { - return fmt.Errorf("updating Log Analytics Cluster %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + if _, err := client.Update(ctx, id.ResourceGroup, id.ClusterName, parameters); err != nil { + return fmt.Errorf("updating Log Analytics Cluster %q (Resource Group %q): %+v", id.ClusterName, id.ResourceGroup, err) } // Need to wait for the cluster to actually finish updating the resource before continuing // since the service returns a 200 instantly while it's still updating in the background log.Printf("[INFO] Checking for Log Analytics Cluster provisioning state") - updateWait := logAnalyticsClusterWaitForState(ctx, meta, d.Timeout(schema.TimeoutUpdate), id.ResourceGroup, id.Name) + updateWait := logAnalyticsClusterWaitForState(ctx, meta, d.Timeout(schema.TimeoutUpdate), id.ResourceGroup, id.ClusterName) if _, err := updateWait.WaitForState(); err != nil { - return fmt.Errorf("waiting for Log Analytics Cluster to finish updating %q (Resource Group %q): %v", id.Name, id.ResourceGroup, err) + return fmt.Errorf("waiting for Log Analytics Cluster to finish updating %q (Resource Group %q): %v", id.ClusterName, id.ResourceGroup, err) } return resourceArmLogAnalyticsClusterRead(d, meta) @@ -248,13 +248,13 @@ func resourceArmLogAnalyticsClusterDelete(d *schema.ResourceData, meta interface return err } - future, err := client.Delete(ctx, id.ResourceGroup, id.Name) + future, err := client.Delete(ctx, id.ResourceGroup, id.ClusterName) if err != nil { - return fmt.Errorf("deleting Log Analytics Cluster %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + return fmt.Errorf("deleting Log Analytics Cluster %q (Resource Group %q): %+v", id.ClusterName, id.ResourceGroup, err) } if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting on deleting future for Log Analytics Cluster %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + return fmt.Errorf("waiting on deleting future for Log Analytics Cluster %q (Resource Group %q): %+v", id.ClusterName, id.ResourceGroup, err) } return nil diff --git a/azurerm/internal/services/loganalytics/log_analytics_cluster_resource_test.go b/azurerm/internal/services/loganalytics/log_analytics_cluster_resource_test.go index cb128ae18c0b..fdca446dd405 100644 --- a/azurerm/internal/services/loganalytics/log_analytics_cluster_resource_test.go +++ b/azurerm/internal/services/loganalytics/log_analytics_cluster_resource_test.go @@ -85,9 +85,9 @@ func testCheckAzureRMLogAnalyticsClusterExists(resourceName string) resource.Tes if err != nil { return err } - if resp, err := client.Get(ctx, id.ResourceGroup, id.Name); err != nil { + if resp, err := client.Get(ctx, id.ResourceGroup, id.ClusterName); err != nil { if !utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("bad: log analytics Cluster %q does not exist", id.Name) + return fmt.Errorf("bad: log analytics Cluster %q does not exist", id.ClusterName) } return fmt.Errorf("bad: Get on LogAnalytics.ClusterClient: %+v", err) } @@ -107,7 +107,7 @@ func testCheckAzureRMLogAnalyticsClusterDestroy(s *terraform.State) error { if err != nil { return err } - if resp, err := client.Get(ctx, id.ResourceGroup, id.Name); err != nil { + if resp, err := client.Get(ctx, id.ResourceGroup, id.ClusterName); err != nil { if !utils.ResponseWasNotFound(resp.Response) { return fmt.Errorf("bad: Get on LogAnalytics.ClusterClient: %+v", err) } diff --git a/azurerm/internal/services/loganalytics/log_analytics_data_export_resource.go b/azurerm/internal/services/loganalytics/log_analytics_data_export_resource.go index 9b2133d33b3c..9b46ba1d4b66 100644 --- a/azurerm/internal/services/loganalytics/log_analytics_data_export_resource.go +++ b/azurerm/internal/services/loganalytics/log_analytics_data_export_resource.go @@ -5,7 +5,7 @@ import ( "log" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights" + "github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" @@ -50,7 +50,7 @@ func resourceArmLogAnalyticsDataExport() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: azure.ValidateResourceID, + ValidateFunc: validate.LogAnalyticsWorkspaceID, }, "destination_resource_id": { @@ -96,10 +96,10 @@ func resourceArmOperationalinsightsDataExportCreateUpdate(d *schema.ResourceData } if d.IsNewResource() { - existing, err := client.Get(ctx, resourceGroup, workspace.Name, name) + existing, err := client.Get(ctx, resourceGroup, workspace.WorkspaceName, name) if err != nil { if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for present of existing Log Analytics Data Export Rule %q (Resource Group %q / workspaceName %q): %+v", name, resourceGroup, workspace.Name, err) + return fmt.Errorf("checking for present of existing Log Analytics Data Export Rule %q (Resource Group %q / workspaceName %q): %+v", name, resourceGroup, workspace.WorkspaceName, err) } } if existing.ID != nil && *existing.ID != "" { @@ -117,17 +117,17 @@ func resourceArmOperationalinsightsDataExportCreateUpdate(d *schema.ResourceData }, } - if _, err := client.CreateOrUpdate(ctx, resourceGroup, workspace.Name, name, parameters); err != nil { - return fmt.Errorf("creating/updating Log Analytics Data Export Rule %q (Resource Group %q / workspaceName %q): %+v", name, resourceGroup, workspace.Name, err) + if _, err := client.CreateOrUpdate(ctx, resourceGroup, workspace.WorkspaceName, name, parameters); err != nil { + return fmt.Errorf("creating/updating Log Analytics Data Export Rule %q (Resource Group %q / workspaceName %q): %+v", name, resourceGroup, workspace.WorkspaceName, err) } - resp, err := client.Get(ctx, resourceGroup, workspace.Name, name) + resp, err := client.Get(ctx, resourceGroup, workspace.WorkspaceName, name) if err != nil { - return fmt.Errorf("retrieving Log Analytics Data Export Rule %q (Resource Group %q / workspaceName %q): %+v", name, resourceGroup, workspace.Name, err) + return fmt.Errorf("retrieving Log Analytics Data Export Rule %q (Resource Group %q / workspaceName %q): %+v", name, resourceGroup, workspace.WorkspaceName, err) } if resp.ID == nil || *resp.ID == "" { - return fmt.Errorf("empty or nil ID returned for Log Analytics Data Export Rule %q (Resource Group %q / workspaceName %q) ID", name, resourceGroup, workspace.Name) + return fmt.Errorf("empty or nil ID returned for Log Analytics Data Export Rule %q (Resource Group %q / workspaceName %q) ID", name, resourceGroup, workspace.WorkspaceName) } d.SetId(*resp.ID) @@ -144,18 +144,18 @@ func resourceArmOperationalinsightsDataExportRead(d *schema.ResourceData, meta i return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, id.Name) + resp, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, id.DataexportName) if err != nil { if utils.ResponseWasNotFound(resp.Response) { log.Printf("[INFO] Log Analytics %q does not exist - removing from state", d.Id()) d.SetId("") return nil } - return fmt.Errorf("retrieving Log Analytics Data Export Rule %q (Resource Group %q / workspaceName %q): %+v", id.Name, id.ResourceGroup, id.WorkspaceName, err) + return fmt.Errorf("retrieving Log Analytics Data Export Rule %q (Resource Group %q / workspaceName %q): %+v", id.DataexportName, id.ResourceGroup, id.WorkspaceName, err) } - d.Set("name", id.Name) + d.Set("name", id.DataexportName) d.Set("resource_group_name", id.ResourceGroup) - d.Set("workspace_resource_id", id.WorkspaceID) + d.Set("workspace_resource_id", parse.NewLogAnalyticsWorkspaceID(id.SubscriptionId, id.ResourceGroup, id.WorkspaceName).ID("")) if props := resp.DataExportProperties; props != nil { d.Set("export_rule_id", props.DataExportID) d.Set("destination_resource_id", flattenArmDataExportDestination(props.Destination)) @@ -175,8 +175,8 @@ func resourceArmOperationalinsightsDataExportDelete(d *schema.ResourceData, meta return err } - if _, err := client.Delete(ctx, id.ResourceGroup, id.WorkspaceName, id.Name); err != nil { - return fmt.Errorf("deleting Log Analytics Data Export Rule %q (Resource Group %q / workspaceName %q): %+v", id.Name, id.ResourceGroup, id.WorkspaceName, err) + if _, err := client.Delete(ctx, id.ResourceGroup, id.WorkspaceName, id.DataexportName); err != nil { + return fmt.Errorf("deleting Log Analytics Data Export Rule %q (Resource Group %q / workspaceName %q): %+v", id.DataexportName, id.ResourceGroup, id.WorkspaceName, err) } return nil } diff --git a/azurerm/internal/services/loganalytics/log_analytics_data_export_resource_test.go b/azurerm/internal/services/loganalytics/log_analytics_data_export_resource_test.go index 2fde2fce2de8..33a271452272 100644 --- a/azurerm/internal/services/loganalytics/log_analytics_data_export_resource_test.go +++ b/azurerm/internal/services/loganalytics/log_analytics_data_export_resource_test.go @@ -20,11 +20,11 @@ func TestAccAzureRMLogAnalyticsDataExportRule_basic(t *testing.T) { CheckDestroy: testCheckAzureRMLogAnalyticsDataExportRuleDestroy, Steps: []resource.TestStep{ { - Config: testAccAzureRMLogAnalyticsDataExportRule_basic(data), + Config: testAccAzureRMLogAnalyticsDataExportRule_basic(data), + ExpectNonEmptyPlan: true, // Due to API changing case of attributes you need to ignore a non-empty plan for this resource Check: resource.ComposeTestCheckFunc( testCheckAzureRMLogAnalyticsDataExportRuleExists(data.ResourceName), ), - ExpectNonEmptyPlan: true, // Due to API changing case of attributes you need to ignore a non-empty plan for this resource }, data.ImportStep(), }, @@ -39,11 +39,11 @@ func TestAccAzureRMLogAnalyticsDataExportRule_requiresImport(t *testing.T) { CheckDestroy: testCheckAzureRMLogAnalyticsDataExportRuleDestroy, Steps: []resource.TestStep{ { - Config: testAccAzureRMLogAnalyticsDataExportRule_basicLower(data), + Config: testAccAzureRMLogAnalyticsDataExportRule_basicLower(data), + ExpectNonEmptyPlan: true, // Due to API changing case of attributes you need to ignore a non-empty plan for this resource Check: resource.ComposeTestCheckFunc( testCheckAzureRMLogAnalyticsDataExportRuleExists(data.ResourceName), ), - ExpectNonEmptyPlan: true, // Due to API changing case of attributes you need to ignore a non-empty plan for this resource }, { Config: testAccAzureRMLogAnalyticsDataExportRule_requiresImport(data), @@ -62,19 +62,19 @@ func TestAccAzureRMLogAnalyticsDataExportRule_update(t *testing.T) { CheckDestroy: testCheckAzureRMLogAnalyticsDataExportRuleDestroy, Steps: []resource.TestStep{ { - Config: testAccAzureRMLogAnalyticsDataExportRule_basic(data), + Config: testAccAzureRMLogAnalyticsDataExportRule_basic(data), + ExpectNonEmptyPlan: true, // Due to API changing case of attributes you need to ignore a non-empty plan for this resource Check: resource.ComposeTestCheckFunc( testCheckAzureRMLogAnalyticsDataExportRuleExists(data.ResourceName), ), - ExpectNonEmptyPlan: true, // Due to API changing case of attributes you need to ignore a non-empty plan for this resource }, data.ImportStep(), { - Config: testAccAzureRMLogAnalyticsDataExportRule_update(data), + Config: testAccAzureRMLogAnalyticsDataExportRule_update(data), + ExpectNonEmptyPlan: true, // Due to API changing case of attributes you need to ignore a non-empty plan for this resource Check: resource.ComposeTestCheckFunc( testCheckAzureRMLogAnalyticsDataExportRuleExists(data.ResourceName), ), - ExpectNonEmptyPlan: true, // Due to API changing case of attributes you need to ignore a non-empty plan for this resource }, data.ImportStep(), }, @@ -89,11 +89,11 @@ func TestAccAzureRMLogAnalyticsDataExportRule_complete(t *testing.T) { CheckDestroy: testCheckAzureRMLogAnalyticsDataExportRuleDestroy, Steps: []resource.TestStep{ { - Config: testAccAzureRMLogAnalyticsDataExportRule_complete(data), + Config: testAccAzureRMLogAnalyticsDataExportRule_complete(data), + ExpectNonEmptyPlan: true, // Due to API changing case of attributes you need to ignore a non-empty plan for this resource Check: resource.ComposeTestCheckFunc( testCheckAzureRMLogAnalyticsDataExportRuleExists(data.ResourceName), ), - ExpectNonEmptyPlan: true, // Due to API changing case of attributes you need to ignore a non-empty plan for this resource }, data.ImportStep(), }, @@ -117,7 +117,7 @@ func testCheckAzureRMLogAnalyticsDataExportRuleDestroy(s *terraform.State) error return nil } - resp, err := conn.Get(ctx, resourceGroup, workspace.Name, name) + resp, err := conn.Get(ctx, resourceGroup, workspace.WorkspaceName, name) if err != nil { return nil } @@ -152,7 +152,7 @@ func testCheckAzureRMLogAnalyticsDataExportRuleExists(resourceName string) resou return fmt.Errorf("Bad: unable to access 'workspace_resource_id' for Log Analytics Data Export Rule: %q", name) } - resp, err := conn.Get(ctx, resourceGroup, workspace.Name, name) + resp, err := conn.Get(ctx, resourceGroup, workspace.WorkspaceName, name) if err != nil { return fmt.Errorf("Bad: Get on Log Analytics Data Export Rule Client: %+v", err) } diff --git a/azurerm/internal/services/loganalytics/log_analytics_datasource_import.go b/azurerm/internal/services/loganalytics/log_analytics_datasource_import.go index 6aeb91a5fb50..2c5684270d2e 100644 --- a/azurerm/internal/services/loganalytics/log_analytics_datasource_import.go +++ b/azurerm/internal/services/loganalytics/log_analytics_datasource_import.go @@ -3,7 +3,7 @@ package loganalytics import ( "fmt" - "github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights" + "github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/loganalytics/parse" diff --git a/azurerm/internal/services/loganalytics/log_analytics_datasource_windows_event_resource.go b/azurerm/internal/services/loganalytics/log_analytics_datasource_windows_event_resource.go index 49077e849015..14ec8d83bc92 100644 --- a/azurerm/internal/services/loganalytics/log_analytics_datasource_windows_event_resource.go +++ b/azurerm/internal/services/loganalytics/log_analytics_datasource_windows_event_resource.go @@ -6,7 +6,7 @@ import ( "log" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights" + "github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/structure" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" diff --git a/azurerm/internal/services/loganalytics/log_analytics_datasource_windows_performance_counter_resource.go b/azurerm/internal/services/loganalytics/log_analytics_datasource_windows_performance_counter_resource.go index 95594ce73376..b64bf64c32f3 100644 --- a/azurerm/internal/services/loganalytics/log_analytics_datasource_windows_performance_counter_resource.go +++ b/azurerm/internal/services/loganalytics/log_analytics_datasource_windows_performance_counter_resource.go @@ -7,7 +7,7 @@ import ( "math" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights" + "github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/structure" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" diff --git a/azurerm/internal/services/loganalytics/log_analytics_linked_service_resource.go b/azurerm/internal/services/loganalytics/log_analytics_linked_service_resource.go index b7710f735459..8acd5e096bd7 100644 --- a/azurerm/internal/services/loganalytics/log_analytics_linked_service_resource.go +++ b/azurerm/internal/services/loganalytics/log_analytics_linked_service_resource.go @@ -5,7 +5,7 @@ import ( "log" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights" + "github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights" "github.com/hashicorp/go-azure-helpers/response" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" diff --git a/azurerm/internal/services/loganalytics/log_analytics_linked_storage_account_resource.go b/azurerm/internal/services/loganalytics/log_analytics_linked_storage_account_resource.go index e62ace04ef19..76ceeed8d9f9 100644 --- a/azurerm/internal/services/loganalytics/log_analytics_linked_storage_account_resource.go +++ b/azurerm/internal/services/loganalytics/log_analytics_linked_storage_account_resource.go @@ -6,7 +6,9 @@ import ( "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/loganalytics/validate" + + "github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" @@ -14,7 +16,6 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/loganalytics/parse" azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/schema" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/suppress" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) @@ -47,8 +48,9 @@ func resourceArmLogAnalyticsLinkedStorageAccount() *schema.Resource { strings.ToLower(string(operationalinsights.CustomLogs)), strings.ToLower(string(operationalinsights.AzureWatson)), strings.ToLower(string(operationalinsights.Query)), - strings.ToLower(string(operationalinsights.Ingestion)), strings.ToLower(string(operationalinsights.Alerts)), + // Value removed from enum in 2020-08-01, but effectively still works + "Ingestion", }, false), }, @@ -58,9 +60,7 @@ func resourceArmLogAnalyticsLinkedStorageAccount() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: azure.ValidateResourceID, - // https://github.com/Azure/azure-rest-api-specs/issues/9633 - DiffSuppressFunc: suppress.CaseDifference, + ValidateFunc: validate.LogAnalyticsWorkspaceID, }, "storage_account_ids": { @@ -89,10 +89,10 @@ func resourceArmLogAnalyticsLinkedStorageAccountCreateUpdate(d *schema.ResourceD } if d.IsNewResource() { - existing, err := client.Get(ctx, resourceGroup, workspace.Name, dataSourceType) + existing, err := client.Get(ctx, resourceGroup, workspace.WorkspaceName, dataSourceType) if err != nil { if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for present of existing Log Analytics Linked Storage Account %q (Resource Group %q / workspaceName %q): %+v", dataSourceType, resourceGroup, workspace.Name, err) + return fmt.Errorf("checking for present of existing Log Analytics Linked Storage Account %q (Resource Group %q / workspaceName %q): %+v", dataSourceType, resourceGroup, workspace.WorkspaceName, err) } } if existing.ID != nil && *existing.ID != "" { @@ -105,17 +105,17 @@ func resourceArmLogAnalyticsLinkedStorageAccountCreateUpdate(d *schema.ResourceD StorageAccountIds: utils.ExpandStringSlice(d.Get("storage_account_ids").(*schema.Set).List()), }, } - if _, err := client.CreateOrUpdate(ctx, resourceGroup, workspace.Name, dataSourceType, parameters); err != nil { - return fmt.Errorf("creating/updating Log Analytics Linked Storage Account %q (Resource Group %q / workspaceName %q): %+v", dataSourceType, resourceGroup, workspace.Name, err) + if _, err := client.CreateOrUpdate(ctx, resourceGroup, workspace.WorkspaceName, dataSourceType, parameters); err != nil { + return fmt.Errorf("creating/updating Log Analytics Linked Storage Account %q (Resource Group %q / workspaceName %q): %+v", dataSourceType, resourceGroup, workspace.WorkspaceName, err) } - resp, err := client.Get(ctx, resourceGroup, workspace.Name, dataSourceType) + resp, err := client.Get(ctx, resourceGroup, workspace.WorkspaceName, dataSourceType) if err != nil { - return fmt.Errorf("retrieving Log Analytics Linked Storage Account %q (Resource Group %q / workspaceName %q): %+v", dataSourceType, resourceGroup, workspace.Name, err) + return fmt.Errorf("retrieving Log Analytics Linked Storage Account %q (Resource Group %q / workspaceName %q): %+v", dataSourceType, resourceGroup, workspace.WorkspaceName, err) } if resp.ID == nil || *resp.ID == "" { - return fmt.Errorf("empty or nil ID returned for Log Analytics Linked Storage Account %q (Resource Group %q / workspaceName %q) ID", dataSourceType, resourceGroup, workspace.Name) + return fmt.Errorf("empty or nil ID returned for Log Analytics Linked Storage Account %q (Resource Group %q / workspaceName %q) ID", dataSourceType, resourceGroup, workspace.WorkspaceName) } d.SetId(*resp.ID) @@ -132,7 +132,7 @@ func resourceArmLogAnalyticsLinkedStorageAccountRead(d *schema.ResourceData, met return err } - dataSourceType := operationalinsights.DataSourceType(id.Name) + dataSourceType := operationalinsights.DataSourceType(id.LinkedStorageAccountName) resp, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, dataSourceType) if err != nil { if utils.ResponseWasNotFound(resp.Response) { @@ -140,12 +140,12 @@ func resourceArmLogAnalyticsLinkedStorageAccountRead(d *schema.ResourceData, met d.SetId("") return nil } - return fmt.Errorf("retrieving Log Analytics Linked Storage Account %q (Resource Group %q / workspaceName %q): %+v", id.Name, id.ResourceGroup, id.WorkspaceName, err) + return fmt.Errorf("retrieving Log Analytics Linked Storage Account %q (Resource Group %q / workspaceName %q): %+v", id.LinkedStorageAccountName, id.ResourceGroup, id.WorkspaceName, err) } d.Set("data_source_type", resp.Name) d.Set("resource_group_name", id.ResourceGroup) - d.Set("workspace_resource_id", id.WorkspaceID) + d.Set("workspace_resource_id", parse.NewLogAnalyticsWorkspaceID(id.SubscriptionId, id.ResourceGroup, id.WorkspaceName).ID("")) if props := resp.LinkedStorageAccountsProperties; props != nil { d.Set("storage_account_ids", utils.FlattenStringSlice(props.StorageAccountIds)) } @@ -163,9 +163,9 @@ func resourceArmLogAnalyticsLinkedStorageAccountDelete(d *schema.ResourceData, m return err } - dataSourceType := operationalinsights.DataSourceType(id.Name) + dataSourceType := operationalinsights.DataSourceType(id.LinkedStorageAccountName) if _, err := client.Delete(ctx, id.ResourceGroup, id.WorkspaceName, dataSourceType); err != nil { - return fmt.Errorf("deleting Log Analytics Linked Storage Account %q (Resource Group %q / workspaceName %q): %+v", id.Name, id.ResourceGroup, id.WorkspaceName, err) + return fmt.Errorf("deleting Log Analytics Linked Storage Account %q (Resource Group %q / workspaceName %q): %+v", id.LinkedStorageAccountName, id.ResourceGroup, id.WorkspaceName, err) } return nil } diff --git a/azurerm/internal/services/loganalytics/log_analytics_linked_storage_account_resource_test.go b/azurerm/internal/services/loganalytics/log_analytics_linked_storage_account_resource_test.go index 688b1db3bbe1..233e06ea1b30 100644 --- a/azurerm/internal/services/loganalytics/log_analytics_linked_storage_account_resource_test.go +++ b/azurerm/internal/services/loganalytics/log_analytics_linked_storage_account_resource_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights" + "github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" @@ -111,9 +111,9 @@ func testCheckAzureRMoperationalinsightsLinkedStorageAccountExists(resourceName if err != nil { return err } - if resp, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, operationalinsights.DataSourceType(id.Name)); err != nil { + if resp, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, operationalinsights.DataSourceType(id.LinkedStorageAccountName)); err != nil { if !utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("bad: Operationalinsights LinkedStorageAccount %q does not exist", id.Name) + return fmt.Errorf("bad: Operationalinsights LinkedStorageAccount %q does not exist", id.LinkedStorageAccountName) } return fmt.Errorf("bad: Get on Operationalinsights.LinkedStorageAccountClient: %+v", err) } @@ -133,7 +133,7 @@ func testCheckAzureRMoperationalinsightsLinkedStorageAccountDestroy(s *terraform if err != nil { return err } - if resp, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, operationalinsights.DataSourceType(id.Name)); err != nil { + if resp, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, operationalinsights.DataSourceType(id.LinkedStorageAccountName)); err != nil { if !utils.ResponseWasNotFound(resp.Response) { return fmt.Errorf("bad: Get on LogAnalytics.LinkedStorageAccountClient: %+v", err) } diff --git a/azurerm/internal/services/loganalytics/log_analytics_saved_search_resource.go b/azurerm/internal/services/loganalytics/log_analytics_saved_search_resource.go index 7a8809b81c84..c4bf90179880 100644 --- a/azurerm/internal/services/loganalytics/log_analytics_saved_search_resource.go +++ b/azurerm/internal/services/loganalytics/log_analytics_saved_search_resource.go @@ -7,7 +7,7 @@ import ( "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights" + "github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/suppress" @@ -115,10 +115,10 @@ func resourceArmLogAnalyticsSavedSearchCreate(d *schema.ResourceData, meta inter } if d.IsNewResource() { - existing, err := client.Get(ctx, id.ResourceGroup, id.Name, name) + existing, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, name) if err != nil { if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing Log Analytics Saved Search %q (WorkSpace %q / Resource Group %q): %s", name, id.Name, id.ResourceGroup, err) + return fmt.Errorf("checking for presence of existing Log Analytics Saved Search %q (WorkSpace %q / Resource Group %q): %s", name, id.WorkspaceName, id.ResourceGroup, err) } } @@ -148,17 +148,17 @@ func resourceArmLogAnalyticsSavedSearchCreate(d *schema.ResourceData, meta inter parameters.SavedSearchProperties.FunctionParameters = utils.String(strings.Join(result, ", ")) } - if _, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.Name, name, parameters); err != nil { - return fmt.Errorf("creating Saved Search %q (Log Analytics Workspace %q / Resource Group %q): %+v", name, id.Name, id.ResourceGroup, err) + if _, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.WorkspaceName, name, parameters); err != nil { + return fmt.Errorf("creating Saved Search %q (Log Analytics Workspace %q / Resource Group %q): %+v", name, id.WorkspaceName, id.ResourceGroup, err) } - read, err := client.Get(ctx, id.ResourceGroup, id.Name, name) + read, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, name) if err != nil { - return fmt.Errorf("retrieving Saved Search %q (Log Analytics Workspace %q / Resource Group %q): %+v", name, id.Name, id.ResourceGroup, err) + return fmt.Errorf("retrieving Saved Search %q (Log Analytics Workspace %q / Resource Group %q): %+v", name, id.WorkspaceName, id.ResourceGroup, err) } if read.ID == nil { - return fmt.Errorf("cannot read Log Analytics Saved Search %q (WorkSpace %q / Resource Group %q): %s", name, id.Name, id.ResourceGroup, err) + return fmt.Errorf("cannot read Log Analytics Saved Search %q (WorkSpace %q / Resource Group %q): %s", name, id.WorkspaceName, id.ResourceGroup, err) } d.SetId(*read.ID) @@ -168,24 +168,26 @@ func resourceArmLogAnalyticsSavedSearchCreate(d *schema.ResourceData, meta inter func resourceArmLogAnalyticsSavedSearchRead(d *schema.ResourceData, meta interface{}) error { client := meta.(*clients.Client).LogAnalytics.SavedSearchesClient + subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.LogAnalyticsSavedSearchID(d.Id()) + // FIXME: @favoretti: API returns ID without a leading slash + id, err := parse.LogAnalyticsSavedSearchID(fmt.Sprintf("/%s", strings.TrimPrefix(d.Id(), "/"))) if err != nil { return err } - workspaceId := parse.NewLogAnalyticsWorkspaceID(id.WorkspaceName, id.ResourceGroup).ID(meta.(*clients.Client).Account.SubscriptionId) + workspaceId := parse.NewLogAnalyticsWorkspaceID(subscriptionId, id.ResourceGroup, id.WorkspaceName).ID("") - resp, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, id.Name) + resp, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, id.SavedSearcheName) if err != nil { if utils.ResponseWasNotFound(resp.Response) { d.SetId("") return nil } - return fmt.Errorf("retrieving Saved Search %q (Log Analytics Workspace %q / Resource Group %q): %s", id.Name, id.WorkspaceName, id.ResourceGroup, err) + return fmt.Errorf("retrieving Saved Search %q (Log Analytics Workspace %q / Resource Group %q): %s", id.WorkspaceName, id.WorkspaceName, id.ResourceGroup, err) } - d.Set("name", id.Name) + d.Set("name", id.SavedSearcheName) d.Set("log_analytics_workspace_id", workspaceId) if props := resp.SavedSearchProperties; props != nil { @@ -212,13 +214,14 @@ func resourceArmLogAnalyticsSavedSearchDelete(d *schema.ResourceData, meta inter client := meta.(*clients.Client).LogAnalytics.SavedSearchesClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.LogAnalyticsSavedSearchID(d.Id()) + // FIXME: @favoretti: API returns ID without a leading slash + id, err := parse.LogAnalyticsSavedSearchID(fmt.Sprintf("/%s", strings.TrimPrefix(d.Id(), "/"))) if err != nil { return err } - if _, err = client.Delete(ctx, id.ResourceGroup, id.WorkspaceName, id.Name); err != nil { - return fmt.Errorf("deleting Saved Search %q (Log Analytics Workspace %q / Resource Group %q): %s", id.Name, id.WorkspaceName, id.ResourceGroup, err) + if _, err = client.Delete(ctx, id.ResourceGroup, id.WorkspaceName, id.SavedSearcheName); err != nil { + return fmt.Errorf("deleting Saved Search %q (Log Analytics Workspace %q / Resource Group %q): %s", id.WorkspaceName, id.WorkspaceName, id.ResourceGroup, err) } return nil diff --git a/azurerm/internal/services/loganalytics/log_analytics_saved_search_resource_test.go b/azurerm/internal/services/loganalytics/log_analytics_saved_search_resource_test.go index d41c49dfb341..7157a608102f 100644 --- a/azurerm/internal/services/loganalytics/log_analytics_saved_search_resource_test.go +++ b/azurerm/internal/services/loganalytics/log_analytics_saved_search_resource_test.go @@ -3,6 +3,7 @@ package loganalytics_test import ( "fmt" "net/http" + "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" @@ -100,12 +101,13 @@ func testCheckAzureRMLogAnalyticsSavedSearchDestroy(s *terraform.State) error { continue } - id, err := parse.LogAnalyticsSavedSearchID(rs.Primary.ID) + // FIXME: @favoretti: API returns ID without a leading slash + id, err := parse.LogAnalyticsSavedSearchID(fmt.Sprintf("/%s", strings.TrimPrefix(rs.Primary.ID, "/"))) if err != nil { return err } - resp, err := conn.Get(ctx, id.ResourceGroup, id.WorkspaceName, id.Name) + resp, err := conn.Get(ctx, id.ResourceGroup, id.WorkspaceName, id.SavedSearcheName) if err != nil { return nil } @@ -129,18 +131,19 @@ func testCheckAzureRMLogAnalyticsSavedSearchExists(resourceName string) resource return fmt.Errorf("Not found: %s", resourceName) } - id, err := parse.LogAnalyticsSavedSearchID(rs.Primary.ID) + // FIXME: @favoretti: Apparently API returns this resource ID without a leading slash + id, err := parse.LogAnalyticsSavedSearchID(fmt.Sprintf("/%s", strings.TrimPrefix(rs.Primary.ID, "/"))) if err != nil { return err } - resp, err := conn.Get(ctx, id.ResourceGroup, id.WorkspaceName, id.Name) + resp, err := conn.Get(ctx, id.ResourceGroup, id.WorkspaceName, id.SavedSearcheName) if err != nil { return fmt.Errorf("Bad: Get on Log Analytics Saved Search Client: %+v", err) } if resp.StatusCode == http.StatusNotFound { - return fmt.Errorf("bad: Log Analytics Saved Search %q (Workspace: %q / Resource Group: %q) does not exist", id.Name, id.WorkspaceName, id.ResourceGroup) + return fmt.Errorf("bad: Log Analytics Saved Search %q (Workspace: %q / Resource Group: %q) does not exist", id.SavedSearcheName, id.WorkspaceName, id.ResourceGroup) } return nil diff --git a/azurerm/internal/services/loganalytics/log_analytics_storage_insights_resource.go b/azurerm/internal/services/loganalytics/log_analytics_storage_insights_resource.go index 97f556ea7db9..7e9eaccf6776 100644 --- a/azurerm/internal/services/loganalytics/log_analytics_storage_insights_resource.go +++ b/azurerm/internal/services/loganalytics/log_analytics_storage_insights_resource.go @@ -5,7 +5,7 @@ import ( "log" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights" + "github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" @@ -105,8 +105,11 @@ func resourceArmLogAnalyticsStorageInsightsCreateUpdate(d *schema.ResourceData, storageAccountId := d.Get("storage_account_id").(string) storageAccountKey := d.Get("storage_account_key").(string) - workspaceId := d.Get("workspace_id").(string) - id := parse.NewLogAnalyticsStorageInsightsId(resourceGroup, workspaceId, name) + workspace, err := parse.LogAnalyticsWorkspaceID(d.Get("workspace_id").(string)) + if err != nil { + return err + } + id := parse.NewLogAnalyticsStorageInsightsID(subscriptionId, resourceGroup, workspace.WorkspaceName, name) if d.IsNewResource() { existing, err := client.Get(ctx, resourceGroup, id.WorkspaceName, name) @@ -153,19 +156,19 @@ func resourceArmLogAnalyticsStorageInsightsRead(d *schema.ResourceData, meta int return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, id.Name) + resp, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, id.StorageInsightConfigName) if err != nil { if utils.ResponseWasNotFound(resp.Response) { log.Printf("[INFO] Log Analytics Storage Insights %q does not exist - removing from state", d.Id()) d.SetId("") return nil } - return fmt.Errorf("retrieving Log Analytics Storage Insights %q (Resource Group %q / workspaceName %q): %+v", id.Name, id.ResourceGroup, id.WorkspaceName, err) + return fmt.Errorf("retrieving Log Analytics Storage Insights %q (Resource Group %q / workspaceName %q): %+v", id.StorageInsightConfigName, id.ResourceGroup, id.WorkspaceName, err) } - d.Set("name", id.Name) + d.Set("name", id.StorageInsightConfigName) d.Set("resource_group_name", id.ResourceGroup) - d.Set("workspace_id", id.WorkspaceID) + d.Set("workspace_id", parse.NewLogAnalyticsWorkspaceID(id.SubscriptionId, id.ResourceGroup, id.WorkspaceName).ID("")) if props := resp.StorageInsightProperties; props != nil { d.Set("blob_container_names", utils.FlattenStringSlice(props.Containers)) @@ -190,8 +193,8 @@ func resourceArmLogAnalyticsStorageInsightsDelete(d *schema.ResourceData, meta i return err } - if _, err := client.Delete(ctx, id.ResourceGroup, id.WorkspaceName, id.Name); err != nil { - return fmt.Errorf("deleting LogAnalytics Storage Insight Config %q (Resource Group %q / workspaceName %q): %+v", id.Name, id.ResourceGroup, id.WorkspaceName, err) + if _, err := client.Delete(ctx, id.ResourceGroup, id.WorkspaceName, id.StorageInsightConfigName); err != nil { + return fmt.Errorf("deleting LogAnalytics Storage Insight Config %q (Resource Group %q / workspaceName %q): %+v", id.StorageInsightConfigName, id.ResourceGroup, id.WorkspaceName, err) } return nil } diff --git a/azurerm/internal/services/loganalytics/log_analytics_storage_insights_resource_test.go b/azurerm/internal/services/loganalytics/log_analytics_storage_insights_resource_test.go index c870e44c7ef5..437934d244a1 100644 --- a/azurerm/internal/services/loganalytics/log_analytics_storage_insights_resource_test.go +++ b/azurerm/internal/services/loganalytics/log_analytics_storage_insights_resource_test.go @@ -135,9 +135,9 @@ func testCheckAzureRMLogAnalyticsStorageInsightsExists(resourceName string) reso if err != nil { return err } - if resp, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, id.Name); err != nil { + if resp, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, id.StorageInsightConfigName); err != nil { if !utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("bad: Log Analytics Storage Insights %q does not exist", id.Name) + return fmt.Errorf("bad: Log Analytics Storage Insights %q does not exist", id.StorageInsightConfigName) } return fmt.Errorf("bad: Get on LogAnalytics.StorageInsightsClient: %+v", err) } @@ -157,7 +157,7 @@ func testCheckAzureRMLogAnalyticsStorageInsightsDestroy(s *terraform.State) erro if err != nil { return err } - if resp, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, id.Name); err != nil { + if resp, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, id.StorageInsightConfigName); err != nil { if !utils.ResponseWasNotFound(resp.Response) { return fmt.Errorf("bad: Get on LogAnalytics.StorageInsightsClient: %+v", err) } @@ -183,6 +183,7 @@ resource "azurerm_log_analytics_workspace" "test" { location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name sku = "PerGB2018" + retention_in_days = 30 } resource "azurerm_storage_account" "test" { diff --git a/azurerm/internal/services/loganalytics/log_analytics_workspace_migrate.go b/azurerm/internal/services/loganalytics/log_analytics_workspace_migrate.go index 928bbd65b436..fbcfb9f86f7a 100644 --- a/azurerm/internal/services/loganalytics/log_analytics_workspace_migrate.go +++ b/azurerm/internal/services/loganalytics/log_analytics_workspace_migrate.go @@ -29,7 +29,7 @@ func workspaceStateMigrateV0toV1(is *terraform.InstanceState, meta interface{}) name := is.Attributes["name"] resourceGroup := is.Attributes["resource_group"] subscriptionId := meta.(*clients.Client).Account.SubscriptionId - id := parse.NewLogAnalyticsWorkspaceID(name, resourceGroup) + id := parse.NewLogAnalyticsWorkspaceID(subscriptionId, resourceGroup, name) is.ID = id.ID(subscriptionId) return is, nil diff --git a/azurerm/internal/services/loganalytics/log_analytics_workspace_resource.go b/azurerm/internal/services/loganalytics/log_analytics_workspace_resource.go index 78c38d0086e9..90c7f0b58e60 100644 --- a/azurerm/internal/services/loganalytics/log_analytics_workspace_resource.go +++ b/azurerm/internal/services/loganalytics/log_analytics_workspace_resource.go @@ -6,7 +6,7 @@ import ( "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights" + "github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights" "github.com/hashicorp/go-azure-helpers/response" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" @@ -138,7 +138,7 @@ func resourceArmLogAnalyticsWorkspaceCreateUpdate(d *schema.ResourceData, meta i name := d.Get("name").(string) resourceGroup := d.Get("resource_group_name").(string) - id := parse.NewLogAnalyticsWorkspaceID(name, resourceGroup) + id := parse.NewLogAnalyticsWorkspaceID(subscriptionId, resourceGroup, name) if d.IsNewResource() { existing, err := client.Get(ctx, resourceGroup, name) @@ -217,13 +217,13 @@ func resourceArmLogAnalyticsWorkspaceRead(d *schema.ResourceData, meta interface return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.Name) + resp, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName) if err != nil { if utils.ResponseWasNotFound(resp.Response) { d.SetId("") return nil } - return fmt.Errorf("Error making Read request on AzureRM Log Analytics workspaces '%s': %+v", id.Name, err) + return fmt.Errorf("Error making Read request on AzureRM Log Analytics workspaces '%s': %+v", id.WorkspaceName, err) } d.Set("name", resp.Name) @@ -250,9 +250,9 @@ func resourceArmLogAnalyticsWorkspaceRead(d *schema.ResourceData, meta interface d.Set("daily_quota_gb", utils.Float(-1)) } - sharedKeys, err := sharedKeysClient.GetSharedKeys(ctx, id.ResourceGroup, id.Name) + sharedKeys, err := sharedKeysClient.GetSharedKeys(ctx, id.ResourceGroup, id.WorkspaceName) if err != nil { - log.Printf("[ERROR] Unable to List Shared keys for Log Analytics workspaces %s: %+v", id.Name, err) + log.Printf("[ERROR] Unable to List Shared keys for Log Analytics workspaces %s: %+v", id.WorkspaceName, err) } else { d.Set("primary_shared_key", sharedKeys.PrimarySharedKey) d.Set("secondary_shared_key", sharedKeys.SecondarySharedKey) @@ -271,14 +271,14 @@ func resourceArmLogAnalyticsWorkspaceDelete(d *schema.ResourceData, meta interfa } force := false - future, err := client.Delete(ctx, id.ResourceGroup, id.Name, utils.Bool(force)) + future, err := client.Delete(ctx, id.ResourceGroup, id.WorkspaceName, utils.Bool(force)) if err != nil { - return fmt.Errorf("issuing AzureRM delete request for Log Analytics Workspaces '%s': %+v", id.Name, err) + return fmt.Errorf("issuing AzureRM delete request for Log Analytics Workspaces '%s': %+v", id.WorkspaceName, err) } if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { if !response.WasNotFound(future.Response()) { - return fmt.Errorf("waiting for deletion of Log Analytics Worspace %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + return fmt.Errorf("waiting for deletion of Log Analytics Worspace %q (Resource Group %q): %+v", id.WorkspaceName, id.ResourceGroup, err) } } diff --git a/azurerm/internal/services/loganalytics/log_analytics_workspace_resource_test.go b/azurerm/internal/services/loganalytics/log_analytics_workspace_resource_test.go index 3efb86ecc58d..127021a310f0 100644 --- a/azurerm/internal/services/loganalytics/log_analytics_workspace_resource_test.go +++ b/azurerm/internal/services/loganalytics/log_analytics_workspace_resource_test.go @@ -222,7 +222,7 @@ func testCheckAzureRMLogAnalyticsWorkspaceDestroy(s *terraform.State) error { return err } - resp, err := conn.Get(ctx, id.ResourceGroup, id.Name) + resp, err := conn.Get(ctx, id.ResourceGroup, id.WorkspaceName) if err != nil { return nil } @@ -251,13 +251,13 @@ func testCheckAzureRMLogAnalyticsWorkspaceExists(resourceName string) resource.T return err } - resp, err := conn.Get(ctx, id.ResourceGroup, id.Name) + resp, err := conn.Get(ctx, id.ResourceGroup, id.WorkspaceName) if err != nil { return fmt.Errorf("Bad: Get on Log Analytics Workspace Client: %+v", err) } if resp.StatusCode == http.StatusNotFound { - return fmt.Errorf("Bad: Log Analytics Workspace '%s' (resource group: '%s') does not exist", id.Name, id.ResourceGroup) + return fmt.Errorf("Bad: Log Analytics Workspace '%s' (resource group: '%s') does not exist", id.WorkspaceName, id.ResourceGroup) } return nil @@ -280,6 +280,7 @@ resource "azurerm_log_analytics_workspace" "test" { location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name sku = "PerGB2018" + retention_in_days = 30 } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } @@ -359,6 +360,7 @@ resource "azurerm_log_analytics_workspace" "test" { name = "acctestLAW-%d" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name + retention_in_days = 30 } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } @@ -431,6 +433,7 @@ resource "azurerm_log_analytics_workspace" "test" { resource_group_name = azurerm_resource_group.test.name internet_ingestion_enabled = true sku = "PerGB2018" + retention_in_days = 30 } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } @@ -452,6 +455,7 @@ resource "azurerm_log_analytics_workspace" "test" { resource_group_name = azurerm_resource_group.test.name internet_ingestion_enabled = false sku = "PerGB2018" + retention_in_days = 30 } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } @@ -473,6 +477,7 @@ resource "azurerm_log_analytics_workspace" "test" { resource_group_name = azurerm_resource_group.test.name internet_query_enabled = true sku = "PerGB2018" + retention_in_days = 30 } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } @@ -494,6 +499,7 @@ resource "azurerm_log_analytics_workspace" "test" { resource_group_name = azurerm_resource_group.test.name internet_query_enabled = false sku = "PerGB2018" + retention_in_days = 30 } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } diff --git a/azurerm/internal/services/loganalytics/parse/log_analytics_cluster.go b/azurerm/internal/services/loganalytics/parse/log_analytics_cluster.go index 84db7d322792..d05ae62f25e3 100644 --- a/azurerm/internal/services/loganalytics/parse/log_analytics_cluster.go +++ b/azurerm/internal/services/loganalytics/parse/log_analytics_cluster.go @@ -1,39 +1,62 @@ package parse +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + import ( "fmt" + "strings" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" ) type LogAnalyticsClusterId struct { - ResourceGroup string - Name string + SubscriptionId string + ResourceGroup string + ClusterName string } -func NewLogAnalyticsClusterId(name, resourceGroup string) LogAnalyticsClusterId { +func NewLogAnalyticsClusterID(subscriptionId, resourceGroup, clusterName string) LogAnalyticsClusterId { return LogAnalyticsClusterId{ - ResourceGroup: resourceGroup, - Name: name, + SubscriptionId: subscriptionId, + ResourceGroup: resourceGroup, + ClusterName: clusterName, } } -func (id LogAnalyticsClusterId) ID(subscriptionId string) string { +func (id LogAnalyticsClusterId) String() string { + segments := []string{ + fmt.Sprintf("Resource Group %q", id.ResourceGroup), + fmt.Sprintf("Cluster Name %q", id.ClusterName), + } + return strings.Join(segments, " / ") +} + +func (id LogAnalyticsClusterId) ID(_ string) string { fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/clusters/%s" - return fmt.Sprintf(fmtString, subscriptionId, id.ResourceGroup, id.Name) + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.ClusterName) } +// LogAnalyticsClusterID parses a LogAnalyticsCluster ID into an LogAnalyticsClusterId struct func LogAnalyticsClusterID(input string) (*LogAnalyticsClusterId, error) { id, err := azure.ParseAzureResourceID(input) if err != nil { - return nil, fmt.Errorf("parsing operationalinsightsCluster ID %q: %+v", input, err) + return nil, err + } + + resourceId := LogAnalyticsClusterId{ + SubscriptionId: id.SubscriptionID, + ResourceGroup: id.ResourceGroup, + } + + if resourceId.SubscriptionId == "" { + return nil, fmt.Errorf("ID was missing the 'subscriptions' element") } - logAnalyticsCluster := LogAnalyticsClusterId{ - ResourceGroup: id.ResourceGroup, + if resourceId.ResourceGroup == "" { + return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") } - if logAnalyticsCluster.Name, err = id.PopSegment("clusters"); err != nil { + if resourceId.ClusterName, err = id.PopSegment("clusters"); err != nil { return nil, err } @@ -41,5 +64,5 @@ func LogAnalyticsClusterID(input string) (*LogAnalyticsClusterId, error) { return nil, err } - return &logAnalyticsCluster, nil + return &resourceId, nil } diff --git a/azurerm/internal/services/loganalytics/parse/log_analytics_cluster_test.go b/azurerm/internal/services/loganalytics/parse/log_analytics_cluster_test.go index 02eae7e4ad71..46af91741683 100644 --- a/azurerm/internal/services/loganalytics/parse/log_analytics_cluster_test.go +++ b/azurerm/internal/services/loganalytics/parse/log_analytics_cluster_test.go @@ -1,72 +1,112 @@ package parse +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + import ( "testing" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/resourceid" ) +var _ resourceid.Formatter = LogAnalyticsClusterId{} + +func TestLogAnalyticsClusterIDFormatter(t *testing.T) { + actual := NewLogAnalyticsClusterID("12345678-1234-9876-4563-123456789012", "resGroup1", "cluster1").ID("") + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/clusters/cluster1" + if actual != expected { + t.Fatalf("Expected %q but got %q", expected, actual) + } +} + func TestLogAnalyticsClusterID(t *testing.T) { testData := []struct { - Name string Input string + Error bool Expected *LogAnalyticsClusterId }{ + { - Name: "Empty", - Input: "", - Expected: nil, + // empty + Input: "", + Error: true, }, + { - Name: "No Resource Groups Segment", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000", - Expected: nil, + // missing SubscriptionId + Input: "/", + Error: true, }, + { - Name: "No Resource Groups Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", - Expected: nil, + // missing value for SubscriptionId + Input: "/subscriptions/", + Error: true, }, + { - Name: "Resource Group ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", - Expected: nil, + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Error: true, }, + { - Name: "Missing Cluster Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resourceGroup1/providers/Microsoft.OperationalInsights/clusters", - Expected: nil, + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Error: true, }, + { - Name: "Log Analytics Cluster ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resourceGroup1/providers/Microsoft.OperationalInsights/clusters/cluster1", + // missing ClusterName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/", + Error: true, + }, + + { + // missing value for ClusterName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/clusters/", + Error: true, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/clusters/cluster1", Expected: &LogAnalyticsClusterId{ - ResourceGroup: "resourceGroup1", - Name: "cluster1", + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "resGroup1", + ClusterName: "cluster1", }, }, + { - Name: "Wrong Casing", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resourceGroup1/providers/Microsoft.OperationalInsights/Clusters/cluster1", - Expected: nil, + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.OPERATIONALINSIGHTS/CLUSTERS/CLUSTER1", + Error: true, }, } for _, v := range testData { - t.Logf("[DEBUG] Testing %q..", v.Name) + t.Logf("[DEBUG] Testing %q", v.Input) actual, err := LogAnalyticsClusterID(v.Input) if err != nil { - if v.Expected == nil { + if v.Error { continue } - t.Fatalf("Expected a value but got an error: %s", err) + + t.Fatalf("Expect a value but got an error: %s", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") } + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } if actual.ResourceGroup != v.Expected.ResourceGroup { t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) } - - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) + if actual.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) } } } diff --git a/azurerm/internal/services/loganalytics/parse/log_analytics_data_export.go b/azurerm/internal/services/loganalytics/parse/log_analytics_data_export.go index 67f15d50edfe..aca4c1cbd1bf 100644 --- a/azurerm/internal/services/loganalytics/parse/log_analytics_data_export.go +++ b/azurerm/internal/services/loganalytics/parse/log_analytics_data_export.go @@ -1,43 +1,74 @@ package parse +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + import ( "fmt" + "strings" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" ) type LogAnalyticsDataExportId struct { - ResourceGroup string - WorkspaceName string - WorkspaceID string - Name string + SubscriptionId string + ResourceGroup string + WorkspaceName string + DataexportName string +} + +func NewLogAnalyticsDataExportID(subscriptionId, resourceGroup, workspaceName, dataexportName string) LogAnalyticsDataExportId { + return LogAnalyticsDataExportId{ + SubscriptionId: subscriptionId, + ResourceGroup: resourceGroup, + WorkspaceName: workspaceName, + DataexportName: dataexportName, + } +} + +func (id LogAnalyticsDataExportId) String() string { + segments := []string{ + fmt.Sprintf("Resource Group %q", id.ResourceGroup), + fmt.Sprintf("Workspace Name %q", id.WorkspaceName), + fmt.Sprintf("Dataexport Name %q", id.DataexportName), + } + return strings.Join(segments, " / ") +} + +func (id LogAnalyticsDataExportId) ID(_ string) string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/dataexports/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.WorkspaceName, id.DataexportName) } +// LogAnalyticsDataExportID parses a LogAnalyticsDataExport ID into an LogAnalyticsDataExportId struct func LogAnalyticsDataExportID(input string) (*LogAnalyticsDataExportId, error) { id, err := azure.ParseAzureResourceID(input) if err != nil { - return nil, fmt.Errorf("parsing Log Analytics Data Export Rule ID %q: %+v", input, err) + return nil, err } - logAnalyticsDataExport := LogAnalyticsDataExportId{ - ResourceGroup: id.ResourceGroup, + resourceId := LogAnalyticsDataExportId{ + SubscriptionId: id.SubscriptionID, + ResourceGroup: id.ResourceGroup, } - if logAnalyticsDataExport.WorkspaceName, err = id.PopSegment("workspaces"); err != nil { - return nil, err + if resourceId.SubscriptionId == "" { + return nil, fmt.Errorf("ID was missing the 'subscriptions' element") + } + + if resourceId.ResourceGroup == "" { + return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") } - if logAnalyticsDataExport.WorkspaceID = fmt.Sprintf("/subscriptions/%s/resourcegroups/%s/providers/%s/workspaces/%s", id.SubscriptionID, id.ResourceGroup, id.Provider, logAnalyticsDataExport.WorkspaceName); err != nil { - return nil, fmt.Errorf("formatting Log Analytics Data Export Rule workspace ID %q", input) + + if resourceId.WorkspaceName, err = id.PopSegment("workspaces"); err != nil { + return nil, err } - if logAnalyticsDataExport.Name, err = id.PopSegment("dataExports"); err != nil { - // API Issue the casing changes for the ID - if logAnalyticsDataExport.Name, err = id.PopSegment("dataexports"); err != nil { - return nil, err - } + if resourceId.DataexportName, err = id.PopSegment("dataexports"); err != nil { + return nil, err } + if err := id.ValidateNoEmptySegments(input); err != nil { return nil, err } - return &logAnalyticsDataExport, nil + return &resourceId, nil } diff --git a/azurerm/internal/services/loganalytics/parse/log_analytics_data_export_test.go b/azurerm/internal/services/loganalytics/parse/log_analytics_data_export_test.go index 9582c5e997f5..14812d16641f 100644 --- a/azurerm/internal/services/loganalytics/parse/log_analytics_data_export_test.go +++ b/azurerm/internal/services/loganalytics/parse/log_analytics_data_export_test.go @@ -1,78 +1,128 @@ package parse +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + import ( "testing" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/resourceid" ) +var _ resourceid.Formatter = LogAnalyticsDataExportId{} + +func TestLogAnalyticsDataExportIDFormatter(t *testing.T) { + actual := NewLogAnalyticsDataExportID("12345678-1234-9876-4563-123456789012", "resGroup1", "workspace1", "dataExport1").ID("") + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/dataexports/dataExport1" + if actual != expected { + t.Fatalf("Expected %q but got %q", expected, actual) + } +} + func TestLogAnalyticsDataExportID(t *testing.T) { testData := []struct { - Name string Input string + Error bool Expected *LogAnalyticsDataExportId }{ + + { + // empty + Input: "", + Error: true, + }, + + { + // missing SubscriptionId + Input: "/", + Error: true, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Error: true, + }, + { - Name: "Empty", - Input: "", - Expected: nil, + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Error: true, }, + { - Name: "No Resource Groups Segment", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000", - Expected: nil, + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Error: true, }, + { - Name: "No Resource Groups Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", - Expected: nil, + // missing WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/", + Error: true, }, + { - Name: "Resource Group ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", - Expected: nil, + // missing value for WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/", + Error: true, }, + { - Name: "Missing DataExport Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resourceGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/dataExports", - Expected: nil, + // missing DataexportName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/", + Error: true, }, + { - Name: "operationalinsights DataExport ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resourceGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/dataExports/dataExport1", + // missing value for DataexportName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/dataexports/", + Error: true, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/dataexports/dataExport1", Expected: &LogAnalyticsDataExportId{ - ResourceGroup: "resourceGroup1", - WorkspaceName: "workspace1", - WorkspaceID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resourceGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1", - Name: "dataExport1", + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "resGroup1", + WorkspaceName: "workspace1", + DataexportName: "dataExport1", }, }, + { - Name: "Wrong Casing", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resourceGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/DataExports/dataExport1", - Expected: nil, + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.OPERATIONALINSIGHTS/WORKSPACES/WORKSPACE1/DATAEXPORTS/DATAEXPORT1", + Error: true, }, } for _, v := range testData { - t.Logf("[DEBUG] Testing %q..", v.Name) + t.Logf("[DEBUG] Testing %q", v.Input) actual, err := LogAnalyticsDataExportID(v.Input) if err != nil { - if v.Expected == nil { + if v.Error { continue } - t.Fatalf("Expected a value but got an error: %s", err) + + t.Fatalf("Expect a value but got an error: %s", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") } + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } if actual.ResourceGroup != v.Expected.ResourceGroup { t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) } - if actual.WorkspaceName != v.Expected.WorkspaceName { t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) } - - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) + if actual.DataexportName != v.Expected.DataexportName { + t.Fatalf("Expected %q but got %q for DataexportName", v.Expected.DataexportName, actual.DataexportName) } } } diff --git a/azurerm/internal/services/loganalytics/parse/log_analytics_data_source_windows_event.go b/azurerm/internal/services/loganalytics/parse/log_analytics_data_source_windows_event.go new file mode 100644 index 000000000000..fec76a66609b --- /dev/null +++ b/azurerm/internal/services/loganalytics/parse/log_analytics_data_source_windows_event.go @@ -0,0 +1,74 @@ +package parse + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + "strings" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) + +type LogAnalyticsDataSourceWindowsEventId struct { + SubscriptionId string + ResourceGroup string + WorkspaceName string + DataSourceName string +} + +func NewLogAnalyticsDataSourceWindowsEventID(subscriptionId, resourceGroup, workspaceName, dataSourceName string) LogAnalyticsDataSourceWindowsEventId { + return LogAnalyticsDataSourceWindowsEventId{ + SubscriptionId: subscriptionId, + ResourceGroup: resourceGroup, + WorkspaceName: workspaceName, + DataSourceName: dataSourceName, + } +} + +func (id LogAnalyticsDataSourceWindowsEventId) String() string { + segments := []string{ + fmt.Sprintf("Resource Group %q", id.ResourceGroup), + fmt.Sprintf("Workspace Name %q", id.WorkspaceName), + fmt.Sprintf("Data Source Name %q", id.DataSourceName), + } + return strings.Join(segments, " / ") +} + +func (id LogAnalyticsDataSourceWindowsEventId) ID(_ string) string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/dataSources/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.WorkspaceName, id.DataSourceName) +} + +// LogAnalyticsDataSourceWindowsEventID parses a LogAnalyticsDataSourceWindowsEvent ID into an LogAnalyticsDataSourceWindowsEventId struct +func LogAnalyticsDataSourceWindowsEventID(input string) (*LogAnalyticsDataSourceWindowsEventId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, err + } + + resourceId := LogAnalyticsDataSourceWindowsEventId{ + SubscriptionId: id.SubscriptionID, + ResourceGroup: id.ResourceGroup, + } + + if resourceId.SubscriptionId == "" { + return nil, fmt.Errorf("ID was missing the 'subscriptions' element") + } + + if resourceId.ResourceGroup == "" { + return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") + } + + if resourceId.WorkspaceName, err = id.PopSegment("workspaces"); err != nil { + return nil, err + } + if resourceId.DataSourceName, err = id.PopSegment("dataSources"); err != nil { + return nil, err + } + + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &resourceId, nil +} diff --git a/azurerm/internal/services/loganalytics/parse/log_analytics_data_source_windows_event_test.go b/azurerm/internal/services/loganalytics/parse/log_analytics_data_source_windows_event_test.go new file mode 100644 index 000000000000..f7c4b418123f --- /dev/null +++ b/azurerm/internal/services/loganalytics/parse/log_analytics_data_source_windows_event_test.go @@ -0,0 +1,128 @@ +package parse + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "testing" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/resourceid" +) + +var _ resourceid.Formatter = LogAnalyticsDataSourceWindowsEventId{} + +func TestLogAnalyticsDataSourceWindowsEventIDFormatter(t *testing.T) { + actual := NewLogAnalyticsDataSourceWindowsEventID("12345678-1234-9876-4563-123456789012", "resGroup1", "workspace1", "dataSource1").ID("") + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/dataSources/dataSource1" + if actual != expected { + t.Fatalf("Expected %q but got %q", expected, actual) + } +} + +func TestLogAnalyticsDataSourceWindowsEventID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LogAnalyticsDataSourceWindowsEventId + }{ + + { + // empty + Input: "", + Error: true, + }, + + { + // missing SubscriptionId + Input: "/", + Error: true, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Error: true, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Error: true, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Error: true, + }, + + { + // missing WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/", + Error: true, + }, + + { + // missing value for WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/", + Error: true, + }, + + { + // missing DataSourceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/", + Error: true, + }, + + { + // missing value for DataSourceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/dataSources/", + Error: true, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/dataSources/dataSource1", + Expected: &LogAnalyticsDataSourceWindowsEventId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "resGroup1", + WorkspaceName: "workspace1", + DataSourceName: "dataSource1", + }, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.OPERATIONALINSIGHTS/WORKSPACES/WORKSPACE1/DATASOURCES/DATASOURCE1", + Error: true, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := LogAnalyticsDataSourceWindowsEventID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %s", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + if actual.ResourceGroup != v.Expected.ResourceGroup { + t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) + } + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + if actual.DataSourceName != v.Expected.DataSourceName { + t.Fatalf("Expected %q but got %q for DataSourceName", v.Expected.DataSourceName, actual.DataSourceName) + } + } +} diff --git a/azurerm/internal/services/loganalytics/parse/log_analytics_linked_service.go b/azurerm/internal/services/loganalytics/parse/log_analytics_linked_service.go new file mode 100644 index 000000000000..b870b3172766 --- /dev/null +++ b/azurerm/internal/services/loganalytics/parse/log_analytics_linked_service.go @@ -0,0 +1,74 @@ +package parse + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + "strings" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) + +type LogAnalyticsLinkedServiceId struct { + SubscriptionId string + ResourceGroup string + WorkspaceName string + LinkedServiceName string +} + +func NewLogAnalyticsLinkedServiceID(subscriptionId, resourceGroup, workspaceName, linkedServiceName string) LogAnalyticsLinkedServiceId { + return LogAnalyticsLinkedServiceId{ + SubscriptionId: subscriptionId, + ResourceGroup: resourceGroup, + WorkspaceName: workspaceName, + LinkedServiceName: linkedServiceName, + } +} + +func (id LogAnalyticsLinkedServiceId) String() string { + segments := []string{ + fmt.Sprintf("Resource Group %q", id.ResourceGroup), + fmt.Sprintf("Workspace Name %q", id.WorkspaceName), + fmt.Sprintf("Linked Service Name %q", id.LinkedServiceName), + } + return strings.Join(segments, " / ") +} + +func (id LogAnalyticsLinkedServiceId) ID(_ string) string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/linkedServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.WorkspaceName, id.LinkedServiceName) +} + +// LogAnalyticsLinkedServiceID parses a LogAnalyticsLinkedService ID into an LogAnalyticsLinkedServiceId struct +func LogAnalyticsLinkedServiceID(input string) (*LogAnalyticsLinkedServiceId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, err + } + + resourceId := LogAnalyticsLinkedServiceId{ + SubscriptionId: id.SubscriptionID, + ResourceGroup: id.ResourceGroup, + } + + if resourceId.SubscriptionId == "" { + return nil, fmt.Errorf("ID was missing the 'subscriptions' element") + } + + if resourceId.ResourceGroup == "" { + return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") + } + + if resourceId.WorkspaceName, err = id.PopSegment("workspaces"); err != nil { + return nil, err + } + if resourceId.LinkedServiceName, err = id.PopSegment("linkedServices"); err != nil { + return nil, err + } + + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &resourceId, nil +} diff --git a/azurerm/internal/services/loganalytics/parse/log_analytics_linked_service_test.go b/azurerm/internal/services/loganalytics/parse/log_analytics_linked_service_test.go new file mode 100644 index 000000000000..3c28566a3e1c --- /dev/null +++ b/azurerm/internal/services/loganalytics/parse/log_analytics_linked_service_test.go @@ -0,0 +1,128 @@ +package parse + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "testing" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/resourceid" +) + +var _ resourceid.Formatter = LogAnalyticsLinkedServiceId{} + +func TestLogAnalyticsLinkedServiceIDFormatter(t *testing.T) { + actual := NewLogAnalyticsLinkedServiceID("12345678-1234-9876-4563-123456789012", "resGroup1", "workspace1", "linkedService1").ID("") + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/linkedServices/linkedService1" + if actual != expected { + t.Fatalf("Expected %q but got %q", expected, actual) + } +} + +func TestLogAnalyticsLinkedServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LogAnalyticsLinkedServiceId + }{ + + { + // empty + Input: "", + Error: true, + }, + + { + // missing SubscriptionId + Input: "/", + Error: true, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Error: true, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Error: true, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Error: true, + }, + + { + // missing WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/", + Error: true, + }, + + { + // missing value for WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/", + Error: true, + }, + + { + // missing LinkedServiceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/", + Error: true, + }, + + { + // missing value for LinkedServiceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/linkedServices/", + Error: true, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/linkedServices/linkedService1", + Expected: &LogAnalyticsLinkedServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "resGroup1", + WorkspaceName: "workspace1", + LinkedServiceName: "linkedService1", + }, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.OPERATIONALINSIGHTS/WORKSPACES/WORKSPACE1/LINKEDSERVICES/LINKEDSERVICE1", + Error: true, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := LogAnalyticsLinkedServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %s", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + if actual.ResourceGroup != v.Expected.ResourceGroup { + t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) + } + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + if actual.LinkedServiceName != v.Expected.LinkedServiceName { + t.Fatalf("Expected %q but got %q for LinkedServiceName", v.Expected.LinkedServiceName, actual.LinkedServiceName) + } + } +} diff --git a/azurerm/internal/services/loganalytics/parse/log_analytics_linked_storage_account.go b/azurerm/internal/services/loganalytics/parse/log_analytics_linked_storage_account.go index c534df49f02e..4cc3a4651cd6 100644 --- a/azurerm/internal/services/loganalytics/parse/log_analytics_linked_storage_account.go +++ b/azurerm/internal/services/loganalytics/parse/log_analytics_linked_storage_account.go @@ -1,45 +1,74 @@ package parse +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + import ( "fmt" + "strings" - "github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" ) -// TODO: @tombuildsstuff pass back through and generate these - type LogAnalyticsLinkedStorageAccountId struct { - ResourceGroup string - WorkspaceName string - WorkspaceID string - Name string + SubscriptionId string + ResourceGroup string + WorkspaceName string + LinkedStorageAccountName string +} + +func NewLogAnalyticsLinkedStorageAccountID(subscriptionId, resourceGroup, workspaceName, linkedStorageAccountName string) LogAnalyticsLinkedStorageAccountId { + return LogAnalyticsLinkedStorageAccountId{ + SubscriptionId: subscriptionId, + ResourceGroup: resourceGroup, + WorkspaceName: workspaceName, + LinkedStorageAccountName: linkedStorageAccountName, + } +} + +func (id LogAnalyticsLinkedStorageAccountId) String() string { + segments := []string{ + fmt.Sprintf("Resource Group %q", id.ResourceGroup), + fmt.Sprintf("Workspace Name %q", id.WorkspaceName), + fmt.Sprintf("Linked Storage Account Name %q", id.LinkedStorageAccountName), + } + return strings.Join(segments, " / ") +} + +func (id LogAnalyticsLinkedStorageAccountId) ID(_ string) string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/linkedStorageAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.WorkspaceName, id.LinkedStorageAccountName) } +// LogAnalyticsLinkedStorageAccountID parses a LogAnalyticsLinkedStorageAccount ID into an LogAnalyticsLinkedStorageAccountId struct func LogAnalyticsLinkedStorageAccountID(input string) (*LogAnalyticsLinkedStorageAccountId, error) { id, err := azure.ParseAzureResourceID(input) if err != nil { - return nil, fmt.Errorf("parsing Log Analytics Linked Storage Account ID %q: %+v", input, err) + return nil, err } - logAnalyticsLinkedStorageAccount := LogAnalyticsLinkedStorageAccountId{ - ResourceGroup: id.ResourceGroup, + resourceId := LogAnalyticsLinkedStorageAccountId{ + SubscriptionId: id.SubscriptionID, + ResourceGroup: id.ResourceGroup, } - if logAnalyticsLinkedStorageAccount.WorkspaceName, err = id.PopSegment("workspaces"); err != nil { - return nil, err + + if resourceId.SubscriptionId == "" { + return nil, fmt.Errorf("ID was missing the 'subscriptions' element") } - if logAnalyticsLinkedStorageAccount.WorkspaceID = fmt.Sprintf("/subscriptions/%s/resourcegroups/%s/providers/%s/workspaces/%s", id.SubscriptionID, id.ResourceGroup, id.Provider, logAnalyticsLinkedStorageAccount.WorkspaceName); err != nil { - return nil, fmt.Errorf("formatting Log Analytics Data Export Rule workspace ID %q", input) + + if resourceId.ResourceGroup == "" { + return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") } - var name string - if name, err = id.PopSegment("linkedStorageAccounts"); err == nil { - logAnalyticsLinkedStorageAccount.Name = string(operationalinsights.DataSourceType(name)) - } else { + + if resourceId.WorkspaceName, err = id.PopSegment("workspaces"); err != nil { + return nil, err + } + if resourceId.LinkedStorageAccountName, err = id.PopSegment("linkedStorageAccounts"); err != nil { return nil, err } + if err := id.ValidateNoEmptySegments(input); err != nil { return nil, err } - return &logAnalyticsLinkedStorageAccount, nil + return &resourceId, nil } diff --git a/azurerm/internal/services/loganalytics/parse/log_analytics_linked_storage_account_test.go b/azurerm/internal/services/loganalytics/parse/log_analytics_linked_storage_account_test.go index 6c8697fbe888..1de9c533abed 100644 --- a/azurerm/internal/services/loganalytics/parse/log_analytics_linked_storage_account_test.go +++ b/azurerm/internal/services/loganalytics/parse/log_analytics_linked_storage_account_test.go @@ -1,78 +1,128 @@ package parse +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + import ( "testing" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/resourceid" ) -func TestOperationalinsightsLinkedStorageAccountID(t *testing.T) { +var _ resourceid.Formatter = LogAnalyticsLinkedStorageAccountId{} + +func TestLogAnalyticsLinkedStorageAccountIDFormatter(t *testing.T) { + actual := NewLogAnalyticsLinkedStorageAccountID("12345678-1234-9876-4563-123456789012", "resGroup1", "workspace1", "query").ID("") + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/linkedStorageAccounts/query" + if actual != expected { + t.Fatalf("Expected %q but got %q", expected, actual) + } +} + +func TestLogAnalyticsLinkedStorageAccountID(t *testing.T) { testData := []struct { - Name string Input string + Error bool Expected *LogAnalyticsLinkedStorageAccountId }{ + + { + // empty + Input: "", + Error: true, + }, + + { + // missing SubscriptionId + Input: "/", + Error: true, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Error: true, + }, + { - Name: "Empty", - Input: "", - Expected: nil, + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Error: true, }, + { - Name: "No Resource Groups Segment", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000", - Expected: nil, + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Error: true, }, + { - Name: "No Resource Groups Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", - Expected: nil, + // missing WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/", + Error: true, }, + { - Name: "Resource Group ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", - Expected: nil, + // missing value for WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/", + Error: true, }, + { - Name: "Missing LinkedStorageAccount Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resourceGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/linkedStorageAccounts", - Expected: nil, + // missing LinkedStorageAccountName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/", + Error: true, }, + { - Name: "Log Analytics Linked Storage Account ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resourceGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/linkedStorageAccounts/dataSourceType1", + // missing value for LinkedStorageAccountName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/linkedStorageAccounts/", + Error: true, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/linkedStorageAccounts/query", Expected: &LogAnalyticsLinkedStorageAccountId{ - ResourceGroup: "resourceGroup1", - WorkspaceName: "workspace1", - WorkspaceID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resourceGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1", - Name: "dataSourceType1", + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "resGroup1", + WorkspaceName: "workspace1", + LinkedStorageAccountName: "query", }, }, + { - Name: "Wrong Casing", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resourceGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/LinkedStorageAccounts/dataSourceType1", - Expected: nil, + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.OPERATIONALINSIGHTS/WORKSPACES/WORKSPACE1/LINKEDSTORAGEACCOUNTS/QUERY", + Error: true, }, } for _, v := range testData { - t.Logf("[DEBUG] Testing %q..", v.Name) + t.Logf("[DEBUG] Testing %q", v.Input) actual, err := LogAnalyticsLinkedStorageAccountID(v.Input) if err != nil { - if v.Expected == nil { + if v.Error { continue } - t.Fatalf("Expected a value but got an error: %s", err) + + t.Fatalf("Expect a value but got an error: %s", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") } + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } if actual.ResourceGroup != v.Expected.ResourceGroup { t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) } - if actual.WorkspaceName != v.Expected.WorkspaceName { t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) } - - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) + if actual.LinkedStorageAccountName != v.Expected.LinkedStorageAccountName { + t.Fatalf("Expected %q but got %q for LinkedStorageAccountName", v.Expected.LinkedStorageAccountName, actual.LinkedStorageAccountName) } } } diff --git a/azurerm/internal/services/loganalytics/parse/log_analytics_saved_search.go b/azurerm/internal/services/loganalytics/parse/log_analytics_saved_search.go index 820f3a2c54ee..fc4007d649a3 100644 --- a/azurerm/internal/services/loganalytics/parse/log_analytics_saved_search.go +++ b/azurerm/internal/services/loganalytics/parse/log_analytics_saved_search.go @@ -1,32 +1,68 @@ package parse +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + import ( "fmt" + "strings" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" ) type LogAnalyticsSavedSearchId struct { - ResourceGroup string - WorkspaceName string - Name string + SubscriptionId string + ResourceGroup string + WorkspaceName string + SavedSearcheName string +} + +func NewLogAnalyticsSavedSearchID(subscriptionId, resourceGroup, workspaceName, savedSearcheName string) LogAnalyticsSavedSearchId { + return LogAnalyticsSavedSearchId{ + SubscriptionId: subscriptionId, + ResourceGroup: resourceGroup, + WorkspaceName: workspaceName, + SavedSearcheName: savedSearcheName, + } } +func (id LogAnalyticsSavedSearchId) String() string { + segments := []string{ + fmt.Sprintf("Resource Group %q", id.ResourceGroup), + fmt.Sprintf("Workspace Name %q", id.WorkspaceName), + fmt.Sprintf("Saved Searche Name %q", id.SavedSearcheName), + } + return strings.Join(segments, " / ") +} + +func (id LogAnalyticsSavedSearchId) ID(_ string) string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/savedSearches/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.WorkspaceName, id.SavedSearcheName) +} + +// LogAnalyticsSavedSearchID parses a LogAnalyticsSavedSearch ID into an LogAnalyticsSavedSearchId struct func LogAnalyticsSavedSearchID(input string) (*LogAnalyticsSavedSearchId, error) { id, err := azure.ParseAzureResourceID(input) if err != nil { - return nil, fmt.Errorf("parsing Log Analytics Saved Search ID %q: %+v", input, err) + return nil, err } - search := LogAnalyticsSavedSearchId{ - ResourceGroup: id.ResourceGroup, + resourceId := LogAnalyticsSavedSearchId{ + SubscriptionId: id.SubscriptionID, + ResourceGroup: id.ResourceGroup, } - if search.WorkspaceName, err = id.PopSegment("workspaces"); err != nil { - return nil, err + if resourceId.SubscriptionId == "" { + return nil, fmt.Errorf("ID was missing the 'subscriptions' element") } - if search.Name, err = id.PopSegment("savedSearches"); err != nil { + if resourceId.ResourceGroup == "" { + return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") + } + + if resourceId.WorkspaceName, err = id.PopSegment("workspaces"); err != nil { + return nil, err + } + if resourceId.SavedSearcheName, err = id.PopSegment("savedSearches"); err != nil { return nil, err } @@ -34,5 +70,5 @@ func LogAnalyticsSavedSearchID(input string) (*LogAnalyticsSavedSearchId, error) return nil, err } - return &search, nil + return &resourceId, nil } diff --git a/azurerm/internal/services/loganalytics/parse/log_analytics_saved_search_test.go b/azurerm/internal/services/loganalytics/parse/log_analytics_saved_search_test.go index 44fcbc86d13a..b3bf17316cba 100644 --- a/azurerm/internal/services/loganalytics/parse/log_analytics_saved_search_test.go +++ b/azurerm/internal/services/loganalytics/parse/log_analytics_saved_search_test.go @@ -1,55 +1,104 @@ package parse +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + import ( "testing" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/resourceid" ) +var _ resourceid.Formatter = LogAnalyticsSavedSearchId{} + +func TestLogAnalyticsSavedSearchIDFormatter(t *testing.T) { + actual := NewLogAnalyticsSavedSearchID("12345678-1234-9876-4563-123456789012", "resGroup1", "workspace1", "search1").ID("") + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/savedSearches/search1" + if actual != expected { + t.Fatalf("Expected %q but got %q", expected, actual) + } +} + func TestLogAnalyticsSavedSearchID(t *testing.T) { testData := []struct { - Name string - Input string - Error bool - Expect *LogAnalyticsSavedSearchId + Input string + Error bool + Expected *LogAnalyticsSavedSearchId }{ + { - Name: "Empty", + // empty Input: "", Error: true, }, + + { + // missing SubscriptionId + Input: "/", + Error: true, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Error: true, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Error: true, + }, + { - Name: "No Resource Groups Segment", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000", + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", Error: true, }, + { - Name: "No Resource Groups Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + // missing WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/", Error: true, }, + { - Name: "Resource Group ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/", + // missing value for WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/", Error: true, }, + + { + // missing SavedSearcheName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/", + Error: true, + }, + { - Name: "Missing Saved Search Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/savedSearches", + // missing value for SavedSearcheName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/savedSearches/", Error: true, }, + { - Name: "Workspace Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/savedSearches/search1", - Error: false, - Expect: &LogAnalyticsSavedSearchId{ - ResourceGroup: "resGroup1", - WorkspaceName: "workspace1", - Name: "search1", + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/savedSearches/search1", + Expected: &LogAnalyticsSavedSearchId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "resGroup1", + WorkspaceName: "workspace1", + SavedSearcheName: "search1", }, }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.OPERATIONALINSIGHTS/WORKSPACES/WORKSPACE1/SAVEDSEARCHES/SEARCH1", + Error: true, + }, } for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Name) + t.Logf("[DEBUG] Testing %q", v.Input) actual, err := LogAnalyticsSavedSearchID(v.Input) if err != nil { @@ -57,15 +106,23 @@ func TestLogAnalyticsSavedSearchID(t *testing.T) { continue } - t.Fatalf("Expected a value but got an error: %s", err) + t.Fatalf("Expect a value but got an error: %s", err) } - - if actual.ResourceGroup != v.Expect.ResourceGroup { - t.Fatalf("Expected %q but got %q for Resource Group", v.Expect.ResourceGroup, actual.ResourceGroup) + if v.Error { + t.Fatal("Expect an error but didn't get one") } - if actual.Name != v.Expect.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expect.Name, actual.Name) + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + if actual.ResourceGroup != v.Expected.ResourceGroup { + t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) + } + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + if actual.SavedSearcheName != v.Expected.SavedSearcheName { + t.Fatalf("Expected %q but got %q for SavedSearcheName", v.Expected.SavedSearcheName, actual.SavedSearcheName) } } } diff --git a/azurerm/internal/services/loganalytics/parse/log_analytics_solution.go b/azurerm/internal/services/loganalytics/parse/log_analytics_solution.go new file mode 100644 index 000000000000..995957a74d2a --- /dev/null +++ b/azurerm/internal/services/loganalytics/parse/log_analytics_solution.go @@ -0,0 +1,68 @@ +package parse + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + "strings" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) + +type LogAnalyticsSolutionId struct { + SubscriptionId string + ResourceGroup string + SolutionName string +} + +func NewLogAnalyticsSolutionID(subscriptionId, resourceGroup, solutionName string) LogAnalyticsSolutionId { + return LogAnalyticsSolutionId{ + SubscriptionId: subscriptionId, + ResourceGroup: resourceGroup, + SolutionName: solutionName, + } +} + +func (id LogAnalyticsSolutionId) String() string { + segments := []string{ + fmt.Sprintf("Resource Group %q", id.ResourceGroup), + fmt.Sprintf("Solution Name %q", id.SolutionName), + } + return strings.Join(segments, " / ") +} + +func (id LogAnalyticsSolutionId) ID(_ string) string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationsManagement/solutions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.SolutionName) +} + +// LogAnalyticsSolutionID parses a LogAnalyticsSolution ID into an LogAnalyticsSolutionId struct +func LogAnalyticsSolutionID(input string) (*LogAnalyticsSolutionId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, err + } + + resourceId := LogAnalyticsSolutionId{ + SubscriptionId: id.SubscriptionID, + ResourceGroup: id.ResourceGroup, + } + + if resourceId.SubscriptionId == "" { + return nil, fmt.Errorf("ID was missing the 'subscriptions' element") + } + + if resourceId.ResourceGroup == "" { + return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") + } + + if resourceId.SolutionName, err = id.PopSegment("solutions"); err != nil { + return nil, err + } + + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &resourceId, nil +} diff --git a/azurerm/internal/services/loganalytics/parse/log_analytics_solution_test.go b/azurerm/internal/services/loganalytics/parse/log_analytics_solution_test.go new file mode 100644 index 000000000000..5b2ce53470df --- /dev/null +++ b/azurerm/internal/services/loganalytics/parse/log_analytics_solution_test.go @@ -0,0 +1,112 @@ +package parse + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "testing" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/resourceid" +) + +var _ resourceid.Formatter = LogAnalyticsSolutionId{} + +func TestLogAnalyticsSolutionIDFormatter(t *testing.T) { + actual := NewLogAnalyticsSolutionID("12345678-1234-9876-4563-123456789012", "resGroup1", "solution1").ID("") + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationsManagement/solutions/solution1" + if actual != expected { + t.Fatalf("Expected %q but got %q", expected, actual) + } +} + +func TestLogAnalyticsSolutionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LogAnalyticsSolutionId + }{ + + { + // empty + Input: "", + Error: true, + }, + + { + // missing SubscriptionId + Input: "/", + Error: true, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Error: true, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Error: true, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Error: true, + }, + + { + // missing SolutionName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationsManagement/", + Error: true, + }, + + { + // missing value for SolutionName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationsManagement/solutions/", + Error: true, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationsManagement/solutions/solution1", + Expected: &LogAnalyticsSolutionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "resGroup1", + SolutionName: "solution1", + }, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.OPERATIONSMANAGEMENT/SOLUTIONS/SOLUTION1", + Error: true, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := LogAnalyticsSolutionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %s", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + if actual.ResourceGroup != v.Expected.ResourceGroup { + t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) + } + if actual.SolutionName != v.Expected.SolutionName { + t.Fatalf("Expected %q but got %q for SolutionName", v.Expected.SolutionName, actual.SolutionName) + } + } +} diff --git a/azurerm/internal/services/loganalytics/parse/log_analytics_storage_insights.go b/azurerm/internal/services/loganalytics/parse/log_analytics_storage_insights.go index b860569555e3..4165ca24dc74 100644 --- a/azurerm/internal/services/loganalytics/parse/log_analytics_storage_insights.go +++ b/azurerm/internal/services/loganalytics/parse/log_analytics_storage_insights.go @@ -1,50 +1,68 @@ package parse +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + import ( "fmt" + "strings" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" ) type LogAnalyticsStorageInsightsId struct { - ResourceGroup string - WorkspaceName string - WorkspaceID string - Name string + SubscriptionId string + ResourceGroup string + WorkspaceName string + StorageInsightConfigName string } -func (id LogAnalyticsStorageInsightsId) ID(subscriptionId string) string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/storageInsightConfigs/%s" - return fmt.Sprintf(fmtString, subscriptionId, id.ResourceGroup, id.WorkspaceName, id.Name) +func NewLogAnalyticsStorageInsightsID(subscriptionId, resourceGroup, workspaceName, storageInsightConfigName string) LogAnalyticsStorageInsightsId { + return LogAnalyticsStorageInsightsId{ + SubscriptionId: subscriptionId, + ResourceGroup: resourceGroup, + WorkspaceName: workspaceName, + StorageInsightConfigName: storageInsightConfigName, + } } -func NewLogAnalyticsStorageInsightsId(resourceGroup, workspaceId, name string) LogAnalyticsStorageInsightsId { - // (@jackofallops) ignoring error here as already passed through validation in schema - workspace, _ := LogAnalyticsWorkspaceID(workspaceId) - return LogAnalyticsStorageInsightsId{ - ResourceGroup: resourceGroup, - WorkspaceName: workspace.Name, - WorkspaceID: workspaceId, - Name: name, +func (id LogAnalyticsStorageInsightsId) String() string { + segments := []string{ + fmt.Sprintf("Resource Group %q", id.ResourceGroup), + fmt.Sprintf("Workspace Name %q", id.WorkspaceName), + fmt.Sprintf("Storage Insight Config Name %q", id.StorageInsightConfigName), } + return strings.Join(segments, " / ") +} + +func (id LogAnalyticsStorageInsightsId) ID(_ string) string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/storageInsightConfigs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.WorkspaceName, id.StorageInsightConfigName) } +// LogAnalyticsStorageInsightsID parses a LogAnalyticsStorageInsights ID into an LogAnalyticsStorageInsightsId struct func LogAnalyticsStorageInsightsID(input string) (*LogAnalyticsStorageInsightsId, error) { id, err := azure.ParseAzureResourceID(input) if err != nil { - return nil, fmt.Errorf("parsing Log Analytics Storage Insights ID %q: %+v", input, err) + return nil, err } - logAnalyticsStorageInsight := LogAnalyticsStorageInsightsId{ - ResourceGroup: id.ResourceGroup, + resourceId := LogAnalyticsStorageInsightsId{ + SubscriptionId: id.SubscriptionID, + ResourceGroup: id.ResourceGroup, } - if logAnalyticsStorageInsight.WorkspaceName, err = id.PopSegment("workspaces"); err != nil { - return nil, err + if resourceId.SubscriptionId == "" { + return nil, fmt.Errorf("ID was missing the 'subscriptions' element") } - logAnalyticsStorageInsight.WorkspaceID = NewLogAnalyticsWorkspaceID(logAnalyticsStorageInsight.WorkspaceName, id.ResourceGroup).ID(id.SubscriptionID) - if logAnalyticsStorageInsight.Name, err = id.PopSegment("storageInsightConfigs"); err != nil { + if resourceId.ResourceGroup == "" { + return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") + } + + if resourceId.WorkspaceName, err = id.PopSegment("workspaces"); err != nil { + return nil, err + } + if resourceId.StorageInsightConfigName, err = id.PopSegment("storageInsightConfigs"); err != nil { return nil, err } @@ -52,5 +70,5 @@ func LogAnalyticsStorageInsightsID(input string) (*LogAnalyticsStorageInsightsId return nil, err } - return &logAnalyticsStorageInsight, nil + return &resourceId, nil } diff --git a/azurerm/internal/services/loganalytics/parse/log_analytics_storage_insights_test.go b/azurerm/internal/services/loganalytics/parse/log_analytics_storage_insights_test.go index 3525e6901478..6b25e6a727bb 100644 --- a/azurerm/internal/services/loganalytics/parse/log_analytics_storage_insights_test.go +++ b/azurerm/internal/services/loganalytics/parse/log_analytics_storage_insights_test.go @@ -1,78 +1,128 @@ package parse +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + import ( "testing" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/resourceid" ) +var _ resourceid.Formatter = LogAnalyticsStorageInsightsId{} + +func TestLogAnalyticsStorageInsightsIDFormatter(t *testing.T) { + actual := NewLogAnalyticsStorageInsightsID("12345678-1234-9876-4563-123456789012", "resGroup1", "workspace1", "storageInsight1").ID("") + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/storageInsightConfigs/storageInsight1" + if actual != expected { + t.Fatalf("Expected %q but got %q", expected, actual) + } +} + func TestLogAnalyticsStorageInsightsID(t *testing.T) { testData := []struct { - Name string Input string + Error bool Expected *LogAnalyticsStorageInsightsId }{ + + { + // empty + Input: "", + Error: true, + }, + + { + // missing SubscriptionId + Input: "/", + Error: true, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Error: true, + }, + { - Name: "Empty", - Input: "", - Expected: nil, + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Error: true, }, + { - Name: "No Resource Groups Segment", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000", - Expected: nil, + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Error: true, }, + { - Name: "No Resource Groups Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", - Expected: nil, + // missing WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/", + Error: true, }, + { - Name: "Resource Group ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", - Expected: nil, + // missing value for WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/", + Error: true, }, + { - Name: "Missing StorageInsightConfig Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resourceGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/storageInsightConfigs", - Expected: nil, + // missing StorageInsightConfigName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/", + Error: true, }, + { - Name: "operationalinsights StorageInsightConfig ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resourceGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/storageInsightConfigs/storageInsight1", + // missing value for StorageInsightConfigName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/storageInsightConfigs/", + Error: true, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/storageInsightConfigs/storageInsight1", Expected: &LogAnalyticsStorageInsightsId{ - ResourceGroup: "resourceGroup1", - WorkspaceName: "workspace1", - WorkspaceID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resourceGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1", - Name: "storageInsight1", + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "resGroup1", + WorkspaceName: "workspace1", + StorageInsightConfigName: "storageInsight1", }, }, + { - Name: "Wrong Casing", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resourceGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/StorageInsightConfigs/storageInsight1", - Expected: nil, + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.OPERATIONALINSIGHTS/WORKSPACES/WORKSPACE1/STORAGEINSIGHTCONFIGS/STORAGEINSIGHT1", + Error: true, }, } for _, v := range testData { - t.Logf("[DEBUG] Testing %q..", v.Name) + t.Logf("[DEBUG] Testing %q", v.Input) actual, err := LogAnalyticsStorageInsightsID(v.Input) if err != nil { - if v.Expected == nil { + if v.Error { continue } - t.Fatalf("Expected a value but got an error: %s", err) + + t.Fatalf("Expect a value but got an error: %s", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") } + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } if actual.ResourceGroup != v.Expected.ResourceGroup { t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) } - if actual.WorkspaceName != v.Expected.WorkspaceName { t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) } - - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) + if actual.StorageInsightConfigName != v.Expected.StorageInsightConfigName { + t.Fatalf("Expected %q but got %q for StorageInsightConfigName", v.Expected.StorageInsightConfigName, actual.StorageInsightConfigName) } } } diff --git a/azurerm/internal/services/loganalytics/parse/log_analytics_workspace.go b/azurerm/internal/services/loganalytics/parse/log_analytics_workspace.go index 24f931b8b951..49c7cb6c4db1 100644 --- a/azurerm/internal/services/loganalytics/parse/log_analytics_workspace.go +++ b/azurerm/internal/services/loganalytics/parse/log_analytics_workspace.go @@ -1,39 +1,62 @@ package parse +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + import ( "fmt" + "strings" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" ) type LogAnalyticsWorkspaceId struct { - ResourceGroup string - Name string + SubscriptionId string + ResourceGroup string + WorkspaceName string } -func NewLogAnalyticsWorkspaceID(name, resourceGroup string) LogAnalyticsWorkspaceId { +func NewLogAnalyticsWorkspaceID(subscriptionId, resourceGroup, workspaceName string) LogAnalyticsWorkspaceId { return LogAnalyticsWorkspaceId{ - ResourceGroup: resourceGroup, - Name: name, + SubscriptionId: subscriptionId, + ResourceGroup: resourceGroup, + WorkspaceName: workspaceName, } } -func (id LogAnalyticsWorkspaceId) ID(subscriptionId string) string { - // Log Analytics ID ignores casing - return fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s", subscriptionId, id.ResourceGroup, id.Name) +func (id LogAnalyticsWorkspaceId) String() string { + segments := []string{ + fmt.Sprintf("Resource Group %q", id.ResourceGroup), + fmt.Sprintf("Workspace Name %q", id.WorkspaceName), + } + return strings.Join(segments, " / ") } +func (id LogAnalyticsWorkspaceId) ID(_ string) string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.WorkspaceName) +} + +// LogAnalyticsWorkspaceID parses a LogAnalyticsWorkspace ID into an LogAnalyticsWorkspaceId struct func LogAnalyticsWorkspaceID(input string) (*LogAnalyticsWorkspaceId, error) { id, err := azure.ParseAzureResourceID(input) if err != nil { - return nil, fmt.Errorf("parsing Log Analytics Workspace ID %q: %+v", input, err) + return nil, err + } + + resourceId := LogAnalyticsWorkspaceId{ + SubscriptionId: id.SubscriptionID, + ResourceGroup: id.ResourceGroup, + } + + if resourceId.SubscriptionId == "" { + return nil, fmt.Errorf("ID was missing the 'subscriptions' element") } - server := LogAnalyticsWorkspaceId{ - ResourceGroup: id.ResourceGroup, + if resourceId.ResourceGroup == "" { + return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") } - if server.Name, err = id.PopSegment("workspaces"); err != nil { + if resourceId.WorkspaceName, err = id.PopSegment("workspaces"); err != nil { return nil, err } @@ -41,5 +64,5 @@ func LogAnalyticsWorkspaceID(input string) (*LogAnalyticsWorkspaceId, error) { return nil, err } - return &server, nil + return &resourceId, nil } diff --git a/azurerm/internal/services/loganalytics/parse/log_analytics_workspace_test.go b/azurerm/internal/services/loganalytics/parse/log_analytics_workspace_test.go index 5e3b113394c9..9244c0fc8b3d 100644 --- a/azurerm/internal/services/loganalytics/parse/log_analytics_workspace_test.go +++ b/azurerm/internal/services/loganalytics/parse/log_analytics_workspace_test.go @@ -1,54 +1,91 @@ package parse +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + import ( "testing" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/resourceid" ) +var _ resourceid.Formatter = LogAnalyticsWorkspaceId{} + +func TestLogAnalyticsWorkspaceIDFormatter(t *testing.T) { + actual := NewLogAnalyticsWorkspaceID("12345678-1234-9876-4563-123456789012", "resGroup1", "workspace1").ID("") + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1" + if actual != expected { + t.Fatalf("Expected %q but got %q", expected, actual) + } +} + func TestLogAnalyticsWorkspaceID(t *testing.T) { testData := []struct { - Name string - Input string - Error bool - Expect *LogAnalyticsWorkspaceId + Input string + Error bool + Expected *LogAnalyticsWorkspaceId }{ + { - Name: "Empty", + // empty Input: "", Error: true, }, + + { + // missing SubscriptionId + Input: "/", + Error: true, + }, + { - Name: "No Resource Groups Segment", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000", + // missing value for SubscriptionId + Input: "/subscriptions/", Error: true, }, + { - Name: "No Resource Groups Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", Error: true, }, + { - Name: "Resource Group ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/", + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", Error: true, }, + { - Name: "Missing Workspace Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces", + // missing WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/", Error: true, }, + { - Name: "Workspace Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1", + // missing value for WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/", Error: true, - Expect: &LogAnalyticsWorkspaceId{ - ResourceGroup: "resGroup1", - Name: "workspace1", + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1", + Expected: &LogAnalyticsWorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "resGroup1", + WorkspaceName: "workspace1", }, }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.OPERATIONALINSIGHTS/WORKSPACES/WORKSPACE1", + Error: true, + }, } for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Name) + t.Logf("[DEBUG] Testing %q", v.Input) actual, err := LogAnalyticsWorkspaceID(v.Input) if err != nil { @@ -56,15 +93,20 @@ func TestLogAnalyticsWorkspaceID(t *testing.T) { continue } - t.Fatalf("Expected a value but got an error: %s", err) + t.Fatalf("Expect a value but got an error: %s", err) } - - if actual.ResourceGroup != v.Expect.ResourceGroup { - t.Fatalf("Expected %q but got %q for Resource Group", v.Expect.ResourceGroup, actual.ResourceGroup) + if v.Error { + t.Fatal("Expect an error but didn't get one") } - if actual.Name != v.Expect.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expect.Name, actual.Name) + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + if actual.ResourceGroup != v.Expected.ResourceGroup { + t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) + } + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) } } } diff --git a/azurerm/internal/services/loganalytics/resourceids.go b/azurerm/internal/services/loganalytics/resourceids.go new file mode 100644 index 000000000000..ff703c49b941 --- /dev/null +++ b/azurerm/internal/services/loganalytics/resourceids.go @@ -0,0 +1,11 @@ +package loganalytics + +//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=LogAnalyticsCluster -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/clusters/cluster1 +//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=LogAnalyticsDataExport -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/dataexports/dataExport1 +//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=LogAnalyticsDataSourceWindowsEvent -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/dataSources/dataSource1 +//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=LogAnalyticsLinkedService -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/linkedServices/linkedService1 +//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=LogAnalyticsLinkedStorageAccount -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/linkedStorageAccounts/query +//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=LogAnalyticsSavedSearch -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/savedSearches/search1 +//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=LogAnalyticsSolution -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationsManagement/solutions/solution1 +//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=LogAnalyticsStorageInsights -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/storageInsightConfigs/storageInsight1 +//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=LogAnalyticsWorkspace -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1 diff --git a/azurerm/internal/services/loganalytics/validate/log_analytics_cluster_id.go b/azurerm/internal/services/loganalytics/validate/log_analytics_cluster_id.go index 90fe3c7f6c80..747d8ede0a12 100644 --- a/azurerm/internal/services/loganalytics/validate/log_analytics_cluster_id.go +++ b/azurerm/internal/services/loganalytics/validate/log_analytics_cluster_id.go @@ -1,22 +1,23 @@ package validate +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + import ( "fmt" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/loganalytics/parse" ) -func LogAnalyticsClusterId(i interface{}, k string) (warnings []string, errors []error) { - v, ok := i.(string) +func LogAnalyticsClusterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) if !ok { - errors = append(errors, fmt.Errorf("expected type of %s to be string", k)) + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) return } - _, err := parse.LogAnalyticsClusterID(v) - if err != nil { - errors = append(errors, fmt.Errorf("expected %s to be a Log Analytics Cluster ID:, %+v", k, err)) + if _, err := parse.LogAnalyticsClusterID(v); err != nil { + errors = append(errors, err) } - return warnings, errors + return } diff --git a/azurerm/internal/services/loganalytics/validate/log_analytics_cluster_id_test.go b/azurerm/internal/services/loganalytics/validate/log_analytics_cluster_id_test.go new file mode 100644 index 000000000000..54d57267f53e --- /dev/null +++ b/azurerm/internal/services/loganalytics/validate/log_analytics_cluster_id_test.go @@ -0,0 +1,76 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import "testing" + +func TestLogAnalyticsClusterID(t *testing.T) { + cases := []struct { + Input string + Valid bool + }{ + + { + // empty + Input: "", + Valid: false, + }, + + { + // missing SubscriptionId + Input: "/", + Valid: false, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Valid: false, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Valid: false, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Valid: false, + }, + + { + // missing ClusterName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/", + Valid: false, + }, + + { + // missing value for ClusterName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/clusters/", + Valid: false, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/clusters/cluster1", + Valid: true, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.OPERATIONALINSIGHTS/CLUSTERS/CLUSTER1", + Valid: false, + }, + } + for _, tc := range cases { + t.Logf("[DEBUG] Testing Value %s", tc.Input) + _, errors := LogAnalyticsClusterID(tc.Input, "test") + valid := len(errors) == 0 + + if tc.Valid != valid { + t.Fatalf("Expected %t but got %t", tc.Valid, valid) + } + } +} diff --git a/azurerm/internal/services/loganalytics/validate/log_analytics_data_export_id.go b/azurerm/internal/services/loganalytics/validate/log_analytics_data_export_id.go new file mode 100644 index 000000000000..283df56925a0 --- /dev/null +++ b/azurerm/internal/services/loganalytics/validate/log_analytics_data_export_id.go @@ -0,0 +1,23 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/loganalytics/parse" +) + +func LogAnalyticsDataExportID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := parse.LogAnalyticsDataExportID(v); err != nil { + errors = append(errors, err) + } + + return +} diff --git a/azurerm/internal/services/loganalytics/validate/log_analytics_data_export_id_test.go b/azurerm/internal/services/loganalytics/validate/log_analytics_data_export_id_test.go new file mode 100644 index 000000000000..aac995f9642a --- /dev/null +++ b/azurerm/internal/services/loganalytics/validate/log_analytics_data_export_id_test.go @@ -0,0 +1,88 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import "testing" + +func TestLogAnalyticsDataExportID(t *testing.T) { + cases := []struct { + Input string + Valid bool + }{ + + { + // empty + Input: "", + Valid: false, + }, + + { + // missing SubscriptionId + Input: "/", + Valid: false, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Valid: false, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Valid: false, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Valid: false, + }, + + { + // missing WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/", + Valid: false, + }, + + { + // missing value for WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/", + Valid: false, + }, + + { + // missing DataexportName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/", + Valid: false, + }, + + { + // missing value for DataexportName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/dataexports/", + Valid: false, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/dataexports/dataExport1", + Valid: true, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.OPERATIONALINSIGHTS/WORKSPACES/WORKSPACE1/DATAEXPORTS/DATAEXPORT1", + Valid: false, + }, + } + for _, tc := range cases { + t.Logf("[DEBUG] Testing Value %s", tc.Input) + _, errors := LogAnalyticsDataExportID(tc.Input, "test") + valid := len(errors) == 0 + + if tc.Valid != valid { + t.Fatalf("Expected %t but got %t", tc.Valid, valid) + } + } +} diff --git a/azurerm/internal/services/loganalytics/validate/log_analytics_data_source_windows_event_id.go b/azurerm/internal/services/loganalytics/validate/log_analytics_data_source_windows_event_id.go new file mode 100644 index 000000000000..81f8e2e9a0c3 --- /dev/null +++ b/azurerm/internal/services/loganalytics/validate/log_analytics_data_source_windows_event_id.go @@ -0,0 +1,23 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/loganalytics/parse" +) + +func LogAnalyticsDataSourceWindowsEventID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := parse.LogAnalyticsDataSourceWindowsEventID(v); err != nil { + errors = append(errors, err) + } + + return +} diff --git a/azurerm/internal/services/loganalytics/validate/log_analytics_data_source_windows_event_id_test.go b/azurerm/internal/services/loganalytics/validate/log_analytics_data_source_windows_event_id_test.go new file mode 100644 index 000000000000..55a0f06c9eae --- /dev/null +++ b/azurerm/internal/services/loganalytics/validate/log_analytics_data_source_windows_event_id_test.go @@ -0,0 +1,88 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import "testing" + +func TestLogAnalyticsDataSourceWindowsEventID(t *testing.T) { + cases := []struct { + Input string + Valid bool + }{ + + { + // empty + Input: "", + Valid: false, + }, + + { + // missing SubscriptionId + Input: "/", + Valid: false, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Valid: false, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Valid: false, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Valid: false, + }, + + { + // missing WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/", + Valid: false, + }, + + { + // missing value for WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/", + Valid: false, + }, + + { + // missing DataSourceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/", + Valid: false, + }, + + { + // missing value for DataSourceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/dataSources/", + Valid: false, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/dataSources/dataSource1", + Valid: true, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.OPERATIONALINSIGHTS/WORKSPACES/WORKSPACE1/DATASOURCES/DATASOURCE1", + Valid: false, + }, + } + for _, tc := range cases { + t.Logf("[DEBUG] Testing Value %s", tc.Input) + _, errors := LogAnalyticsDataSourceWindowsEventID(tc.Input, "test") + valid := len(errors) == 0 + + if tc.Valid != valid { + t.Fatalf("Expected %t but got %t", tc.Valid, valid) + } + } +} diff --git a/azurerm/internal/services/loganalytics/validate/log_analytics_linked_service_id.go b/azurerm/internal/services/loganalytics/validate/log_analytics_linked_service_id.go new file mode 100644 index 000000000000..a4e5f65315a0 --- /dev/null +++ b/azurerm/internal/services/loganalytics/validate/log_analytics_linked_service_id.go @@ -0,0 +1,23 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/loganalytics/parse" +) + +func LogAnalyticsLinkedServiceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := parse.LogAnalyticsLinkedServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} diff --git a/azurerm/internal/services/loganalytics/validate/log_analytics_linked_service_id_test.go b/azurerm/internal/services/loganalytics/validate/log_analytics_linked_service_id_test.go new file mode 100644 index 000000000000..0895b011acb8 --- /dev/null +++ b/azurerm/internal/services/loganalytics/validate/log_analytics_linked_service_id_test.go @@ -0,0 +1,88 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import "testing" + +func TestLogAnalyticsLinkedServiceID(t *testing.T) { + cases := []struct { + Input string + Valid bool + }{ + + { + // empty + Input: "", + Valid: false, + }, + + { + // missing SubscriptionId + Input: "/", + Valid: false, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Valid: false, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Valid: false, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Valid: false, + }, + + { + // missing WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/", + Valid: false, + }, + + { + // missing value for WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/", + Valid: false, + }, + + { + // missing LinkedServiceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/", + Valid: false, + }, + + { + // missing value for LinkedServiceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/linkedServices/", + Valid: false, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/linkedServices/linkedService1", + Valid: true, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.OPERATIONALINSIGHTS/WORKSPACES/WORKSPACE1/LINKEDSERVICES/LINKEDSERVICE1", + Valid: false, + }, + } + for _, tc := range cases { + t.Logf("[DEBUG] Testing Value %s", tc.Input) + _, errors := LogAnalyticsLinkedServiceID(tc.Input, "test") + valid := len(errors) == 0 + + if tc.Valid != valid { + t.Fatalf("Expected %t but got %t", tc.Valid, valid) + } + } +} diff --git a/azurerm/internal/services/loganalytics/validate/log_analytics_linked_storage_account_id.go b/azurerm/internal/services/loganalytics/validate/log_analytics_linked_storage_account_id.go new file mode 100644 index 000000000000..6164151c25a0 --- /dev/null +++ b/azurerm/internal/services/loganalytics/validate/log_analytics_linked_storage_account_id.go @@ -0,0 +1,23 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/loganalytics/parse" +) + +func LogAnalyticsLinkedStorageAccountID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := parse.LogAnalyticsLinkedStorageAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} diff --git a/azurerm/internal/services/loganalytics/validate/log_analytics_linked_storage_account_id_test.go b/azurerm/internal/services/loganalytics/validate/log_analytics_linked_storage_account_id_test.go new file mode 100644 index 000000000000..634da80088e6 --- /dev/null +++ b/azurerm/internal/services/loganalytics/validate/log_analytics_linked_storage_account_id_test.go @@ -0,0 +1,88 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import "testing" + +func TestLogAnalyticsLinkedStorageAccountID(t *testing.T) { + cases := []struct { + Input string + Valid bool + }{ + + { + // empty + Input: "", + Valid: false, + }, + + { + // missing SubscriptionId + Input: "/", + Valid: false, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Valid: false, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Valid: false, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Valid: false, + }, + + { + // missing WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/", + Valid: false, + }, + + { + // missing value for WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/", + Valid: false, + }, + + { + // missing LinkedStorageAccountName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/", + Valid: false, + }, + + { + // missing value for LinkedStorageAccountName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/linkedStorageAccounts/", + Valid: false, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/linkedStorageAccounts/query", + Valid: true, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.OPERATIONALINSIGHTS/WORKSPACES/WORKSPACE1/LINKEDSTORAGEACCOUNTS/QUERY", + Valid: false, + }, + } + for _, tc := range cases { + t.Logf("[DEBUG] Testing Value %s", tc.Input) + _, errors := LogAnalyticsLinkedStorageAccountID(tc.Input, "test") + valid := len(errors) == 0 + + if tc.Valid != valid { + t.Fatalf("Expected %t but got %t", tc.Valid, valid) + } + } +} diff --git a/azurerm/internal/services/loganalytics/validate/log_analytics_saved_search_id.go b/azurerm/internal/services/loganalytics/validate/log_analytics_saved_search_id.go new file mode 100644 index 000000000000..cdd150c34734 --- /dev/null +++ b/azurerm/internal/services/loganalytics/validate/log_analytics_saved_search_id.go @@ -0,0 +1,23 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/loganalytics/parse" +) + +func LogAnalyticsSavedSearchID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := parse.LogAnalyticsSavedSearchID(v); err != nil { + errors = append(errors, err) + } + + return +} diff --git a/azurerm/internal/services/loganalytics/validate/log_analytics_saved_search_id_test.go b/azurerm/internal/services/loganalytics/validate/log_analytics_saved_search_id_test.go new file mode 100644 index 000000000000..85c0144f3c93 --- /dev/null +++ b/azurerm/internal/services/loganalytics/validate/log_analytics_saved_search_id_test.go @@ -0,0 +1,88 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import "testing" + +func TestLogAnalyticsSavedSearchID(t *testing.T) { + cases := []struct { + Input string + Valid bool + }{ + + { + // empty + Input: "", + Valid: false, + }, + + { + // missing SubscriptionId + Input: "/", + Valid: false, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Valid: false, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Valid: false, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Valid: false, + }, + + { + // missing WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/", + Valid: false, + }, + + { + // missing value for WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/", + Valid: false, + }, + + { + // missing SavedSearcheName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/", + Valid: false, + }, + + { + // missing value for SavedSearcheName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/savedSearches/", + Valid: false, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/savedSearches/search1", + Valid: true, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.OPERATIONALINSIGHTS/WORKSPACES/WORKSPACE1/SAVEDSEARCHES/SEARCH1", + Valid: false, + }, + } + for _, tc := range cases { + t.Logf("[DEBUG] Testing Value %s", tc.Input) + _, errors := LogAnalyticsSavedSearchID(tc.Input, "test") + valid := len(errors) == 0 + + if tc.Valid != valid { + t.Fatalf("Expected %t but got %t", tc.Valid, valid) + } + } +} diff --git a/azurerm/internal/services/loganalytics/validate/log_analytics_solution_id.go b/azurerm/internal/services/loganalytics/validate/log_analytics_solution_id.go new file mode 100644 index 000000000000..19ced3da2f66 --- /dev/null +++ b/azurerm/internal/services/loganalytics/validate/log_analytics_solution_id.go @@ -0,0 +1,23 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/loganalytics/parse" +) + +func LogAnalyticsSolutionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := parse.LogAnalyticsSolutionID(v); err != nil { + errors = append(errors, err) + } + + return +} diff --git a/azurerm/internal/services/loganalytics/validate/log_analytics_solution_id_test.go b/azurerm/internal/services/loganalytics/validate/log_analytics_solution_id_test.go new file mode 100644 index 000000000000..07ab5d185b88 --- /dev/null +++ b/azurerm/internal/services/loganalytics/validate/log_analytics_solution_id_test.go @@ -0,0 +1,76 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import "testing" + +func TestLogAnalyticsSolutionID(t *testing.T) { + cases := []struct { + Input string + Valid bool + }{ + + { + // empty + Input: "", + Valid: false, + }, + + { + // missing SubscriptionId + Input: "/", + Valid: false, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Valid: false, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Valid: false, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Valid: false, + }, + + { + // missing SolutionName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationsManagement/", + Valid: false, + }, + + { + // missing value for SolutionName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationsManagement/solutions/", + Valid: false, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationsManagement/solutions/solution1", + Valid: true, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.OPERATIONSMANAGEMENT/SOLUTIONS/SOLUTION1", + Valid: false, + }, + } + for _, tc := range cases { + t.Logf("[DEBUG] Testing Value %s", tc.Input) + _, errors := LogAnalyticsSolutionID(tc.Input, "test") + valid := len(errors) == 0 + + if tc.Valid != valid { + t.Fatalf("Expected %t but got %t", tc.Valid, valid) + } + } +} diff --git a/azurerm/internal/services/loganalytics/validate/log_analytics_storage_insights_id.go b/azurerm/internal/services/loganalytics/validate/log_analytics_storage_insights_id.go new file mode 100644 index 000000000000..1f26cc00f1a3 --- /dev/null +++ b/azurerm/internal/services/loganalytics/validate/log_analytics_storage_insights_id.go @@ -0,0 +1,23 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/loganalytics/parse" +) + +func LogAnalyticsStorageInsightsID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := parse.LogAnalyticsStorageInsightsID(v); err != nil { + errors = append(errors, err) + } + + return +} diff --git a/azurerm/internal/services/loganalytics/validate/log_analytics_storage_insights_id_test.go b/azurerm/internal/services/loganalytics/validate/log_analytics_storage_insights_id_test.go new file mode 100644 index 000000000000..6b879f1869ad --- /dev/null +++ b/azurerm/internal/services/loganalytics/validate/log_analytics_storage_insights_id_test.go @@ -0,0 +1,88 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import "testing" + +func TestLogAnalyticsStorageInsightsID(t *testing.T) { + cases := []struct { + Input string + Valid bool + }{ + + { + // empty + Input: "", + Valid: false, + }, + + { + // missing SubscriptionId + Input: "/", + Valid: false, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Valid: false, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Valid: false, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Valid: false, + }, + + { + // missing WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/", + Valid: false, + }, + + { + // missing value for WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/", + Valid: false, + }, + + { + // missing StorageInsightConfigName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/", + Valid: false, + }, + + { + // missing value for StorageInsightConfigName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/storageInsightConfigs/", + Valid: false, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/storageInsightConfigs/storageInsight1", + Valid: true, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.OPERATIONALINSIGHTS/WORKSPACES/WORKSPACE1/STORAGEINSIGHTCONFIGS/STORAGEINSIGHT1", + Valid: false, + }, + } + for _, tc := range cases { + t.Logf("[DEBUG] Testing Value %s", tc.Input) + _, errors := LogAnalyticsStorageInsightsID(tc.Input, "test") + valid := len(errors) == 0 + + if tc.Valid != valid { + t.Fatalf("Expected %t but got %t", tc.Valid, valid) + } + } +} diff --git a/azurerm/internal/services/loganalytics/validate/log_analytics_workspace_id.go b/azurerm/internal/services/loganalytics/validate/log_analytics_workspace_id.go index f40d4b02f424..217489c3f176 100644 --- a/azurerm/internal/services/loganalytics/validate/log_analytics_workspace_id.go +++ b/azurerm/internal/services/loganalytics/validate/log_analytics_workspace_id.go @@ -1,22 +1,23 @@ package validate +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + import ( "fmt" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/loganalytics/parse" ) -func LogAnalyticsWorkspaceID(i interface{}, k string) (warnings []string, errors []error) { - v, ok := i.(string) +func LogAnalyticsWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) if !ok { - errors = append(errors, fmt.Errorf("expected type of %q to be string", k)) + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) return } if _, err := parse.LogAnalyticsWorkspaceID(v); err != nil { - errors = append(errors, fmt.Errorf("parsing %q as a resource id: %v", k, err)) - return + errors = append(errors, err) } - return warnings, errors + return } diff --git a/azurerm/internal/services/loganalytics/validate/log_analytics_workspace_id_test.go b/azurerm/internal/services/loganalytics/validate/log_analytics_workspace_id_test.go new file mode 100644 index 000000000000..2fd0b3b2011c --- /dev/null +++ b/azurerm/internal/services/loganalytics/validate/log_analytics_workspace_id_test.go @@ -0,0 +1,76 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import "testing" + +func TestLogAnalyticsWorkspaceID(t *testing.T) { + cases := []struct { + Input string + Valid bool + }{ + + { + // empty + Input: "", + Valid: false, + }, + + { + // missing SubscriptionId + Input: "/", + Valid: false, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Valid: false, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Valid: false, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Valid: false, + }, + + { + // missing WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/", + Valid: false, + }, + + { + // missing value for WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/", + Valid: false, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1", + Valid: true, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.OPERATIONALINSIGHTS/WORKSPACES/WORKSPACE1", + Valid: false, + }, + } + for _, tc := range cases { + t.Logf("[DEBUG] Testing Value %s", tc.Input) + _, errors := LogAnalyticsWorkspaceID(tc.Input, "test") + valid := len(errors) == 0 + + if tc.Valid != valid { + t.Fatalf("Expected %t but got %t", tc.Valid, valid) + } + } +} diff --git a/azurerm/internal/services/sentinel/parse/sentinel_alert_rules.go b/azurerm/internal/services/sentinel/parse/sentinel_alert_rules.go index adc5b576015b..b054416e4e32 100644 --- a/azurerm/internal/services/sentinel/parse/sentinel_alert_rules.go +++ b/azurerm/internal/services/sentinel/parse/sentinel_alert_rules.go @@ -28,7 +28,7 @@ func SentinelAlertRuleID(input string) (*SentinelAlertRuleId, error) { } return &SentinelAlertRuleId{ ResourceGroup: workspaceId.ResourceGroup, - Workspace: workspaceId.Name, + Workspace: workspaceId.WorkspaceName, Name: name, }, nil } diff --git a/azurerm/internal/services/sentinel/sentinel_alert_rule_data_source.go b/azurerm/internal/services/sentinel/sentinel_alert_rule_data_source.go index 3825224a89aa..423f5f05ddb5 100644 --- a/azurerm/internal/services/sentinel/sentinel_alert_rule_data_source.go +++ b/azurerm/internal/services/sentinel/sentinel_alert_rule_data_source.go @@ -48,18 +48,18 @@ func dataSourceArmSentinelAlertRuleRead(d *schema.ResourceData, meta interface{} return err } - resp, err := client.Get(ctx, workspaceID.ResourceGroup, "Microsoft.OperationalInsights", workspaceID.Name, name) + resp, err := client.Get(ctx, workspaceID.ResourceGroup, "Microsoft.OperationalInsights", workspaceID.WorkspaceName, name) if err != nil { if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("Sentinel Alert Rule %q (Resource Group %q / Workspace: %q) was not found", name, workspaceID.ResourceGroup, workspaceID.Name) + return fmt.Errorf("Sentinel Alert Rule %q (Resource Group %q / Workspace: %q) was not found", name, workspaceID.ResourceGroup, workspaceID.WorkspaceName) } - return fmt.Errorf("retrieving Sentinel Alert Rule %q (Resource Group %q / Workspace: %q): %+v", name, workspaceID.ResourceGroup, workspaceID.Name, err) + return fmt.Errorf("retrieving Sentinel Alert Rule %q (Resource Group %q / Workspace: %q): %+v", name, workspaceID.ResourceGroup, workspaceID.WorkspaceName, err) } id := alertRuleID(resp.Value) if id == nil || *id == "" { - return fmt.Errorf("nil or empty ID of Sentinel Alert Rule %q (Resource Group %q / Workspace: %q)", name, workspaceID.ResourceGroup, workspaceID.Name) + return fmt.Errorf("nil or empty ID of Sentinel Alert Rule %q (Resource Group %q / Workspace: %q)", name, workspaceID.ResourceGroup, workspaceID.WorkspaceName) } d.SetId(*id) diff --git a/azurerm/internal/services/sentinel/sentinel_alert_rule_ms_security_incident_resource.go b/azurerm/internal/services/sentinel/sentinel_alert_rule_ms_security_incident_resource.go index e7d63cbaf1af..5d1d1f41607c 100644 --- a/azurerm/internal/services/sentinel/sentinel_alert_rule_ms_security_incident_resource.go +++ b/azurerm/internal/services/sentinel/sentinel_alert_rule_ms_security_incident_resource.go @@ -137,7 +137,7 @@ func resourceArmSentinelAlertRuleMsSecurityIncidentCreateUpdate(d *schema.Resour } if d.IsNewResource() { - resp, err := client.Get(ctx, workspaceID.ResourceGroup, "Microsoft.OperationalInsights", workspaceID.Name, name) + resp, err := client.Get(ctx, workspaceID.ResourceGroup, "Microsoft.OperationalInsights", workspaceID.WorkspaceName, name) if err != nil { if !utils.ResponseWasNotFound(resp.Response) { return fmt.Errorf("checking for existing Sentinel Alert Rule Ms Security Incident %q (Resource Group %q): %+v", name, workspaceID.ResourceGroup, err) @@ -169,28 +169,28 @@ func resourceArmSentinelAlertRuleMsSecurityIncidentCreateUpdate(d *schema.Resour // Service avoid concurrent update of this resource via checking the "etag" to guarantee it is the same value as last Read. if !d.IsNewResource() { - resp, err := client.Get(ctx, workspaceID.ResourceGroup, "Microsoft.OperationalInsights", workspaceID.Name, name) + resp, err := client.Get(ctx, workspaceID.ResourceGroup, "Microsoft.OperationalInsights", workspaceID.WorkspaceName, name) if err != nil { - return fmt.Errorf("retrieving Sentinel Alert Rule Ms Security Incident %q (Resource Group %q / Workspace: %q): %+v", name, workspaceID.ResourceGroup, workspaceID.Name, err) + return fmt.Errorf("retrieving Sentinel Alert Rule Ms Security Incident %q (Resource Group %q / Workspace: %q): %+v", name, workspaceID.ResourceGroup, workspaceID.WorkspaceName, err) } if err := assertAlertRuleKind(resp.Value, securityinsight.MicrosoftSecurityIncidentCreation); err != nil { - return fmt.Errorf("asserting alert rule of %q (Resource Group %q / Workspace: %q): %+v", name, workspaceID.ResourceGroup, workspaceID.Name, err) + return fmt.Errorf("asserting alert rule of %q (Resource Group %q / Workspace: %q): %+v", name, workspaceID.ResourceGroup, workspaceID.WorkspaceName, err) } param.Etag = resp.Value.(securityinsight.MicrosoftSecurityIncidentCreationAlertRule).Etag } - if _, err := client.CreateOrUpdate(ctx, workspaceID.ResourceGroup, "Microsoft.OperationalInsights", workspaceID.Name, name, param); err != nil { - return fmt.Errorf("creating Sentinel Alert Rule Ms Security Incident %q (Resource Group %q / Workspace: %q): %+v", name, workspaceID.ResourceGroup, workspaceID.Name, err) + if _, err := client.CreateOrUpdate(ctx, workspaceID.ResourceGroup, "Microsoft.OperationalInsights", workspaceID.WorkspaceName, name, param); err != nil { + return fmt.Errorf("creating Sentinel Alert Rule Ms Security Incident %q (Resource Group %q / Workspace: %q): %+v", name, workspaceID.ResourceGroup, workspaceID.WorkspaceName, err) } - resp, err := client.Get(ctx, workspaceID.ResourceGroup, "Microsoft.OperationalInsights", workspaceID.Name, name) + resp, err := client.Get(ctx, workspaceID.ResourceGroup, "Microsoft.OperationalInsights", workspaceID.WorkspaceName, name) if err != nil { - return fmt.Errorf("retrieving Sentinel Alert Rule Ms Security Incident %q (Resource Group %q / Workspace: %q): %+v", name, workspaceID.ResourceGroup, workspaceID.Name, err) + return fmt.Errorf("retrieving Sentinel Alert Rule Ms Security Incident %q (Resource Group %q / Workspace: %q): %+v", name, workspaceID.ResourceGroup, workspaceID.WorkspaceName, err) } id := alertRuleID(resp.Value) if id == nil || *id == "" { - return fmt.Errorf("empty or nil ID returned for Sentinel Alert Rule Ms Security Incident %q (Resource Group %q / Workspace: %q) ID", name, workspaceID.ResourceGroup, workspaceID.Name) + return fmt.Errorf("empty or nil ID returned for Sentinel Alert Rule Ms Security Incident %q (Resource Group %q / Workspace: %q) ID", name, workspaceID.ResourceGroup, workspaceID.WorkspaceName) } d.SetId(*id) diff --git a/azurerm/internal/services/sentinel/sentinel_alert_rule_scheduled_resource.go b/azurerm/internal/services/sentinel/sentinel_alert_rule_scheduled_resource.go index f60f3f2b9cc5..3ef0835d45f5 100644 --- a/azurerm/internal/services/sentinel/sentinel_alert_rule_scheduled_resource.go +++ b/azurerm/internal/services/sentinel/sentinel_alert_rule_scheduled_resource.go @@ -171,10 +171,10 @@ func resourceArmSentinelAlertRuleScheduledCreateUpdate(d *schema.ResourceData, m } if d.IsNewResource() { - resp, err := client.Get(ctx, workspaceID.ResourceGroup, "Microsoft.OperationalInsights", workspaceID.Name, name) + resp, err := client.Get(ctx, workspaceID.ResourceGroup, "Microsoft.OperationalInsights", workspaceID.WorkspaceName, name) if err != nil { if !utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("checking for existing Sentinel Alert Rule Scheduled %q (Resource Group %q / Workspace %q): %+v", name, workspaceID.ResourceGroup, workspaceID.Name, err) + return fmt.Errorf("checking for existing Sentinel Alert Rule Scheduled %q (Resource Group %q / Workspace %q): %+v", name, workspaceID.ResourceGroup, workspaceID.WorkspaceName, err) } } @@ -226,29 +226,29 @@ func resourceArmSentinelAlertRuleScheduledCreateUpdate(d *schema.ResourceData, m // Service avoid concurrent update of this resource via checking the "etag" to guarantee it is the same value as last Read. if !d.IsNewResource() { - resp, err := client.Get(ctx, workspaceID.ResourceGroup, "Microsoft.OperationalInsights", workspaceID.Name, name) + resp, err := client.Get(ctx, workspaceID.ResourceGroup, "Microsoft.OperationalInsights", workspaceID.WorkspaceName, name) if err != nil { - return fmt.Errorf("retrieving Sentinel Alert Rule Scheduled %q (Resource Group %q / Workspace %q): %+v", name, workspaceID.ResourceGroup, workspaceID.Name, err) + return fmt.Errorf("retrieving Sentinel Alert Rule Scheduled %q (Resource Group %q / Workspace %q): %+v", name, workspaceID.ResourceGroup, workspaceID.WorkspaceName, err) } if err := assertAlertRuleKind(resp.Value, securityinsight.Scheduled); err != nil { - return fmt.Errorf("asserting alert rule of %q (Resource Group %q / Workspace %q): %+v", name, workspaceID.ResourceGroup, workspaceID.Name, err) + return fmt.Errorf("asserting alert rule of %q (Resource Group %q / Workspace %q): %+v", name, workspaceID.ResourceGroup, workspaceID.WorkspaceName, err) } param.Etag = resp.Value.(securityinsight.ScheduledAlertRule).Etag } - if _, err := client.CreateOrUpdate(ctx, workspaceID.ResourceGroup, "Microsoft.OperationalInsights", workspaceID.Name, name, param); err != nil { - return fmt.Errorf("creating Sentinel Alert Rule Scheduled %q (Resource Group %q / Workspace %q): %+v", name, workspaceID.ResourceGroup, workspaceID.Name, err) + if _, err := client.CreateOrUpdate(ctx, workspaceID.ResourceGroup, "Microsoft.OperationalInsights", workspaceID.WorkspaceName, name, param); err != nil { + return fmt.Errorf("creating Sentinel Alert Rule Scheduled %q (Resource Group %q / Workspace %q): %+v", name, workspaceID.ResourceGroup, workspaceID.WorkspaceName, err) } - resp, err := client.Get(ctx, workspaceID.ResourceGroup, "Microsoft.OperationalInsights", workspaceID.Name, name) + resp, err := client.Get(ctx, workspaceID.ResourceGroup, "Microsoft.OperationalInsights", workspaceID.WorkspaceName, name) if err != nil { - return fmt.Errorf("retrieving Sentinel Alert Rule Scheduled %q (Resource Group %q / Workspace %q): %+v", name, workspaceID.ResourceGroup, workspaceID.Name, err) + return fmt.Errorf("retrieving Sentinel Alert Rule Scheduled %q (Resource Group %q / Workspace %q): %+v", name, workspaceID.ResourceGroup, workspaceID.WorkspaceName, err) } id := alertRuleID(resp.Value) if id == nil || *id == "" { - return fmt.Errorf("empty or nil ID returned for Sentinel Alert Rule Scheduled %q (Resource Group %q / Workspace %q) ID", name, workspaceID.ResourceGroup, workspaceID.Name) + return fmt.Errorf("empty or nil ID returned for Sentinel Alert Rule Scheduled %q (Resource Group %q / Workspace %q) ID", name, workspaceID.ResourceGroup, workspaceID.WorkspaceName) } d.SetId(*id) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/availableservicetiers.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/availableservicetiers.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/availableservicetiers.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/availableservicetiers.go index 5136dc0a017d..b3821e410a0f 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/availableservicetiers.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/availableservicetiers.go @@ -101,7 +101,7 @@ func (client AvailableServiceTiersClient) ListByWorkspacePreparer(ctx context.Co "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/client.go similarity index 97% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/client.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/client.go index c1f4a6a3b76d..e712a58f9e3d 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/client.go @@ -1,4 +1,4 @@ -// Package operationalinsights implements the Azure ARM Operationalinsights service API version 2020-03-01-preview. +// Package operationalinsights implements the Azure ARM Operationalinsights service API version 2020-08-01. // // Operational Insights Client package operationalinsights diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/clusters.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/clusters.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/clusters.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/clusters.go index ac897e830e6b..7ab6a927fcf9 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/clusters.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/clusters.go @@ -95,7 +95,7 @@ func (client ClustersClient) CreateOrUpdatePreparer(ctx context.Context, resourc "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -182,7 +182,7 @@ func (client ClustersClient) DeletePreparer(ctx context.Context, resourceGroupNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -272,7 +272,7 @@ func (client ClustersClient) GetPreparer(ctx context.Context, resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -352,7 +352,7 @@ func (client ClustersClient) ListPreparer(ctx context.Context) (*http.Request, e "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -476,7 +476,7 @@ func (client ClustersClient) ListByResourceGroupPreparer(ctx context.Context, re "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -599,7 +599,7 @@ func (client ClustersClient) UpdatePreparer(ctx context.Context, resourceGroupNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/dataexports.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/dataexports.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/dataexports.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/dataexports.go index f9f4d17eb202..dcfc9ac7dbe5 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/dataexports.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/dataexports.go @@ -112,7 +112,7 @@ func (client DataExportsClient) CreateOrUpdatePreparer(ctx context.Context, reso "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -205,7 +205,7 @@ func (client DataExportsClient) DeletePreparer(ctx context.Context, resourceGrou "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -295,7 +295,7 @@ func (client DataExportsClient) GetPreparer(ctx context.Context, resourceGroupNa "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -384,7 +384,7 @@ func (client DataExportsClient) ListByWorkspacePreparer(ctx context.Context, res "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/datasources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/datasources.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/datasources.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/datasources.go index 5b7b70d1ebb3..fa4e4b64ce89 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/datasources.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/datasources.go @@ -105,7 +105,7 @@ func (client DataSourcesClient) CreateOrUpdatePreparer(ctx context.Context, reso "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -198,7 +198,7 @@ func (client DataSourcesClient) DeletePreparer(ctx context.Context, resourceGrou "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -288,7 +288,7 @@ func (client DataSourcesClient) GetPreparer(ctx context.Context, resourceGroupNa "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -383,7 +383,7 @@ func (client DataSourcesClient) ListByWorkspacePreparer(ctx context.Context, res "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "$filter": autorest.Encode("query", filter), "api-version": APIVersion, diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/deletedworkspaces.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/deletedworkspaces.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/deletedworkspaces.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/deletedworkspaces.go index 48a77e3de8d7..813d3cfdb876 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/deletedworkspaces.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/deletedworkspaces.go @@ -88,7 +88,7 @@ func (client DeletedWorkspacesClient) ListPreparer(ctx context.Context) (*http.R "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -171,7 +171,7 @@ func (client DeletedWorkspacesClient) ListByResourceGroupPreparer(ctx context.Co "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/enums.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/enums.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/enums.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/enums.go index c1ae7667277b..73d03e40e82a 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/enums.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/enums.go @@ -165,15 +165,13 @@ const ( AzureWatson DataSourceType = "AzureWatson" // CustomLogs ... CustomLogs DataSourceType = "CustomLogs" - // Ingestion ... - Ingestion DataSourceType = "Ingestion" // Query ... Query DataSourceType = "Query" ) // PossibleDataSourceTypeValues returns an array of possible values for the DataSourceType const type. func PossibleDataSourceTypeValues() []DataSourceType { - return []DataSourceType{Alerts, AzureWatson, CustomLogs, Ingestion, Query} + return []DataSourceType{Alerts, AzureWatson, CustomLogs, Query} } // IdentityType enumerates the values for identity type. diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/gateways.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/gateways.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/gateways.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/gateways.go index 97176d7fb7f4..f967ded1e80e 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/gateways.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/gateways.go @@ -102,7 +102,7 @@ func (client GatewaysClient) DeletePreparer(ctx context.Context, resourceGroupNa "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/intelligencepacks.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/intelligencepacks.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/intelligencepacks.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/intelligencepacks.go index 31f1f43df75d..8e870e73d324 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/intelligencepacks.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/intelligencepacks.go @@ -103,7 +103,7 @@ func (client IntelligencePacksClient) DisablePreparer(ctx context.Context, resou "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -193,7 +193,7 @@ func (client IntelligencePacksClient) EnablePreparer(ctx context.Context, resour "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -281,7 +281,7 @@ func (client IntelligencePacksClient) ListPreparer(ctx context.Context, resource "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/linkedservices.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/linkedservices.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/linkedservices.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/linkedservices.go index dcdb52cd355d..585fa4047bf1 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/linkedservices.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/linkedservices.go @@ -99,7 +99,7 @@ func (client LinkedServicesClient) CreateOrUpdatePreparer(ctx context.Context, r "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -192,7 +192,7 @@ func (client LinkedServicesClient) DeletePreparer(ctx context.Context, resourceG "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -289,7 +289,7 @@ func (client LinkedServicesClient) GetPreparer(ctx context.Context, resourceGrou "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -378,7 +378,7 @@ func (client LinkedServicesClient) ListByWorkspacePreparer(ctx context.Context, "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/linkedstorageaccounts.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/linkedstorageaccounts.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/linkedstorageaccounts.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/linkedstorageaccounts.go index 41a5b473957a..27c051c0f898 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/linkedstorageaccounts.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/linkedstorageaccounts.go @@ -107,7 +107,7 @@ func (client LinkedStorageAccountsClient) CreateOrUpdatePreparer(ctx context.Con "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -200,7 +200,7 @@ func (client LinkedStorageAccountsClient) DeletePreparer(ctx context.Context, re "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -290,7 +290,7 @@ func (client LinkedStorageAccountsClient) GetPreparer(ctx context.Context, resou "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -380,7 +380,7 @@ func (client LinkedStorageAccountsClient) ListByWorkspacePreparer(ctx context.Co "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/managementgroups.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/managementgroups.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/managementgroups.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/managementgroups.go index 84e4559db0a1..4cf1a3a71a5c 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/managementgroups.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/managementgroups.go @@ -101,7 +101,7 @@ func (client ManagementGroupsClient) ListPreparer(ctx context.Context, resourceG "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/models.go similarity index 93% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/models.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/models.go index 7d02a3588e5d..d1a318bdf532 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/models.go @@ -29,7 +29,7 @@ import ( ) // The package's fully qualified name. -const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights" +const fqdn = "github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights" // AvailableServiceTier service Tier details. type AvailableServiceTier struct { @@ -49,15 +49,15 @@ type AvailableServiceTier struct { LastSkuUpdate *string `json:"lastSkuUpdate,omitempty"` } -// AzureEntityResource the resource model definition for a Azure Resource Manager resource with an etag. +// AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag. type AzureEntityResource struct { // Etag - READ-ONLY; Resource Etag. Etag *string `json:"etag,omitempty"` - // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string `json:"id,omitempty"` // Name - READ-ONLY; The name of the resource Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string `json:"type,omitempty"` } @@ -74,11 +74,11 @@ type Cluster struct { Tags map[string]*string `json:"tags"` // Location - The geo-location where the resource lives Location *string `json:"location,omitempty"` - // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string `json:"id,omitempty"` // Name - READ-ONLY; The name of the resource Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string `json:"type,omitempty"` } @@ -517,103 +517,16 @@ type CoreSummary struct { NumberOfDocuments *int64 `json:"numberOfDocuments,omitempty"` } -// DataCollectorLog data collector log top level resource container. -type DataCollectorLog struct { - autorest.Response `json:"-"` - // DataCollectorLogProperties - Data collector log properties. - *DataCollectorLogProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the resource - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for DataCollectorLog. -func (dcl DataCollectorLog) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if dcl.DataCollectorLogProperties != nil { - objectMap["properties"] = dcl.DataCollectorLogProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for DataCollectorLog struct. -func (dcl *DataCollectorLog) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var dataCollectorLogProperties DataCollectorLogProperties - err = json.Unmarshal(*v, &dataCollectorLogProperties) - if err != nil { - return err - } - dcl.DataCollectorLogProperties = &dataCollectorLogProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - dcl.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - dcl.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - dcl.Type = &typeVar - } - } - } - - return nil -} - -// DataCollectorLogProperties data collector log properties. -type DataCollectorLogProperties struct { - // Name - Table's name. - Name *string `json:"name,omitempty"` -} - -// DataCollectorLogsListResult data collector log tables collection, all tables are scoped to the specified -// workspace. -type DataCollectorLogsListResult struct { - autorest.Response `json:"-"` - // Value - data collector log collection. - Value *[]DataCollectorLog `json:"value,omitempty"` -} - // DataExport the top level data export resource container. type DataExport struct { autorest.Response `json:"-"` // DataExportProperties - data export properties. *DataExportProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string `json:"id,omitempty"` // Name - READ-ONLY; The name of the resource Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string `json:"type,omitempty"` } @@ -695,6 +608,8 @@ type DataExportListResult struct { type DataExportProperties struct { // DataExportID - The data export rule ID. DataExportID *string `json:"dataExportId,omitempty"` + // AllTables - When ‘true’, all workspace's tables are exported. + AllTables *bool `json:"allTables,omitempty"` // TableNames - An array of tables to export, for example: [“Heartbeat, SecurityEvent”]. TableNames *[]string `json:"tableNames,omitempty"` // Destination - destination properties. @@ -713,6 +628,9 @@ func (dep DataExportProperties) MarshalJSON() ([]byte, error) { if dep.DataExportID != nil { objectMap["dataExportId"] = dep.DataExportID } + if dep.AllTables != nil { + objectMap["allTables"] = dep.AllTables + } if dep.TableNames != nil { objectMap["tableNames"] = dep.TableNames } @@ -749,6 +667,15 @@ func (dep *DataExportProperties) UnmarshalJSON(body []byte) error { } dep.DataExportID = &dataExportID } + case "allTables": + if v != nil { + var allTables bool + err = json.Unmarshal(*v, &allTables) + if err != nil { + return err + } + dep.AllTables = &allTables + } case "tableNames": if v != nil { var tableNames []string @@ -811,11 +738,11 @@ type DataSource struct { Kind DataSourceKind `json:"kind,omitempty"` // Tags - Resource tags. Tags map[string]*string `json:"tags"` - // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string `json:"id,omitempty"` // Name - READ-ONLY; The name of the resource Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string `json:"type,omitempty"` } @@ -1083,7 +1010,8 @@ type ErrorContract struct { Error *ErrorResponse `json:"error,omitempty"` } -// ErrorResponse the resource management error response. +// ErrorResponse common error response for all Azure Resource Manager APIs to return error details for failed +// operations. (This also follows the OData error response format.) type ErrorResponse struct { // Code - READ-ONLY; The error code. Code *string `json:"code,omitempty"` @@ -1143,11 +1071,11 @@ type LinkedService struct { *LinkedServiceProperties `json:"properties,omitempty"` // Tags - Resource tags. Tags map[string]*string `json:"tags"` - // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string `json:"id,omitempty"` // Name - READ-ONLY; The name of the resource Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string `json:"type,omitempty"` } @@ -1307,7 +1235,7 @@ type LinkedStorageAccountsListResult struct { // LinkedStorageAccountsProperties linked storage accounts properties. type LinkedStorageAccountsProperties struct { - // DataSourceType - READ-ONLY; Linked storage accounts type. Possible values include: 'CustomLogs', 'AzureWatson', 'Query', 'Ingestion', 'Alerts' + // DataSourceType - READ-ONLY; Linked storage accounts type. Possible values include: 'CustomLogs', 'AzureWatson', 'Query', 'Alerts' DataSourceType DataSourceType `json:"dataSourceType,omitempty"` // StorageAccountIds - Linked storage accounts resources ids. StorageAccountIds *[]string `json:"storageAccountIds,omitempty"` @@ -1327,11 +1255,11 @@ type LinkedStorageAccountsResource struct { autorest.Response `json:"-"` // LinkedStorageAccountsProperties - Linked storage accounts properties. *LinkedStorageAccountsProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string `json:"id,omitempty"` // Name - READ-ONLY; The name of the resource Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string `json:"type,omitempty"` } @@ -1684,24 +1612,24 @@ type PrivateLinkScopedResource struct { ScopeID *string `json:"scopeId,omitempty"` } -// ProxyResource the resource model definition for a ARM proxy resource. It will have everything other than -// required location and tags +// ProxyResource the resource model definition for a Azure Resource Manager proxy resource. It will not have +// tags and a location type ProxyResource struct { - // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string `json:"id,omitempty"` // Name - READ-ONLY; The name of the resource Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string `json:"type,omitempty"` } -// Resource ... +// Resource common fields that are returned in the response for all Azure Resource Manager resources type Resource struct { - // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string `json:"id,omitempty"` // Name - READ-ONLY; The name of the resource Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string `json:"type,omitempty"` } @@ -1712,11 +1640,11 @@ type SavedSearch struct { Etag *string `json:"etag,omitempty"` // SavedSearchProperties - The properties of the saved search. *SavedSearchProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string `json:"id,omitempty"` // Name - READ-ONLY; The name of the resource Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string `json:"type,omitempty"` } @@ -1924,11 +1852,11 @@ type StorageInsight struct { ETag *string `json:"eTag,omitempty"` // Tags - Resource tags. Tags map[string]*string `json:"tags"` - // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string `json:"id,omitempty"` // Name - READ-ONLY; The name of the resource Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string `json:"type,omitempty"` } @@ -2212,11 +2140,11 @@ type Table struct { autorest.Response `json:"-"` // TableProperties - Table properties. *TableProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string `json:"id,omitempty"` // Name - READ-ONLY; The name of the resource Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string `json:"type,omitempty"` } @@ -2301,17 +2229,18 @@ type Tag struct { Value *string `json:"value,omitempty"` } -// TrackedResource the resource model definition for a ARM tracked top level resource +// TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource which +// has 'tags' and a 'location' type TrackedResource struct { // Tags - Resource tags. Tags map[string]*string `json:"tags"` // Location - The geo-location where the resource lives Location *string `json:"location,omitempty"` - // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string `json:"id,omitempty"` // Name - READ-ONLY; The name of the resource Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string `json:"type,omitempty"` } @@ -2354,11 +2283,11 @@ type Workspace struct { Tags map[string]*string `json:"tags"` // Location - The geo-location where the resource lives Location *string `json:"location,omitempty"` - // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string `json:"id,omitempty"` // Name - READ-ONLY; The name of the resource Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string `json:"type,omitempty"` } @@ -2460,7 +2389,7 @@ func (w *Workspace) UnmarshalJSON(body []byte) error { // WorkspaceCapping the daily volume cap for ingestion. type WorkspaceCapping struct { - // DailyQuotaGb - The workspace daily quota for ingestion. -1 means unlimited. + // DailyQuotaGb - The workspace daily quota for ingestion. DailyQuotaGb *float64 `json:"dailyQuotaGb,omitempty"` // QuotaNextResetTime - READ-ONLY; The time when the quota will be rest. QuotaNextResetTime *string `json:"quotaNextResetTime,omitempty"` @@ -2506,11 +2435,11 @@ type WorkspacePatch struct { Tags map[string]*string `json:"tags"` // Etag - READ-ONLY; Resource Etag. Etag *string `json:"etag,omitempty"` - // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string `json:"id,omitempty"` // Name - READ-ONLY; The name of the resource Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string `json:"type,omitempty"` } @@ -2603,7 +2532,7 @@ type WorkspaceProperties struct { CustomerID *string `json:"customerId,omitempty"` // Sku - The SKU of the workspace. Sku *WorkspaceSku `json:"sku,omitempty"` - // RetentionInDays - The workspace data retention in days. -1 means Unlimited retention for the Unlimited Sku. 730 days is the maximum allowed for all other Skus. + // RetentionInDays - The workspace data retention in days, between 30 and 730. RetentionInDays *int32 `json:"retentionInDays,omitempty"` // WorkspaceCapping - The daily volume cap for ingestion. WorkspaceCapping *WorkspaceCapping `json:"workspaceCapping,omitempty"` diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/operations.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/operations.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/operations.go index 87b8b7a3b4a9..35e4d3cbaa5c 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/operations.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/operations.go @@ -80,7 +80,7 @@ func (client OperationsClient) List(ctx context.Context) (result OperationListRe // ListPreparer prepares the List request. func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/operationstatuses.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/operationstatuses.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/operationstatuses.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/operationstatuses.go index b24f85303dbe..3ef21a819905 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/operationstatuses.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/operationstatuses.go @@ -93,7 +93,7 @@ func (client OperationStatusesClient) GetPreparer(ctx context.Context, location "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/savedsearches.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/savedsearches.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/savedsearches.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/savedsearches.go index ab179d79f01e..29faa7ca1acb 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/savedsearches.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/savedsearches.go @@ -109,7 +109,7 @@ func (client SavedSearchesClient) CreateOrUpdatePreparer(ctx context.Context, re "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -202,7 +202,7 @@ func (client SavedSearchesClient) DeletePreparer(ctx context.Context, resourceGr "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -292,7 +292,7 @@ func (client SavedSearchesClient) GetPreparer(ctx context.Context, resourceGroup "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -381,7 +381,7 @@ func (client SavedSearchesClient) ListByWorkspacePreparer(ctx context.Context, r "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/schema.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/schema.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/schema.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/schema.go index eb1fe3ed1bf6..2a3127124039 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/schema.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/schema.go @@ -100,7 +100,7 @@ func (client SchemaClient) GetPreparer(ctx context.Context, resourceGroupName st "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/sharedkeys.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/sharedkeys.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/sharedkeys.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/sharedkeys.go index 74bf44b0ad4d..7264484f65ad 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/sharedkeys.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/sharedkeys.go @@ -100,7 +100,7 @@ func (client SharedKeysClient) GetSharedKeysPreparer(ctx context.Context, resour "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -190,7 +190,7 @@ func (client SharedKeysClient) RegeneratePreparer(ctx context.Context, resourceG "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/storageinsightconfigs.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/storageinsightconfigs.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/storageinsightconfigs.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/storageinsightconfigs.go index 6660b53c4e6b..eec4bf039656 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/storageinsightconfigs.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/storageinsightconfigs.go @@ -111,7 +111,7 @@ func (client StorageInsightConfigsClient) CreateOrUpdatePreparer(ctx context.Con "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -204,7 +204,7 @@ func (client StorageInsightConfigsClient) DeletePreparer(ctx context.Context, re "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -294,7 +294,7 @@ func (client StorageInsightConfigsClient) GetPreparer(ctx context.Context, resou "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -387,7 +387,7 @@ func (client StorageInsightConfigsClient) ListByWorkspacePreparer(ctx context.Co "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/tables.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/tables.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/tables.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/tables.go index 08a7b9c74101..cc773725b2a3 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/tables.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/tables.go @@ -102,7 +102,7 @@ func (client TablesClient) GetPreparer(ctx context.Context, resourceGroupName st "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -191,7 +191,7 @@ func (client TablesClient) ListByWorkspacePreparer(ctx context.Context, resource "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -283,7 +283,7 @@ func (client TablesClient) UpdatePreparer(ctx context.Context, resourceGroupName "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/usages.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/usages.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/usages.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/usages.go index ef6da64d4689..92022a75ed15 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/usages.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/usages.go @@ -100,7 +100,7 @@ func (client UsagesClient) ListPreparer(ctx context.Context, resourceGroupName s "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/version.go similarity index 98% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/version.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/version.go index d1385fe5cc8a..537f9b1cc642 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/version.go @@ -21,7 +21,7 @@ import "github.com/Azure/azure-sdk-for-go/version" // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/" + Version() + " operationalinsights/2020-03-01-preview" + return "Azure-SDK-For-Go/" + Version() + " operationalinsights/2020-08-01" } // Version returns the semantic version (see http://semver.org) of the client. diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/workspacepurge.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/workspacepurge.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/workspacepurge.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/workspacepurge.go index 051f12f629b2..d467385e045a 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/workspacepurge.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/workspacepurge.go @@ -102,7 +102,7 @@ func (client WorkspacePurgeClient) GetPurgeStatusPreparer(ctx context.Context, r "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -200,7 +200,7 @@ func (client WorkspacePurgeClient) PurgePreparer(ctx context.Context, resourceGr "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/workspaces.go b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/workspaces.go similarity index 98% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/workspaces.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/workspaces.go index 47925ba78da8..040f896bf159 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/workspaces.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights/workspaces.go @@ -71,7 +71,7 @@ func (client WorkspacesClient) CreateOrUpdate(ctx context.Context, resourceGroup Constraints: []validation.Constraint{{Target: "parameters.WorkspaceProperties", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.WorkspaceProperties.RetentionInDays", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.WorkspaceProperties.RetentionInDays", Name: validation.InclusiveMaximum, Rule: int64(730), Chain: nil}, - {Target: "parameters.WorkspaceProperties.RetentionInDays", Name: validation.InclusiveMinimum, Rule: int64(-1), Chain: nil}, + {Target: "parameters.WorkspaceProperties.RetentionInDays", Name: validation.InclusiveMinimum, Rule: int64(30), Chain: nil}, }}, }}}}, {TargetValue: client.SubscriptionID, @@ -102,7 +102,7 @@ func (client WorkspacesClient) CreateOrUpdatePreparer(ctx context.Context, resou "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -197,7 +197,7 @@ func (client WorkspacesClient) DeletePreparer(ctx context.Context, resourceGroup "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -294,7 +294,7 @@ func (client WorkspacesClient) GetPreparer(ctx context.Context, resourceGroupNam "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -370,7 +370,7 @@ func (client WorkspacesClient) ListPreparer(ctx context.Context) (*http.Request, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -453,7 +453,7 @@ func (client WorkspacesClient) ListByResourceGroupPreparer(ctx context.Context, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -543,7 +543,7 @@ func (client WorkspacesClient) UpdatePreparer(ctx context.Context, resourceGroup "workspaceName": autorest.Encode("path", workspaceName), } - const APIVersion = "2020-03-01-preview" + const APIVersion = "2020-08-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/datacollectorlogs.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/datacollectorlogs.go deleted file mode 100644 index c0df602a0a85..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights/datacollectorlogs.go +++ /dev/null @@ -1,331 +0,0 @@ -package operationalinsights - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// DataCollectorLogsClient is the operational Insights Client -type DataCollectorLogsClient struct { - BaseClient -} - -// NewDataCollectorLogsClient creates an instance of the DataCollectorLogsClient client. -func NewDataCollectorLogsClient(subscriptionID string) DataCollectorLogsClient { - return NewDataCollectorLogsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewDataCollectorLogsClientWithBaseURI creates an instance of the DataCollectorLogsClient client using a custom -// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure -// stack). -func NewDataCollectorLogsClientWithBaseURI(baseURI string, subscriptionID string) DataCollectorLogsClient { - return DataCollectorLogsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// Delete deletes a specify data collector log table. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// workspaceName - the name of the workspace. -// tableName - dataCollector table name. -// force - when true, enables bypassing retention validation. -func (client DataCollectorLogsClient) Delete(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, force *bool) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectorLogsClient.Delete") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: workspaceName, - Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, - {Target: "workspaceName", Name: validation.MinLength, Rule: 4, Chain: nil}, - {Target: "workspaceName", Name: validation.Pattern, Rule: `^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$`, Chain: nil}}}, - {TargetValue: tableName, - Constraints: []validation.Constraint{{Target: "tableName", Name: validation.MaxLength, Rule: 63, Chain: nil}, - {Target: "tableName", Name: validation.MinLength, Rule: 4, Chain: nil}, - {Target: "tableName", Name: validation.Pattern, Rule: `^[A-Za-z0-9]+[A-Za-z0-9]_CL$`, Chain: nil}}}, - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("operationalinsights.DataCollectorLogsClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, workspaceName, tableName, force) - if err != nil { - err = autorest.NewErrorWithError(err, "operationalinsights.DataCollectorLogsClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "operationalinsights.DataCollectorLogsClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "operationalinsights.DataCollectorLogsClient", "Delete", resp, "Failure responding to request") - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client DataCollectorLogsClient) DeletePreparer(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, force *bool) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "tableName": autorest.Encode("path", tableName), - "workspaceName": autorest.Encode("path", workspaceName), - } - - const APIVersion = "2020-03-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if force != nil { - queryParameters["force"] = autorest.Encode("query", *force) - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataCollectorLogs/{tableName}", 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 DataCollectorLogsClient) DeleteSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client DataCollectorLogsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get retrieves a specify data collector log table. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// workspaceName - the name of the workspace. -// tableName - dataCollector table name. -// force - when true, enables bypassing retention validation. -func (client DataCollectorLogsClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, force *bool) (result DataCollectorLog, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectorLogsClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: workspaceName, - Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, - {Target: "workspaceName", Name: validation.MinLength, Rule: 4, Chain: nil}, - {Target: "workspaceName", Name: validation.Pattern, Rule: `^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$`, Chain: nil}}}, - {TargetValue: tableName, - Constraints: []validation.Constraint{{Target: "tableName", Name: validation.MaxLength, Rule: 63, Chain: nil}, - {Target: "tableName", Name: validation.MinLength, Rule: 4, Chain: nil}, - {Target: "tableName", Name: validation.Pattern, Rule: `^[A-Za-z0-9]+[A-Za-z0-9]_CL$`, Chain: nil}}}, - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("operationalinsights.DataCollectorLogsClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, workspaceName, tableName, force) - if err != nil { - err = autorest.NewErrorWithError(err, "operationalinsights.DataCollectorLogsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "operationalinsights.DataCollectorLogsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "operationalinsights.DataCollectorLogsClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client DataCollectorLogsClient) GetPreparer(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, force *bool) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "tableName": autorest.Encode("path", tableName), - "workspaceName": autorest.Encode("path", workspaceName), - } - - const APIVersion = "2020-03-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if force != nil { - queryParameters["force"] = autorest.Encode("query", *force) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataCollectorLogs/{tableName}", 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 DataCollectorLogsClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client DataCollectorLogsClient) GetResponder(resp *http.Response) (result DataCollectorLog, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListByWorkspace listing all data collector log tables, being created via data collector endpoint and scoped to the -// specified workspace -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// workspaceName - the name of the workspace. -func (client DataCollectorLogsClient) ListByWorkspace(ctx context.Context, resourceGroupName string, workspaceName string) (result DataCollectorLogsListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectorLogsClient.ListByWorkspace") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: workspaceName, - Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, - {Target: "workspaceName", Name: validation.MinLength, Rule: 4, Chain: nil}, - {Target: "workspaceName", Name: validation.Pattern, Rule: `^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("operationalinsights.DataCollectorLogsClient", "ListByWorkspace", err.Error()) - } - - req, err := client.ListByWorkspacePreparer(ctx, resourceGroupName, workspaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "operationalinsights.DataCollectorLogsClient", "ListByWorkspace", nil, "Failure preparing request") - return - } - - resp, err := client.ListByWorkspaceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "operationalinsights.DataCollectorLogsClient", "ListByWorkspace", resp, "Failure sending request") - return - } - - result, err = client.ListByWorkspaceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "operationalinsights.DataCollectorLogsClient", "ListByWorkspace", resp, "Failure responding to request") - } - - return -} - -// ListByWorkspacePreparer prepares the ListByWorkspace request. -func (client DataCollectorLogsClient) ListByWorkspacePreparer(ctx context.Context, resourceGroupName string, workspaceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "workspaceName": autorest.Encode("path", workspaceName), - } - - const APIVersion = "2020-03-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataCollectorLogs", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListByWorkspaceSender sends the ListByWorkspace request. The method will close the -// http.Response Body if it receives an error. -func (client DataCollectorLogsClient) ListByWorkspaceSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListByWorkspaceResponder handles the response to the ListByWorkspace request. The method always -// closes the http.Response Body. -func (client DataCollectorLogsClient) ListByWorkspaceResponder(resp *http.Response) (result DataCollectorLogsListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/modules.txt b/vendor/modules.txt index fb9d60b5d1a2..fba991128265 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -54,6 +54,7 @@ github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp github.com/Azure/azure-sdk-for-go/services/network/mgmt/2020-03-01/network github.com/Azure/azure-sdk-for-go/services/network/mgmt/2020-05-01/network github.com/Azure/azure-sdk-for-go/services/notificationhubs/mgmt/2017-04-01/notificationhubs +github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2020-01-01/postgresql github.com/Azure/azure-sdk-for-go/services/powerbidedicated/mgmt/2017-10-01/powerbidedicated github.com/Azure/azure-sdk-for-go/services/preview/alertsmanagement/mgmt/2019-06-01-preview/alertsmanagement @@ -73,7 +74,6 @@ github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-p github.com/Azure/azure-sdk-for-go/services/preview/mixedreality/mgmt/2019-02-28/mixedreality github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2019-06-01/insights github.com/Azure/azure-sdk-for-go/services/preview/msi/mgmt/2015-08-31-preview/msi -github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2020-03-01-preview/operationalinsights github.com/Azure/azure-sdk-for-go/services/preview/operationsmanagement/mgmt/2015-11-01-preview/operationsmanagement github.com/Azure/azure-sdk-for-go/services/preview/policyinsights/mgmt/2019-10-01-preview/policyinsights github.com/Azure/azure-sdk-for-go/services/preview/portal/mgmt/2019-01-01-preview/portal