diff --git a/internal/provider/services.go b/internal/provider/services.go index e6a12356bf1f..d06680e52d59 100644 --- a/internal/provider/services.go +++ b/internal/provider/services.go @@ -129,6 +129,7 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration { keyvault.Registration{}, loadbalancer.Registration{}, loadtest.Registration{}, + loganalytics.Registration{}, monitor.Registration{}, mssql.Registration{}, policy.Registration{}, diff --git a/internal/services/loganalytics/client/client.go b/internal/services/loganalytics/client/client.go index 844608189cd9..ba0162e3098f 100644 --- a/internal/services/loganalytics/client/client.go +++ b/internal/services/loganalytics/client/client.go @@ -3,6 +3,7 @@ package client import ( "github.com/Azure/azure-sdk-for-go/services/operationalinsights/mgmt/2020-08-01/operationalinsights" "github.com/Azure/azure-sdk-for-go/services/preview/operationsmanagement/mgmt/2015-11-01-preview/operationsmanagement" + queryPacks "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights" "github.com/hashicorp/terraform-provider-azurerm/internal/common" ) @@ -12,6 +13,7 @@ type Client struct { DataSourcesClient *operationalinsights.DataSourcesClient LinkedServicesClient *operationalinsights.LinkedServicesClient LinkedStorageAccountClient *operationalinsights.LinkedStorageAccountsClient + QueryPacksClient *queryPacks.OperationalInsightsClient SavedSearchesClient *operationalinsights.SavedSearchesClient SharedKeysClient *operationalinsights.SharedKeysClient SolutionsClient *operationsmanagement.SolutionsClient @@ -50,12 +52,16 @@ func NewClient(o *common.ClientOptions) *Client { LinkedStorageAccountClient := operationalinsights.NewLinkedStorageAccountsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&LinkedStorageAccountClient.Client, o.ResourceManagerAuthorizer) + QueryPacksClient := queryPacks.NewOperationalInsightsClientWithBaseURI(o.ResourceManagerEndpoint) + o.ConfigureClient(&QueryPacksClient.Client, o.ResourceManagerAuthorizer) + return &Client{ ClusterClient: &ClusterClient, DataExportClient: &DataExportClient, DataSourcesClient: &DataSourcesClient, LinkedServicesClient: &LinkedServicesClient, LinkedStorageAccountClient: &LinkedStorageAccountClient, + QueryPacksClient: &QueryPacksClient, SavedSearchesClient: &SavedSearchesClient, SharedKeysClient: &SharedKeysClient, SolutionsClient: &SolutionsClient, diff --git a/internal/services/loganalytics/log_analytics_query_pack_resource.go b/internal/services/loganalytics/log_analytics_query_pack_resource.go new file mode 100644 index 000000000000..31cae69a391f --- /dev/null +++ b/internal/services/loganalytics/log_analytics_query_pack_resource.go @@ -0,0 +1,205 @@ +package loganalytics + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + queryPacks "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type LogAnalyticsQueryPackModel struct { + Name string `tfschema:"name"` + ResourceGroupName string `tfschema:"resource_group_name"` + Location string `tfschema:"location"` + Tags map[string]string `tfschema:"tags"` +} + +type LogAnalyticsQueryPackResource struct{} + +var _ sdk.ResourceWithUpdate = LogAnalyticsQueryPackResource{} + +func (r LogAnalyticsQueryPackResource) ResourceType() string { + return "azurerm_log_analytics_query_pack" +} + +func (r LogAnalyticsQueryPackResource) ModelObject() interface{} { + return &LogAnalyticsQueryPackModel{} +} + +func (r LogAnalyticsQueryPackResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return queryPacks.ValidateQueryPackID +} + +func (r LogAnalyticsQueryPackResource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "resource_group_name": commonschema.ResourceGroupName(), + + "location": commonschema.Location(), + + "tags": commonschema.Tags(), + } +} + +func (r LogAnalyticsQueryPackResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{} +} + +func (r LogAnalyticsQueryPackResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + var model LogAnalyticsQueryPackModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + client := metadata.Client.LogAnalytics.QueryPacksClient + subscriptionId := metadata.Client.Account.SubscriptionId + + id := queryPacks.NewQueryPackID(subscriptionId, model.ResourceGroupName, model.Name) + + existing, err := client.QueryPacksGet(ctx, id) + if err != nil && !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for existing %s: %+v", id, err) + } + + if !response.WasNotFound(existing.HttpResponse) { + return metadata.ResourceRequiresImport(r.ResourceType(), id) + } + + properties := &queryPacks.LogAnalyticsQueryPack{ + Location: location.Normalize(model.Location), + Properties: queryPacks.LogAnalyticsQueryPackProperties{}, + Tags: &model.Tags, + } + + if resp, err := client.QueryPacksCreateOrUpdate(ctx, id, *properties); err != nil { + // update check logic once the issue https://github.com/Azure/azure-rest-api-specs/issues/19603 is fixed + if !response.WasStatusCode(resp.HttpResponse, http.StatusCreated) { + return fmt.Errorf("creating %s: %+v", id, err) + } + } + + metadata.SetID(id) + return nil + }, + } +} + +func (r LogAnalyticsQueryPackResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.LogAnalytics.QueryPacksClient + + id, err := queryPacks.ParseQueryPackID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + var model LogAnalyticsQueryPackModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + resp, err := client.QueryPacksGet(ctx, *id) + if err != nil { + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + properties := resp.Model + if properties == nil { + return fmt.Errorf("retrieving %s: properties was nil", id) + } + + if metadata.ResourceData.HasChange("tags") { + properties.Tags = &model.Tags + } + + if resp, err := client.QueryPacksCreateOrUpdate(ctx, *id, *properties); err != nil { + // update check logic once the issue https://github.com/Azure/azure-rest-api-specs/issues/19603 is fixed + if !response.WasStatusCode(resp.HttpResponse, http.StatusCreated) { + return fmt.Errorf("updating %s: %+v", *id, err) + } + } + + return nil + }, + } +} + +func (r LogAnalyticsQueryPackResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.LogAnalytics.QueryPacksClient + + id, err := queryPacks.ParseQueryPackID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + resp, err := client.QueryPacksGet(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return metadata.MarkAsGone(id) + } + + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + model := resp.Model + if model == nil { + return fmt.Errorf("retrieving %s: model was nil", id) + } + + state := LogAnalyticsQueryPackModel{ + Name: id.QueryPackName, + ResourceGroupName: id.ResourceGroupName, + Location: location.NormalizeNilable(utils.String(model.Location)), + } + + if model.Tags != nil { + state.Tags = *model.Tags + } + + return metadata.Encode(&state) + }, + } +} + +func (r LogAnalyticsQueryPackResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.LogAnalytics.QueryPacksClient + + id, err := queryPacks.ParseQueryPackID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + if _, err := client.QueryPacksDelete(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", id, err) + } + + return nil + }, + } +} diff --git a/internal/services/loganalytics/log_analytics_query_pack_resource_test.go b/internal/services/loganalytics/log_analytics_query_pack_resource_test.go new file mode 100644 index 000000000000..c6605715fdd8 --- /dev/null +++ b/internal/services/loganalytics/log_analytics_query_pack_resource_test.go @@ -0,0 +1,138 @@ +package loganalytics_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-helpers/lang/response" + queryPacks "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type LogAnalyticsQueryPackResource struct{} + +func (r LogAnalyticsQueryPackResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := queryPacks.ParseQueryPackID(state.ID) + if err != nil { + return nil, err + } + + resp, err := client.LogAnalytics.QueryPacksClient.QueryPacksGet(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return utils.Bool(false), nil + } + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) + } + return utils.Bool(true), nil +} + +func TestAccLogAnalyticsQueryPack_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_log_analytics_query_pack", "test") + r := LogAnalyticsQueryPackResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccLogAnalyticsQueryPack_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_log_analytics_query_pack", "test") + r := LogAnalyticsQueryPackResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func TestAccLogAnalyticsQueryPack_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_log_analytics_query_pack", "test") + r := LogAnalyticsQueryPackResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.update(data, "Test1"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.update(data, "Test2"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func (r LogAnalyticsQueryPackResource) basic(data acceptance.TestData) string { + return fmt.Sprintf(` +%[1]s + +resource "azurerm_log_analytics_query_pack" "test" { + name = "acctestlaqp-%[2]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location +} +`, r.template(data), data.RandomInteger) +} + +func (r LogAnalyticsQueryPackResource) update(data acceptance.TestData, tag string) string { + return fmt.Sprintf(` +%[1]s + +resource "azurerm_log_analytics_query_pack" "test" { + name = "acctestlaqp-%[2]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + + tags = { + ENV = "%[3]s" + } +} +`, r.template(data), data.RandomInteger, tag) +} + +func (r LogAnalyticsQueryPackResource) requiresImport(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_log_analytics_query_pack" "import" { + name = azurerm_log_analytics_query_pack.test.name + resource_group_name = azurerm_log_analytics_query_pack.test.resource_group_name + location = azurerm_log_analytics_query_pack.test.location +} +`, r.basic(data)) +} + +func (r LogAnalyticsQueryPackResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-LA-%[1]d" + location = "%[2]s" +} +`, data.RandomInteger, data.Locations.Primary) +} diff --git a/internal/services/loganalytics/registration.go b/internal/services/loganalytics/registration.go index 975f0e46ca66..1161e33c882a 100644 --- a/internal/services/loganalytics/registration.go +++ b/internal/services/loganalytics/registration.go @@ -7,12 +7,25 @@ import ( type Registration struct{} -var _ sdk.UntypedServiceRegistrationWithAGitHubLabel = Registration{} +var ( + _ sdk.TypedServiceRegistration = Registration{} + _ sdk.UntypedServiceRegistrationWithAGitHubLabel = Registration{} +) func (r Registration) AssociatedGitHubLabel() string { return "service/log-analytics" } +func (r Registration) DataSources() []sdk.DataSource { + return []sdk.DataSource{} +} + +func (r Registration) Resources() []sdk.Resource { + return []sdk.Resource{ + LogAnalyticsQueryPackResource{}, + } +} + // Name is the name of this Service func (r Registration) Name() string { return "Log Analytics" diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/applicationinsights/2022-04-01/applicationinsights/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/applicationinsights/2022-04-01/applicationinsights/README.md index e67de93e11a0..8080cc0ccaf5 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/applicationinsights/2022-04-01/applicationinsights/README.md +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/applicationinsights/2022-04-01/applicationinsights/README.md @@ -77,7 +77,7 @@ if model := read.Model; model != nil { ```go ctx := context.TODO() -id := applicationinsights.NewResourceGroupID() +id := applicationinsights.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") // alternatively `client.WorkbooksListByResourceGroup(ctx, id, applicationinsights.DefaultWorkbooksListByResourceGroupOperationOptions())` can be used to do batched pagination items, err := client.WorkbooksListByResourceGroupComplete(ctx, id, applicationinsights.DefaultWorkbooksListByResourceGroupOperationOptions()) @@ -94,7 +94,7 @@ for _, item := range items { ```go ctx := context.TODO() -id := applicationinsights.NewSubscriptionID() +id := applicationinsights.NewSubscriptionID("12345678-1234-9876-4563-123456789012") // alternatively `client.WorkbooksListBySubscription(ctx, id, applicationinsights.DefaultWorkbooksListBySubscriptionOperationOptions())` can be used to do batched pagination items, err := client.WorkbooksListBySubscriptionComplete(ctx, id, applicationinsights.DefaultWorkbooksListBySubscriptionOperationOptions()) diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/README.md new file mode 100644 index 000000000000..5f22f8cc4499 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/README.md @@ -0,0 +1,241 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights` Documentation + +The `operationalinsights` SDK allows for interaction with the Azure Resource Manager Service `operationalinsights` (API Version `2019-09-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights" +``` + + +### Client Initialization + +```go +client := operationalinsights.NewOperationalInsightsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `OperationalInsightsClient.QueriesDelete` + +```go +ctx := context.TODO() +id := operationalinsights.NewQueriesID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackValue", "idValue") + +read, err := client.QueriesDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `OperationalInsightsClient.QueriesGet` + +```go +ctx := context.TODO() +id := operationalinsights.NewQueriesID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackValue", "idValue") + +read, err := client.QueriesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `OperationalInsightsClient.QueriesList` + +```go +ctx := context.TODO() +id := operationalinsights.NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackValue") + +// alternatively `client.QueriesList(ctx, id, operationalinsights.DefaultQueriesListOperationOptions())` can be used to do batched pagination +items, err := client.QueriesListComplete(ctx, id, operationalinsights.DefaultQueriesListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `OperationalInsightsClient.QueriesPut` + +```go +ctx := context.TODO() +id := operationalinsights.NewQueriesID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackValue", "idValue") + +payload := operationalinsights.LogAnalyticsQueryPackQuery{ + // ... +} + + +read, err := client.QueriesPut(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `OperationalInsightsClient.QueriesSearch` + +```go +ctx := context.TODO() +id := operationalinsights.NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackValue") + +payload := operationalinsights.LogAnalyticsQueryPackQuerySearchProperties{ + // ... +} + + +// alternatively `client.QueriesSearch(ctx, id, payload, operationalinsights.DefaultQueriesSearchOperationOptions())` can be used to do batched pagination +items, err := client.QueriesSearchComplete(ctx, id, payload, operationalinsights.DefaultQueriesSearchOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `OperationalInsightsClient.QueriesUpdate` + +```go +ctx := context.TODO() +id := operationalinsights.NewQueriesID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackValue", "idValue") + +payload := operationalinsights.LogAnalyticsQueryPackQuery{ + // ... +} + + +read, err := client.QueriesUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `OperationalInsightsClient.QueryPacksCreateOrUpdate` + +```go +ctx := context.TODO() +id := operationalinsights.NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackValue") + +payload := operationalinsights.LogAnalyticsQueryPack{ + // ... +} + + +read, err := client.QueryPacksCreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `OperationalInsightsClient.QueryPacksDelete` + +```go +ctx := context.TODO() +id := operationalinsights.NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackValue") + +read, err := client.QueryPacksDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `OperationalInsightsClient.QueryPacksGet` + +```go +ctx := context.TODO() +id := operationalinsights.NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackValue") + +read, err := client.QueryPacksGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `OperationalInsightsClient.QueryPacksList` + +```go +ctx := context.TODO() +id := operationalinsights.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.QueryPacksList(ctx, id)` can be used to do batched pagination +items, err := client.QueryPacksListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `OperationalInsightsClient.QueryPacksListByResourceGroup` + +```go +ctx := context.TODO() +id := operationalinsights.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.QueryPacksListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.QueryPacksListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `OperationalInsightsClient.QueryPacksUpdateTags` + +```go +ctx := context.TODO() +id := operationalinsights.NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackValue") + +payload := operationalinsights.TagsResource{ + // ... +} + + +read, err := client.QueryPacksUpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/client.go new file mode 100644 index 000000000000..f870e5c2d7b0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/client.go @@ -0,0 +1,18 @@ +package operationalinsights + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OperationalInsightsClient struct { + Client autorest.Client + baseUri string +} + +func NewOperationalInsightsClientWithBaseURI(endpoint string) OperationalInsightsClient { + return OperationalInsightsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/id_queries.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/id_queries.go new file mode 100644 index 000000000000..55cbdcc5b4d9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/id_queries.go @@ -0,0 +1,137 @@ +package operationalinsights + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = QueriesId{} + +// QueriesId is a struct representing the Resource ID for a Queries +type QueriesId struct { + SubscriptionId string + ResourceGroupName string + QueryPackName string + Id string +} + +// NewQueriesID returns a new QueriesId struct +func NewQueriesID(subscriptionId string, resourceGroupName string, queryPackName string, id string) QueriesId { + return QueriesId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + QueryPackName: queryPackName, + Id: id, + } +} + +// ParseQueriesID parses 'input' into a QueriesId +func ParseQueriesID(input string) (*QueriesId, error) { + parser := resourceids.NewParserFromResourceIdType(QueriesId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := QueriesId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.QueryPackName, ok = parsed.Parsed["queryPackName"]; !ok { + return nil, fmt.Errorf("the segment 'queryPackName' was not found in the resource id %q", input) + } + + if id.Id, ok = parsed.Parsed["id"]; !ok { + return nil, fmt.Errorf("the segment 'id' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseQueriesIDInsensitively parses 'input' case-insensitively into a QueriesId +// note: this method should only be used for API response data and not user input +func ParseQueriesIDInsensitively(input string) (*QueriesId, error) { + parser := resourceids.NewParserFromResourceIdType(QueriesId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := QueriesId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.QueryPackName, ok = parsed.Parsed["queryPackName"]; !ok { + return nil, fmt.Errorf("the segment 'queryPackName' was not found in the resource id %q", input) + } + + if id.Id, ok = parsed.Parsed["id"]; !ok { + return nil, fmt.Errorf("the segment 'id' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateQueriesID checks that 'input' can be parsed as a Queries ID +func ValidateQueriesID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseQueriesID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Queries ID +func (id QueriesId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/queryPacks/%s/queries/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.QueryPackName, id.Id) +} + +// Segments returns a slice of Resource ID Segments which comprise this Queries ID +func (id QueriesId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticQueryPacks", "queryPacks", "queryPacks"), + resourceids.UserSpecifiedSegment("queryPackName", "queryPackValue"), + resourceids.StaticSegment("staticQueries", "queries", "queries"), + resourceids.UserSpecifiedSegment("id", "idValue"), + } +} + +// String returns a human-readable description of this Queries ID +func (id QueriesId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Query Pack Name: %q", id.QueryPackName), + fmt.Sprintf(": %q", id.Id), + } + return fmt.Sprintf("Queries (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/id_querypack.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/id_querypack.go new file mode 100644 index 000000000000..b7a249a5c602 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/id_querypack.go @@ -0,0 +1,124 @@ +package operationalinsights + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = QueryPackId{} + +// QueryPackId is a struct representing the Resource ID for a Query Pack +type QueryPackId struct { + SubscriptionId string + ResourceGroupName string + QueryPackName string +} + +// NewQueryPackID returns a new QueryPackId struct +func NewQueryPackID(subscriptionId string, resourceGroupName string, queryPackName string) QueryPackId { + return QueryPackId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + QueryPackName: queryPackName, + } +} + +// ParseQueryPackID parses 'input' into a QueryPackId +func ParseQueryPackID(input string) (*QueryPackId, error) { + parser := resourceids.NewParserFromResourceIdType(QueryPackId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := QueryPackId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.QueryPackName, ok = parsed.Parsed["queryPackName"]; !ok { + return nil, fmt.Errorf("the segment 'queryPackName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseQueryPackIDInsensitively parses 'input' case-insensitively into a QueryPackId +// note: this method should only be used for API response data and not user input +func ParseQueryPackIDInsensitively(input string) (*QueryPackId, error) { + parser := resourceids.NewParserFromResourceIdType(QueryPackId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := QueryPackId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.QueryPackName, ok = parsed.Parsed["queryPackName"]; !ok { + return nil, fmt.Errorf("the segment 'queryPackName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateQueryPackID checks that 'input' can be parsed as a Query Pack ID +func ValidateQueryPackID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseQueryPackID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Query Pack ID +func (id QueryPackId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/queryPacks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.QueryPackName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Query Pack ID +func (id QueryPackId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticQueryPacks", "queryPacks", "queryPacks"), + resourceids.UserSpecifiedSegment("queryPackName", "queryPackValue"), + } +} + +// String returns a human-readable description of this Query Pack ID +func (id QueryPackId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Query Pack Name: %q", id.QueryPackName), + } + return fmt.Sprintf("Query Pack (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_queriesdelete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_queriesdelete_autorest.go new file mode 100644 index 000000000000..eb8278f90180 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_queriesdelete_autorest.go @@ -0,0 +1,65 @@ +package operationalinsights + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueriesDeleteOperationResponse struct { + HttpResponse *http.Response +} + +// QueriesDelete ... +func (c OperationalInsightsClient) QueriesDelete(ctx context.Context, id QueriesId) (result QueriesDeleteOperationResponse, err error) { + req, err := c.preparerForQueriesDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesDelete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesDelete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForQueriesDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesDelete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForQueriesDelete prepares the QueriesDelete request. +func (c OperationalInsightsClient) preparerForQueriesDelete(ctx context.Context, id QueriesId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForQueriesDelete handles the response to the QueriesDelete request. The method always +// closes the http.Response Body. +func (c OperationalInsightsClient) responderForQueriesDelete(resp *http.Response) (result QueriesDeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_queriesget_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_queriesget_autorest.go new file mode 100644 index 000000000000..7b014b8e89db --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_queriesget_autorest.go @@ -0,0 +1,67 @@ +package operationalinsights + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueriesGetOperationResponse struct { + HttpResponse *http.Response + Model *LogAnalyticsQueryPackQuery +} + +// QueriesGet ... +func (c OperationalInsightsClient) QueriesGet(ctx context.Context, id QueriesId) (result QueriesGetOperationResponse, err error) { + req, err := c.preparerForQueriesGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesGet", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesGet", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForQueriesGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesGet", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForQueriesGet prepares the QueriesGet request. +func (c OperationalInsightsClient) preparerForQueriesGet(ctx context.Context, id QueriesId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForQueriesGet handles the response to the QueriesGet request. The method always +// closes the http.Response Body. +func (c OperationalInsightsClient) responderForQueriesGet(resp *http.Response) (result QueriesGetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_querieslist_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_querieslist_autorest.go new file mode 100644 index 000000000000..1254f7c00d55 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_querieslist_autorest.go @@ -0,0 +1,220 @@ +package operationalinsights + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueriesListOperationResponse struct { + HttpResponse *http.Response + Model *[]LogAnalyticsQueryPackQuery + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (QueriesListOperationResponse, error) +} + +type QueriesListCompleteResult struct { + Items []LogAnalyticsQueryPackQuery +} + +func (r QueriesListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r QueriesListOperationResponse) LoadMore(ctx context.Context) (resp QueriesListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type QueriesListOperationOptions struct { + IncludeBody *bool + Top *int64 +} + +func DefaultQueriesListOperationOptions() QueriesListOperationOptions { + return QueriesListOperationOptions{} +} + +func (o QueriesListOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o QueriesListOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.IncludeBody != nil { + out["includeBody"] = *o.IncludeBody + } + + if o.Top != nil { + out["$top"] = *o.Top + } + + return out +} + +// QueriesList ... +func (c OperationalInsightsClient) QueriesList(ctx context.Context, id QueryPackId, options QueriesListOperationOptions) (resp QueriesListOperationResponse, err error) { + req, err := c.preparerForQueriesList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesList", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesList", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForQueriesList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesList", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// QueriesListComplete retrieves all of the results into a single object +func (c OperationalInsightsClient) QueriesListComplete(ctx context.Context, id QueryPackId, options QueriesListOperationOptions) (QueriesListCompleteResult, error) { + return c.QueriesListCompleteMatchingPredicate(ctx, id, options, LogAnalyticsQueryPackQueryOperationPredicate{}) +} + +// QueriesListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c OperationalInsightsClient) QueriesListCompleteMatchingPredicate(ctx context.Context, id QueryPackId, options QueriesListOperationOptions, predicate LogAnalyticsQueryPackQueryOperationPredicate) (resp QueriesListCompleteResult, err error) { + items := make([]LogAnalyticsQueryPackQuery, 0) + + page, err := c.QueriesList(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := QueriesListCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForQueriesList prepares the QueriesList request. +func (c OperationalInsightsClient) preparerForQueriesList(ctx context.Context, id QueryPackId, options QueriesListOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/queries", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForQueriesListWithNextLink prepares the QueriesList request with the given nextLink token. +func (c OperationalInsightsClient) preparerForQueriesListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForQueriesList handles the response to the QueriesList request. The method always +// closes the http.Response Body. +func (c OperationalInsightsClient) responderForQueriesList(resp *http.Response) (result QueriesListOperationResponse, err error) { + type page struct { + Values []LogAnalyticsQueryPackQuery `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result QueriesListOperationResponse, err error) { + req, err := c.preparerForQueriesListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesList", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesList", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForQueriesList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesList", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_queriesput_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_queriesput_autorest.go new file mode 100644 index 000000000000..5e93a3d3e9d7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_queriesput_autorest.go @@ -0,0 +1,68 @@ +package operationalinsights + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueriesPutOperationResponse struct { + HttpResponse *http.Response + Model *LogAnalyticsQueryPackQuery +} + +// QueriesPut ... +func (c OperationalInsightsClient) QueriesPut(ctx context.Context, id QueriesId, input LogAnalyticsQueryPackQuery) (result QueriesPutOperationResponse, err error) { + req, err := c.preparerForQueriesPut(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesPut", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesPut", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForQueriesPut(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesPut", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForQueriesPut prepares the QueriesPut request. +func (c OperationalInsightsClient) preparerForQueriesPut(ctx context.Context, id QueriesId, input LogAnalyticsQueryPackQuery) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForQueriesPut handles the response to the QueriesPut request. The method always +// closes the http.Response Body. +func (c OperationalInsightsClient) responderForQueriesPut(resp *http.Response) (result QueriesPutOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_queriessearch_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_queriessearch_autorest.go new file mode 100644 index 000000000000..871113c98db0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_queriessearch_autorest.go @@ -0,0 +1,221 @@ +package operationalinsights + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueriesSearchOperationResponse struct { + HttpResponse *http.Response + Model *[]LogAnalyticsQueryPackQuery + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (QueriesSearchOperationResponse, error) +} + +type QueriesSearchCompleteResult struct { + Items []LogAnalyticsQueryPackQuery +} + +func (r QueriesSearchOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r QueriesSearchOperationResponse) LoadMore(ctx context.Context) (resp QueriesSearchOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type QueriesSearchOperationOptions struct { + IncludeBody *bool + Top *int64 +} + +func DefaultQueriesSearchOperationOptions() QueriesSearchOperationOptions { + return QueriesSearchOperationOptions{} +} + +func (o QueriesSearchOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o QueriesSearchOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.IncludeBody != nil { + out["includeBody"] = *o.IncludeBody + } + + if o.Top != nil { + out["$top"] = *o.Top + } + + return out +} + +// QueriesSearch ... +func (c OperationalInsightsClient) QueriesSearch(ctx context.Context, id QueryPackId, input LogAnalyticsQueryPackQuerySearchProperties, options QueriesSearchOperationOptions) (resp QueriesSearchOperationResponse, err error) { + req, err := c.preparerForQueriesSearch(ctx, id, input, options) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesSearch", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesSearch", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForQueriesSearch(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesSearch", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// QueriesSearchComplete retrieves all of the results into a single object +func (c OperationalInsightsClient) QueriesSearchComplete(ctx context.Context, id QueryPackId, input LogAnalyticsQueryPackQuerySearchProperties, options QueriesSearchOperationOptions) (QueriesSearchCompleteResult, error) { + return c.QueriesSearchCompleteMatchingPredicate(ctx, id, input, options, LogAnalyticsQueryPackQueryOperationPredicate{}) +} + +// QueriesSearchCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c OperationalInsightsClient) QueriesSearchCompleteMatchingPredicate(ctx context.Context, id QueryPackId, input LogAnalyticsQueryPackQuerySearchProperties, options QueriesSearchOperationOptions, predicate LogAnalyticsQueryPackQueryOperationPredicate) (resp QueriesSearchCompleteResult, err error) { + items := make([]LogAnalyticsQueryPackQuery, 0) + + page, err := c.QueriesSearch(ctx, id, input, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := QueriesSearchCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForQueriesSearch prepares the QueriesSearch request. +func (c OperationalInsightsClient) preparerForQueriesSearch(ctx context.Context, id QueryPackId, input LogAnalyticsQueryPackQuerySearchProperties, options QueriesSearchOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/queries/search", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForQueriesSearchWithNextLink prepares the QueriesSearch request with the given nextLink token. +func (c OperationalInsightsClient) preparerForQueriesSearchWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForQueriesSearch handles the response to the QueriesSearch request. The method always +// closes the http.Response Body. +func (c OperationalInsightsClient) responderForQueriesSearch(resp *http.Response) (result QueriesSearchOperationResponse, err error) { + type page struct { + Values []LogAnalyticsQueryPackQuery `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result QueriesSearchOperationResponse, err error) { + req, err := c.preparerForQueriesSearchWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesSearch", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesSearch", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForQueriesSearch(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesSearch", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_queriesupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_queriesupdate_autorest.go new file mode 100644 index 000000000000..8d2380d9c891 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_queriesupdate_autorest.go @@ -0,0 +1,68 @@ +package operationalinsights + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueriesUpdateOperationResponse struct { + HttpResponse *http.Response + Model *LogAnalyticsQueryPackQuery +} + +// QueriesUpdate ... +func (c OperationalInsightsClient) QueriesUpdate(ctx context.Context, id QueriesId, input LogAnalyticsQueryPackQuery) (result QueriesUpdateOperationResponse, err error) { + req, err := c.preparerForQueriesUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesUpdate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesUpdate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForQueriesUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueriesUpdate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForQueriesUpdate prepares the QueriesUpdate request. +func (c OperationalInsightsClient) preparerForQueriesUpdate(ctx context.Context, id QueriesId, input LogAnalyticsQueryPackQuery) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForQueriesUpdate handles the response to the QueriesUpdate request. The method always +// closes the http.Response Body. +func (c OperationalInsightsClient) responderForQueriesUpdate(resp *http.Response) (result QueriesUpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_querypackscreateorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_querypackscreateorupdate_autorest.go new file mode 100644 index 000000000000..5c63cfc96fab --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_querypackscreateorupdate_autorest.go @@ -0,0 +1,68 @@ +package operationalinsights + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryPacksCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + Model *LogAnalyticsQueryPack +} + +// QueryPacksCreateOrUpdate ... +func (c OperationalInsightsClient) QueryPacksCreateOrUpdate(ctx context.Context, id QueryPackId, input LogAnalyticsQueryPack) (result QueryPacksCreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForQueryPacksCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksCreateOrUpdate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksCreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForQueryPacksCreateOrUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksCreateOrUpdate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForQueryPacksCreateOrUpdate prepares the QueryPacksCreateOrUpdate request. +func (c OperationalInsightsClient) preparerForQueryPacksCreateOrUpdate(ctx context.Context, id QueryPackId, input LogAnalyticsQueryPack) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForQueryPacksCreateOrUpdate handles the response to the QueryPacksCreateOrUpdate request. The method always +// closes the http.Response Body. +func (c OperationalInsightsClient) responderForQueryPacksCreateOrUpdate(resp *http.Response) (result QueryPacksCreateOrUpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_querypacksdelete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_querypacksdelete_autorest.go new file mode 100644 index 000000000000..fd595d13bc48 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_querypacksdelete_autorest.go @@ -0,0 +1,65 @@ +package operationalinsights + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryPacksDeleteOperationResponse struct { + HttpResponse *http.Response +} + +// QueryPacksDelete ... +func (c OperationalInsightsClient) QueryPacksDelete(ctx context.Context, id QueryPackId) (result QueryPacksDeleteOperationResponse, err error) { + req, err := c.preparerForQueryPacksDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksDelete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksDelete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForQueryPacksDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksDelete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForQueryPacksDelete prepares the QueryPacksDelete request. +func (c OperationalInsightsClient) preparerForQueryPacksDelete(ctx context.Context, id QueryPackId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForQueryPacksDelete handles the response to the QueryPacksDelete request. The method always +// closes the http.Response Body. +func (c OperationalInsightsClient) responderForQueryPacksDelete(resp *http.Response) (result QueryPacksDeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_querypacksget_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_querypacksget_autorest.go new file mode 100644 index 000000000000..072d930b2c2d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_querypacksget_autorest.go @@ -0,0 +1,67 @@ +package operationalinsights + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryPacksGetOperationResponse struct { + HttpResponse *http.Response + Model *LogAnalyticsQueryPack +} + +// QueryPacksGet ... +func (c OperationalInsightsClient) QueryPacksGet(ctx context.Context, id QueryPackId) (result QueryPacksGetOperationResponse, err error) { + req, err := c.preparerForQueryPacksGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksGet", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksGet", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForQueryPacksGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksGet", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForQueryPacksGet prepares the QueryPacksGet request. +func (c OperationalInsightsClient) preparerForQueryPacksGet(ctx context.Context, id QueryPackId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForQueryPacksGet handles the response to the QueryPacksGet request. The method always +// closes the http.Response Body. +func (c OperationalInsightsClient) responderForQueryPacksGet(resp *http.Response) (result QueryPacksGetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_querypackslist_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_querypackslist_autorest.go new file mode 100644 index 000000000000..579cd4fbb24d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_querypackslist_autorest.go @@ -0,0 +1,187 @@ +package operationalinsights + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryPacksListOperationResponse struct { + HttpResponse *http.Response + Model *[]LogAnalyticsQueryPack + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (QueryPacksListOperationResponse, error) +} + +type QueryPacksListCompleteResult struct { + Items []LogAnalyticsQueryPack +} + +func (r QueryPacksListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r QueryPacksListOperationResponse) LoadMore(ctx context.Context) (resp QueryPacksListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// QueryPacksList ... +func (c OperationalInsightsClient) QueryPacksList(ctx context.Context, id commonids.SubscriptionId) (resp QueryPacksListOperationResponse, err error) { + req, err := c.preparerForQueryPacksList(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksList", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksList", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForQueryPacksList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksList", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// QueryPacksListComplete retrieves all of the results into a single object +func (c OperationalInsightsClient) QueryPacksListComplete(ctx context.Context, id commonids.SubscriptionId) (QueryPacksListCompleteResult, error) { + return c.QueryPacksListCompleteMatchingPredicate(ctx, id, LogAnalyticsQueryPackOperationPredicate{}) +} + +// QueryPacksListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c OperationalInsightsClient) QueryPacksListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate LogAnalyticsQueryPackOperationPredicate) (resp QueryPacksListCompleteResult, err error) { + items := make([]LogAnalyticsQueryPack, 0) + + page, err := c.QueryPacksList(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := QueryPacksListCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForQueryPacksList prepares the QueryPacksList request. +func (c OperationalInsightsClient) preparerForQueryPacksList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.OperationalInsights/queryPacks", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForQueryPacksListWithNextLink prepares the QueryPacksList request with the given nextLink token. +func (c OperationalInsightsClient) preparerForQueryPacksListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForQueryPacksList handles the response to the QueryPacksList request. The method always +// closes the http.Response Body. +func (c OperationalInsightsClient) responderForQueryPacksList(resp *http.Response) (result QueryPacksListOperationResponse, err error) { + type page struct { + Values []LogAnalyticsQueryPack `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result QueryPacksListOperationResponse, err error) { + req, err := c.preparerForQueryPacksListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksList", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksList", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForQueryPacksList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksList", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_querypackslistbyresourcegroup_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_querypackslistbyresourcegroup_autorest.go new file mode 100644 index 000000000000..039d8addb9a3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_querypackslistbyresourcegroup_autorest.go @@ -0,0 +1,187 @@ +package operationalinsights + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryPacksListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + Model *[]LogAnalyticsQueryPack + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (QueryPacksListByResourceGroupOperationResponse, error) +} + +type QueryPacksListByResourceGroupCompleteResult struct { + Items []LogAnalyticsQueryPack +} + +func (r QueryPacksListByResourceGroupOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r QueryPacksListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp QueryPacksListByResourceGroupOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// QueryPacksListByResourceGroup ... +func (c OperationalInsightsClient) QueryPacksListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp QueryPacksListByResourceGroupOperationResponse, err error) { + req, err := c.preparerForQueryPacksListByResourceGroup(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksListByResourceGroup", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksListByResourceGroup", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForQueryPacksListByResourceGroup(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksListByResourceGroup", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// QueryPacksListByResourceGroupComplete retrieves all of the results into a single object +func (c OperationalInsightsClient) QueryPacksListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (QueryPacksListByResourceGroupCompleteResult, error) { + return c.QueryPacksListByResourceGroupCompleteMatchingPredicate(ctx, id, LogAnalyticsQueryPackOperationPredicate{}) +} + +// QueryPacksListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c OperationalInsightsClient) QueryPacksListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate LogAnalyticsQueryPackOperationPredicate) (resp QueryPacksListByResourceGroupCompleteResult, err error) { + items := make([]LogAnalyticsQueryPack, 0) + + page, err := c.QueryPacksListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := QueryPacksListByResourceGroupCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForQueryPacksListByResourceGroup prepares the QueryPacksListByResourceGroup request. +func (c OperationalInsightsClient) preparerForQueryPacksListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.OperationalInsights/queryPacks", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForQueryPacksListByResourceGroupWithNextLink prepares the QueryPacksListByResourceGroup request with the given nextLink token. +func (c OperationalInsightsClient) preparerForQueryPacksListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForQueryPacksListByResourceGroup handles the response to the QueryPacksListByResourceGroup request. The method always +// closes the http.Response Body. +func (c OperationalInsightsClient) responderForQueryPacksListByResourceGroup(resp *http.Response) (result QueryPacksListByResourceGroupOperationResponse, err error) { + type page struct { + Values []LogAnalyticsQueryPack `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result QueryPacksListByResourceGroupOperationResponse, err error) { + req, err := c.preparerForQueryPacksListByResourceGroupWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksListByResourceGroup", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksListByResourceGroup", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForQueryPacksListByResourceGroup(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksListByResourceGroup", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_querypacksupdatetags_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_querypacksupdatetags_autorest.go new file mode 100644 index 000000000000..c79573724951 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/method_querypacksupdatetags_autorest.go @@ -0,0 +1,68 @@ +package operationalinsights + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryPacksUpdateTagsOperationResponse struct { + HttpResponse *http.Response + Model *LogAnalyticsQueryPack +} + +// QueryPacksUpdateTags ... +func (c OperationalInsightsClient) QueryPacksUpdateTags(ctx context.Context, id QueryPackId, input TagsResource) (result QueryPacksUpdateTagsOperationResponse, err error) { + req, err := c.preparerForQueryPacksUpdateTags(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksUpdateTags", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksUpdateTags", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForQueryPacksUpdateTags(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.OperationalInsightsClient", "QueryPacksUpdateTags", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForQueryPacksUpdateTags prepares the QueryPacksUpdateTags request. +func (c OperationalInsightsClient) preparerForQueryPacksUpdateTags(ctx context.Context, id QueryPackId, input TagsResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForQueryPacksUpdateTags handles the response to the QueryPacksUpdateTags request. The method always +// closes the http.Response Body. +func (c OperationalInsightsClient) responderForQueryPacksUpdateTags(resp *http.Response) (result QueryPacksUpdateTagsOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_loganalyticsquerypack.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_loganalyticsquerypack.go new file mode 100644 index 000000000000..e57399848453 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_loganalyticsquerypack.go @@ -0,0 +1,13 @@ +package operationalinsights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogAnalyticsQueryPack struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties LogAnalyticsQueryPackProperties `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_loganalyticsquerypackproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_loganalyticsquerypackproperties.go new file mode 100644 index 000000000000..1f1a23095fb3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_loganalyticsquerypackproperties.go @@ -0,0 +1,41 @@ +package operationalinsights + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogAnalyticsQueryPackProperties struct { + ProvisioningState *string `json:"provisioningState,omitempty"` + QueryPackId *string `json:"queryPackId,omitempty"` + TimeCreated *string `json:"timeCreated,omitempty"` + TimeModified *string `json:"timeModified,omitempty"` +} + +func (o *LogAnalyticsQueryPackProperties) GetTimeCreatedAsTime() (*time.Time, error) { + if o.TimeCreated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") +} + +func (o *LogAnalyticsQueryPackProperties) SetTimeCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeCreated = &formatted +} + +func (o *LogAnalyticsQueryPackProperties) GetTimeModifiedAsTime() (*time.Time, error) { + if o.TimeModified == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeModified, "2006-01-02T15:04:05Z07:00") +} + +func (o *LogAnalyticsQueryPackProperties) SetTimeModifiedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeModified = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_loganalyticsquerypackquery.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_loganalyticsquerypackquery.go new file mode 100644 index 000000000000..287060b61cc1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_loganalyticsquerypackquery.go @@ -0,0 +1,16 @@ +package operationalinsights + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogAnalyticsQueryPackQuery struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *LogAnalyticsQueryPackQueryProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_loganalyticsquerypackqueryproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_loganalyticsquerypackqueryproperties.go new file mode 100644 index 000000000000..879779960ca4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_loganalyticsquerypackqueryproperties.go @@ -0,0 +1,47 @@ +package operationalinsights + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogAnalyticsQueryPackQueryProperties struct { + Author *string `json:"author,omitempty"` + Body string `json:"body"` + Description *string `json:"description,omitempty"` + DisplayName string `json:"displayName"` + Id *string `json:"id,omitempty"` + Properties *interface{} `json:"properties,omitempty"` + Related *LogAnalyticsQueryPackQueryPropertiesRelated `json:"related,omitempty"` + Tags *map[string][]string `json:"tags,omitempty"` + TimeCreated *string `json:"timeCreated,omitempty"` + TimeModified *string `json:"timeModified,omitempty"` +} + +func (o *LogAnalyticsQueryPackQueryProperties) GetTimeCreatedAsTime() (*time.Time, error) { + if o.TimeCreated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") +} + +func (o *LogAnalyticsQueryPackQueryProperties) SetTimeCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeCreated = &formatted +} + +func (o *LogAnalyticsQueryPackQueryProperties) GetTimeModifiedAsTime() (*time.Time, error) { + if o.TimeModified == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeModified, "2006-01-02T15:04:05Z07:00") +} + +func (o *LogAnalyticsQueryPackQueryProperties) SetTimeModifiedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeModified = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_loganalyticsquerypackquerypropertiesrelated.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_loganalyticsquerypackquerypropertiesrelated.go new file mode 100644 index 000000000000..af17f38c40bd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_loganalyticsquerypackquerypropertiesrelated.go @@ -0,0 +1,10 @@ +package operationalinsights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogAnalyticsQueryPackQueryPropertiesRelated struct { + Categories *[]string `json:"categories,omitempty"` + ResourceTypes *[]string `json:"resourceTypes,omitempty"` + Solutions *[]string `json:"solutions,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_loganalyticsquerypackquerysearchproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_loganalyticsquerypackquerysearchproperties.go new file mode 100644 index 000000000000..f801bd037f50 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_loganalyticsquerypackquerysearchproperties.go @@ -0,0 +1,9 @@ +package operationalinsights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogAnalyticsQueryPackQuerySearchProperties struct { + Related *LogAnalyticsQueryPackQuerySearchPropertiesRelated `json:"related,omitempty"` + Tags *map[string][]string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_loganalyticsquerypackquerysearchpropertiesrelated.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_loganalyticsquerypackquerysearchpropertiesrelated.go new file mode 100644 index 000000000000..77f06e6f257e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_loganalyticsquerypackquerysearchpropertiesrelated.go @@ -0,0 +1,10 @@ +package operationalinsights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogAnalyticsQueryPackQuerySearchPropertiesRelated struct { + Categories *[]string `json:"categories,omitempty"` + ResourceTypes *[]string `json:"resourceTypes,omitempty"` + Solutions *[]string `json:"solutions,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_tagsresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_tagsresource.go new file mode 100644 index 000000000000..a3a35998071c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/model_tagsresource.go @@ -0,0 +1,8 @@ +package operationalinsights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsResource struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/predicates.go new file mode 100644 index 000000000000..510b201b5b1d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/predicates.go @@ -0,0 +1,52 @@ +package operationalinsights + +type LogAnalyticsQueryPackOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p LogAnalyticsQueryPackOperationPredicate) Matches(input LogAnalyticsQueryPack) bool { + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { + return false + } + + return true +} + +type LogAnalyticsQueryPackQueryOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p LogAnalyticsQueryPackQueryOperationPredicate) Matches(input LogAnalyticsQueryPackQuery) bool { + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/version.go new file mode 100644 index 000000000000..c3778597984a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights/version.go @@ -0,0 +1,12 @@ +package operationalinsights + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2019-09-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/operationalinsights/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 7db8b191f03b..9a9643b2876b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -247,6 +247,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/volumes github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/volumesreplication github.com/hashicorp/go-azure-sdk/resource-manager/notificationhubs/2017-04-01/namespaces github.com/hashicorp/go-azure-sdk/resource-manager/notificationhubs/2017-04-01/notificationhubs +github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2019-09-01/operationalinsights github.com/hashicorp/go-azure-sdk/resource-manager/policyinsights/2021-10-01/policyinsights github.com/hashicorp/go-azure-sdk/resource-manager/portal/2019-01-01-preview/dashboard github.com/hashicorp/go-azure-sdk/resource-manager/portal/2019-01-01-preview/tenantconfiguration diff --git a/website/docs/r/log_analytics_query_pack.html.markdown b/website/docs/r/log_analytics_query_pack.html.markdown new file mode 100644 index 000000000000..116fbe8fd528 --- /dev/null +++ b/website/docs/r/log_analytics_query_pack.html.markdown @@ -0,0 +1,63 @@ +--- +subcategory: "Log Analytics" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_log_analytics_query_pack" +description: |- + Manages a Log Analytics Query Pack. +--- + +# azurerm_log_analytics_query_pack + +Manages a Log Analytics Query Pack. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_log_analytics_query_pack" "example" { + name = "example-laqp" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) The name which should be used for this Log Analytics Query Pack. Changing this forces a new resource to be created. + +* `location` - (Required) The Azure Region where the Log Analytics Query Pack should exist. Changing this forces a new resource to be created. + +* `resource_group_name` - (Required) The name of the Resource Group where the Log Analytics Query Pack should exist. Changing this forces a new resource to be created. + +* `tags` - (Optional) A mapping of tags which should be assigned to the Log Analytics Query Pack. + +--- + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Log Analytics Query Pack. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the Log Analytics Query Pack. +* `read` - (Defaults to 5 minutes) Used when retrieving the Log Analytics Query Pack. +* `update` - (Defaults to 30 minutes) Used when updating the Log Analytics Query Pack. +* `delete` - (Defaults to 30 minutes) Used when deleting the Log Analytics Query Pack. + +## Import + +Log Analytics Query Packs can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_log_analytics_query_pack.example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.OperationalInsights/queryPacks/queryPack1 +```