From 9c15af6edd9d7b1fcba95f2ffdfe4abedb549e8c Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Tue, 26 Dec 2023 13:44:23 +0800 Subject: [PATCH 1/3] `azurerm_log_analytics_cluster`: swap to typed sdk --- .gitignore | 4 + .../log_analytics_cluster_resource.go | 381 ++++++++++-------- .../services/loganalytics/registration.go | 2 +- .../2021-06-01/clusters/README.md | 116 ++++++ .../2021-06-01/clusters/client.go | 26 ++ .../2021-06-01/clusters/constants.go | 163 ++++++++ .../2021-06-01/clusters/id_cluster.go | 125 ++++++ .../clusters/method_createorupdate.go | 75 ++++ .../2021-06-01/clusters/method_delete.go | 71 ++++ .../2021-06-01/clusters/method_get.go | 51 +++ .../2021-06-01/clusters/method_list.go | 90 +++++ .../clusters/method_listbyresourcegroup.go | 90 +++++ .../2021-06-01/clusters/method_update.go | 73 ++++ .../clusters/model_associatedworkspace.go | 11 + .../model_capacityreservationproperties.go | 9 + .../2021-06-01/clusters/model_cluster.go | 19 + .../2021-06-01/clusters/model_clusterpatch.go | 15 + .../clusters/model_clusterpatchproperties.go | 9 + .../clusters/model_clusterproperties.go | 17 + .../2021-06-01/clusters/model_clustersku.go | 9 + .../clusters/model_keyvaultproperties.go | 11 + .../2021-06-01/clusters/predicates.go | 32 ++ .../2021-06-01/clusters/version.go | 12 + vendor/modules.txt | 1 + 24 files changed, 1238 insertions(+), 174 deletions(-) create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/id_cluster.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_list.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_listbyresourcegroup.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_update.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_associatedworkspace.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_capacityreservationproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_cluster.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clusterpatch.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clusterpatchproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clusterproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clustersku.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_keyvaultproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/version.go diff --git a/.gitignore b/.gitignore index d66003bb9a31..20e8707e6489 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,7 @@ tf.zip # do not upload secrets .env + +# custom for myself +.gitignore +.typos.toml diff --git a/internal/services/loganalytics/log_analytics_cluster_resource.go b/internal/services/loganalytics/log_analytics_cluster_resource.go index 136d8f7a761b..665ac312fc3f 100644 --- a/internal/services/loganalytics/log_analytics_cluster_resource.go +++ b/internal/services/loganalytics/log_analytics_cluster_resource.go @@ -4,237 +4,272 @@ package loganalytics import ( + "context" "fmt" - "log" "time" + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2020-08-01/clusters" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" - "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" "github.com/hashicorp/terraform-provider-azurerm/internal/services/loganalytics/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" - "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) -func resourceLogAnalyticsCluster() *pluginsdk.Resource { - return &pluginsdk.Resource{ - Create: resourceLogAnalyticsClusterCreate, - Read: resourceLogAnalyticsClusterRead, - Update: resourceLogAnalyticsClusterUpdate, - Delete: resourceLogAnalyticsClusterDelete, - - Timeouts: &pluginsdk.ResourceTimeout{ - Create: pluginsdk.DefaultTimeout(6 * time.Hour), - Read: pluginsdk.DefaultTimeout(5 * time.Minute), - Update: pluginsdk.DefaultTimeout(6 * time.Hour), - Delete: pluginsdk.DefaultTimeout(30 * time.Minute), - }, +type LogAnalyticsClusterResource struct{} - Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := clusters.ParseClusterID(id) - return err - }), +type LogAnalyticsClusterModel struct { + Name string `tfschema:"name"` + ResourceGroupName string `tfschema:"resource_group_name"` + Location string `tfschema:"location"` + Identity []identity.ModelSystemAssigned `tfschema:"identity"` + SizeGB int64 `tfschema:"size_gb"` + Tags map[string]string `tfschema:"tags"` + ClusterId string `tfschema:"cluster_id"` +} - Schema: map[string]*pluginsdk.Schema{ - "name": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validate.LogAnalyticsClusterName, - }, +var _ sdk.ResourceWithUpdate = LogAnalyticsClusterResource{} - "resource_group_name": commonschema.ResourceGroupName(), +func (l LogAnalyticsClusterResource) Arguments() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.LogAnalyticsClusterName, + }, - "location": commonschema.Location(), + "resource_group_name": commonschema.ResourceGroupName(), - "identity": commonschema.SystemAssignedIdentityRequiredForceNew(), + "location": commonschema.Location(), - "size_gb": { - Type: pluginsdk.TypeInt, - Optional: true, - Default: func() int { - if !features.FourPointOh() { - return 1000 - } - return 500 - }(), - ValidateFunc: validation.IntInSlice([]int{500, 1000, 2000, 5000}), - }, + "identity": commonschema.SystemAssignedIdentityRequiredForceNew(), - "cluster_id": { - Type: pluginsdk.TypeString, - Computed: true, - }, + "size_gb": { + Type: pluginsdk.TypeInt, + Optional: true, + Default: func() int { + if !features.FourPointOh() { + return 1000 + } + return 500 + }(), + ValidateFunc: validation.IntInSlice([]int{500, 1000, 2000, 5000}), + }, - "tags": tags.Schema(), + "availability_zones_enabled": { + Type: pluginsdk.TypeBool, + Default: true, + Optional: true, + ForceNew: true, // check the value previous created cluster }, + + "tags": tags.Schema(), } } -func resourceLogAnalyticsClusterCreate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).LogAnalytics.ClusterClient - subscriptionId := meta.(*clients.Client).Account.SubscriptionId - ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) - defer cancel() +func (l LogAnalyticsClusterResource) Attributes() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "cluster_id": { + Type: pluginsdk.TypeString, + Computed: true, + }, + } +} - id := clusters.NewClusterID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) +func (r LogAnalyticsClusterResource) ModelObject() interface{} { + return &LogAnalyticsClusterModel{} +} - locks.ByID(id.ID()) - defer locks.UnlockByID(id.ID()) +func (r LogAnalyticsClusterResource) ResourceType() string { + return "azurerm_log_analytics_cluster" +} - existing, err := client.Get(ctx, id) - if err != nil { - if !response.WasNotFound(existing.HttpResponse) { - return fmt.Errorf("checking for presence of existing %s: %+v", id, err) - } - } - if !response.WasNotFound(existing.HttpResponse) { - return tf.ImportAsExistsError("azurerm_log_analytics_cluster", id.ID()) - } +func (r LogAnalyticsClusterResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return clusters.ValidateClusterID +} - expandedIdentity, err := identity.ExpandSystemAssigned(d.Get("identity").([]interface{})) - if err != nil { - return fmt.Errorf("expanding `identity`: %+v", err) - } +func (r LogAnalyticsClusterResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 6 * time.Hour, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.LogAnalytics.ClusterClient + subscriptionId := metadata.Client.Account.SubscriptionId - capacityReservation := clusters.ClusterSkuNameEnumCapacityReservation - parameters := clusters.Cluster{ - Location: location.Normalize(d.Get("location").(string)), - Identity: expandedIdentity, - Sku: &clusters.ClusterSku{ - Capacity: utils.Int64(int64(d.Get("size_gb").(int))), - Name: &capacityReservation, - }, - Tags: expandTags(d.Get("tags").(map[string]interface{})), - } + var config LogAnalyticsClusterModel + if err := metadata.Decode(&config); err != nil { + return fmt.Errorf("decoding: %+v", err) + } - err = client.CreateOrUpdateThenPoll(ctx, id, parameters) - if err != nil { - return fmt.Errorf("creating %s: %+v", id, err) - } + id := clusters.NewClusterID(subscriptionId, config.ResourceGroupName, config.Name) - d.SetId(id.ID()) - return resourceLogAnalyticsClusterRead(d, meta) -} + locks.ByID(id.ID()) + defer locks.UnlockByID(id.ID()) -func resourceLogAnalyticsClusterRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).LogAnalytics.ClusterClient - ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) - defer cancel() + existing, err := client.Get(ctx, id) + if err != nil { + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) + } + } + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError(r.ResourceType(), id.ID()) + } - id, err := clusters.ParseClusterID(d.Id()) - if err != nil { - return err - } + expandedIdentity, err := identity.ExpandSystemAssignedFromModel(config.Identity) + if err != nil { + return fmt.Errorf("expanding `identity`: %+v", err) + } + + capacityReservation := clusters.ClusterSkuNameEnumCapacityReservation + parameters := clusters.Cluster{ + Location: location.Normalize(config.Location), + Identity: expandedIdentity, + Sku: &clusters.ClusterSku{ + Capacity: pointer.To(config.SizeGB), + Name: &capacityReservation, + }, + Tags: pointer.To(config.Tags), + } - resp, err := client.Get(ctx, *id) - if err != nil { - if response.WasNotFound(resp.HttpResponse) { - log.Printf("[INFO] Log Analytics %q does not exist - removing from state", d.Id()) - d.SetId("") + err = client.CreateOrUpdateThenPoll(ctx, id, parameters) + if err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) return nil - } - return fmt.Errorf("retrieving Log Analytics Cluster %q (Resource Group %q): %+v", id.ClusterName, id.ResourceGroupName, err) - } - d.Set("name", id.ClusterName) - d.Set("resource_group_name", id.ResourceGroupName) - - if model := resp.Model; model != nil { - d.Set("location", location.NormalizeNilable(&model.Location)) - if err = d.Set("identity", identity.FlattenSystemAssigned(model.Identity)); err != nil { - return fmt.Errorf("setting `identity`: %+v", err) - } - if props := model.Properties; props != nil { - d.Set("cluster_id", props.ClusterId) - } - capacity := 0 - if sku := model.Sku; sku != nil { - if sku.Capacity != nil { - capacity = int(*sku.Capacity) - } - } - d.Set("size_gb", capacity) - - if err = tags.FlattenAndSet(d, flattenTags(model.Tags)); err != nil { - return err - } + }, } - - return nil } -func resourceLogAnalyticsClusterUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).LogAnalytics.ClusterClient - ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) - defer cancel() +func (r LogAnalyticsClusterResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.LogAnalytics.ClusterClient - id, err := clusters.ParseClusterID(d.Id()) - if err != nil { - return err - } + id, err := clusters.ParseClusterID(metadata.ResourceData.Id()) + if err != nil { + return err + } - locks.ByID(id.ID()) - defer locks.UnlockByID(id.ID()) + resp, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return metadata.MarkAsGone(id) + } + return fmt.Errorf("retrieving %s: %+v", id, err) + } - resp, err := client.Get(ctx, *id) - if err != nil { - if response.WasNotFound(resp.HttpResponse) { - return fmt.Errorf("%s was not found", *id) - } + state := LogAnalyticsClusterModel{ + Name: id.ClusterName, + ResourceGroupName: id.ResourceGroupName, + } - return fmt.Errorf("retrieving %s: %+v", *id, err) - } + if model := resp.Model; model != nil { + state.Location = location.NormalizeNilable(&model.Location) - model := resp.Model - if model == nil { - return fmt.Errorf("`azurerm_log_analytics_cluster` %s: `model` is nil", *id) - } + flattenedIdentity := identity.FlattenSystemAssignedToModel(model.Identity) + if err != nil { + return fmt.Errorf("flattening `identity`: %+v", err) + } + state.Identity = flattenedIdentity - if props := model.Properties; props == nil { - return fmt.Errorf("`azurerm_log_analytics_cluster` %s: `Properties` is nil", *id) - } + if props := model.Properties; props != nil { + state.ClusterId = pointer.From(props.ClusterId) + } - if d.HasChange("size_gb") && model.Sku != nil && model.Sku.Capacity != nil { - model.Sku.Capacity = utils.Int64(int64(d.Get("size_gb").(int))) - } + capacity := 0 + if sku := model.Sku; sku != nil { + if sku.Capacity != nil { + capacity = int(*sku.Capacity) + } + } + state.SizeGB = int64(capacity) + state.Tags = pointer.From(model.Tags) + } - if d.HasChange("tags") { - model.Tags = expandTags(d.Get("tags").(map[string]interface{})) + return metadata.Encode(&state) + }, } +} - if err = client.CreateOrUpdateThenPoll(ctx, *id, *model); err != nil { - return fmt.Errorf("updating %s: %+v", id, err) - } +func (r LogAnalyticsClusterResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 6 * time.Hour, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.LogAnalytics.ClusterClient - return resourceLogAnalyticsClusterRead(d, meta) -} + var config LogAnalyticsClusterModel + if err := metadata.Decode(&config); err != nil { + return fmt.Errorf("decoding: %+v", err) + } -func resourceLogAnalyticsClusterDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).LogAnalytics.ClusterClient - ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) - defer cancel() + id, err := clusters.ParseClusterID(metadata.ResourceData.Id()) + if err != nil { + return err + } - id, err := clusters.ParseClusterID(d.Id()) - if err != nil { - return err - } + locks.ByID(id.ID()) + defer locks.UnlockByID(id.ID()) + + resp, err := client.Get(ctx, *id) + if err != nil { + return fmt.Errorf("retrieving %s: +%v", *id, err) + } + + model := resp.Model + if model == nil { + return fmt.Errorf("retrieving `azurerm_log_analytics_cluster` %s: `model` is nil", *id) + } - locks.ByID(id.ID()) - defer locks.UnlockByID(id.ID()) + if props := model.Properties; props == nil { + return fmt.Errorf("retrieving `azurerm_log_analytics_cluster` %s: `Properties` is nil", *id) + } + + if metadata.ResourceData.HasChange("tags") { + model.Tags = pointer.To(config.Tags) + } + + if err = client.CreateOrUpdateThenPoll(ctx, *id, *model); err != nil { + return fmt.Errorf("updating %s: %+v", id, err) + } - err = client.DeleteThenPoll(ctx, *id) - if err != nil { - return fmt.Errorf("deleting Log Analytics Cluster %q (Resource Group %q): %+v", id.ClusterName, id.ResourceGroupName, err) + return nil + }, } +} + +func (r LogAnalyticsClusterResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.LogAnalytics.ClusterClient - return nil + id, err := clusters.ParseClusterID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + locks.ByID(id.ID()) + defer locks.UnlockByID(id.ID()) + + err = client.DeleteThenPoll(ctx, *id) + if err != nil { + return fmt.Errorf("deleting %s: %+v", id, err) + } + + return nil + }, + } } diff --git a/internal/services/loganalytics/registration.go b/internal/services/loganalytics/registration.go index 8dbf237b4754..2fb2d9852d14 100644 --- a/internal/services/loganalytics/registration.go +++ b/internal/services/loganalytics/registration.go @@ -25,6 +25,7 @@ func (r Registration) DataSources() []sdk.DataSource { func (r Registration) Resources() []sdk.Resource { return []sdk.Resource{ + LogAnalyticsClusterResource{}, LogAnalyticsQueryPackResource{}, LogAnalyticsQueryPackQueryResource{}, LogAnalyticsSolutionResource{}, @@ -54,7 +55,6 @@ func (r Registration) SupportedDataSources() map[string]*pluginsdk.Resource { // SupportedResources returns the supported Resources supported by this Service func (r Registration) SupportedResources() map[string]*pluginsdk.Resource { return map[string]*pluginsdk.Resource{ - "azurerm_log_analytics_cluster": resourceLogAnalyticsCluster(), "azurerm_log_analytics_cluster_customer_managed_key": resourceLogAnalyticsClusterCustomerManagedKey(), "azurerm_log_analytics_datasource_windows_event": resourceLogAnalyticsDataSourceWindowsEvent(), "azurerm_log_analytics_datasource_windows_performance_counter": resourceLogAnalyticsDataSourceWindowsPerformanceCounter(), diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/README.md new file mode 100644 index 000000000000..8f960067990b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/README.md @@ -0,0 +1,116 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters` Documentation + +The `clusters` SDK allows for interaction with the Azure Resource Manager Service `operationalinsights` (API Version `2021-06-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/2021-06-01/clusters" +``` + + +### Client Initialization + +```go +client := clusters.NewClustersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ClustersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := clusters.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue") + +payload := clusters.Cluster{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ClustersClient.Delete` + +```go +ctx := context.TODO() +id := clusters.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ClustersClient.Get` + +```go +ctx := context.TODO() +id := clusters.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ClustersClient.List` + +```go +ctx := context.TODO() +id := clusters.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ClustersClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := clusters.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ClustersClient.Update` + +```go +ctx := context.TODO() +id := clusters.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue") + +payload := clusters.ClusterPatch{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/client.go new file mode 100644 index 000000000000..e4ab7fd89ad8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/client.go @@ -0,0 +1,26 @@ +package clusters + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClustersClient struct { + Client *resourcemanager.Client +} + +func NewClustersClientWithBaseURI(sdkApi sdkEnv.Api) (*ClustersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "clusters", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ClustersClient: %+v", err) + } + + return &ClustersClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/constants.go new file mode 100644 index 000000000000..641c4e928692 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/constants.go @@ -0,0 +1,163 @@ +package clusters + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BillingType string + +const ( + BillingTypeCluster BillingType = "Cluster" + BillingTypeWorkspaces BillingType = "Workspaces" +) + +func PossibleValuesForBillingType() []string { + return []string{ + string(BillingTypeCluster), + string(BillingTypeWorkspaces), + } +} + +func (s *BillingType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBillingType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBillingType(input string) (*BillingType, error) { + vals := map[string]BillingType{ + "cluster": BillingTypeCluster, + "workspaces": BillingTypeWorkspaces, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BillingType(input) + return &out, nil +} + +type Capacity int64 + +const ( + CapacityFiveHundred Capacity = 500 + CapacityFiveThousand Capacity = 5000 + CapacityOneThousand Capacity = 1000 + CapacityTwoThousand Capacity = 2000 +) + +func PossibleValuesForCapacity() []int64 { + return []int64{ + int64(CapacityFiveHundred), + int64(CapacityFiveThousand), + int64(CapacityOneThousand), + int64(CapacityTwoThousand), + } +} + +type ClusterEntityStatus string + +const ( + ClusterEntityStatusCanceled ClusterEntityStatus = "Canceled" + ClusterEntityStatusCreating ClusterEntityStatus = "Creating" + ClusterEntityStatusDeleting ClusterEntityStatus = "Deleting" + ClusterEntityStatusFailed ClusterEntityStatus = "Failed" + ClusterEntityStatusProvisioningAccount ClusterEntityStatus = "ProvisioningAccount" + ClusterEntityStatusSucceeded ClusterEntityStatus = "Succeeded" + ClusterEntityStatusUpdating ClusterEntityStatus = "Updating" +) + +func PossibleValuesForClusterEntityStatus() []string { + return []string{ + string(ClusterEntityStatusCanceled), + string(ClusterEntityStatusCreating), + string(ClusterEntityStatusDeleting), + string(ClusterEntityStatusFailed), + string(ClusterEntityStatusProvisioningAccount), + string(ClusterEntityStatusSucceeded), + string(ClusterEntityStatusUpdating), + } +} + +func (s *ClusterEntityStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterEntityStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterEntityStatus(input string) (*ClusterEntityStatus, error) { + vals := map[string]ClusterEntityStatus{ + "canceled": ClusterEntityStatusCanceled, + "creating": ClusterEntityStatusCreating, + "deleting": ClusterEntityStatusDeleting, + "failed": ClusterEntityStatusFailed, + "provisioningaccount": ClusterEntityStatusProvisioningAccount, + "succeeded": ClusterEntityStatusSucceeded, + "updating": ClusterEntityStatusUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterEntityStatus(input) + return &out, nil +} + +type ClusterSkuNameEnum string + +const ( + ClusterSkuNameEnumCapacityReservation ClusterSkuNameEnum = "CapacityReservation" +) + +func PossibleValuesForClusterSkuNameEnum() []string { + return []string{ + string(ClusterSkuNameEnumCapacityReservation), + } +} + +func (s *ClusterSkuNameEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterSkuNameEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterSkuNameEnum(input string) (*ClusterSkuNameEnum, error) { + vals := map[string]ClusterSkuNameEnum{ + "capacityreservation": ClusterSkuNameEnumCapacityReservation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterSkuNameEnum(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/id_cluster.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/id_cluster.go new file mode 100644 index 000000000000..d87cbd6e769f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/id_cluster.go @@ -0,0 +1,125 @@ +package clusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = ClusterId{} + +// ClusterId is a struct representing the Resource ID for a Cluster +type ClusterId struct { + SubscriptionId string + ResourceGroupName string + ClusterName string +} + +// NewClusterID returns a new ClusterId struct +func NewClusterID(subscriptionId string, resourceGroupName string, clusterName string) ClusterId { + return ClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ClusterName: clusterName, + } +} + +// ParseClusterID parses 'input' into a ClusterId +func ParseClusterID(input string) (*ClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(ClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseClusterIDInsensitively parses 'input' case-insensitively into a ClusterId +// note: this method should only be used for API response data and not user input +func ParseClusterIDInsensitively(input string) (*ClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(ClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ClusterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ClusterName, ok = input.Parsed["clusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "clusterName", input) + } + + return nil +} + +// ValidateClusterID checks that 'input' can be parsed as a Cluster ID +func ValidateClusterID(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 := ParseClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cluster ID +func (id ClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/clusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cluster ID +func (id ClusterId) 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("staticClusters", "clusters", "clusters"), + resourceids.UserSpecifiedSegment("clusterName", "clusterValue"), + } +} + +// String returns a human-readable description of this Cluster ID +func (id ClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cluster Name: %q", id.ClusterName), + } + return fmt.Sprintf("Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_createorupdate.go new file mode 100644 index 000000000000..c98ff96d4094 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_createorupdate.go @@ -0,0 +1,75 @@ +package clusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateOrUpdate ... +func (c ClustersClient) CreateOrUpdate(ctx context.Context, id ClusterId, input Cluster) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ClustersClient) CreateOrUpdateThenPoll(ctx context.Context, id ClusterId, input Cluster) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_delete.go new file mode 100644 index 000000000000..13e2610ffd6b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_delete.go @@ -0,0 +1,71 @@ +package clusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ClustersClient) Delete(ctx context.Context, id ClusterId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ClustersClient) DeleteThenPoll(ctx context.Context, id ClusterId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_get.go new file mode 100644 index 000000000000..34ea1e2c3d02 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_get.go @@ -0,0 +1,51 @@ +package clusters + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Cluster +} + +// Get ... +func (c ClustersClient) Get(ctx context.Context, id ClusterId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_list.go new file mode 100644 index 000000000000..8f3ecedcc3f8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_list.go @@ -0,0 +1,90 @@ +package clusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Cluster +} + +type ListCompleteResult struct { + Items []Cluster +} + +// List ... +func (c ClustersClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.OperationalInsights/clusters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Cluster `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ClustersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ClusterOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ClustersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ClusterOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Cluster, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_listbyresourcegroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_listbyresourcegroup.go new file mode 100644 index 000000000000..6210f3fed88c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_listbyresourcegroup.go @@ -0,0 +1,90 @@ +package clusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Cluster +} + +type ListByResourceGroupCompleteResult struct { + Items []Cluster +} + +// ListByResourceGroup ... +func (c ClustersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.OperationalInsights/clusters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Cluster `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ClustersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ClusterOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ClustersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ClusterOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Cluster, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_update.go new file mode 100644 index 000000000000..7c7a1471fb16 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_update.go @@ -0,0 +1,73 @@ +package clusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Update ... +func (c ClustersClient) Update(ctx context.Context, id ClusterId, input ClusterPatch) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ClustersClient) UpdateThenPoll(ctx context.Context, id ClusterId, input ClusterPatch) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_associatedworkspace.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_associatedworkspace.go new file mode 100644 index 000000000000..ad5986522e0a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_associatedworkspace.go @@ -0,0 +1,11 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssociatedWorkspace struct { + AssociateDate *string `json:"associateDate,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceName *string `json:"workspaceName,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_capacityreservationproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_capacityreservationproperties.go new file mode 100644 index 000000000000..2e65bfb192fd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_capacityreservationproperties.go @@ -0,0 +1,9 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CapacityReservationProperties struct { + LastSkuUpdate *string `json:"lastSkuUpdate,omitempty"` + MinCapacity *int64 `json:"minCapacity,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_cluster.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_cluster.go new file mode 100644 index 000000000000..50ba4797fcaa --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_cluster.go @@ -0,0 +1,19 @@ +package clusters + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Cluster struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemOrUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ClusterProperties `json:"properties,omitempty"` + Sku *ClusterSku `json:"sku,omitempty"` + 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/2021-06-01/clusters/model_clusterpatch.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clusterpatch.go new file mode 100644 index 000000000000..c12a546a9c55 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clusterpatch.go @@ -0,0 +1,15 @@ +package clusters + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterPatch struct { + Identity *identity.SystemOrUserAssignedMap `json:"identity,omitempty"` + Properties *ClusterPatchProperties `json:"properties,omitempty"` + Sku *ClusterSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clusterpatchproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clusterpatchproperties.go new file mode 100644 index 000000000000..7960ea89b28a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clusterpatchproperties.go @@ -0,0 +1,9 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterPatchProperties struct { + BillingType *BillingType `json:"billingType,omitempty"` + KeyVaultProperties *KeyVaultProperties `json:"keyVaultProperties,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clusterproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clusterproperties.go new file mode 100644 index 000000000000..36f519cd0d4e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clusterproperties.go @@ -0,0 +1,17 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterProperties struct { + AssociatedWorkspaces *[]AssociatedWorkspace `json:"associatedWorkspaces,omitempty"` + BillingType *BillingType `json:"billingType,omitempty"` + CapacityReservationProperties *CapacityReservationProperties `json:"capacityReservationProperties,omitempty"` + ClusterId *string `json:"clusterId,omitempty"` + CreatedDate *string `json:"createdDate,omitempty"` + IsAvailabilityZonesEnabled *bool `json:"isAvailabilityZonesEnabled,omitempty"` + IsDoubleEncryptionEnabled *bool `json:"isDoubleEncryptionEnabled,omitempty"` + KeyVaultProperties *KeyVaultProperties `json:"keyVaultProperties,omitempty"` + LastModifiedDate *string `json:"lastModifiedDate,omitempty"` + ProvisioningState *ClusterEntityStatus `json:"provisioningState,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clustersku.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clustersku.go new file mode 100644 index 000000000000..6f279c158d72 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clustersku.go @@ -0,0 +1,9 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterSku struct { + Capacity *Capacity `json:"capacity,omitempty"` + Name *ClusterSkuNameEnum `json:"name,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_keyvaultproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_keyvaultproperties.go new file mode 100644 index 000000000000..b2cfa77b7d40 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_keyvaultproperties.go @@ -0,0 +1,11 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultProperties struct { + KeyName *string `json:"keyName,omitempty"` + KeyRsaSize *int64 `json:"keyRsaSize,omitempty"` + KeyVaultUri *string `json:"keyVaultUri,omitempty"` + KeyVersion *string `json:"keyVersion,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/predicates.go new file mode 100644 index 000000000000..cc13b7c6220f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/predicates.go @@ -0,0 +1,32 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ClusterOperationPredicate) Matches(input Cluster) 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 +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/version.go new file mode 100644 index 000000000000..99c68bbf7754 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/version.go @@ -0,0 +1,12 @@ +package clusters + +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 = "2021-06-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/clusters/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index d3f8d7d27c08..6d2a6d99c42e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -787,6 +787,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2020-08-0 github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2020-08-01/savedsearches github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2020-08-01/storageinsights github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2020-08-01/workspaces +github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2022-10-01/tables github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2022-10-01/workspaces github.com/hashicorp/go-azure-sdk/resource-manager/operationsmanagement/2015-11-01-preview/solution From d4f4d4feb83d550dc15bada3f3140ec06118e24e Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Tue, 26 Dec 2023 13:45:53 +0800 Subject: [PATCH 2/3] refresh vendor --- .../2021-06-01/clusters/README.md | 116 ------------- .../2021-06-01/clusters/client.go | 26 --- .../2021-06-01/clusters/constants.go | 163 ------------------ .../2021-06-01/clusters/id_cluster.go | 125 -------------- .../clusters/method_createorupdate.go | 75 -------- .../2021-06-01/clusters/method_delete.go | 71 -------- .../2021-06-01/clusters/method_get.go | 51 ------ .../2021-06-01/clusters/method_list.go | 90 ---------- .../clusters/method_listbyresourcegroup.go | 90 ---------- .../2021-06-01/clusters/method_update.go | 73 -------- .../clusters/model_associatedworkspace.go | 11 -- .../model_capacityreservationproperties.go | 9 - .../2021-06-01/clusters/model_cluster.go | 19 -- .../2021-06-01/clusters/model_clusterpatch.go | 15 -- .../clusters/model_clusterpatchproperties.go | 9 - .../clusters/model_clusterproperties.go | 17 -- .../2021-06-01/clusters/model_clustersku.go | 9 - .../clusters/model_keyvaultproperties.go | 11 -- .../2021-06-01/clusters/predicates.go | 32 ---- .../2021-06-01/clusters/version.go | 12 -- vendor/modules.txt | 1 - 21 files changed, 1025 deletions(-) delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/README.md delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/client.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/constants.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/id_cluster.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_createorupdate.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_delete.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_get.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_list.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_listbyresourcegroup.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_update.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_associatedworkspace.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_capacityreservationproperties.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_cluster.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clusterpatch.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clusterpatchproperties.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clusterproperties.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clustersku.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_keyvaultproperties.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/predicates.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/version.go diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/README.md deleted file mode 100644 index 8f960067990b..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/README.md +++ /dev/null @@ -1,116 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters` Documentation - -The `clusters` SDK allows for interaction with the Azure Resource Manager Service `operationalinsights` (API Version `2021-06-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/2021-06-01/clusters" -``` - - -### Client Initialization - -```go -client := clusters.NewClustersClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `ClustersClient.CreateOrUpdate` - -```go -ctx := context.TODO() -id := clusters.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue") - -payload := clusters.Cluster{ - // ... -} - - -if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { - // handle the error -} -``` - - -### Example Usage: `ClustersClient.Delete` - -```go -ctx := context.TODO() -id := clusters.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue") - -if err := client.DeleteThenPoll(ctx, id); err != nil { - // handle the error -} -``` - - -### Example Usage: `ClustersClient.Get` - -```go -ctx := context.TODO() -id := clusters.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue") - -read, err := client.Get(ctx, id) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `ClustersClient.List` - -```go -ctx := context.TODO() -id := clusters.NewSubscriptionID("12345678-1234-9876-4563-123456789012") - -// alternatively `client.List(ctx, id)` can be used to do batched pagination -items, err := client.ListComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `ClustersClient.ListByResourceGroup` - -```go -ctx := context.TODO() -id := clusters.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") - -// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination -items, err := client.ListByResourceGroupComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `ClustersClient.Update` - -```go -ctx := context.TODO() -id := clusters.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue") - -payload := clusters.ClusterPatch{ - // ... -} - - -if err := client.UpdateThenPoll(ctx, id, payload); err != nil { - // handle the error -} -``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/client.go deleted file mode 100644 index e4ab7fd89ad8..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/client.go +++ /dev/null @@ -1,26 +0,0 @@ -package clusters - -import ( - "fmt" - - "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" - sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ClustersClient struct { - Client *resourcemanager.Client -} - -func NewClustersClientWithBaseURI(sdkApi sdkEnv.Api) (*ClustersClient, error) { - client, err := resourcemanager.NewResourceManagerClient(sdkApi, "clusters", defaultApiVersion) - if err != nil { - return nil, fmt.Errorf("instantiating ClustersClient: %+v", err) - } - - return &ClustersClient{ - Client: client, - }, nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/constants.go deleted file mode 100644 index 641c4e928692..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/constants.go +++ /dev/null @@ -1,163 +0,0 @@ -package clusters - -import ( - "encoding/json" - "fmt" - "strings" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type BillingType string - -const ( - BillingTypeCluster BillingType = "Cluster" - BillingTypeWorkspaces BillingType = "Workspaces" -) - -func PossibleValuesForBillingType() []string { - return []string{ - string(BillingTypeCluster), - string(BillingTypeWorkspaces), - } -} - -func (s *BillingType) UnmarshalJSON(bytes []byte) error { - var decoded string - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling: %+v", err) - } - out, err := parseBillingType(decoded) - if err != nil { - return fmt.Errorf("parsing %q: %+v", decoded, err) - } - *s = *out - return nil -} - -func parseBillingType(input string) (*BillingType, error) { - vals := map[string]BillingType{ - "cluster": BillingTypeCluster, - "workspaces": BillingTypeWorkspaces, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := BillingType(input) - return &out, nil -} - -type Capacity int64 - -const ( - CapacityFiveHundred Capacity = 500 - CapacityFiveThousand Capacity = 5000 - CapacityOneThousand Capacity = 1000 - CapacityTwoThousand Capacity = 2000 -) - -func PossibleValuesForCapacity() []int64 { - return []int64{ - int64(CapacityFiveHundred), - int64(CapacityFiveThousand), - int64(CapacityOneThousand), - int64(CapacityTwoThousand), - } -} - -type ClusterEntityStatus string - -const ( - ClusterEntityStatusCanceled ClusterEntityStatus = "Canceled" - ClusterEntityStatusCreating ClusterEntityStatus = "Creating" - ClusterEntityStatusDeleting ClusterEntityStatus = "Deleting" - ClusterEntityStatusFailed ClusterEntityStatus = "Failed" - ClusterEntityStatusProvisioningAccount ClusterEntityStatus = "ProvisioningAccount" - ClusterEntityStatusSucceeded ClusterEntityStatus = "Succeeded" - ClusterEntityStatusUpdating ClusterEntityStatus = "Updating" -) - -func PossibleValuesForClusterEntityStatus() []string { - return []string{ - string(ClusterEntityStatusCanceled), - string(ClusterEntityStatusCreating), - string(ClusterEntityStatusDeleting), - string(ClusterEntityStatusFailed), - string(ClusterEntityStatusProvisioningAccount), - string(ClusterEntityStatusSucceeded), - string(ClusterEntityStatusUpdating), - } -} - -func (s *ClusterEntityStatus) UnmarshalJSON(bytes []byte) error { - var decoded string - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling: %+v", err) - } - out, err := parseClusterEntityStatus(decoded) - if err != nil { - return fmt.Errorf("parsing %q: %+v", decoded, err) - } - *s = *out - return nil -} - -func parseClusterEntityStatus(input string) (*ClusterEntityStatus, error) { - vals := map[string]ClusterEntityStatus{ - "canceled": ClusterEntityStatusCanceled, - "creating": ClusterEntityStatusCreating, - "deleting": ClusterEntityStatusDeleting, - "failed": ClusterEntityStatusFailed, - "provisioningaccount": ClusterEntityStatusProvisioningAccount, - "succeeded": ClusterEntityStatusSucceeded, - "updating": ClusterEntityStatusUpdating, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ClusterEntityStatus(input) - return &out, nil -} - -type ClusterSkuNameEnum string - -const ( - ClusterSkuNameEnumCapacityReservation ClusterSkuNameEnum = "CapacityReservation" -) - -func PossibleValuesForClusterSkuNameEnum() []string { - return []string{ - string(ClusterSkuNameEnumCapacityReservation), - } -} - -func (s *ClusterSkuNameEnum) UnmarshalJSON(bytes []byte) error { - var decoded string - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling: %+v", err) - } - out, err := parseClusterSkuNameEnum(decoded) - if err != nil { - return fmt.Errorf("parsing %q: %+v", decoded, err) - } - *s = *out - return nil -} - -func parseClusterSkuNameEnum(input string) (*ClusterSkuNameEnum, error) { - vals := map[string]ClusterSkuNameEnum{ - "capacityreservation": ClusterSkuNameEnumCapacityReservation, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ClusterSkuNameEnum(input) - return &out, nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/id_cluster.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/id_cluster.go deleted file mode 100644 index d87cbd6e769f..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/id_cluster.go +++ /dev/null @@ -1,125 +0,0 @@ -package clusters - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = ClusterId{} - -// ClusterId is a struct representing the Resource ID for a Cluster -type ClusterId struct { - SubscriptionId string - ResourceGroupName string - ClusterName string -} - -// NewClusterID returns a new ClusterId struct -func NewClusterID(subscriptionId string, resourceGroupName string, clusterName string) ClusterId { - return ClusterId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ClusterName: clusterName, - } -} - -// ParseClusterID parses 'input' into a ClusterId -func ParseClusterID(input string) (*ClusterId, error) { - parser := resourceids.NewParserFromResourceIdType(ClusterId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := ClusterId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseClusterIDInsensitively parses 'input' case-insensitively into a ClusterId -// note: this method should only be used for API response data and not user input -func ParseClusterIDInsensitively(input string) (*ClusterId, error) { - parser := resourceids.NewParserFromResourceIdType(ClusterId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := ClusterId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *ClusterId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.ClusterName, ok = input.Parsed["clusterName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "clusterName", input) - } - - return nil -} - -// ValidateClusterID checks that 'input' can be parsed as a Cluster ID -func ValidateClusterID(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 := ParseClusterID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Cluster ID -func (id ClusterId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/clusters/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Cluster ID -func (id ClusterId) 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("staticClusters", "clusters", "clusters"), - resourceids.UserSpecifiedSegment("clusterName", "clusterValue"), - } -} - -// String returns a human-readable description of this Cluster ID -func (id ClusterId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Cluster Name: %q", id.ClusterName), - } - return fmt.Sprintf("Cluster (%s)", strings.Join(components, "\n")) -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_createorupdate.go deleted file mode 100644 index c98ff96d4094..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_createorupdate.go +++ /dev/null @@ -1,75 +0,0 @@ -package clusters - -import ( - "context" - "fmt" - "net/http" - - "github.com/hashicorp/go-azure-sdk/sdk/client" - "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" - "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" - "github.com/hashicorp/go-azure-sdk/sdk/odata" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateOperationResponse struct { - Poller pollers.Poller - HttpResponse *http.Response - OData *odata.OData -} - -// CreateOrUpdate ... -func (c ClustersClient) CreateOrUpdate(ctx context.Context, id ClusterId, input Cluster) (result CreateOrUpdateOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusAccepted, - http.StatusCreated, - http.StatusOK, - }, - HttpMethod: http.MethodPut, - Path: id.ID(), - } - - req, err := c.Client.NewRequest(ctx, opts) - if err != nil { - return - } - - if err = req.Marshal(input); err != nil { - return - } - - var resp *client.Response - resp, err = req.Execute(ctx) - if resp != nil { - result.OData = resp.OData - result.HttpResponse = resp.Response - } - if err != nil { - return - } - - result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) - if err != nil { - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c ClustersClient) CreateOrUpdateThenPoll(ctx context.Context, id ClusterId, input Cluster) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(ctx); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_delete.go deleted file mode 100644 index 13e2610ffd6b..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_delete.go +++ /dev/null @@ -1,71 +0,0 @@ -package clusters - -import ( - "context" - "fmt" - "net/http" - - "github.com/hashicorp/go-azure-sdk/sdk/client" - "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" - "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" - "github.com/hashicorp/go-azure-sdk/sdk/odata" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteOperationResponse struct { - Poller pollers.Poller - HttpResponse *http.Response - OData *odata.OData -} - -// Delete ... -func (c ClustersClient) Delete(ctx context.Context, id ClusterId) (result DeleteOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusAccepted, - http.StatusNoContent, - http.StatusOK, - }, - HttpMethod: http.MethodDelete, - Path: id.ID(), - } - - req, err := c.Client.NewRequest(ctx, opts) - if err != nil { - return - } - - var resp *client.Response - resp, err = req.Execute(ctx) - if resp != nil { - result.OData = resp.OData - result.HttpResponse = resp.Response - } - if err != nil { - return - } - - result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) - if err != nil { - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c ClustersClient) DeleteThenPoll(ctx context.Context, id ClusterId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(ctx); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_get.go deleted file mode 100644 index 34ea1e2c3d02..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_get.go +++ /dev/null @@ -1,51 +0,0 @@ -package clusters - -import ( - "context" - "net/http" - - "github.com/hashicorp/go-azure-sdk/sdk/client" - "github.com/hashicorp/go-azure-sdk/sdk/odata" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData - Model *Cluster -} - -// Get ... -func (c ClustersClient) Get(ctx context.Context, id ClusterId) (result GetOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusOK, - }, - HttpMethod: http.MethodGet, - Path: id.ID(), - } - - req, err := c.Client.NewRequest(ctx, opts) - if err != nil { - return - } - - var resp *client.Response - resp, err = req.Execute(ctx) - if resp != nil { - result.OData = resp.OData - result.HttpResponse = resp.Response - } - if err != nil { - return - } - - if err = resp.Unmarshal(&result.Model); err != nil { - return - } - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_list.go deleted file mode 100644 index 8f3ecedcc3f8..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_list.go +++ /dev/null @@ -1,90 +0,0 @@ -package clusters - -import ( - "context" - "fmt" - "net/http" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" - "github.com/hashicorp/go-azure-sdk/sdk/client" - "github.com/hashicorp/go-azure-sdk/sdk/odata" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData - Model *[]Cluster -} - -type ListCompleteResult struct { - Items []Cluster -} - -// List ... -func (c ClustersClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusOK, - }, - HttpMethod: http.MethodGet, - Path: fmt.Sprintf("%s/providers/Microsoft.OperationalInsights/clusters", id.ID()), - } - - req, err := c.Client.NewRequest(ctx, opts) - if err != nil { - return - } - - var resp *client.Response - resp, err = req.ExecutePaged(ctx) - if resp != nil { - result.OData = resp.OData - result.HttpResponse = resp.Response - } - if err != nil { - return - } - - var values struct { - Values *[]Cluster `json:"value"` - } - if err = resp.Unmarshal(&values); err != nil { - return - } - - result.Model = values.Values - - return -} - -// ListComplete retrieves all the results into a single object -func (c ClustersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, ClusterOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate -func (c ClustersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ClusterOperationPredicate) (result ListCompleteResult, err error) { - items := make([]Cluster, 0) - - resp, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading results: %+v", err) - return - } - if resp.Model != nil { - for _, v := range *resp.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - result = ListCompleteResult{ - Items: items, - } - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_listbyresourcegroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_listbyresourcegroup.go deleted file mode 100644 index 6210f3fed88c..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_listbyresourcegroup.go +++ /dev/null @@ -1,90 +0,0 @@ -package clusters - -import ( - "context" - "fmt" - "net/http" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" - "github.com/hashicorp/go-azure-sdk/sdk/client" - "github.com/hashicorp/go-azure-sdk/sdk/odata" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData - Model *[]Cluster -} - -type ListByResourceGroupCompleteResult struct { - Items []Cluster -} - -// ListByResourceGroup ... -func (c ClustersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusOK, - }, - HttpMethod: http.MethodGet, - Path: fmt.Sprintf("%s/providers/Microsoft.OperationalInsights/clusters", id.ID()), - } - - req, err := c.Client.NewRequest(ctx, opts) - if err != nil { - return - } - - var resp *client.Response - resp, err = req.ExecutePaged(ctx) - if resp != nil { - result.OData = resp.OData - result.HttpResponse = resp.Response - } - if err != nil { - return - } - - var values struct { - Values *[]Cluster `json:"value"` - } - if err = resp.Unmarshal(&values); err != nil { - return - } - - result.Model = values.Values - - return -} - -// ListByResourceGroupComplete retrieves all the results into a single object -func (c ClustersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ClusterOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate -func (c ClustersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ClusterOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { - items := make([]Cluster, 0) - - resp, err := c.ListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading results: %+v", err) - return - } - if resp.Model != nil { - for _, v := range *resp.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - result = ListByResourceGroupCompleteResult{ - Items: items, - } - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_update.go deleted file mode 100644 index 7c7a1471fb16..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/method_update.go +++ /dev/null @@ -1,73 +0,0 @@ -package clusters - -import ( - "context" - "fmt" - "net/http" - - "github.com/hashicorp/go-azure-sdk/sdk/client" - "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" - "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" - "github.com/hashicorp/go-azure-sdk/sdk/odata" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller pollers.Poller - HttpResponse *http.Response - OData *odata.OData -} - -// Update ... -func (c ClustersClient) Update(ctx context.Context, id ClusterId, input ClusterPatch) (result UpdateOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusOK, - }, - HttpMethod: http.MethodPatch, - Path: id.ID(), - } - - req, err := c.Client.NewRequest(ctx, opts) - if err != nil { - return - } - - if err = req.Marshal(input); err != nil { - return - } - - var resp *client.Response - resp, err = req.Execute(ctx) - if resp != nil { - result.OData = resp.OData - result.HttpResponse = resp.Response - } - if err != nil { - return - } - - result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) - if err != nil { - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c ClustersClient) UpdateThenPoll(ctx context.Context, id ClusterId, input ClusterPatch) error { - result, err := c.Update(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(ctx); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_associatedworkspace.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_associatedworkspace.go deleted file mode 100644 index ad5986522e0a..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_associatedworkspace.go +++ /dev/null @@ -1,11 +0,0 @@ -package clusters - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AssociatedWorkspace struct { - AssociateDate *string `json:"associateDate,omitempty"` - ResourceId *string `json:"resourceId,omitempty"` - WorkspaceId *string `json:"workspaceId,omitempty"` - WorkspaceName *string `json:"workspaceName,omitempty"` -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_capacityreservationproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_capacityreservationproperties.go deleted file mode 100644 index 2e65bfb192fd..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_capacityreservationproperties.go +++ /dev/null @@ -1,9 +0,0 @@ -package clusters - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CapacityReservationProperties struct { - LastSkuUpdate *string `json:"lastSkuUpdate,omitempty"` - MinCapacity *int64 `json:"minCapacity,omitempty"` -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_cluster.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_cluster.go deleted file mode 100644 index 50ba4797fcaa..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_cluster.go +++ /dev/null @@ -1,19 +0,0 @@ -package clusters - -import ( - "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type Cluster struct { - Id *string `json:"id,omitempty"` - Identity *identity.SystemOrUserAssignedMap `json:"identity,omitempty"` - Location string `json:"location"` - Name *string `json:"name,omitempty"` - Properties *ClusterProperties `json:"properties,omitempty"` - Sku *ClusterSku `json:"sku,omitempty"` - 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/2021-06-01/clusters/model_clusterpatch.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clusterpatch.go deleted file mode 100644 index c12a546a9c55..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clusterpatch.go +++ /dev/null @@ -1,15 +0,0 @@ -package clusters - -import ( - "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ClusterPatch struct { - Identity *identity.SystemOrUserAssignedMap `json:"identity,omitempty"` - Properties *ClusterPatchProperties `json:"properties,omitempty"` - Sku *ClusterSku `json:"sku,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clusterpatchproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clusterpatchproperties.go deleted file mode 100644 index 7960ea89b28a..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clusterpatchproperties.go +++ /dev/null @@ -1,9 +0,0 @@ -package clusters - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ClusterPatchProperties struct { - BillingType *BillingType `json:"billingType,omitempty"` - KeyVaultProperties *KeyVaultProperties `json:"keyVaultProperties,omitempty"` -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clusterproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clusterproperties.go deleted file mode 100644 index 36f519cd0d4e..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clusterproperties.go +++ /dev/null @@ -1,17 +0,0 @@ -package clusters - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ClusterProperties struct { - AssociatedWorkspaces *[]AssociatedWorkspace `json:"associatedWorkspaces,omitempty"` - BillingType *BillingType `json:"billingType,omitempty"` - CapacityReservationProperties *CapacityReservationProperties `json:"capacityReservationProperties,omitempty"` - ClusterId *string `json:"clusterId,omitempty"` - CreatedDate *string `json:"createdDate,omitempty"` - IsAvailabilityZonesEnabled *bool `json:"isAvailabilityZonesEnabled,omitempty"` - IsDoubleEncryptionEnabled *bool `json:"isDoubleEncryptionEnabled,omitempty"` - KeyVaultProperties *KeyVaultProperties `json:"keyVaultProperties,omitempty"` - LastModifiedDate *string `json:"lastModifiedDate,omitempty"` - ProvisioningState *ClusterEntityStatus `json:"provisioningState,omitempty"` -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clustersku.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clustersku.go deleted file mode 100644 index 6f279c158d72..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_clustersku.go +++ /dev/null @@ -1,9 +0,0 @@ -package clusters - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ClusterSku struct { - Capacity *Capacity `json:"capacity,omitempty"` - Name *ClusterSkuNameEnum `json:"name,omitempty"` -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_keyvaultproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_keyvaultproperties.go deleted file mode 100644 index b2cfa77b7d40..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/model_keyvaultproperties.go +++ /dev/null @@ -1,11 +0,0 @@ -package clusters - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type KeyVaultProperties struct { - KeyName *string `json:"keyName,omitempty"` - KeyRsaSize *int64 `json:"keyRsaSize,omitempty"` - KeyVaultUri *string `json:"keyVaultUri,omitempty"` - KeyVersion *string `json:"keyVersion,omitempty"` -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/predicates.go deleted file mode 100644 index cc13b7c6220f..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/predicates.go +++ /dev/null @@ -1,32 +0,0 @@ -package clusters - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ClusterOperationPredicate struct { - Id *string - Location *string - Name *string - Type *string -} - -func (p ClusterOperationPredicate) Matches(input Cluster) 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 -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/version.go deleted file mode 100644 index 99c68bbf7754..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package clusters - -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 = "2021-06-01" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/clusters/%s", defaultApiVersion) -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 6d2a6d99c42e..d3f8d7d27c08 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -787,7 +787,6 @@ github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2020-08-0 github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2020-08-01/savedsearches github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2020-08-01/storageinsights github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2020-08-01/workspaces -github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2021-06-01/clusters github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2022-10-01/tables github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2022-10-01/workspaces github.com/hashicorp/go-azure-sdk/resource-manager/operationsmanagement/2015-11-01-preview/solution From 1b7f371a65b3788392002db7361807dfb288c85d Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Wed, 27 Dec 2023 10:06:48 +0800 Subject: [PATCH 3/3] update code --- .gitignore | 4 ---- .../loganalytics/log_analytics_cluster_resource.go | 11 ++++------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 20e8707e6489..d66003bb9a31 100644 --- a/.gitignore +++ b/.gitignore @@ -53,7 +53,3 @@ tf.zip # do not upload secrets .env - -# custom for myself -.gitignore -.typos.toml diff --git a/internal/services/loganalytics/log_analytics_cluster_resource.go b/internal/services/loganalytics/log_analytics_cluster_resource.go index 665ac312fc3f..67dd2008df29 100644 --- a/internal/services/loganalytics/log_analytics_cluster_resource.go +++ b/internal/services/loganalytics/log_analytics_cluster_resource.go @@ -66,13 +66,6 @@ func (l LogAnalyticsClusterResource) Arguments() map[string]*schema.Schema { ValidateFunc: validation.IntInSlice([]int{500, 1000, 2000, 5000}), }, - "availability_zones_enabled": { - Type: pluginsdk.TypeBool, - Default: true, - Optional: true, - ForceNew: true, // check the value previous created cluster - }, - "tags": tags.Schema(), } } @@ -237,6 +230,10 @@ func (r LogAnalyticsClusterResource) Update() sdk.ResourceFunc { return fmt.Errorf("retrieving `azurerm_log_analytics_cluster` %s: `Properties` is nil", *id) } + if metadata.ResourceData.HasChange("size_gb") && model.Sku != nil && model.Sku.Capacity != nil { + model.Sku.Capacity = &config.SizeGB + } + if metadata.ResourceData.HasChange("tags") { model.Tags = pointer.To(config.Tags) }