From 78cca50cc7f505e09d10b726c657d2218fb41ce8 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Wed, 13 Sep 2017 10:16:09 +0900 Subject: [PATCH 01/27] Adding operationalinsight workspace --- azurerm/config.go | 9 + ..._arm_operational_insight_workspace_test.go | 56 ++ azurerm/provider.go | 42 +- ...ource_arm_operational_insight_workspace.go | 224 +++++ ..._arm_operational_insight_workspace_test.go | 166 ++++ .../github.com/Azure/azure-sdk-for-go/NOTICE | 5 + .../arm/operationalinsights/client.go | 53 ++ .../arm/operationalinsights/datasources.go | 380 ++++++++ .../arm/operationalinsights/linkedservices.go | 354 ++++++++ .../arm/operationalinsights/models.go | 285 ++++++ .../arm/operationalinsights/version.go | 28 + .../arm/operationalinsights/workspaces.go | 858 ++++++++++++++++++ vendor/vendor.json | 6 + 13 files changed, 2446 insertions(+), 20 deletions(-) create mode 100644 azurerm/import_arm_operational_insight_workspace_test.go create mode 100644 azurerm/resource_arm_operational_insight_workspace.go create mode 100644 azurerm/resource_arm_operational_insight_workspace_test.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/NOTICE create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/client.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/datasources.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/linkedservices.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/models.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/version.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/workspaces.go diff --git a/azurerm/config.go b/azurerm/config.go index 4688ebc5911b..8d474ba78ec9 100644 --- a/azurerm/config.go +++ b/azurerm/config.go @@ -19,6 +19,7 @@ import ( "github.com/Azure/azure-sdk-for-go/arm/graphrbac" "github.com/Azure/azure-sdk-for-go/arm/keyvault" "github.com/Azure/azure-sdk-for-go/arm/network" + "github.com/Azure/azure-sdk-for-go/arm/operationalinsights" "github.com/Azure/azure-sdk-for-go/arm/redis" "github.com/Azure/azure-sdk-for-go/arm/resources/resources" "github.com/Azure/azure-sdk-for-go/arm/scheduler" @@ -87,6 +88,8 @@ type ArmClient struct { eventHubConsumerGroupClient eventhub.ConsumerGroupsClient eventHubNamespacesClient eventhub.NamespacesClient + workspacesClient operationalinsights.WorkspacesClient + providers resources.ProvidersClient resourceGroupClient resources.GroupsClient tagsClient resources.TagsClient @@ -334,6 +337,12 @@ func (c *Config) getArmClient() (*ArmClient, error) { lgc.Sender = autorest.CreateSender(withRequestLogging()) client.localNetConnClient = lgc + opwc := operationalinsights.NewWorkspacesClient(c.SubscriptionID) + setUserAgent(&opwc.Client) + opwc.Authorizer = auth + opwc.Sender = autorest.CreateSender(withRequestLogging()) + client.workspacesClient = opwc + pipc := network.NewPublicIPAddressesClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&pipc.Client) pipc.Authorizer = auth diff --git a/azurerm/import_arm_operational_insight_workspace_test.go b/azurerm/import_arm_operational_insight_workspace_test.go new file mode 100644 index 000000000000..a6beb40abc1c --- /dev/null +++ b/azurerm/import_arm_operational_insight_workspace_test.go @@ -0,0 +1,56 @@ +package azurerm + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAzureRMOperationalInsightWorkspace_importrequiredOnly(t *testing.T) { + resourceName := "azurerm_operational_insight_workspace.test" + + ri := acctest.RandInt() + config := testAccAzureRMOperationalInsightWorkspace_requiredOnly(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMOperationalInsightWorkspaceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMOperationalInsightWorkspace_importoptional(t *testing.T) { + resourceName := "azurerm_operational_insight_workspace.test" + + ri := acctest.RandInt() + config := testAccAzureRMOperationalInsightWorkspace_optional(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMOperationalInsightWorkspaceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} diff --git a/azurerm/provider.go b/azurerm/provider.go index fd6479914aa7..45644f227fd8 100644 --- a/azurerm/provider.go +++ b/azurerm/provider.go @@ -104,11 +104,12 @@ func Provider() terraform.ResourceProvider { "azurerm_lb_rule": resourceArmLoadBalancerRule(), "azurerm_local_network_gateway": resourceArmLocalNetworkGateway(), - "azurerm_managed_disk": resourceArmManagedDisk(), - "azurerm_network_interface": resourceArmNetworkInterface(), - "azurerm_network_security_group": resourceArmNetworkSecurityGroup(), - "azurerm_network_security_rule": resourceArmNetworkSecurityRule(), - "azurerm_public_ip": resourceArmPublicIp(), + "azurerm_managed_disk": resourceArmManagedDisk(), + "azurerm_network_interface": resourceArmNetworkInterface(), + "azurerm_network_security_group": resourceArmNetworkSecurityGroup(), + "azurerm_network_security_rule": resourceArmNetworkSecurityRule(), + "azurerm_operational_insight_workspace": resourceArmOperationalInsightWorkspaceService(), + "azurerm_public_ip": resourceArmPublicIp(), "azurerm_redis_cache": resourceArmRedisCache(), "azurerm_route": resourceArmRoute(), @@ -254,21 +255,22 @@ func registerAzureResourceProvidersWithSubscription(providerList []resources.Pro var err error providerRegistrationOnce.Do(func() { providers := map[string]struct{}{ - "Microsoft.Cache": struct{}{}, - "Microsoft.Cdn": struct{}{}, - "Microsoft.Compute": struct{}{}, - "Microsoft.ContainerRegistry": struct{}{}, - "Microsoft.ContainerService": struct{}{}, - "Microsoft.DocumentDB": struct{}{}, - "Microsoft.EventHub": struct{}{}, - "Microsoft.KeyVault": struct{}{}, - "Microsoft.Insights": struct{}{}, - "Microsoft.Network": struct{}{}, - "Microsoft.Resources": struct{}{}, - "Microsoft.Search": struct{}{}, - "Microsoft.ServiceBus": struct{}{}, - "Microsoft.Sql": struct{}{}, - "Microsoft.Storage": struct{}{}, + "Microsoft.Cache": struct{}{}, + "Microsoft.Cdn": struct{}{}, + "Microsoft.Compute": struct{}{}, + "Microsoft.ContainerRegistry": struct{}{}, + "Microsoft.ContainerService": struct{}{}, + "Microsoft.DocumentDB": struct{}{}, + "Microsoft.EventHub": struct{}{}, + "Microsoft.KeyVault": struct{}{}, + "Microsoft.Insights": struct{}{}, + "Microsoft.Network": struct{}{}, + "Microsoft.OperationalInsights": struct{}{}, + "Microsoft.Resources": struct{}{}, + "Microsoft.Search": struct{}{}, + "Microsoft.ServiceBus": struct{}{}, + "Microsoft.Sql": struct{}{}, + "Microsoft.Storage": struct{}{}, } // filter out any providers already registered diff --git a/azurerm/resource_arm_operational_insight_workspace.go b/azurerm/resource_arm_operational_insight_workspace.go new file mode 100644 index 000000000000..277729f46922 --- /dev/null +++ b/azurerm/resource_arm_operational_insight_workspace.go @@ -0,0 +1,224 @@ +package azurerm + +import ( + "fmt" + "log" + "net/http" + "regexp" + + "github.com/Azure/azure-sdk-for-go/arm/operationalinsights" + "github.com/hashicorp/terraform/helper/schema" +) + +func resourceArmOperationalInsightWorkspaceService() *schema.Resource { + return &schema.Resource{ + Create: resourceArmOperationalInsightWorkspaceCreateUpdate, + Read: resourceArmOperationalInsightWorkspaceRead, + Update: resourceArmOperationalInsightWorkspaceCreateUpdate, + Delete: resourceArmOperationalInsightWorkspaceDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validateAzureRmOperationalInsightWorkspaceName, + }, + "location": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + StateFunc: azureRMNormalizeLocation, + }, + "resource_group_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "workspace_id": { // a.k.a. customer_id + Type: schema.TypeString, + Computed: true, + }, + "portal_url": { + Type: schema.TypeString, + Computed: true, + }, + "sku": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "retention_in_days": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + "primary_shared_key": { + Type: schema.TypeString, + Computed: true, + }, + "secondary_shared_key": { + Type: schema.TypeString, + Computed: true, + }, + "tags": tagsSchema(), + }, + } +} + +func resourceArmOperationalInsightWorkspaceCreateUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).workspacesClient + log.Printf("[INFO] preparing arguments for AzureRM Operational Insight workspace creation.") + + name := d.Get("name").(string) + location := d.Get("location").(string) + resGroup := d.Get("resource_group_name").(string) + + skuName := d.Get("sku") + sku, err := getSku(skuName) + if err != nil { + return err + } + + retentionInDays := int32(d.Get("retention_in_days").(int)) + + tags := d.Get("tags").(map[string]interface{}) + + parameters := operationalinsights.Workspace{ + Name: &name, + Location: &location, + Tags: expandTags(tags), + WorkspaceProperties: &operationalinsights.WorkspaceProperties{ + Sku: sku, + RetentionInDays: &retentionInDays, + }, + } + + cancel := make(chan struct{}) + workspaceChannel, error := client.CreateOrUpdate(resGroup, name, parameters, cancel) + workspace := <-workspaceChannel + err = <-error + if err != nil { + return err + } + // The cosmos DB read rest api again for getting id. Try remove it. + // read, err := client.Get(resGroup, name) + // if err != nil { + // return err + //} + + //if read.ID == nil { + // return fmt.Errorf("Cannot read Operational Inight Workspace '%s' (resource group %s) ID", name, resGroup) + //} + d.SetId(*workspace.ID) + + return resourceArmOperationalInsightWorkspaceRead(d, meta) + +} + +func resourceArmOperationalInsightWorkspaceRead(d *schema.ResourceData, meta interface{}) error { + // I don't understand why we can get the meta data. How the framework set it. + client := meta.(*ArmClient).workspacesClient + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + resGroup := id.ResourceGroup + name := id.Path["workspaces"] + + resp, err := client.Get(resGroup, name) + if err != nil { + if responseWasNotFound(resp.Response) { + d.SetId("") + return nil + } + return fmt.Errorf("Error making Read request on AzureRM Operational Insight workspaces '%s': %s", name, err) + } + + d.Set("name", resp.Name) + d.Set("location", resp.Location) + d.Set("resource_group_name", resGroup) + d.Set("workspace_id", resp.CustomerID) + d.Set("portal_url", resp.PortalURL) + d.Set("sku", resp.Sku.Name) + d.Set("retention_in_days", resp.RetentionInDays) + + sharedKeys, err := client.GetSharedKeys(resGroup, name) + if err != nil { + log.Printf("[ERROR] Unable to List Shared keys for Operatinal Insight workspaces %s: %s", name, err) + } else { + d.Set("primary_shared_key", sharedKeys.PrimarySharedKey) + d.Set("secondary_shared_key", sharedKeys.SecondarySharedKey) + } + + flattenAndSetTags(d, resp.Tags) + return nil +} + +func resourceArmOperationalInsightWorkspaceDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).workspacesClient + + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + resGroup := id.ResourceGroup + name := id.Path["workspaces"] + + resp, err := client.Delete(resGroup, name) + + if err != nil { + if resp.StatusCode == http.StatusNotFound { + return nil + } + + return fmt.Errorf("Error issuing AzureRM delete request for Operational Insight Workspaces '%s': %+v", name, err) + } + + return nil +} + +func getSku(skuName interface{}) (*operationalinsights.Sku, error) { + if skuName == nil { + return nil, nil + } + skuEnum, err := getSkuNameEnum(skuName.(string)) + if err != nil { + return nil, err + } + return &operationalinsights.Sku{ + Name: skuEnum, + }, nil +} + +func getSkuNameEnum(skuName string) (operationalinsights.SkuNameEnum, error) { + switch skuName { + case "Free": + return operationalinsights.Free, nil + case "PerNode": + return operationalinsights.PerNode, nil + case "Premium": + return operationalinsights.Premium, nil + case "Standalone": + return operationalinsights.Standalone, nil + case "Standard": + return operationalinsights.Standard, nil + case "Unlimited": + return operationalinsights.Unlimited, nil + default: + return operationalinsights.Free, fmt.Errorf("Sku name not found") + } +} + +func validateAzureRmOperationalInsightWorkspaceName(v interface{}, k string) (ws []string, errors []error) { + value := v.(string) + + r, _ := regexp.Compile("^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$") + if !r.MatchString(value) { + errors = append(errors, fmt.Errorf("Workspace Name can only contain alphabet, number, and '-' charactor. You can not use '-' as the start and end of the name.")) + } + return +} diff --git a/azurerm/resource_arm_operational_insight_workspace_test.go b/azurerm/resource_arm_operational_insight_workspace_test.go new file mode 100644 index 000000000000..0328be9eaeee --- /dev/null +++ b/azurerm/resource_arm_operational_insight_workspace_test.go @@ -0,0 +1,166 @@ +package azurerm + +import ( + "fmt" + "net/http" + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/terraform" +) + +func TestAccAzureRmOperationalInsightWorkspaceName_validation(t *testing.T) { + cases := []struct { + Value string + ErrCount int + }{ + { + Value: "ab", + ErrCount: 1, + }, + { + Value: "Ab-c", + ErrCount: 0, + }, + { + Value: "-ab", + ErrCount: 1, + }, + { + Value: "ab-", + ErrCount: 1, + }, + } + + for _, tc := range cases { + _, errors := validateAzureRmOperationalInsightWorkspaceName(tc.Value, "azurerm_operational_insight_workspace") + + if len(errors) != tc.ErrCount { + t.Fatalf("Expected the AzureRM Operational Insight Workspace Name to trigger a validation error for '%s'", tc.Value) + } + } +} + +func TestAccAzureRMOperationalInsightWorkspace_requiredOnly(t *testing.T) { + ri := acctest.RandInt() + config := testAccAzureRMOperationalInsightWorkspace_requiredOnly(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMOperationalInsightWorkspaceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMOperationalInsightWorkspaceExists("azurerm_operational_insight_workspace.test"), + ), + }, + }, + }) +} +func TestAccAzureRMOperationalInsightWorkspace_optional(t *testing.T) { + ri := acctest.RandInt() + config := testAccAzureRMOperationalInsightWorkspace_optional(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMOperationalInsightWorkspaceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMOperationalInsightWorkspaceExists("azurerm_operational_insight_workspace.test"), + ), + }, + }, + }) +} + +func testCheckAzureRMOperationalInsightWorkspaceDestroy(s *terraform.State) error { + conn := testAccProvider.Meta().(*ArmClient).workspacesClient + + for _, rs := range s.RootModule().Resources { + if rs.Type != "azurerm_operational_insight_workspace" { + continue + } + + name := rs.Primary.Attributes["name"] + resourceGroup := rs.Primary.Attributes["resource_group_name"] + + resp, err := conn.Get(resourceGroup, name) + + if err != nil { + return nil + } + + if resp.StatusCode != http.StatusNotFound { + return fmt.Errorf("OperationalInsight Workspace still exists:\n%#v", resp) + } + } + + return nil +} + +func testCheckAzureRMOperationalInsightWorkspaceExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + // Ensure we have enough information in state to look up in API + rs, ok := s.RootModule().Resources[name] + if !ok { + return fmt.Errorf("Not found: %s", name) + } + + name := rs.Primary.Attributes["name"] + resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] + if !hasResourceGroup { + return fmt.Errorf("Bad: no resource group found in state for OperationalInsight Workspace: '%s'", name) + } + + conn := testAccProvider.Meta().(*ArmClient).workspacesClient + + resp, err := conn.Get(resourceGroup, name) + if err != nil { + return fmt.Errorf("Bad: Get on OperationalInsight Workspace Client: %+v", err) + } + + if resp.StatusCode == http.StatusNotFound { + return fmt.Errorf("Bad: OperationalInsight Workspace '%s' (resource group: '%s') does not exist", name, resourceGroup) + } + + return nil + } +} + +func testAccAzureRMOperationalInsightWorkspace_requiredOnly(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_operational_insight_workspace" "test" { + name = "acctest-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" +} +`, rInt, location, rInt) +} + +func testAccAzureRMOperationalInsightWorkspace_optional(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_operational_insight_workspace" "test" { + name = "acctest-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + sku = "Standard" + retention_in_days = 5 +} +`, rInt, location, rInt) +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/NOTICE b/vendor/github.com/Azure/azure-sdk-for-go/NOTICE new file mode 100644 index 000000000000..2d1d72608c28 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/NOTICE @@ -0,0 +1,5 @@ +Microsoft Azure-SDK-for-Go +Copyright 2014-2017 Microsoft + +This product includes software developed at +the Microsoft Corporation (https://www.microsoft.com). diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/client.go new file mode 100755 index 000000000000..a42ac00b4574 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/client.go @@ -0,0 +1,53 @@ +// Package operationalinsights implements the Azure ARM Operationalinsights +// service API version 2015-11-01-preview. +// +// Azure Log Analytics API reference +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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Operationalinsights + DefaultBaseURI = "https://management.azure.com" +) + +// ManagementClient is the base client for Operationalinsights. +type ManagementClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the ManagementClient client. +func New(subscriptionID string) ManagementClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the ManagementClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { + return ManagementClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/datasources.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/datasources.go new file mode 100755 index 000000000000..0a0653d0f749 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/datasources.go @@ -0,0 +1,380 @@ +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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// DataSourcesClient is the azure Log Analytics API reference +type DataSourcesClient struct { + ManagementClient +} + +// NewDataSourcesClient creates an instance of the DataSourcesClient client. +func NewDataSourcesClient(subscriptionID string) DataSourcesClient { + return NewDataSourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDataSourcesClientWithBaseURI creates an instance of the DataSourcesClient +// client. +func NewDataSourcesClientWithBaseURI(baseURI string, subscriptionID string) DataSourcesClient { + return DataSourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update a data source. +// +// resourceGroupName is the name of the resource group to get. The name is case +// insensitive. workspaceName is name of the Log Analytics Workspace that will +// contain the datasource dataSourceName is the name of the datasource +// resource. parameters is the parameters required to create or update a +// datasource. +func (client DataSourcesClient) CreateOrUpdate(resourceGroupName string, workspaceName string, dataSourceName string, parameters DataSource) (result DataSource, err error) { + 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: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "operationalinsights.DataSourcesClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, workspaceName, dataSourceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.DataSourcesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "operationalinsights.DataSourcesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.DataSourcesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DataSourcesClient) CreateOrUpdatePreparer(resourceGroupName string, workspaceName string, dataSourceName string, parameters DataSource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dataSourceName": autorest.Encode("path", dataSourceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2015-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DataSourcesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DataSourcesClient) CreateOrUpdateResponder(resp *http.Response) (result DataSource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a data source instance. +// +// resourceGroupName is the name of the resource group to get. The name is case +// insensitive. workspaceName is name of the Log Analytics Workspace that +// contains the datasource. dataSourceName is name of the datasource. +func (client DataSourcesClient) Delete(resourceGroupName string, workspaceName string, dataSourceName string) (result autorest.Response, err error) { + 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}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "operationalinsights.DataSourcesClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, workspaceName, dataSourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.DataSourcesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "operationalinsights.DataSourcesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.DataSourcesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DataSourcesClient) DeletePreparer(resourceGroupName string, workspaceName string, dataSourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dataSourceName": autorest.Encode("path", dataSourceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2015-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DataSourcesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DataSourcesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a datasource instance. +// +// resourceGroupName is the name of the resource group to get. The name is case +// insensitive. workspaceName is name of the Log Analytics Workspace that +// contains the datasource. dataSourceName is name of the datasource +func (client DataSourcesClient) Get(resourceGroupName string, workspaceName string, dataSourceName string) (result DataSource, err error) { + 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}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "operationalinsights.DataSourcesClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, workspaceName, dataSourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.DataSourcesClient", "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.DataSourcesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.DataSourcesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DataSourcesClient) GetPreparer(resourceGroupName string, workspaceName string, dataSourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dataSourceName": autorest.Encode("path", dataSourceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2015-11-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}/dataSources/{dataSourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DataSourcesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DataSourcesClient) GetResponder(resp *http.Response) (result DataSource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByWorkspace gets the first page of data source instances in a workspace +// with the link to the next page. +// +// resourceGroupName is the name of the resource group to get. The name is case +// insensitive. workspaceName is the workspace that contains the data sources. +// filter is the filter to apply on the operation. skiptoken is starting point +// of the collection of data source instances. +func (client DataSourcesClient) ListByWorkspace(resourceGroupName string, workspaceName string, filter string, skiptoken string) (result DataSourceListResult, err error) { + 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}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "operationalinsights.DataSourcesClient", "ListByWorkspace") + } + + req, err := client.ListByWorkspacePreparer(resourceGroupName, workspaceName, filter, skiptoken) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.DataSourcesClient", "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.DataSourcesClient", "ListByWorkspace", resp, "Failure sending request") + return + } + + result, err = client.ListByWorkspaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.DataSourcesClient", "ListByWorkspace", resp, "Failure responding to request") + } + + return +} + +// ListByWorkspacePreparer prepares the ListByWorkspace request. +func (client DataSourcesClient) ListByWorkspacePreparer(resourceGroupName string, workspaceName string, filter string, skiptoken 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 = "2015-11-01-preview" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByWorkspaceSender sends the ListByWorkspace request. The method will close the +// http.Response Body if it receives an error. +func (client DataSourcesClient) ListByWorkspaceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByWorkspaceResponder handles the response to the ListByWorkspace request. The method always +// closes the http.Response Body. +func (client DataSourcesClient) ListByWorkspaceResponder(resp *http.Response) (result DataSourceListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByWorkspaceNextResults retrieves the next set of results, if any. +func (client DataSourcesClient) ListByWorkspaceNextResults(lastResults DataSourceListResult) (result DataSourceListResult, err error) { + req, err := lastResults.DataSourceListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "operationalinsights.DataSourcesClient", "ListByWorkspace", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByWorkspaceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "operationalinsights.DataSourcesClient", "ListByWorkspace", resp, "Failure sending next results request") + } + + result, err = client.ListByWorkspaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.DataSourcesClient", "ListByWorkspace", resp, "Failure responding to next results request") + } + + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/linkedservices.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/linkedservices.go new file mode 100755 index 000000000000..c7ef6756279e --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/linkedservices.go @@ -0,0 +1,354 @@ +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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// LinkedServicesClient is the azure Log Analytics API reference +type LinkedServicesClient struct { + ManagementClient +} + +// NewLinkedServicesClient creates an instance of the LinkedServicesClient +// client. +func NewLinkedServicesClient(subscriptionID string) LinkedServicesClient { + return NewLinkedServicesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLinkedServicesClientWithBaseURI creates an instance of the +// LinkedServicesClient client. +func NewLinkedServicesClientWithBaseURI(baseURI string, subscriptionID string) LinkedServicesClient { + return LinkedServicesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update a linked service. +// +// resourceGroupName is the name of the resource group to get. The name is case +// insensitive. workspaceName is name of the Log Analytics Workspace that will +// contain the linkedServices resource linkedServiceName is name of the +// linkedServices resource parameters is the parameters required to create or +// update a linked service. +func (client LinkedServicesClient) CreateOrUpdate(resourceGroupName string, workspaceName string, linkedServiceName string, parameters LinkedService) (result LinkedService, err error) { + 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: parameters, + Constraints: []validation.Constraint{{Target: "parameters.LinkedServiceProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.LinkedServiceProperties.ResourceID", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "operationalinsights.LinkedServicesClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, workspaceName, linkedServiceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.LinkedServicesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "operationalinsights.LinkedServicesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.LinkedServicesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client LinkedServicesClient) CreateOrUpdatePreparer(resourceGroupName string, workspaceName string, linkedServiceName string, parameters LinkedService) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "linkedServiceName": autorest.Encode("path", linkedServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2015-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client LinkedServicesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client LinkedServicesClient) CreateOrUpdateResponder(resp *http.Response) (result LinkedService, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a linked service instance. +// +// resourceGroupName is the name of the resource group to get. The name is case +// insensitive. workspaceName is name of the Log Analytics Workspace that +// contains the linkedServices resource linkedServiceName is name of the linked +// service. +func (client LinkedServicesClient) Delete(resourceGroupName string, workspaceName string, linkedServiceName string) (result autorest.Response, err error) { + 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}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "operationalinsights.LinkedServicesClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, workspaceName, linkedServiceName) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.LinkedServicesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "operationalinsights.LinkedServicesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.LinkedServicesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client LinkedServicesClient) DeletePreparer(resourceGroupName string, workspaceName string, linkedServiceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "linkedServiceName": autorest.Encode("path", linkedServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2015-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client LinkedServicesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client LinkedServicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a linked service instance. +// +// resourceGroupName is the name of the resource group to get. The name is case +// insensitive. workspaceName is name of the Log Analytics Workspace that +// contains the linkedServices resource linkedServiceName is name of the linked +// service. +func (client LinkedServicesClient) Get(resourceGroupName string, workspaceName string, linkedServiceName string) (result LinkedService, err error) { + 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}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "operationalinsights.LinkedServicesClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, workspaceName, linkedServiceName) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.LinkedServicesClient", "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.LinkedServicesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.LinkedServicesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client LinkedServicesClient) GetPreparer(resourceGroupName string, workspaceName string, linkedServiceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "linkedServiceName": autorest.Encode("path", linkedServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2015-11-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}/linkedServices/{linkedServiceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client LinkedServicesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client LinkedServicesClient) GetResponder(resp *http.Response) (result LinkedService, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByWorkspace gets the linked services instances in a workspace. +// +// resourceGroupName is the name of the resource group to get. The name is case +// insensitive. workspaceName is name of the Log Analytics Workspace that +// contains the linked services. +func (client LinkedServicesClient) ListByWorkspace(resourceGroupName string, workspaceName string) (result LinkedServiceListResult, err error) { + 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}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "operationalinsights.LinkedServicesClient", "ListByWorkspace") + } + + req, err := client.ListByWorkspacePreparer(resourceGroupName, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.LinkedServicesClient", "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.LinkedServicesClient", "ListByWorkspace", resp, "Failure sending request") + return + } + + result, err = client.ListByWorkspaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.LinkedServicesClient", "ListByWorkspace", resp, "Failure responding to request") + } + + return +} + +// ListByWorkspacePreparer prepares the ListByWorkspace request. +func (client LinkedServicesClient) ListByWorkspacePreparer(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 = "2015-11-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}/linkedServices", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByWorkspaceSender sends the ListByWorkspace request. The method will close the +// http.Response Body if it receives an error. +func (client LinkedServicesClient) ListByWorkspaceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByWorkspaceResponder handles the response to the ListByWorkspace request. The method always +// closes the http.Response Body. +func (client LinkedServicesClient) ListByWorkspaceResponder(resp *http.Response) (result LinkedServiceListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/models.go new file mode 100755 index 000000000000..b4057b90c808 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/models.go @@ -0,0 +1,285 @@ +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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "net/http" +) + +// DataSourceKind enumerates the values for data source kind. +type DataSourceKind string + +const ( + // AzureActivityLog specifies the azure activity log state for data source + // kind. + AzureActivityLog DataSourceKind = "AzureActivityLog" + // ChangeTrackingCustomRegistry specifies the change tracking custom + // registry state for data source kind. + ChangeTrackingCustomRegistry DataSourceKind = "ChangeTrackingCustomRegistry" + // ChangeTrackingDefaultPath specifies the change tracking default path + // state for data source kind. + ChangeTrackingDefaultPath DataSourceKind = "ChangeTrackingDefaultPath" + // ChangeTrackingDefaultRegistry specifies the change tracking default + // registry state for data source kind. + ChangeTrackingDefaultRegistry DataSourceKind = "ChangeTrackingDefaultRegistry" + // ChangeTrackingPath specifies the change tracking path state for data + // source kind. + ChangeTrackingPath DataSourceKind = "ChangeTrackingPath" + // CustomLog specifies the custom log state for data source kind. + CustomLog DataSourceKind = "CustomLog" + // CustomLogCollection specifies the custom log collection state for data + // source kind. + CustomLogCollection DataSourceKind = "CustomLogCollection" + // GenericDataSource specifies the generic data source state for data + // source kind. + GenericDataSource DataSourceKind = "GenericDataSource" + // IISLogs specifies the iis logs state for data source kind. + IISLogs DataSourceKind = "IISLogs" + // LinuxPerformanceCollection specifies the linux performance collection + // state for data source kind. + LinuxPerformanceCollection DataSourceKind = "LinuxPerformanceCollection" + // LinuxPerformanceObject specifies the linux performance object state for + // data source kind. + LinuxPerformanceObject DataSourceKind = "LinuxPerformanceObject" + // LinuxSyslog specifies the linux syslog state for data source kind. + LinuxSyslog DataSourceKind = "LinuxSyslog" + // LinuxSyslogCollection specifies the linux syslog collection state for + // data source kind. + LinuxSyslogCollection DataSourceKind = "LinuxSyslogCollection" + // WindowsEvent specifies the windows event state for data source kind. + WindowsEvent DataSourceKind = "WindowsEvent" + // WindowsPerformanceCounter specifies the windows performance counter + // state for data source kind. + WindowsPerformanceCounter DataSourceKind = "WindowsPerformanceCounter" +) + +// EntityStatus enumerates the values for entity status. +type EntityStatus string + +const ( + // Canceled specifies the canceled state for entity status. + Canceled EntityStatus = "Canceled" + // Creating specifies the creating state for entity status. + Creating EntityStatus = "Creating" + // Deleting specifies the deleting state for entity status. + Deleting EntityStatus = "Deleting" + // Failed specifies the failed state for entity status. + Failed EntityStatus = "Failed" + // ProvisioningAccount specifies the provisioning account state for entity + // status. + ProvisioningAccount EntityStatus = "ProvisioningAccount" + // Succeeded specifies the succeeded state for entity status. + Succeeded EntityStatus = "Succeeded" +) + +// SkuNameEnum enumerates the values for sku name enum. +type SkuNameEnum string + +const ( + // Free specifies the free state for sku name enum. + Free SkuNameEnum = "Free" + // PerNode specifies the per node state for sku name enum. + PerNode SkuNameEnum = "PerNode" + // Premium specifies the premium state for sku name enum. + Premium SkuNameEnum = "Premium" + // Standalone specifies the standalone state for sku name enum. + Standalone SkuNameEnum = "Standalone" + // Standard specifies the standard state for sku name enum. + Standard SkuNameEnum = "Standard" + // Unlimited specifies the unlimited state for sku name enum. + Unlimited SkuNameEnum = "Unlimited" +) + +// DataSource is datasources under OMS Workspace. +type DataSource struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + Properties *map[string]interface{} `json:"properties,omitempty"` + ETag *string `json:"eTag,omitempty"` + Kind DataSourceKind `json:"kind,omitempty"` +} + +// DataSourceFilter is dataSource filter. Right now, only filter by kind is +// supported. +type DataSourceFilter struct { + Kind DataSourceKind `json:"kind,omitempty"` +} + +// DataSourceListResult is the list data source by workspace operation +// response. +type DataSourceListResult struct { + autorest.Response `json:"-"` + Value *[]DataSource `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// DataSourceListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client DataSourceListResult) DataSourceListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// IntelligencePack is intelligence Pack containing a string name and boolean +// indicating if it's enabled. +type IntelligencePack struct { + Name *string `json:"name,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} + +// LinkedService is the top level Linked service resource container. +type LinkedService struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *LinkedServiceProperties `json:"properties,omitempty"` +} + +// LinkedServiceListResult is the list linked service operation response. +type LinkedServiceListResult struct { + autorest.Response `json:"-"` + Value *[]LinkedService `json:"value,omitempty"` +} + +// LinkedServiceProperties is linked service properties. +type LinkedServiceProperties struct { + ResourceID *string `json:"resourceId,omitempty"` +} + +// ListIntelligencePack is +type ListIntelligencePack struct { + autorest.Response `json:"-"` + Value *[]IntelligencePack `json:"value,omitempty"` +} + +// ManagementGroup is a management group that is connected to a workspace +type ManagementGroup struct { + *ManagementGroupProperties `json:"properties,omitempty"` +} + +// ManagementGroupProperties is management group properties. +type ManagementGroupProperties struct { + ServerCount *int32 `json:"serverCount,omitempty"` + IsGateway *bool `json:"isGateway,omitempty"` + Name *string `json:"name,omitempty"` + ID *string `json:"id,omitempty"` + Created *date.Time `json:"created,omitempty"` + DataReceived *date.Time `json:"dataReceived,omitempty"` + Version *string `json:"version,omitempty"` + Sku *string `json:"sku,omitempty"` +} + +// MetricName is the name of a metric. +type MetricName struct { + Value *string `json:"value,omitempty"` + LocalizedValue *string `json:"localizedValue,omitempty"` +} + +// ProxyResource is common properties of proxy resource. +type ProxyResource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// Resource is the resource definition. +type Resource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// SharedKeys is the shared keys for a workspace. +type SharedKeys struct { + autorest.Response `json:"-"` + PrimarySharedKey *string `json:"primarySharedKey,omitempty"` + SecondarySharedKey *string `json:"secondarySharedKey,omitempty"` +} + +// Sku is the SKU (tier) of a workspace. +type Sku struct { + Name SkuNameEnum `json:"name,omitempty"` +} + +// UsageMetric is a metric describing the usage of a resource. +type UsageMetric struct { + Name *MetricName `json:"name,omitempty"` + Unit *string `json:"unit,omitempty"` + CurrentValue *float64 `json:"currentValue,omitempty"` + Limit *float64 `json:"limit,omitempty"` + NextResetTime *date.Time `json:"nextResetTime,omitempty"` + QuotaPeriod *string `json:"quotaPeriod,omitempty"` +} + +// Workspace is the top level Workspace resource container. +type Workspace struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *WorkspaceProperties `json:"properties,omitempty"` + ETag *string `json:"eTag,omitempty"` +} + +// WorkspaceListManagementGroupsResult is the list workspace managmement groups +// operation response. +type WorkspaceListManagementGroupsResult struct { + autorest.Response `json:"-"` + Value *[]ManagementGroup `json:"value,omitempty"` +} + +// WorkspaceListResult is the list workspaces operation response. +type WorkspaceListResult struct { + autorest.Response `json:"-"` + Value *[]Workspace `json:"value,omitempty"` +} + +// WorkspaceListUsagesResult is the list workspace usages operation response. +type WorkspaceListUsagesResult struct { + autorest.Response `json:"-"` + Value *[]UsageMetric `json:"value,omitempty"` +} + +// WorkspaceProperties is workspace properties. +type WorkspaceProperties struct { + ProvisioningState EntityStatus `json:"provisioningState,omitempty"` + Source *string `json:"source,omitempty"` + CustomerID *string `json:"customerId,omitempty"` + PortalURL *string `json:"portalUrl,omitempty"` + Sku *Sku `json:"sku,omitempty"` + RetentionInDays *int32 `json:"retentionInDays,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/version.go new file mode 100755 index 000000000000..503cc1280862 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/version.go @@ -0,0 +1,28 @@ +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 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/v10.2.0-beta arm-operationalinsights/2015-11-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return "v10.2.0-beta" +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/workspaces.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/workspaces.go new file mode 100755 index 000000000000..be4d9c1f7b69 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/workspaces.go @@ -0,0 +1,858 @@ +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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// WorkspacesClient is the azure Log Analytics API reference +type WorkspacesClient struct { + ManagementClient +} + +// NewWorkspacesClient creates an instance of the WorkspacesClient client. +func NewWorkspacesClient(subscriptionID string) WorkspacesClient { + return NewWorkspacesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWorkspacesClientWithBaseURI creates an instance of the WorkspacesClient +// client. +func NewWorkspacesClientWithBaseURI(baseURI string, subscriptionID string) WorkspacesClient { + return WorkspacesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update a workspace. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// resourceGroupName is the resource group name of the workspace. workspaceName +// is the name of the workspace. parameters is the parameters required to +// create or update a workspace. +func (client WorkspacesClient) CreateOrUpdate(resourceGroupName string, workspaceName string, parameters Workspace, cancel <-chan struct{}) (<-chan Workspace, <-chan error) { + resultChan := make(chan Workspace, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {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: parameters, + 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: 730, Chain: nil}, + {Target: "parameters.WorkspaceProperties.RetentionInDays", Name: validation.InclusiveMinimum, Rule: -1, Chain: nil}, + }}, + }}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "operationalinsights.WorkspacesClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Workspace + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, workspaceName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client WorkspacesClient) CreateOrUpdatePreparer(resourceGroupName string, workspaceName string, parameters Workspace, cancel <-chan struct{}) (*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 = "2015-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client WorkspacesClient) CreateOrUpdateResponder(resp *http.Response) (result Workspace, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a workspace instance. +// +// resourceGroupName is the resource group name of the workspace. workspaceName +// is name of the Log Analytics Workspace. +func (client WorkspacesClient) Delete(resourceGroupName string, workspaceName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client WorkspacesClient) DeletePreparer(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 = "2015-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WorkspacesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DisableIntelligencePack disables an intelligence pack for a given workspace. +// +// resourceGroupName is the name of the resource group to get. The name is case +// insensitive. workspaceName is name of the Log Analytics Workspace. +// intelligencePackName is the name of the intelligence pack to be disabled. +func (client WorkspacesClient) DisableIntelligencePack(resourceGroupName string, workspaceName string, intelligencePackName string) (result autorest.Response, err error) { + 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}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "operationalinsights.WorkspacesClient", "DisableIntelligencePack") + } + + req, err := client.DisableIntelligencePackPreparer(resourceGroupName, workspaceName, intelligencePackName) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "DisableIntelligencePack", nil, "Failure preparing request") + return + } + + resp, err := client.DisableIntelligencePackSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "DisableIntelligencePack", resp, "Failure sending request") + return + } + + result, err = client.DisableIntelligencePackResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "DisableIntelligencePack", resp, "Failure responding to request") + } + + return +} + +// DisableIntelligencePackPreparer prepares the DisableIntelligencePack request. +func (client WorkspacesClient) DisableIntelligencePackPreparer(resourceGroupName string, workspaceName string, intelligencePackName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "intelligencePackName": autorest.Encode("path", intelligencePackName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2015-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks/{intelligencePackName}/Disable", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DisableIntelligencePackSender sends the DisableIntelligencePack request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacesClient) DisableIntelligencePackSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DisableIntelligencePackResponder handles the response to the DisableIntelligencePack request. The method always +// closes the http.Response Body. +func (client WorkspacesClient) DisableIntelligencePackResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// EnableIntelligencePack enables an intelligence pack for a given workspace. +// +// resourceGroupName is the name of the resource group to get. The name is case +// insensitive. workspaceName is name of the Log Analytics Workspace. +// intelligencePackName is the name of the intelligence pack to be enabled. +func (client WorkspacesClient) EnableIntelligencePack(resourceGroupName string, workspaceName string, intelligencePackName string) (result autorest.Response, err error) { + 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}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "operationalinsights.WorkspacesClient", "EnableIntelligencePack") + } + + req, err := client.EnableIntelligencePackPreparer(resourceGroupName, workspaceName, intelligencePackName) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "EnableIntelligencePack", nil, "Failure preparing request") + return + } + + resp, err := client.EnableIntelligencePackSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "EnableIntelligencePack", resp, "Failure sending request") + return + } + + result, err = client.EnableIntelligencePackResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "EnableIntelligencePack", resp, "Failure responding to request") + } + + return +} + +// EnableIntelligencePackPreparer prepares the EnableIntelligencePack request. +func (client WorkspacesClient) EnableIntelligencePackPreparer(resourceGroupName string, workspaceName string, intelligencePackName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "intelligencePackName": autorest.Encode("path", intelligencePackName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2015-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks/{intelligencePackName}/Enable", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// EnableIntelligencePackSender sends the EnableIntelligencePack request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacesClient) EnableIntelligencePackSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// EnableIntelligencePackResponder handles the response to the EnableIntelligencePack request. The method always +// closes the http.Response Body. +func (client WorkspacesClient) EnableIntelligencePackResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a workspace instance. +// +// resourceGroupName is the resource group name of the workspace. workspaceName +// is name of the Log Analytics Workspace. +func (client WorkspacesClient) Get(resourceGroupName string, workspaceName string) (result Workspace, err error) { + req, err := client.GetPreparer(resourceGroupName, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "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.WorkspacesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client WorkspacesClient) GetPreparer(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 = "2015-11-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}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WorkspacesClient) GetResponder(resp *http.Response) (result Workspace, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSharedKeys gets the shared keys for a workspace. +// +// resourceGroupName is the name of the resource group to get. The name is case +// insensitive. workspaceName is name of the Log Analytics Workspace. +func (client WorkspacesClient) GetSharedKeys(resourceGroupName string, workspaceName string) (result SharedKeys, err error) { + 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}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "operationalinsights.WorkspacesClient", "GetSharedKeys") + } + + req, err := client.GetSharedKeysPreparer(resourceGroupName, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "GetSharedKeys", nil, "Failure preparing request") + return + } + + resp, err := client.GetSharedKeysSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "GetSharedKeys", resp, "Failure sending request") + return + } + + result, err = client.GetSharedKeysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "GetSharedKeys", resp, "Failure responding to request") + } + + return +} + +// GetSharedKeysPreparer prepares the GetSharedKeys request. +func (client WorkspacesClient) GetSharedKeysPreparer(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 = "2015-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/sharedKeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSharedKeysSender sends the GetSharedKeys request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacesClient) GetSharedKeysSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetSharedKeysResponder handles the response to the GetSharedKeys request. The method always +// closes the http.Response Body. +func (client WorkspacesClient) GetSharedKeysResponder(resp *http.Response) (result SharedKeys, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets the workspaces in a subscription. +func (client WorkspacesClient) List() (result WorkspaceListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client WorkspacesClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/workspaces", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacesClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client WorkspacesClient) ListResponder(resp *http.Response) (result WorkspaceListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup gets workspaces in a resource group. +// +// resourceGroupName is the name of the resource group to get. The name is case +// insensitive. +func (client WorkspacesClient) ListByResourceGroup(resourceGroupName string) (result WorkspaceListResult, err error) { + 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}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "operationalinsights.WorkspacesClient", "ListByResourceGroup") + } + + req, err := client.ListByResourceGroupPreparer(resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client WorkspacesClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-11-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", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client WorkspacesClient) ListByResourceGroupResponder(resp *http.Response) (result WorkspaceListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListIntelligencePacks lists all the intelligence packs possible and whether +// they are enabled or disabled for a given workspace. +// +// resourceGroupName is the name of the resource group to get. The name is case +// insensitive. workspaceName is name of the Log Analytics Workspace. +func (client WorkspacesClient) ListIntelligencePacks(resourceGroupName string, workspaceName string) (result ListIntelligencePack, err error) { + 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}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "operationalinsights.WorkspacesClient", "ListIntelligencePacks") + } + + req, err := client.ListIntelligencePacksPreparer(resourceGroupName, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "ListIntelligencePacks", nil, "Failure preparing request") + return + } + + resp, err := client.ListIntelligencePacksSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "ListIntelligencePacks", resp, "Failure sending request") + return + } + + result, err = client.ListIntelligencePacksResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "ListIntelligencePacks", resp, "Failure responding to request") + } + + return +} + +// ListIntelligencePacksPreparer prepares the ListIntelligencePacks request. +func (client WorkspacesClient) ListIntelligencePacksPreparer(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 = "2015-11-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}/intelligencePacks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListIntelligencePacksSender sends the ListIntelligencePacks request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacesClient) ListIntelligencePacksSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListIntelligencePacksResponder handles the response to the ListIntelligencePacks request. The method always +// closes the http.Response Body. +func (client WorkspacesClient) ListIntelligencePacksResponder(resp *http.Response) (result ListIntelligencePack, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListManagementGroups gets a list of management groups connected to a +// workspace. +// +// resourceGroupName is the name of the resource group to get. The name is case +// insensitive. workspaceName is the name of the workspace. +func (client WorkspacesClient) ListManagementGroups(resourceGroupName string, workspaceName string) (result WorkspaceListManagementGroupsResult, err error) { + 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}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "operationalinsights.WorkspacesClient", "ListManagementGroups") + } + + req, err := client.ListManagementGroupsPreparer(resourceGroupName, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "ListManagementGroups", nil, "Failure preparing request") + return + } + + resp, err := client.ListManagementGroupsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "ListManagementGroups", resp, "Failure sending request") + return + } + + result, err = client.ListManagementGroupsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "ListManagementGroups", resp, "Failure responding to request") + } + + return +} + +// ListManagementGroupsPreparer prepares the ListManagementGroups request. +func (client WorkspacesClient) ListManagementGroupsPreparer(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 = "2015-11-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}/managementGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListManagementGroupsSender sends the ListManagementGroups request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacesClient) ListManagementGroupsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListManagementGroupsResponder handles the response to the ListManagementGroups request. The method always +// closes the http.Response Body. +func (client WorkspacesClient) ListManagementGroupsResponder(resp *http.Response) (result WorkspaceListManagementGroupsResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListUsages gets a list of usage metrics for a workspace. +// +// resourceGroupName is the name of the resource group to get. The name is case +// insensitive. workspaceName is the name of the workspace. +func (client WorkspacesClient) ListUsages(resourceGroupName string, workspaceName string) (result WorkspaceListUsagesResult, err error) { + 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}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "operationalinsights.WorkspacesClient", "ListUsages") + } + + req, err := client.ListUsagesPreparer(resourceGroupName, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "ListUsages", nil, "Failure preparing request") + return + } + + resp, err := client.ListUsagesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "ListUsages", resp, "Failure sending request") + return + } + + result, err = client.ListUsagesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "ListUsages", resp, "Failure responding to request") + } + + return +} + +// ListUsagesPreparer prepares the ListUsages request. +func (client WorkspacesClient) ListUsagesPreparer(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 = "2015-11-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}/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListUsagesSender sends the ListUsages request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacesClient) ListUsagesSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListUsagesResponder handles the response to the ListUsages request. The method always +// closes the http.Response Body. +func (client WorkspacesClient) ListUsagesResponder(resp *http.Response) (result WorkspaceListUsagesResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/vendor.json b/vendor/vendor.json index afc67a5dbca0..b62d6e2b79b9 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -98,6 +98,12 @@ "version": "=v10.2.1-beta", "versionExact": "v10.2.1-beta" }, + { + "checksumSHA1": "/TBRYaTTjpsuKRCKH6nvQfSlLOw=", + "path": "github.com/Azure/azure-sdk-for-go/arm/operationalinsights", + "revision": "df4dd90d076ebbf6e87d08d3f00bfac8ff4bde1a", + "revisionTime": "2017-09-06T21:46:31Z" + }, { "checksumSHA1": "olhzqBgaJuavhtLduDqKF88RJXU=", "path": "github.com/Azure/azure-sdk-for-go/arm/redis", From db9621c6be5d7cfb563fdeacfb648b8230b3bdfe Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Wed, 13 Sep 2017 22:33:29 +0900 Subject: [PATCH 02/27] Set SKU as default --- azurerm/resource_arm_operational_insight_workspace.go | 4 ++-- azurerm/resource_arm_operational_insight_workspace_test.go | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/azurerm/resource_arm_operational_insight_workspace.go b/azurerm/resource_arm_operational_insight_workspace.go index 277729f46922..188e8a513131 100644 --- a/azurerm/resource_arm_operational_insight_workspace.go +++ b/azurerm/resource_arm_operational_insight_workspace.go @@ -48,8 +48,8 @@ func resourceArmOperationalInsightWorkspaceService() *schema.Resource { }, "sku": { Type: schema.TypeString, - Optional: true, - Computed: true, + Required: true, + ForceNew: true, }, "retention_in_days": { Type: schema.TypeInt, diff --git a/azurerm/resource_arm_operational_insight_workspace_test.go b/azurerm/resource_arm_operational_insight_workspace_test.go index 0328be9eaeee..432cefcefec0 100644 --- a/azurerm/resource_arm_operational_insight_workspace_test.go +++ b/azurerm/resource_arm_operational_insight_workspace_test.go @@ -144,6 +144,7 @@ resource "azurerm_operational_insight_workspace" "test" { name = "acctest-%d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" + sku = "Free" } `, rInt, location, rInt) } From 357bc065fd19c0755b35057d03ff750b1fcd7460 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Fri, 22 Sep 2017 15:44:00 -0700 Subject: [PATCH 03/27] Follow the naming Rule with using location Sceme --- azurerm/import_arm_operational_insight_workspace_test.go | 4 ++-- azurerm/resource_arm_operational_insight_workspace.go | 7 +------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/azurerm/import_arm_operational_insight_workspace_test.go b/azurerm/import_arm_operational_insight_workspace_test.go index a6beb40abc1c..a642274def8b 100644 --- a/azurerm/import_arm_operational_insight_workspace_test.go +++ b/azurerm/import_arm_operational_insight_workspace_test.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform/helper/resource" ) -func TestAccAzureRMOperationalInsightWorkspace_importrequiredOnly(t *testing.T) { +func TestAccAzureRMOperationalInsightWorkspace_importRequiredOnly(t *testing.T) { resourceName := "azurerm_operational_insight_workspace.test" ri := acctest.RandInt() @@ -31,7 +31,7 @@ func TestAccAzureRMOperationalInsightWorkspace_importrequiredOnly(t *testing.T) }) } -func TestAccAzureRMOperationalInsightWorkspace_importoptional(t *testing.T) { +func TestAccAzureRMOperationalInsightWorkspace_importOptional(t *testing.T) { resourceName := "azurerm_operational_insight_workspace.test" ri := acctest.RandInt() diff --git a/azurerm/resource_arm_operational_insight_workspace.go b/azurerm/resource_arm_operational_insight_workspace.go index 188e8a513131..25ffae5330b8 100644 --- a/azurerm/resource_arm_operational_insight_workspace.go +++ b/azurerm/resource_arm_operational_insight_workspace.go @@ -27,12 +27,7 @@ func resourceArmOperationalInsightWorkspaceService() *schema.Resource { ForceNew: true, ValidateFunc: validateAzureRmOperationalInsightWorkspaceName, }, - "location": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - StateFunc: azureRMNormalizeLocation, - }, + "location": locationSchema(), "resource_group_name": { Type: schema.TypeString, Required: true, From d5ebef8c883034bb054fd1704cbb4eea68b19962 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Fri, 22 Sep 2017 17:10:36 -0700 Subject: [PATCH 04/27] Use resourceGroupNameSchema() --- azurerm/resource_arm_operational_insight_workspace.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/azurerm/resource_arm_operational_insight_workspace.go b/azurerm/resource_arm_operational_insight_workspace.go index 0d2b4cbcd1f9..7f87a40c640c 100644 --- a/azurerm/resource_arm_operational_insight_workspace.go +++ b/azurerm/resource_arm_operational_insight_workspace.go @@ -29,12 +29,8 @@ func resourceArmOperationalInsightWorkspaceService() *schema.Resource { ForceNew: true, ValidateFunc: validateAzureRmOperationalInsightWorkspaceName, }, - "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "location": locationSchema(), + "resource_group_name": resourceGroupNameSchema(), "workspace_id": { // a.k.a. customer_id Type: schema.TypeString, Computed: true, From 75dc27cd4a308dfd54476c7731a5e4aa726ee126 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Fri, 22 Sep 2017 23:25:32 -0700 Subject: [PATCH 05/27] Remove comment. I'll write the comment to the documentation. --- azurerm/resource_arm_operational_insight_workspace.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/resource_arm_operational_insight_workspace.go b/azurerm/resource_arm_operational_insight_workspace.go index 7f87a40c640c..a89af37330bf 100644 --- a/azurerm/resource_arm_operational_insight_workspace.go +++ b/azurerm/resource_arm_operational_insight_workspace.go @@ -31,7 +31,7 @@ func resourceArmOperationalInsightWorkspaceService() *schema.Resource { }, "location": locationSchema(), "resource_group_name": resourceGroupNameSchema(), - "workspace_id": { // a.k.a. customer_id + "workspace_id": { Type: schema.TypeString, Computed: true, }, From 1fe74eaaff0dea790be8a17a4f1c40ed001378bd Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Fri, 22 Sep 2017 23:31:49 -0700 Subject: [PATCH 06/27] Adding SKU types validation --- azurerm/resource_arm_operational_insight_workspace.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/azurerm/resource_arm_operational_insight_workspace.go b/azurerm/resource_arm_operational_insight_workspace.go index a89af37330bf..b62f54276e6b 100644 --- a/azurerm/resource_arm_operational_insight_workspace.go +++ b/azurerm/resource_arm_operational_insight_workspace.go @@ -8,6 +8,7 @@ import ( "github.com/Azure/azure-sdk-for-go/arm/operationalinsights" "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/helper/validation" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) @@ -43,6 +44,15 @@ func resourceArmOperationalInsightWorkspaceService() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + string(operationalinsights.Free), + string(operationalinsights.PerNode), + string(operationalinsights.Premium), + string(operationalinsights.Standalone), + string(operationalinsights.Standard), + string(operationalinsights.Unlimited), + }, true), + DiffSuppressFunc: ignoreCaseDiffSuppressFunc, }, "retention_in_days": { Type: schema.TypeInt, From e86a8a27a2aee62d9773db739fb0b4d63ef44e20 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Sat, 23 Sep 2017 00:09:03 -0700 Subject: [PATCH 07/27] Refactor: Remove getSku(). We don't need to write this, we can use SkuEnum instead. --- ...ource_arm_operational_insight_workspace.go | 41 ++----------------- 1 file changed, 4 insertions(+), 37 deletions(-) diff --git a/azurerm/resource_arm_operational_insight_workspace.go b/azurerm/resource_arm_operational_insight_workspace.go index b62f54276e6b..093dc533b335 100644 --- a/azurerm/resource_arm_operational_insight_workspace.go +++ b/azurerm/resource_arm_operational_insight_workspace.go @@ -80,10 +80,9 @@ func resourceArmOperationalInsightWorkspaceCreateUpdate(d *schema.ResourceData, location := d.Get("location").(string) resGroup := d.Get("resource_group_name").(string) - skuName := d.Get("sku") - sku, err := getSku(skuName) - if err != nil { - return err + skuName := d.Get("sku").(string) + sku := &operationalinsights.Sku{ + Name: operationalinsights.SkuNameEnum(skuName), } retentionInDays := int32(d.Get("retention_in_days").(int)) @@ -103,7 +102,7 @@ func resourceArmOperationalInsightWorkspaceCreateUpdate(d *schema.ResourceData, cancel := make(chan struct{}) workspaceChannel, error := client.CreateOrUpdate(resGroup, name, parameters, cancel) workspace := <-workspaceChannel - err = <-error + err := <-error if err != nil { return err } @@ -184,38 +183,6 @@ func resourceArmOperationalInsightWorkspaceDelete(d *schema.ResourceData, meta i return nil } -func getSku(skuName interface{}) (*operationalinsights.Sku, error) { - if skuName == nil { - return nil, nil - } - skuEnum, err := getSkuNameEnum(skuName.(string)) - if err != nil { - return nil, err - } - return &operationalinsights.Sku{ - Name: skuEnum, - }, nil -} - -func getSkuNameEnum(skuName string) (operationalinsights.SkuNameEnum, error) { - switch skuName { - case "Free": - return operationalinsights.Free, nil - case "PerNode": - return operationalinsights.PerNode, nil - case "Premium": - return operationalinsights.Premium, nil - case "Standalone": - return operationalinsights.Standalone, nil - case "Standard": - return operationalinsights.Standard, nil - case "Unlimited": - return operationalinsights.Unlimited, nil - default: - return operationalinsights.Free, fmt.Errorf("Sku name not found") - } -} - func validateAzureRmOperationalInsightWorkspaceName(v interface{}, k string) (ws []string, errors []error) { value := v.(string) From c3408b26e14d088d86646d880b994eff251b9f11 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Sat, 23 Sep 2017 00:33:25 -0700 Subject: [PATCH 08/27] Follow the coding style. --- ...ource_arm_operational_insight_workspace.go | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/azurerm/resource_arm_operational_insight_workspace.go b/azurerm/resource_arm_operational_insight_workspace.go index 093dc533b335..0d6c4016629b 100644 --- a/azurerm/resource_arm_operational_insight_workspace.go +++ b/azurerm/resource_arm_operational_insight_workspace.go @@ -99,23 +99,22 @@ func resourceArmOperationalInsightWorkspaceCreateUpdate(d *schema.ResourceData, }, } - cancel := make(chan struct{}) - workspaceChannel, error := client.CreateOrUpdate(resGroup, name, parameters, cancel) - workspace := <-workspaceChannel + _, error := client.CreateOrUpdate(resGroup, name, parameters, make(chan struct{})) err := <-error if err != nil { return err } - // The cosmos DB read rest api again for getting id. Try remove it. - // read, err := client.Get(resGroup, name) - // if err != nil { - // return err - //} - - //if read.ID == nil { - // return fmt.Errorf("Cannot read Operational Inight Workspace '%s' (resource group %s) ID", name, resGroup) - //} - d.SetId(*workspace.ID) + + read, err := client.Get(resGroup, name) + if err != nil { + return err + } + + if read.ID == nil { + return fmt.Errorf("Cannot read Operational Inight Workspace '%s' (resource group %s) ID", name, resGroup) + } + + d.SetId(*read.ID) return resourceArmOperationalInsightWorkspaceRead(d, meta) From 2f74b8e6b1fead81c46b2823013b432c904c34a2 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Sat, 23 Sep 2017 01:09:16 -0700 Subject: [PATCH 09/27] Remove unnecessary comment --- azurerm/resource_arm_operational_insight_workspace.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/resource_arm_operational_insight_workspace.go b/azurerm/resource_arm_operational_insight_workspace.go index 0d6c4016629b..67d901edd257 100644 --- a/azurerm/resource_arm_operational_insight_workspace.go +++ b/azurerm/resource_arm_operational_insight_workspace.go @@ -121,7 +121,7 @@ func resourceArmOperationalInsightWorkspaceCreateUpdate(d *schema.ResourceData, } func resourceArmOperationalInsightWorkspaceRead(d *schema.ResourceData, meta interface{}) error { - // I don't understand why we can get the meta data. How the framework set it. + client := meta.(*ArmClient).workspacesClient id, err := parseAzureResourceID(d.Id()) if err != nil { From 4d4678f50fea94cb5c9f45f2ab22964f088b3466 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Sat, 23 Sep 2017 13:55:04 -0700 Subject: [PATCH 10/27] Error message improvement to dump more for error struct. --- azurerm/resource_arm_operational_insight_workspace.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/resource_arm_operational_insight_workspace.go b/azurerm/resource_arm_operational_insight_workspace.go index 67d901edd257..e6c4d650d7d5 100644 --- a/azurerm/resource_arm_operational_insight_workspace.go +++ b/azurerm/resource_arm_operational_insight_workspace.go @@ -136,7 +136,7 @@ func resourceArmOperationalInsightWorkspaceRead(d *schema.ResourceData, meta int d.SetId("") return nil } - return fmt.Errorf("Error making Read request on AzureRM Operational Insight workspaces '%s': %s", name, err) + return fmt.Errorf("Error making Read request on AzureRM Operational Insight workspaces '%s': %+v", name, err) } d.Set("name", resp.Name) From 011e38f11e8bfef8eeab98f0dabe9e2506d4a913 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Sat, 23 Sep 2017 13:57:26 -0700 Subject: [PATCH 11/27] Make error more dump for error struct --- azurerm/resource_arm_operational_insight_workspace.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/resource_arm_operational_insight_workspace.go b/azurerm/resource_arm_operational_insight_workspace.go index e6c4d650d7d5..5ef3c4489c0c 100644 --- a/azurerm/resource_arm_operational_insight_workspace.go +++ b/azurerm/resource_arm_operational_insight_workspace.go @@ -149,7 +149,7 @@ func resourceArmOperationalInsightWorkspaceRead(d *schema.ResourceData, meta int sharedKeys, err := client.GetSharedKeys(resGroup, name) if err != nil { - log.Printf("[ERROR] Unable to List Shared keys for Operatinal Insight workspaces %s: %s", name, err) + log.Printf("[ERROR] Unable to List Shared keys for Operatinal Insight workspaces %s: %+v", name, err) } else { d.Set("primary_shared_key", sharedKeys.PrimarySharedKey) d.Set("secondary_shared_key", sharedKeys.SecondarySharedKey) From c821a98535c4acbd84c41be1eae214783c63c6d4 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Sat, 23 Sep 2017 14:12:13 -0700 Subject: [PATCH 12/27] Using utility method. --- azurerm/resource_arm_operational_insight_workspace.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/azurerm/resource_arm_operational_insight_workspace.go b/azurerm/resource_arm_operational_insight_workspace.go index 5ef3c4489c0c..44a3faa9a9d1 100644 --- a/azurerm/resource_arm_operational_insight_workspace.go +++ b/azurerm/resource_arm_operational_insight_workspace.go @@ -3,7 +3,6 @@ package azurerm import ( "fmt" "log" - "net/http" "regexp" "github.com/Azure/azure-sdk-for-go/arm/operationalinsights" @@ -172,7 +171,7 @@ func resourceArmOperationalInsightWorkspaceDelete(d *schema.ResourceData, meta i resp, err := client.Delete(resGroup, name) if err != nil { - if resp.StatusCode == http.StatusNotFound { + if utils.ResponseWasNotFound(resp) { return nil } From 577502d3826b34097f27e56ee5442d33c0d9ee08 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Sat, 23 Sep 2017 14:35:30 -0700 Subject: [PATCH 13/27] Adding workspace name validation --- .../resource_arm_operational_insight_workspace.go | 8 +++++++- ...urce_arm_operational_insight_workspace_test.go | 15 ++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/azurerm/resource_arm_operational_insight_workspace.go b/azurerm/resource_arm_operational_insight_workspace.go index 44a3faa9a9d1..ebb0353c521b 100644 --- a/azurerm/resource_arm_operational_insight_workspace.go +++ b/azurerm/resource_arm_operational_insight_workspace.go @@ -186,7 +186,13 @@ func validateAzureRmOperationalInsightWorkspaceName(v interface{}, k string) (ws r, _ := regexp.Compile("^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$") if !r.MatchString(value) { - errors = append(errors, fmt.Errorf("Workspace Name can only contain alphabet, number, and '-' charactor. You can not use '-' as the start and end of the name.")) + errors = append(errors, fmt.Errorf("Workspace Name can only contain alphabet, number, and '-' charactor. You can not use '-' as the start and end of the name")) } + + length := len(value) + if length > 63 || 4 > length { + errors = append(errors, fmt.Errorf("Workspace Name can only be between 4 and 63 letters")) + } + return } diff --git a/azurerm/resource_arm_operational_insight_workspace_test.go b/azurerm/resource_arm_operational_insight_workspace_test.go index 432cefcefec0..5381142143db 100644 --- a/azurerm/resource_arm_operational_insight_workspace_test.go +++ b/azurerm/resource_arm_operational_insight_workspace_test.go @@ -11,12 +11,13 @@ import ( ) func TestAccAzureRmOperationalInsightWorkspaceName_validation(t *testing.T) { + str := acctest.RandString(63) cases := []struct { Value string ErrCount int }{ { - Value: "ab", + Value: "abc", ErrCount: 1, }, { @@ -24,11 +25,19 @@ func TestAccAzureRmOperationalInsightWorkspaceName_validation(t *testing.T) { ErrCount: 0, }, { - Value: "-ab", + Value: "-abc", ErrCount: 1, }, { - Value: "ab-", + Value: "abc-", + ErrCount: 1, + }, + { + Value: str, + ErrCount: 0, + }, + { + Value: str + "a", ErrCount: 1, }, } From 3e8c7b5dca5fa0942da0c98cd6026661b808b5ce Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Sat, 23 Sep 2017 14:48:19 -0700 Subject: [PATCH 14/27] Follow the naming rule --- azurerm/import_arm_operational_insight_workspace_test.go | 4 ++-- azurerm/resource_arm_operational_insight_workspace_test.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/azurerm/import_arm_operational_insight_workspace_test.go b/azurerm/import_arm_operational_insight_workspace_test.go index a642274def8b..9790b56ed27b 100644 --- a/azurerm/import_arm_operational_insight_workspace_test.go +++ b/azurerm/import_arm_operational_insight_workspace_test.go @@ -31,11 +31,11 @@ func TestAccAzureRMOperationalInsightWorkspace_importRequiredOnly(t *testing.T) }) } -func TestAccAzureRMOperationalInsightWorkspace_importOptional(t *testing.T) { +func TestAccAzureRMOperationalInsightWorkspace_importRetentionInDaysComplete(t *testing.T) { resourceName := "azurerm_operational_insight_workspace.test" ri := acctest.RandInt() - config := testAccAzureRMOperationalInsightWorkspace_optional(ri, testLocation()) + config := testAccAzureRMOperationalInsightWorkspace_retentionInDaysComplete(ri, testLocation()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/azurerm/resource_arm_operational_insight_workspace_test.go b/azurerm/resource_arm_operational_insight_workspace_test.go index 5381142143db..43e73602d518 100644 --- a/azurerm/resource_arm_operational_insight_workspace_test.go +++ b/azurerm/resource_arm_operational_insight_workspace_test.go @@ -69,9 +69,9 @@ func TestAccAzureRMOperationalInsightWorkspace_requiredOnly(t *testing.T) { }, }) } -func TestAccAzureRMOperationalInsightWorkspace_optional(t *testing.T) { +func TestAccAzureRMOperationalInsightWorkspace_retentionInDaysComplete(t *testing.T) { ri := acctest.RandInt() - config := testAccAzureRMOperationalInsightWorkspace_optional(ri, testLocation()) + config := testAccAzureRMOperationalInsightWorkspace_retentionInDaysComplete(ri, testLocation()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -158,7 +158,7 @@ resource "azurerm_operational_insight_workspace" "test" { `, rInt, location, rInt) } -func testAccAzureRMOperationalInsightWorkspace_optional(rInt int, location string) string { +func testAccAzureRMOperationalInsightWorkspace_retentionInDaysComplete(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { name = "acctestRG-%d" From a578ba237276ee70a622e93fa7d62d9e70b22499 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Sat, 23 Sep 2017 15:13:12 -0700 Subject: [PATCH 15/27] Adjust SDK version for operational insight --- vendor/vendor.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vendor/vendor.json b/vendor/vendor.json index f551c5a89b24..896c9aabc11d 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -125,8 +125,10 @@ { "checksumSHA1": "/TBRYaTTjpsuKRCKH6nvQfSlLOw=", "path": "github.com/Azure/azure-sdk-for-go/arm/operationalinsights", - "revision": "df4dd90d076ebbf6e87d08d3f00bfac8ff4bde1a", - "revisionTime": "2017-09-06T21:46:31Z" + "revision": "57db66900881e9fd21fd041a9d013514700ecab3", + "revisionTime": "2017-08-18T20:19:01Z", + "version": "=v10.3.0-beta", + "versionExact": "v10.3.0-beta" }, { "checksumSHA1": "aJQ7rml6haLjCsNhe5OOPOgqozM=", From 0cd140ace5bde1abfa9c4c734ee0c7cebdaea5f8 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Sat, 23 Sep 2017 17:37:42 -0700 Subject: [PATCH 16/27] Change provider name and fix the Acceptance testing error Talked with the Log Analytics production team, they'd love to go log analytics. I change the name. However, the REST-API name is operational analytics. I change the schema name as log analytics however, keep the source code as operational insights for the consistency of the Azure SDK naming. Also, I fix the Acceptance testing error. The root cause of the problem is the Retention in days. It is not stated however, we can use 30 - 730. I add validation function and test for that. https://blogs.msdn.microsoft.com/canberrapfe/2017/01/25/change-oms-log-analytics-retention-period-in-the-azure-portal/ The blog says 31 - 730, however 30 is default value it works. --- ..._arm_operational_insight_workspace_test.go | 4 +- azurerm/provider.go | 154 +++++++++--------- ...ource_arm_operational_insight_workspace.go | 15 +- ..._arm_operational_insight_workspace_test.go | 46 +++++- 4 files changed, 130 insertions(+), 89 deletions(-) diff --git a/azurerm/import_arm_operational_insight_workspace_test.go b/azurerm/import_arm_operational_insight_workspace_test.go index 9790b56ed27b..63e2674a1bb3 100644 --- a/azurerm/import_arm_operational_insight_workspace_test.go +++ b/azurerm/import_arm_operational_insight_workspace_test.go @@ -8,7 +8,7 @@ import ( ) func TestAccAzureRMOperationalInsightWorkspace_importRequiredOnly(t *testing.T) { - resourceName := "azurerm_operational_insight_workspace.test" + resourceName := "azurerm_log_analytics.test" ri := acctest.RandInt() config := testAccAzureRMOperationalInsightWorkspace_requiredOnly(ri, testLocation()) @@ -32,7 +32,7 @@ func TestAccAzureRMOperationalInsightWorkspace_importRequiredOnly(t *testing.T) } func TestAccAzureRMOperationalInsightWorkspace_importRetentionInDaysComplete(t *testing.T) { - resourceName := "azurerm_operational_insight_workspace.test" + resourceName := "azurerm_log_analytics.test" ri := acctest.RandInt() config := testAccAzureRMOperationalInsightWorkspace_retentionInDaysComplete(ri, testLocation()) diff --git a/azurerm/provider.go b/azurerm/provider.go index de1d39a41977..60e228f126aa 100644 --- a/azurerm/provider.go +++ b/azurerm/provider.go @@ -70,83 +70,83 @@ func Provider() terraform.ResourceProvider { }, ResourcesMap: map[string]*schema.Resource{ - "azurerm_application_insights": resourceArmApplicationInsights(), - "azurerm_app_service": resourceArmAppService(), - "azurerm_app_service_plan": resourceArmAppServicePlan(), - "azurerm_automation_account": resourceArmAutomationAccount(), - "azurerm_automation_runbook": resourceArmAutomationRunbook(), - "azurerm_automation_credential": resourceArmAutomationCredential(), - "azurerm_automation_schedule": resourceArmAutomationSchedule(), - "azurerm_availability_set": resourceArmAvailabilitySet(), - "azurerm_cdn_endpoint": resourceArmCdnEndpoint(), - "azurerm_cdn_profile": resourceArmCdnProfile(), - "azurerm_container_registry": resourceArmContainerRegistry(), - "azurerm_container_service": resourceArmContainerService(), - "azurerm_container_group": resourceArmContainerGroup(), - "azurerm_cosmosdb_account": resourceArmCosmosDBAccount(), - "azurerm_dns_a_record": resourceArmDnsARecord(), - "azurerm_dns_aaaa_record": resourceArmDnsAAAARecord(), - "azurerm_dns_cname_record": resourceArmDnsCNameRecord(), - "azurerm_dns_mx_record": resourceArmDnsMxRecord(), - "azurerm_dns_ns_record": resourceArmDnsNsRecord(), - "azurerm_dns_ptr_record": resourceArmDnsPtrRecord(), - "azurerm_dns_srv_record": resourceArmDnsSrvRecord(), - "azurerm_dns_txt_record": resourceArmDnsTxtRecord(), - "azurerm_dns_zone": resourceArmDnsZone(), - "azurerm_eventgrid_topic": resourceArmEventGridTopic(), - "azurerm_eventhub": resourceArmEventHub(), - "azurerm_eventhub_authorization_rule": resourceArmEventHubAuthorizationRule(), - "azurerm_eventhub_consumer_group": resourceArmEventHubConsumerGroup(), - "azurerm_eventhub_namespace": resourceArmEventHubNamespace(), - "azurerm_express_route_circuit": resourceArmExpressRouteCircuit(), - "azurerm_image": resourceArmImage(), - "azurerm_key_vault": resourceArmKeyVault(), - "azurerm_key_vault_secret": resourceArmKeyVaultSecret(), - "azurerm_lb": resourceArmLoadBalancer(), - "azurerm_lb_backend_address_pool": resourceArmLoadBalancerBackendAddressPool(), - "azurerm_lb_nat_rule": resourceArmLoadBalancerNatRule(), - "azurerm_lb_nat_pool": resourceArmLoadBalancerNatPool(), - "azurerm_lb_probe": resourceArmLoadBalancerProbe(), - "azurerm_lb_rule": resourceArmLoadBalancerRule(), - "azurerm_local_network_gateway": resourceArmLocalNetworkGateway(), - "azurerm_managed_disk": resourceArmManagedDisk(), - "azurerm_network_interface": resourceArmNetworkInterface(), - "azurerm_network_security_group": resourceArmNetworkSecurityGroup(), - "azurerm_network_security_rule": resourceArmNetworkSecurityRule(), - "azurerm_operational_insight_workspace": resourceArmOperationalInsightWorkspaceService(), - "azurerm_postgresql_configuration": resourceArmPostgreSQLConfiguration(), - "azurerm_postgresql_database": resourceArmPostgreSQLDatabase(), - "azurerm_postgresql_firewall_rule": resourceArmPostgreSQLFirewallRule(), - "azurerm_postgresql_server": resourceArmPostgreSQLServer(), - "azurerm_public_ip": resourceArmPublicIp(), - "azurerm_redis_cache": resourceArmRedisCache(), - "azurerm_resource_group": resourceArmResourceGroup(), - "azurerm_route": resourceArmRoute(), - "azurerm_route_table": resourceArmRouteTable(), - "azurerm_search_service": resourceArmSearchService(), - "azurerm_servicebus_namespace": resourceArmServiceBusNamespace(), - "azurerm_servicebus_queue": resourceArmServiceBusQueue(), - "azurerm_servicebus_subscription": resourceArmServiceBusSubscription(), - "azurerm_servicebus_topic": resourceArmServiceBusTopic(), - "azurerm_sql_database": resourceArmSqlDatabase(), - "azurerm_sql_elasticpool": resourceArmSqlElasticPool(), - "azurerm_sql_firewall_rule": resourceArmSqlFirewallRule(), - "azurerm_sql_server": resourceArmSqlServer(), - "azurerm_storage_account": resourceArmStorageAccount(), - "azurerm_storage_blob": resourceArmStorageBlob(), - "azurerm_storage_container": resourceArmStorageContainer(), - "azurerm_storage_share": resourceArmStorageShare(), - "azurerm_storage_queue": resourceArmStorageQueue(), - "azurerm_storage_table": resourceArmStorageTable(), - "azurerm_subnet": resourceArmSubnet(), - "azurerm_template_deployment": resourceArmTemplateDeployment(), - "azurerm_traffic_manager_endpoint": resourceArmTrafficManagerEndpoint(), - "azurerm_traffic_manager_profile": resourceArmTrafficManagerProfile(), - "azurerm_virtual_machine_extension": resourceArmVirtualMachineExtensions(), - "azurerm_virtual_machine": resourceArmVirtualMachine(), - "azurerm_virtual_machine_scale_set": resourceArmVirtualMachineScaleSet(), - "azurerm_virtual_network": resourceArmVirtualNetwork(), - "azurerm_virtual_network_peering": resourceArmVirtualNetworkPeering(), + "azurerm_application_insights": resourceArmApplicationInsights(), + "azurerm_app_service": resourceArmAppService(), + "azurerm_app_service_plan": resourceArmAppServicePlan(), + "azurerm_automation_account": resourceArmAutomationAccount(), + "azurerm_automation_runbook": resourceArmAutomationRunbook(), + "azurerm_automation_credential": resourceArmAutomationCredential(), + "azurerm_automation_schedule": resourceArmAutomationSchedule(), + "azurerm_availability_set": resourceArmAvailabilitySet(), + "azurerm_cdn_endpoint": resourceArmCdnEndpoint(), + "azurerm_cdn_profile": resourceArmCdnProfile(), + "azurerm_container_registry": resourceArmContainerRegistry(), + "azurerm_container_service": resourceArmContainerService(), + "azurerm_container_group": resourceArmContainerGroup(), + "azurerm_cosmosdb_account": resourceArmCosmosDBAccount(), + "azurerm_dns_a_record": resourceArmDnsARecord(), + "azurerm_dns_aaaa_record": resourceArmDnsAAAARecord(), + "azurerm_dns_cname_record": resourceArmDnsCNameRecord(), + "azurerm_dns_mx_record": resourceArmDnsMxRecord(), + "azurerm_dns_ns_record": resourceArmDnsNsRecord(), + "azurerm_dns_ptr_record": resourceArmDnsPtrRecord(), + "azurerm_dns_srv_record": resourceArmDnsSrvRecord(), + "azurerm_dns_txt_record": resourceArmDnsTxtRecord(), + "azurerm_dns_zone": resourceArmDnsZone(), + "azurerm_eventgrid_topic": resourceArmEventGridTopic(), + "azurerm_eventhub": resourceArmEventHub(), + "azurerm_eventhub_authorization_rule": resourceArmEventHubAuthorizationRule(), + "azurerm_eventhub_consumer_group": resourceArmEventHubConsumerGroup(), + "azurerm_eventhub_namespace": resourceArmEventHubNamespace(), + "azurerm_express_route_circuit": resourceArmExpressRouteCircuit(), + "azurerm_image": resourceArmImage(), + "azurerm_key_vault": resourceArmKeyVault(), + "azurerm_key_vault_secret": resourceArmKeyVaultSecret(), + "azurerm_lb": resourceArmLoadBalancer(), + "azurerm_lb_backend_address_pool": resourceArmLoadBalancerBackendAddressPool(), + "azurerm_lb_nat_rule": resourceArmLoadBalancerNatRule(), + "azurerm_lb_nat_pool": resourceArmLoadBalancerNatPool(), + "azurerm_lb_probe": resourceArmLoadBalancerProbe(), + "azurerm_lb_rule": resourceArmLoadBalancerRule(), + "azurerm_local_network_gateway": resourceArmLocalNetworkGateway(), + "azurerm_managed_disk": resourceArmManagedDisk(), + "azurerm_network_interface": resourceArmNetworkInterface(), + "azurerm_network_security_group": resourceArmNetworkSecurityGroup(), + "azurerm_network_security_rule": resourceArmNetworkSecurityRule(), + "azurerm_log_analytics": resourceArmOperationalInsightWorkspaceService(), + "azurerm_postgresql_configuration": resourceArmPostgreSQLConfiguration(), + "azurerm_postgresql_database": resourceArmPostgreSQLDatabase(), + "azurerm_postgresql_firewall_rule": resourceArmPostgreSQLFirewallRule(), + "azurerm_postgresql_server": resourceArmPostgreSQLServer(), + "azurerm_public_ip": resourceArmPublicIp(), + "azurerm_redis_cache": resourceArmRedisCache(), + "azurerm_resource_group": resourceArmResourceGroup(), + "azurerm_route": resourceArmRoute(), + "azurerm_route_table": resourceArmRouteTable(), + "azurerm_search_service": resourceArmSearchService(), + "azurerm_servicebus_namespace": resourceArmServiceBusNamespace(), + "azurerm_servicebus_queue": resourceArmServiceBusQueue(), + "azurerm_servicebus_subscription": resourceArmServiceBusSubscription(), + "azurerm_servicebus_topic": resourceArmServiceBusTopic(), + "azurerm_sql_database": resourceArmSqlDatabase(), + "azurerm_sql_elasticpool": resourceArmSqlElasticPool(), + "azurerm_sql_firewall_rule": resourceArmSqlFirewallRule(), + "azurerm_sql_server": resourceArmSqlServer(), + "azurerm_storage_account": resourceArmStorageAccount(), + "azurerm_storage_blob": resourceArmStorageBlob(), + "azurerm_storage_container": resourceArmStorageContainer(), + "azurerm_storage_share": resourceArmStorageShare(), + "azurerm_storage_queue": resourceArmStorageQueue(), + "azurerm_storage_table": resourceArmStorageTable(), + "azurerm_subnet": resourceArmSubnet(), + "azurerm_template_deployment": resourceArmTemplateDeployment(), + "azurerm_traffic_manager_endpoint": resourceArmTrafficManagerEndpoint(), + "azurerm_traffic_manager_profile": resourceArmTrafficManagerProfile(), + "azurerm_virtual_machine_extension": resourceArmVirtualMachineExtensions(), + "azurerm_virtual_machine": resourceArmVirtualMachine(), + "azurerm_virtual_machine_scale_set": resourceArmVirtualMachineScaleSet(), + "azurerm_virtual_network": resourceArmVirtualNetwork(), + "azurerm_virtual_network_peering": resourceArmVirtualNetworkPeering(), }, } diff --git a/azurerm/resource_arm_operational_insight_workspace.go b/azurerm/resource_arm_operational_insight_workspace.go index ebb0353c521b..b2937a2fe303 100644 --- a/azurerm/resource_arm_operational_insight_workspace.go +++ b/azurerm/resource_arm_operational_insight_workspace.go @@ -54,9 +54,10 @@ func resourceArmOperationalInsightWorkspaceService() *schema.Resource { DiffSuppressFunc: ignoreCaseDiffSuppressFunc, }, "retention_in_days": { - Type: schema.TypeInt, - Optional: true, - Computed: true, + Type: schema.TypeInt, + Optional: true, + Computed: true, + ValidateFunc: validateAzureRmOperationalInsightWorkspaceRetentionInDays, }, "primary_shared_key": { Type: schema.TypeString, @@ -196,3 +197,11 @@ func validateAzureRmOperationalInsightWorkspaceName(v interface{}, k string) (ws return } + +func validateAzureRmOperationalInsightWorkspaceRetentionInDays(v interface{}, k string) (ws []string, errors []error) { + value := v.(int) + if value < 30 || value > 730 { + errors = append(errors, fmt.Errorf("The `retention_in_days` can only be between 30 and 730")) + } + return +} diff --git a/azurerm/resource_arm_operational_insight_workspace_test.go b/azurerm/resource_arm_operational_insight_workspace_test.go index 43e73602d518..ddfa74e1957d 100644 --- a/azurerm/resource_arm_operational_insight_workspace_test.go +++ b/azurerm/resource_arm_operational_insight_workspace_test.go @@ -43,7 +43,39 @@ func TestAccAzureRmOperationalInsightWorkspaceName_validation(t *testing.T) { } for _, tc := range cases { - _, errors := validateAzureRmOperationalInsightWorkspaceName(tc.Value, "azurerm_operational_insight_workspace") + _, errors := validateAzureRmOperationalInsightWorkspaceName(tc.Value, "azurerm_log_analytics") + + if len(errors) != tc.ErrCount { + t.Fatalf("Expected the AzureRM Operational Insight Workspace Name to trigger a validation error for '%s'", tc.Value) + } + } +} + +func TestAccAzureRmOperationalInsightWorkspaceRetentionInDays_validation(t *testing.T) { + cases := []struct { + Value int + ErrCount int + }{ + { + Value: 29, + ErrCount: 1, + }, + { + Value: 30, + ErrCount: 0, + }, + { + Value: 730, + ErrCount: 0, + }, + { + Value: 731, + ErrCount: 1, + }, + } + + for _, tc := range cases { + _, errors := validateAzureRmOperationalInsightWorkspaceRetentionInDays(tc.Value, "azurerm_log_analytics") if len(errors) != tc.ErrCount { t.Fatalf("Expected the AzureRM Operational Insight Workspace Name to trigger a validation error for '%s'", tc.Value) @@ -63,7 +95,7 @@ func TestAccAzureRMOperationalInsightWorkspace_requiredOnly(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMOperationalInsightWorkspaceExists("azurerm_operational_insight_workspace.test"), + testCheckAzureRMOperationalInsightWorkspaceExists("azurerm_log_analytics.test"), ), }, }, @@ -81,7 +113,7 @@ func TestAccAzureRMOperationalInsightWorkspace_retentionInDaysComplete(t *testin { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMOperationalInsightWorkspaceExists("azurerm_operational_insight_workspace.test"), + testCheckAzureRMOperationalInsightWorkspaceExists("azurerm_log_analytics.test"), ), }, }, @@ -92,7 +124,7 @@ func testCheckAzureRMOperationalInsightWorkspaceDestroy(s *terraform.State) erro conn := testAccProvider.Meta().(*ArmClient).workspacesClient for _, rs := range s.RootModule().Resources { - if rs.Type != "azurerm_operational_insight_workspace" { + if rs.Type != "azurerm_log_analytics" { continue } @@ -149,7 +181,7 @@ resource "azurerm_resource_group" "test" { location = "%s" } -resource "azurerm_operational_insight_workspace" "test" { +resource "azurerm_log_analytics" "test" { name = "acctest-%d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" @@ -165,12 +197,12 @@ resource "azurerm_resource_group" "test" { location = "%s" } -resource "azurerm_operational_insight_workspace" "test" { +resource "azurerm_log_analytics" "test" { name = "acctest-%d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" sku = "Standard" - retention_in_days = 5 + retention_in_days = 30 } `, rInt, location, rInt) } From ea0692ee33abf61724dc5baa06dd6d8621f09431 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Sat, 23 Sep 2017 18:24:34 -0700 Subject: [PATCH 17/27] Adding the log anaylytics documentation --- website/azurerm.erb | 9 +++ website/docs/r/log_analytics.html.markdown | 64 ++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 website/docs/r/log_analytics.html.markdown diff --git a/website/azurerm.erb b/website/azurerm.erb index beb08b95efd7..904f5bf93235 100644 --- a/website/azurerm.erb +++ b/website/azurerm.erb @@ -387,6 +387,15 @@ + > + OMS Resources + + + > Redis Resources