diff --git a/.github/labeler-issue-triage.yml b/.github/labeler-issue-triage.yml index b63e12b40d7b..d3979d46d8aa 100644 --- a/.github/labeler-issue-triage.yml +++ b/.github/labeler-issue-triage.yml @@ -218,6 +218,9 @@ service/mixed-reality: service/mobile-network: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_mobile_network((.|\n)*)###' +service/mongo-cluster: + - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_mongo_cluster((.|\n)*)###' + service/monitor: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_monitor_((.|\n)*)###' diff --git a/.github/labeler-pull-request-triage.yml b/.github/labeler-pull-request-triage.yml index a3b481100fa2..7d31ecaaaea5 100644 --- a/.github/labeler-pull-request-triage.yml +++ b/.github/labeler-pull-request-triage.yml @@ -364,6 +364,11 @@ service/mobile-network: - any-glob-to-any-file: - internal/services/mobilenetwork/**/* +service/mongo-cluster: +- changed-files: + - any-glob-to-any-file: + - internal/services/mongocluster/**/* + service/monitor: - changed-files: - any-glob-to-any-file: diff --git a/.teamcity/components/generated/services.kt b/.teamcity/components/generated/services.kt index f70ec7ae8653..9c85e78f57e6 100644 --- a/.teamcity/components/generated/services.kt +++ b/.teamcity/components/generated/services.kt @@ -82,6 +82,7 @@ var services = mapOf( "mssqlmanagedinstance" to "Microsoft SQL Server Managed Instances", "mixedreality" to "Mixed Reality", "mobilenetwork" to "Mobile Network", + "mongocluster" to "MongoCluster", "monitor" to "Monitor", "mysql" to "MySQL", "netapp" to "NetApp", diff --git a/internal/clients/client.go b/internal/clients/client.go index 384faa8fd86a..973f7e5c5e63 100644 --- a/internal/clients/client.go +++ b/internal/clients/client.go @@ -96,6 +96,7 @@ import ( maps "github.com/hashicorp/terraform-provider-azurerm/internal/services/maps/client" mixedreality "github.com/hashicorp/terraform-provider-azurerm/internal/services/mixedreality/client" mobilenetwork "github.com/hashicorp/terraform-provider-azurerm/internal/services/mobilenetwork/client" + mongocluster "github.com/hashicorp/terraform-provider-azurerm/internal/services/mongocluster/client" monitor "github.com/hashicorp/terraform-provider-azurerm/internal/services/monitor/client" mssql "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssql/client" mssqlmanagedinstance "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssqlmanagedinstance/client" @@ -228,6 +229,7 @@ type Client struct { MixedReality *mixedreality.Client Monitor *monitor.Client MobileNetwork *mobilenetwork.Client + MongoCluster *mongocluster.Client MSSQL *mssql.Client MSSQLManagedInstance *mssqlmanagedinstance.Client MySQL *mysql.Client @@ -507,6 +509,9 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error if client.MobileNetwork, err = mobilenetwork.NewClient(o); err != nil { return fmt.Errorf("building clients for Mobile Network: %+v", err) } + if client.MongoCluster, err = mongocluster.NewClient(o); err != nil { + return fmt.Errorf("building clients for Mongo Cluster: %+v", err) + } if client.MSSQL, err = mssql.NewClient(o); err != nil { return fmt.Errorf("building clients for MSSQL: %+v", err) } diff --git a/internal/provider/services.go b/internal/provider/services.go index 6da74bc6f280..734e75f9d86f 100644 --- a/internal/provider/services.go +++ b/internal/provider/services.go @@ -80,6 +80,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/services/maps" "github.com/hashicorp/terraform-provider-azurerm/internal/services/mixedreality" "github.com/hashicorp/terraform-provider-azurerm/internal/services/mobilenetwork" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/mongocluster" "github.com/hashicorp/terraform-provider-azurerm/internal/services/monitor" "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssql" "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssqlmanagedinstance" @@ -180,6 +181,7 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration { maintenance.Registration{}, managedhsm.Registration{}, mobilenetwork.Registration{}, + mongocluster.Registration{}, monitor.Registration{}, mssql.Registration{}, mssqlmanagedinstance.Registration{}, diff --git a/internal/services/mongocluster/client/client.go b/internal/services/mongocluster/client/client.go new file mode 100644 index 000000000000..423033b4201e --- /dev/null +++ b/internal/services/mongocluster/client/client.go @@ -0,0 +1,28 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package client + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters" + "github.com/hashicorp/terraform-provider-azurerm/internal/common" +) + +type Client struct { + MongoClustersClient *mongoclusters.MongoClustersClient +} + +func NewClient(o *common.ClientOptions) (*Client, error) { + + mongoClustersClient, err := mongoclusters.NewMongoClustersClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building MongoClusters client: %+v", err) + } + o.Configure(mongoClustersClient.Client, o.Authorizers.ResourceManager) + + return &Client{ + MongoClustersClient: mongoClustersClient, + }, nil +} diff --git a/internal/services/mongocluster/mongo_cluster_resource.go b/internal/services/mongocluster/mongo_cluster_resource.go new file mode 100644 index 000000000000..a2532a6d635f --- /dev/null +++ b/internal/services/mongocluster/mongo_cluster_resource.go @@ -0,0 +1,561 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package mongocluster + +import ( + "context" + "fmt" + "regexp" + "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/location" + "github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" +) + +type MongoClusterResource struct{} + +var _ sdk.ResourceWithUpdate = MongoClusterResource{} + +var _ sdk.ResourceWithCustomizeDiff = MongoClusterResource{} + +type MongoClusterResourceModel struct { + Name string `tfschema:"name"` + ResourceGroupName string `tfschema:"resource_group_name"` + Location string `tfschema:"location"` + AdministratorLogin string `tfschema:"administrator_login"` + AdministratorLoginPassword string `tfschema:"administrator_login_password"` + CreateMode string `tfschema:"create_mode"` + ShardCount int64 `tfschema:"shard_count"` + SourceLocation string `tfschema:"source_location"` + SourceServerId string `tfschema:"source_server_id"` + ComputeTier string `tfschema:"compute_tier"` + HighAvailabilityMode string `tfschema:"high_availability_mode"` + PublicNetworkAccessEnabled bool `tfschema:"public_network_access_enabled"` + PreviewFeatures []string `tfschema:"preview_features"` + StorageSizeInGb int64 `tfschema:"storage_size_in_gb"` + Tags map[string]string `tfschema:"tags"` + Version string `tfschema:"version"` +} + +func (r MongoClusterResource) ModelObject() interface{} { + return &MongoClusterResourceModel{} +} + +func (r MongoClusterResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return mongoclusters.ValidateMongoClusterID +} + +func (r MongoClusterResource) ResourceType() string { + return "azurerm_mongo_cluster" +} + +func (r MongoClusterResource) Arguments() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "name": { + ForceNew: true, + Required: true, + Type: schema.TypeString, + ValidateFunc: validation.All( + validation.StringLenBetween(3, 40), + validation.StringMatch( + regexp.MustCompile(`^[a-z0-9]+(-[a-z0-9]+)*$`), + "The name contains only lowercase letters, numbers and hyphens.", + ), + ), + }, + + "resource_group_name": commonschema.ResourceGroupName(), + + "location": commonschema.Location(), + + "administrator_login": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "create_mode": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Default: string(mongoclusters.CreateModeDefault), + // Confirmed with service team the 'Default' and `GeoReplica` are the only accepted value currently, other values will be supported later. + ValidateFunc: validation.StringInSlice([]string{ + string(mongoclusters.CreateModeDefault), + string(mongoclusters.CreateModeGeoReplica), + }, false), + }, + + "preview_features": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringInSlice(mongoclusters.PossibleValuesForPreviewFeature(), false), + }, + }, + + "shard_count": { + Type: schema.TypeInt, + Optional: true, + ValidateFunc: validation.IntAtLeast(1), + ForceNew: true, + }, + + "source_location": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + StateFunc: location.StateFunc, + DiffSuppressFunc: location.DiffSuppressFunc, + ValidateFunc: validation.StringIsNotEmpty, + RequiredWith: []string{"source_server_id"}, + }, + + "source_server_id": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "administrator_login_password": { + Type: schema.TypeString, + Optional: true, + Sensitive: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "compute_tier": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + "Free", + "M25", + "M30", + "M40", + "M50", + "M60", + "M80", + }, false), + }, + + "high_availability_mode": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + // Confirmed with service team the `SameZone` is currently not supported. + string(mongoclusters.HighAvailabilityModeDisabled), + string(mongoclusters.HighAvailabilityModeZoneRedundantPreferred), + }, false), + }, + + "public_network_access_enabled": { + Type: schema.TypeBool, + Optional: true, + Default: true, + }, + + "storage_size_in_gb": { + Type: schema.TypeInt, + Optional: true, + ValidateFunc: validation.IntBetween(32, 16384), + }, + + "tags": commonschema.Tags(), + + "version": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + "5.0", + "6.0", + "7.0", + }, false), + }, + } +} + +func (r MongoClusterResource) Attributes() map[string]*schema.Schema { + return map[string]*schema.Schema{} +} + +func (r MongoClusterResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.MongoCluster.MongoClustersClient + subscriptionId := metadata.Client.Account.SubscriptionId + + var state MongoClusterResourceModel + if err := metadata.Decode(&state); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + id := mongoclusters.NewMongoClusterID(subscriptionId, state.ResourceGroupName, state.Name) + existing, err := client.Get(ctx, id) + if err != nil { + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for the presence of an existing %s: %+v", id, err) + } + } + if !response.WasNotFound(existing.HttpResponse) { + return metadata.ResourceRequiresImport(r.ResourceType(), id) + } + + parameter := mongoclusters.MongoCluster{ + Location: azure.NormalizeLocation(state.Location), + Properties: &mongoclusters.MongoClusterProperties{}, + } + + if _, ok := metadata.ResourceData.GetOk("administrator_login"); ok { + parameter.Properties.Administrator = &mongoclusters.AdministratorProperties{ + UserName: pointer.To(state.AdministratorLogin), + Password: pointer.To(state.AdministratorLoginPassword), + } + } + + if _, ok := metadata.ResourceData.GetOk("create_mode"); ok { + parameter.Properties.CreateMode = pointer.To(mongoclusters.CreateMode(state.CreateMode)) + } + + if v, ok := metadata.ResourceData.GetOk("preview_features"); ok { + parameter.Properties.PreviewFeatures = expandPreviewFeatures(v.([]interface{})) + } + + if _, ok := metadata.ResourceData.GetOk("shard_count"); ok { + parameter.Properties.Sharding = &mongoclusters.ShardingProperties{ + ShardCount: pointer.To(state.ShardCount), + } + } + + if state.CreateMode == string(mongoclusters.CreateModeGeoReplica) { + parameter.Properties.ReplicaParameters = &mongoclusters.MongoClusterReplicaParameters{ + SourceLocation: state.SourceLocation, + SourceResourceId: state.SourceServerId, + } + } + + if _, ok := metadata.ResourceData.GetOk("compute_tier"); ok { + parameter.Properties.Compute = &mongoclusters.ComputeProperties{ + Tier: pointer.To(state.ComputeTier), + } + } + + if _, ok := metadata.ResourceData.GetOk("high_availability_mode"); ok { + parameter.Properties.HighAvailability = &mongoclusters.HighAvailabilityProperties{ + TargetMode: pointer.To(mongoclusters.HighAvailabilityMode(state.HighAvailabilityMode)), + } + } + + if state.PublicNetworkAccessEnabled { + parameter.Properties.PublicNetworkAccess = pointer.To(mongoclusters.PublicNetworkAccessEnabled) + } else { + parameter.Properties.PublicNetworkAccess = pointer.To(mongoclusters.PublicNetworkAccessDisabled) + } + + if _, ok := metadata.ResourceData.GetOk("storage_size_in_gb"); ok { + parameter.Properties.Storage = &mongoclusters.StorageProperties{ + SizeGb: pointer.To(state.StorageSizeInGb), + } + } + + if _, ok := metadata.ResourceData.GetOk("tags"); ok { + parameter.Tags = pointer.To(state.Tags) + } + + if _, ok := metadata.ResourceData.GetOk("version"); ok { + parameter.Properties.ServerVersion = pointer.To(state.Version) + } + + if err := client.CreateOrUpdateThenPoll(ctx, id, parameter); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + + return nil + }, + } +} + +func (r MongoClusterResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.MongoCluster.MongoClustersClient + + id, err := mongoclusters.ParseMongoClusterID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + metadata.Logger.Info("Decoding state...") + var state MongoClusterResourceModel + if err := metadata.Decode(&state); err != nil { + return err + } + + existing, err := client.Get(ctx, *id) + if err != nil { + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + model := existing.Model + if model == nil { + return fmt.Errorf("reading %s for update: model was nil", *id) + } + + metadata.Logger.Infof("updating %s", *id) + + model.SystemData = nil + + // upgrades involving Free or M25(Burstable) cluster tier require first upgrading the cluster tier, after which other configurations can be updated. + if metadata.ResourceData.HasChange("compute_tier") { + model.Properties.Compute = &mongoclusters.ComputeProperties{ + Tier: pointer.To(state.ComputeTier), + } + oldComputeTier, newComputeTier := metadata.ResourceData.GetChange("compute_tier") + if (oldComputeTier == "Free" || oldComputeTier == "M25") && newComputeTier != "Free" && newComputeTier != "M25" { + metadata.Logger.Infof("updating cluster tier for %s", *id) + if err := client.CreateOrUpdateThenPoll(ctx, *id, *model); err != nil { + return fmt.Errorf("updating %s: %+v", *id, err) + } + } + } + + metadata.Logger.Infof("updating other configurations for %s", *id) + if metadata.ResourceData.HasChange("administrator_login_password") { + model.Properties.Administrator = &mongoclusters.AdministratorProperties{ + UserName: pointer.To(state.AdministratorLogin), + Password: pointer.To(state.AdministratorLoginPassword), + } + } + + if metadata.ResourceData.HasChange("high_availability_mode") { + model.Properties.HighAvailability = &mongoclusters.HighAvailabilityProperties{ + TargetMode: pointer.To(mongoclusters.HighAvailabilityMode(state.HighAvailabilityMode)), + } + } + + if metadata.ResourceData.HasChange("public_network_access_enabled") { + if state.PublicNetworkAccessEnabled { + model.Properties.PublicNetworkAccess = pointer.To(mongoclusters.PublicNetworkAccessEnabled) + } else { + model.Properties.PublicNetworkAccess = pointer.To(mongoclusters.PublicNetworkAccessDisabled) + } + } + + if metadata.ResourceData.HasChange("storage_size_in_gb") { + model.Properties.Storage = &mongoclusters.StorageProperties{ + SizeGb: pointer.To(state.StorageSizeInGb), + } + } + + if metadata.ResourceData.HasChange("tags") { + model.Tags = pointer.To(state.Tags) + } + + if metadata.ResourceData.HasChange("version") { + model.Properties.ServerVersion = pointer.To(state.Version) + } + + if err := client.CreateOrUpdateThenPoll(ctx, *id, *model); err != nil { + return fmt.Errorf("updating %s: %+v", *id, err) + } + + return nil + }, + } +} + +func (r MongoClusterResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.MongoCluster.MongoClustersClient + + id, err := mongoclusters.ParseMongoClusterID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + 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) + } + + state := MongoClusterResourceModel{ + Name: id.MongoClusterName, + ResourceGroupName: id.ResourceGroupName, + } + + if model := resp.Model; model != nil { + state.Location = location.NormalizeNilable(&model.Location) + + if props := model.Properties; props != nil { + // API doesn't return the value of administrator_login_password + state.AdministratorLoginPassword = metadata.ResourceData.Get("administrator_login_password").(string) + + // API doesn't return the value of create_mode + state.CreateMode = metadata.ResourceData.Get("create_mode").(string) + + if v := props.Administrator; v != nil { + state.AdministratorLogin = pointer.From(v.UserName) + } + + if v := props.Replica; v != nil { + // API doesn't return the value of source_location + state.SourceLocation = metadata.ResourceData.Get("source_location").(string) + state.SourceServerId = pointer.From(v.SourceResourceId) + } + + if v := props.Sharding; v != nil { + state.ShardCount = pointer.From(v.ShardCount) + } + if v := props.Compute; v != nil { + state.ComputeTier = pointer.From(v.Tier) + } + + if v := props.HighAvailability; v != nil { + state.HighAvailabilityMode = string(pointer.From(v.TargetMode)) + } + state.PublicNetworkAccessEnabled = pointer.From(props.PublicNetworkAccess) == mongoclusters.PublicNetworkAccessEnabled + + if v := props.Storage; v != nil { + state.StorageSizeInGb = pointer.From(v.SizeGb) + } + if v := props.PreviewFeatures; v != nil { + state.PreviewFeatures = flattenMongoClusterPreviewFeatures(v) + } + state.Version = pointer.From(props.ServerVersion) + } + + state.Tags = pointer.From(model.Tags) + } + + return metadata.Encode(&state) + }, + } +} + +func (r MongoClusterResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.MongoCluster.MongoClustersClient + + id, err := mongoclusters.ParseMongoClusterID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + if err := client.DeleteThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) + } + + return nil + }, + } +} + +func (r MongoClusterResource) CustomizeDiff() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + var state MongoClusterResourceModel + if err := metadata.DecodeDiff(&state); err != nil { + return fmt.Errorf("DecodeDiff: %+v", err) + } + + switch state.CreateMode { + case string(mongoclusters.CreateModeDefault): + if _, ok := metadata.ResourceDiff.GetOk("administrator_login"); !ok { + return fmt.Errorf("`administrator_login` is required when `create_mode` is %s", string(mongoclusters.CreateModeDefault)) + } + + if _, ok := metadata.ResourceDiff.GetOk("administrator_login_password"); !ok { + return fmt.Errorf("`administrator_login_password` is required when `create_mode` is %s", string(mongoclusters.CreateModeDefault)) + } + + if _, ok := metadata.ResourceDiff.GetOk("compute_tier"); !ok { + return fmt.Errorf("`compute_tier` is required when `create_mode` is %s", string(mongoclusters.CreateModeDefault)) + } + + if _, ok := metadata.ResourceDiff.GetOk("storage_size_in_gb"); !ok { + return fmt.Errorf("`storage_size_in_gb` is required when `create_mode` is %s", string(mongoclusters.CreateModeDefault)) + } + + if _, ok := metadata.ResourceDiff.GetOk("high_availability_mode"); !ok { + return fmt.Errorf("`high_availability_mode` is required when `create_mode` is %s", string(mongoclusters.CreateModeDefault)) + } + + if _, ok := metadata.ResourceDiff.GetOk("shard_count"); !ok { + return fmt.Errorf("`shard_count` is required when `create_mode` is %s", string(mongoclusters.CreateModeDefault)) + } + + if _, ok := metadata.ResourceDiff.GetOk("version"); !ok { + return fmt.Errorf("`version` is required when `create_mode` is %s", string(mongoclusters.CreateModeDefault)) + } + case string(mongoclusters.CreateModeGeoReplica): + if state.SourceServerId == "" { + return fmt.Errorf("`source_server_id` is required when `create_mode` is `GeoReplica`") + } + if state.SourceLocation == "" { + return fmt.Errorf("`source_location` is required when `create_mode` is `GeoReplica`") + } + } + + if state.ComputeTier == "Free" || state.ComputeTier == "M25" { + if state.HighAvailabilityMode == string(mongoclusters.HighAvailabilityModeZoneRedundantPreferred) { + return fmt.Errorf("high Availability is not available with the 'Free' or 'M25' Cluster Tier") + } + + if state.ShardCount > 1 { + return fmt.Errorf("the value of `shard_count` cannot exceed 1 for the 'Free' or 'M25' Cluster Tier") + } + } + + return nil + }, + } +} + +func expandPreviewFeatures(input []interface{}) *[]mongoclusters.PreviewFeature { + result := make([]mongoclusters.PreviewFeature, 0) + + for _, v := range input { + if v != "" { + result = append(result, mongoclusters.PreviewFeature(v.(string))) + } + } + + return &result +} + +func flattenMongoClusterPreviewFeatures(input *[]mongoclusters.PreviewFeature) []string { + results := make([]string, 0) + if input == nil { + return results + } + + for _, v := range *input { + results = append(results, string(v)) + } + + return results +} diff --git a/internal/services/mongocluster/mongo_cluster_resource_test.go b/internal/services/mongocluster/mongo_cluster_resource_test.go new file mode 100644 index 000000000000..52bbae8bde86 --- /dev/null +++ b/internal/services/mongocluster/mongo_cluster_resource_test.go @@ -0,0 +1,227 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package mongocluster_test + +import ( + "context" + "fmt" + "os" + "testing" + + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" +) + +type MongoClusterResource struct{} + +func TestAccMongoCluster_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_mongo_cluster", "test") + r := MongoClusterResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("administrator_login_password", "create_mode"), + }) +} + +func TestAccMongoCluster_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_mongo_cluster", "test") + r := MongoClusterResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("administrator_login_password", "create_mode"), + { + Config: r.update(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("administrator_login_password", "create_mode"), + }) +} + +func TestAccMongoCluster_previewFeature(t *testing.T) { + if os.Getenv("ARM_GEO_RESTORE_LOCATION") == "" { + t.Skip("Skipping as `ARM_GEO_RESTORE_LOCATION` is not specified") + return + } + + data := acceptance.BuildTestData(t, "azurerm_mongo_cluster", "test") + r := MongoClusterResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.previewFeature(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("administrator_login_password", "create_mode"), + { + Config: r.geoReplica(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("administrator_login_password", "create_mode", "source_location"), + }) +} + +func TestAccMongoCluster_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_mongo_cluster", "test") + r := MongoClusterResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func (r MongoClusterResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := mongoclusters.ParseMongoClusterID(state.ID) + if err != nil { + return nil, err + } + + resp, err := clients.MongoCluster.MongoClustersClient.Get(ctx, *id) + if err != nil { + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) + } + + return pointer.To(resp.Model != nil), nil +} + +func (r MongoClusterResource) basic(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_mongo_cluster" "test" { + name = "acctest-mc%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + administrator_login = "adminTerraform" + administrator_login_password = "QAZwsx123" + shard_count = "1" + compute_tier = "Free" + high_availability_mode = "Disabled" + storage_size_in_gb = "32" + version = "6.0" +} +`, r.template(data), data.RandomInteger) +} + +func (r MongoClusterResource) update(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_mongo_cluster" "test" { + name = "acctest-mc%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + administrator_login = "adminTerraform" + administrator_login_password = "QAZwsx123update" + shard_count = "1" + compute_tier = "M30" + high_availability_mode = "ZoneRedundantPreferred" + public_network_access_enabled = false + storage_size_in_gb = "64" + version = "7.0" + + tags = { + environment = "test" + } +} +`, r.template(data), data.RandomInteger) +} + +func (r MongoClusterResource) requiresImport(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_mongo_cluster" "import" { + name = azurerm_mongo_cluster.test.name + resource_group_name = azurerm_mongo_cluster.test.resource_group_name + location = azurerm_mongo_cluster.test.location + administrator_login = azurerm_mongo_cluster.test.administrator_login + administrator_login_password = azurerm_mongo_cluster.test.administrator_login_password + shard_count = azurerm_mongo_cluster.test.shard_count + compute_tier = azurerm_mongo_cluster.test.compute_tier + high_availability_mode = azurerm_mongo_cluster.test.high_availability_mode + storage_size_in_gb = azurerm_mongo_cluster.test.storage_size_in_gb + version = azurerm_mongo_cluster.test.version +} +`, r.basic(data)) +} + +func (r MongoClusterResource) previewFeature(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_mongo_cluster" "test" { + name = "acctest-mc%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + administrator_login = "adminTerraform" + administrator_login_password = "testQAZwsx123" + shard_count = "1" + compute_tier = "M30" + high_availability_mode = "ZoneRedundantPreferred" + storage_size_in_gb = "64" + preview_features = ["GeoReplicas"] + version = "7.0" +} +`, r.template(data), data.RandomInteger) +} + +func (r MongoClusterResource) geoReplica(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_mongo_cluster" "geo_replica" { + name = "acctest-mc-replica%d" + resource_group_name = azurerm_resource_group.test.name + location = "%s" + source_server_id = azurerm_mongo_cluster.test.id + source_location = azurerm_mongo_cluster.test.location + create_mode = "GeoReplica" + + lifecycle { + ignore_changes = ["administrator_login", "high_availability_mode", "preview_features", "shard_count", "storage_size_in_gb", "compute_tier", "version"] + } +} +`, r.previewFeature(data), data.RandomInteger, os.Getenv("ARM_GEO_RESTORE_LOCATION")) +} + +func (r MongoClusterResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} +`, data.RandomInteger, data.Locations.Primary) +} diff --git a/internal/services/mongocluster/registration.go b/internal/services/mongocluster/registration.go new file mode 100644 index 000000000000..c09ac8b45afc --- /dev/null +++ b/internal/services/mongocluster/registration.go @@ -0,0 +1,40 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package mongocluster + +import ( + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" +) + +type Registration struct{} + +var ( + _ sdk.TypedServiceRegistration = Registration{} +) + +func (r Registration) AssociatedGitHubLabel() string { + return "service/mongo-cluster" +} + +// Name is the name of this Service +func (r Registration) Name() string { + return "MongoCluster" +} + +// WebsiteCategories returns a list of categories which can be used for the sidebar +func (r Registration) WebsiteCategories() []string { + return []string{"MongoCluster"} +} + +// DataSources returns a list of Data Sources supported by this Service +func (r Registration) DataSources() []sdk.DataSource { + return []sdk.DataSource{} +} + +// Resources returns a list of Resources supported by this Service +func (r Registration) Resources() []sdk.Resource { + return []sdk.Resource{ + MongoClusterResource{}, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/README.md new file mode 100644 index 000000000000..d103a70de620 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/README.md @@ -0,0 +1,171 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters` Documentation + +The `mongoclusters` SDK allows for interaction with Azure Resource Manager `mongocluster` (API Version `2024-07-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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters" +``` + + +### Client Initialization + +```go +client := mongoclusters.NewMongoClustersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `MongoClustersClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := mongoclusters.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := mongoclusters.CheckNameAvailabilityRequest{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `MongoClustersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := mongoclusters.NewMongoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mongoClusterName") + +payload := mongoclusters.MongoCluster{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `MongoClustersClient.Delete` + +```go +ctx := context.TODO() +id := mongoclusters.NewMongoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mongoClusterName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `MongoClustersClient.Get` + +```go +ctx := context.TODO() +id := mongoclusters.NewMongoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mongoClusterName") + +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: `MongoClustersClient.List` + +```go +ctx := context.TODO() +id := commonids.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: `MongoClustersClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.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: `MongoClustersClient.ListConnectionStrings` + +```go +ctx := context.TODO() +id := mongoclusters.NewMongoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mongoClusterName") + +read, err := client.ListConnectionStrings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `MongoClustersClient.Promote` + +```go +ctx := context.TODO() +id := mongoclusters.NewMongoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mongoClusterName") + +payload := mongoclusters.PromoteReplicaRequest{ + // ... +} + + +if err := client.PromoteThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `MongoClustersClient.Update` + +```go +ctx := context.TODO() +id := mongoclusters.NewMongoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mongoClusterName") + +payload := mongoclusters.MongoClusterUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/client.go new file mode 100644 index 000000000000..2d0a465d2b90 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/client.go @@ -0,0 +1,26 @@ +package mongoclusters + +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 MongoClustersClient struct { + Client *resourcemanager.Client +} + +func NewMongoClustersClientWithBaseURI(sdkApi sdkEnv.Api) (*MongoClustersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "mongoclusters", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MongoClustersClient: %+v", err) + } + + return &MongoClustersClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/constants.go new file mode 100644 index 000000000000..4835148e9a53 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/constants.go @@ -0,0 +1,594 @@ +package mongoclusters + +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 CheckNameAvailabilityReason string + +const ( + CheckNameAvailabilityReasonAlreadyExists CheckNameAvailabilityReason = "AlreadyExists" + CheckNameAvailabilityReasonInvalid CheckNameAvailabilityReason = "Invalid" +) + +func PossibleValuesForCheckNameAvailabilityReason() []string { + return []string{ + string(CheckNameAvailabilityReasonAlreadyExists), + string(CheckNameAvailabilityReasonInvalid), + } +} + +func (s *CheckNameAvailabilityReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCheckNameAvailabilityReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCheckNameAvailabilityReason(input string) (*CheckNameAvailabilityReason, error) { + vals := map[string]CheckNameAvailabilityReason{ + "alreadyexists": CheckNameAvailabilityReasonAlreadyExists, + "invalid": CheckNameAvailabilityReasonInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CheckNameAvailabilityReason(input) + return &out, nil +} + +type CreateMode string + +const ( + CreateModeDefault CreateMode = "Default" + CreateModeGeoReplica CreateMode = "GeoReplica" + CreateModePointInTimeRestore CreateMode = "PointInTimeRestore" + CreateModeReplica CreateMode = "Replica" +) + +func PossibleValuesForCreateMode() []string { + return []string{ + string(CreateModeDefault), + string(CreateModeGeoReplica), + string(CreateModePointInTimeRestore), + string(CreateModeReplica), + } +} + +func (s *CreateMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCreateMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCreateMode(input string) (*CreateMode, error) { + vals := map[string]CreateMode{ + "default": CreateModeDefault, + "georeplica": CreateModeGeoReplica, + "pointintimerestore": CreateModePointInTimeRestore, + "replica": CreateModeReplica, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreateMode(input) + return &out, nil +} + +type HighAvailabilityMode string + +const ( + HighAvailabilityModeDisabled HighAvailabilityMode = "Disabled" + HighAvailabilityModeSameZone HighAvailabilityMode = "SameZone" + HighAvailabilityModeZoneRedundantPreferred HighAvailabilityMode = "ZoneRedundantPreferred" +) + +func PossibleValuesForHighAvailabilityMode() []string { + return []string{ + string(HighAvailabilityModeDisabled), + string(HighAvailabilityModeSameZone), + string(HighAvailabilityModeZoneRedundantPreferred), + } +} + +func (s *HighAvailabilityMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHighAvailabilityMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHighAvailabilityMode(input string) (*HighAvailabilityMode, error) { + vals := map[string]HighAvailabilityMode{ + "disabled": HighAvailabilityModeDisabled, + "samezone": HighAvailabilityModeSameZone, + "zoneredundantpreferred": HighAvailabilityModeZoneRedundantPreferred, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HighAvailabilityMode(input) + return &out, nil +} + +type MongoClusterStatus string + +const ( + MongoClusterStatusDropping MongoClusterStatus = "Dropping" + MongoClusterStatusProvisioning MongoClusterStatus = "Provisioning" + MongoClusterStatusReady MongoClusterStatus = "Ready" + MongoClusterStatusStarting MongoClusterStatus = "Starting" + MongoClusterStatusStopped MongoClusterStatus = "Stopped" + MongoClusterStatusStopping MongoClusterStatus = "Stopping" + MongoClusterStatusUpdating MongoClusterStatus = "Updating" +) + +func PossibleValuesForMongoClusterStatus() []string { + return []string{ + string(MongoClusterStatusDropping), + string(MongoClusterStatusProvisioning), + string(MongoClusterStatusReady), + string(MongoClusterStatusStarting), + string(MongoClusterStatusStopped), + string(MongoClusterStatusStopping), + string(MongoClusterStatusUpdating), + } +} + +func (s *MongoClusterStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMongoClusterStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMongoClusterStatus(input string) (*MongoClusterStatus, error) { + vals := map[string]MongoClusterStatus{ + "dropping": MongoClusterStatusDropping, + "provisioning": MongoClusterStatusProvisioning, + "ready": MongoClusterStatusReady, + "starting": MongoClusterStatusStarting, + "stopped": MongoClusterStatusStopped, + "stopping": MongoClusterStatusStopping, + "updating": MongoClusterStatusUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MongoClusterStatus(input) + return &out, nil +} + +type PreviewFeature string + +const ( + PreviewFeatureGeoReplicas PreviewFeature = "GeoReplicas" +) + +func PossibleValuesForPreviewFeature() []string { + return []string{ + string(PreviewFeatureGeoReplicas), + } +} + +func (s *PreviewFeature) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePreviewFeature(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePreviewFeature(input string) (*PreviewFeature, error) { + vals := map[string]PreviewFeature{ + "georeplicas": PreviewFeatureGeoReplicas, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PreviewFeature(input) + return &out, nil +} + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + } +} + +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} + +type PromoteMode string + +const ( + PromoteModeSwitchover PromoteMode = "Switchover" +) + +func PossibleValuesForPromoteMode() []string { + return []string{ + string(PromoteModeSwitchover), + } +} + +func (s *PromoteMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePromoteMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePromoteMode(input string) (*PromoteMode, error) { + vals := map[string]PromoteMode{ + "switchover": PromoteModeSwitchover, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PromoteMode(input) + return &out, nil +} + +type PromoteOption string + +const ( + PromoteOptionForced PromoteOption = "Forced" +) + +func PossibleValuesForPromoteOption() []string { + return []string{ + string(PromoteOptionForced), + } +} + +func (s *PromoteOption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePromoteOption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePromoteOption(input string) (*PromoteOption, error) { + vals := map[string]PromoteOption{ + "forced": PromoteOptionForced, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PromoteOption(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDropping ProvisioningState = "Dropping" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateInProgress ProvisioningState = "InProgress" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDropping), + string(ProvisioningStateFailed), + string(ProvisioningStateInProgress), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "dropping": ProvisioningStateDropping, + "failed": ProvisioningStateFailed, + "inprogress": ProvisioningStateInProgress, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" +) + +func PossibleValuesForPublicNetworkAccess() []string { + return []string{ + string(PublicNetworkAccessDisabled), + string(PublicNetworkAccessEnabled), + } +} + +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { + vals := map[string]PublicNetworkAccess{ + "disabled": PublicNetworkAccessDisabled, + "enabled": PublicNetworkAccessEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccess(input) + return &out, nil +} + +type ReplicationRole string + +const ( + ReplicationRoleAsyncReplica ReplicationRole = "AsyncReplica" + ReplicationRoleGeoAsyncReplica ReplicationRole = "GeoAsyncReplica" + ReplicationRolePrimary ReplicationRole = "Primary" +) + +func PossibleValuesForReplicationRole() []string { + return []string{ + string(ReplicationRoleAsyncReplica), + string(ReplicationRoleGeoAsyncReplica), + string(ReplicationRolePrimary), + } +} + +func (s *ReplicationRole) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReplicationRole(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReplicationRole(input string) (*ReplicationRole, error) { + vals := map[string]ReplicationRole{ + "asyncreplica": ReplicationRoleAsyncReplica, + "geoasyncreplica": ReplicationRoleGeoAsyncReplica, + "primary": ReplicationRolePrimary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReplicationRole(input) + return &out, nil +} + +type ReplicationState string + +const ( + ReplicationStateActive ReplicationState = "Active" + ReplicationStateBroken ReplicationState = "Broken" + ReplicationStateCatchup ReplicationState = "Catchup" + ReplicationStateProvisioning ReplicationState = "Provisioning" + ReplicationStateReconfiguring ReplicationState = "Reconfiguring" + ReplicationStateUpdating ReplicationState = "Updating" +) + +func PossibleValuesForReplicationState() []string { + return []string{ + string(ReplicationStateActive), + string(ReplicationStateBroken), + string(ReplicationStateCatchup), + string(ReplicationStateProvisioning), + string(ReplicationStateReconfiguring), + string(ReplicationStateUpdating), + } +} + +func (s *ReplicationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReplicationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReplicationState(input string) (*ReplicationState, error) { + vals := map[string]ReplicationState{ + "active": ReplicationStateActive, + "broken": ReplicationStateBroken, + "catchup": ReplicationStateCatchup, + "provisioning": ReplicationStateProvisioning, + "reconfiguring": ReplicationStateReconfiguring, + "updating": ReplicationStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReplicationState(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/id_location.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/id_location.go new file mode 100644 index 000000000000..175236f72925 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/id_location.go @@ -0,0 +1,121 @@ +package mongoclusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(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 := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.DocumentDB/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/id_mongocluster.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/id_mongocluster.go new file mode 100644 index 000000000000..ddfa466ceb72 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/id_mongocluster.go @@ -0,0 +1,130 @@ +package mongoclusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&MongoClusterId{}) +} + +var _ resourceids.ResourceId = &MongoClusterId{} + +// MongoClusterId is a struct representing the Resource ID for a Mongo Cluster +type MongoClusterId struct { + SubscriptionId string + ResourceGroupName string + MongoClusterName string +} + +// NewMongoClusterID returns a new MongoClusterId struct +func NewMongoClusterID(subscriptionId string, resourceGroupName string, mongoClusterName string) MongoClusterId { + return MongoClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + MongoClusterName: mongoClusterName, + } +} + +// ParseMongoClusterID parses 'input' into a MongoClusterId +func ParseMongoClusterID(input string) (*MongoClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&MongoClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MongoClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMongoClusterIDInsensitively parses 'input' case-insensitively into a MongoClusterId +// note: this method should only be used for API response data and not user input +func ParseMongoClusterIDInsensitively(input string) (*MongoClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&MongoClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MongoClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MongoClusterId) 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.MongoClusterName, ok = input.Parsed["mongoClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "mongoClusterName", input) + } + + return nil +} + +// ValidateMongoClusterID checks that 'input' can be parsed as a Mongo Cluster ID +func ValidateMongoClusterID(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 := ParseMongoClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Mongo Cluster ID +func (id MongoClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/mongoClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MongoClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Mongo Cluster ID +func (id MongoClusterId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticMongoClusters", "mongoClusters", "mongoClusters"), + resourceids.UserSpecifiedSegment("mongoClusterName", "mongoClusterName"), + } +} + +// String returns a human-readable description of this Mongo Cluster ID +func (id MongoClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Mongo Cluster Name: %q", id.MongoClusterName), + } + return fmt.Sprintf("Mongo Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_checknameavailability.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_checknameavailability.go new file mode 100644 index 000000000000..d29c03d95ff3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_checknameavailability.go @@ -0,0 +1,58 @@ +package mongoclusters + +import ( + "context" + "fmt" + "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 CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameAvailabilityResponse +} + +// CheckNameAvailability ... +func (c MongoClustersClient) CheckNameAvailability(ctx context.Context, id LocationId, input CheckNameAvailabilityRequest) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkMongoClusterNameAvailability", 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 + } + + var model CheckNameAvailabilityResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_createorupdate.go new file mode 100644 index 000000000000..d31c486a5a77 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_createorupdate.go @@ -0,0 +1,75 @@ +package mongoclusters + +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 + Model *MongoCluster +} + +// CreateOrUpdate ... +func (c MongoClustersClient) CreateOrUpdate(ctx context.Context, id MongoClusterId, input MongoCluster) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 MongoClustersClient) CreateOrUpdateThenPoll(ctx context.Context, id MongoClusterId, input MongoCluster) 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/mongocluster/2024-07-01/mongoclusters/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_delete.go new file mode 100644 index 000000000000..f2ab5c143c44 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_delete.go @@ -0,0 +1,70 @@ +package mongoclusters + +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 MongoClustersClient) Delete(ctx context.Context, id MongoClusterId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + 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 MongoClustersClient) DeleteThenPoll(ctx context.Context, id MongoClusterId) 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/mongocluster/2024-07-01/mongoclusters/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_get.go new file mode 100644 index 000000000000..19be380881ab --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_get.go @@ -0,0 +1,53 @@ +package mongoclusters + +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 *MongoCluster +} + +// Get ... +func (c MongoClustersClient) Get(ctx context.Context, id MongoClusterId) (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 + } + + var model MongoCluster + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_list.go new file mode 100644 index 000000000000..957796bf6058 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_list.go @@ -0,0 +1,106 @@ +package mongoclusters + +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 *[]MongoCluster +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []MongoCluster +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c MongoClustersClient) 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, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DocumentDB/mongoClusters", 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 *[]MongoCluster `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 MongoClustersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, MongoClusterOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MongoClustersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate MongoClusterOperationPredicate) (result ListCompleteResult, err error) { + items := make([]MongoCluster, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_listbyresourcegroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_listbyresourcegroup.go new file mode 100644 index 000000000000..87c9b7822106 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package mongoclusters + +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 *[]MongoCluster +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []MongoCluster +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c MongoClustersClient) 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, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DocumentDB/mongoClusters", 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 *[]MongoCluster `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 MongoClustersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, MongoClusterOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MongoClustersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate MongoClusterOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]MongoCluster, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_listconnectionstrings.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_listconnectionstrings.go new file mode 100644 index 000000000000..3ac12241859f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_listconnectionstrings.go @@ -0,0 +1,54 @@ +package mongoclusters + +import ( + "context" + "fmt" + "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 ListConnectionStringsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ListConnectionStringsResult +} + +// ListConnectionStrings ... +func (c MongoClustersClient) ListConnectionStrings(ctx context.Context, id MongoClusterId) (result ListConnectionStringsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listConnectionStrings", 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 + } + + var model ListConnectionStringsResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_promote.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_promote.go new file mode 100644 index 000000000000..e1305fefd777 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_promote.go @@ -0,0 +1,73 @@ +package mongoclusters + +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 PromoteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Promote ... +func (c MongoClustersClient) Promote(ctx context.Context, id MongoClusterId, input PromoteReplicaRequest) (result PromoteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/promote", 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 +} + +// PromoteThenPoll performs Promote then polls until it's completed +func (c MongoClustersClient) PromoteThenPoll(ctx context.Context, id MongoClusterId, input PromoteReplicaRequest) error { + result, err := c.Promote(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Promote: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Promote: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_update.go new file mode 100644 index 000000000000..b0971a437631 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/method_update.go @@ -0,0 +1,75 @@ +package mongoclusters + +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 + Model *MongoCluster +} + +// Update ... +func (c MongoClustersClient) Update(ctx context.Context, id MongoClusterId, input MongoClusterUpdate) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 MongoClustersClient) UpdateThenPoll(ctx context.Context, id MongoClusterId, input MongoClusterUpdate) 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/mongocluster/2024-07-01/mongoclusters/model_administratorproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_administratorproperties.go new file mode 100644 index 000000000000..0d5e695ec050 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_administratorproperties.go @@ -0,0 +1,9 @@ +package mongoclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdministratorProperties struct { + Password *string `json:"password,omitempty"` + UserName *string `json:"userName,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_backupproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_backupproperties.go new file mode 100644 index 000000000000..1a78556df72f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_backupproperties.go @@ -0,0 +1,8 @@ +package mongoclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupProperties struct { + EarliestRestoreTime *string `json:"earliestRestoreTime,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_checknameavailabilityrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_checknameavailabilityrequest.go new file mode 100644 index 000000000000..b834e55f5ff8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_checknameavailabilityrequest.go @@ -0,0 +1,9 @@ +package mongoclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityRequest struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_checknameavailabilityresponse.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_checknameavailabilityresponse.go new file mode 100644 index 000000000000..51db08775d65 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_checknameavailabilityresponse.go @@ -0,0 +1,10 @@ +package mongoclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityResponse struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *CheckNameAvailabilityReason `json:"reason,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_computeproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_computeproperties.go new file mode 100644 index 000000000000..750d420bf66d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_computeproperties.go @@ -0,0 +1,8 @@ +package mongoclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeProperties struct { + Tier *string `json:"tier,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_connectionstring.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_connectionstring.go new file mode 100644 index 000000000000..75c56104190b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_connectionstring.go @@ -0,0 +1,10 @@ +package mongoclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionString struct { + ConnectionString *string `json:"connectionString,omitempty"` + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_highavailabilityproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_highavailabilityproperties.go new file mode 100644 index 000000000000..7aa466fd3706 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_highavailabilityproperties.go @@ -0,0 +1,8 @@ +package mongoclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HighAvailabilityProperties struct { + TargetMode *HighAvailabilityMode `json:"targetMode,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_listconnectionstringsresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_listconnectionstringsresult.go new file mode 100644 index 000000000000..bab5c3229246 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_listconnectionstringsresult.go @@ -0,0 +1,8 @@ +package mongoclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListConnectionStringsResult struct { + ConnectionStrings *[]ConnectionString `json:"connectionStrings,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_mongocluster.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_mongocluster.go new file mode 100644 index 000000000000..7f6d9cb3fd54 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_mongocluster.go @@ -0,0 +1,18 @@ +package mongoclusters + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoCluster struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *MongoClusterProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,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/mongocluster/2024-07-01/mongoclusters/model_mongoclusterproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_mongoclusterproperties.go new file mode 100644 index 000000000000..6474ffeeb4ff --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_mongoclusterproperties.go @@ -0,0 +1,25 @@ +package mongoclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoClusterProperties struct { + Administrator *AdministratorProperties `json:"administrator,omitempty"` + Backup *BackupProperties `json:"backup,omitempty"` + ClusterStatus *MongoClusterStatus `json:"clusterStatus,omitempty"` + Compute *ComputeProperties `json:"compute,omitempty"` + ConnectionString *string `json:"connectionString,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + HighAvailability *HighAvailabilityProperties `json:"highAvailability,omitempty"` + InfrastructureVersion *string `json:"infrastructureVersion,omitempty"` + PreviewFeatures *[]PreviewFeature `json:"previewFeatures,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + Replica *ReplicationProperties `json:"replica,omitempty"` + ReplicaParameters *MongoClusterReplicaParameters `json:"replicaParameters,omitempty"` + RestoreParameters *MongoClusterRestoreParameters `json:"restoreParameters,omitempty"` + ServerVersion *string `json:"serverVersion,omitempty"` + Sharding *ShardingProperties `json:"sharding,omitempty"` + Storage *StorageProperties `json:"storage,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_mongoclusterreplicaparameters.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_mongoclusterreplicaparameters.go new file mode 100644 index 000000000000..d76486d9568b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_mongoclusterreplicaparameters.go @@ -0,0 +1,9 @@ +package mongoclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoClusterReplicaParameters struct { + SourceLocation string `json:"sourceLocation"` + SourceResourceId string `json:"sourceResourceId"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_mongoclusterrestoreparameters.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_mongoclusterrestoreparameters.go new file mode 100644 index 000000000000..0cc10482f00d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_mongoclusterrestoreparameters.go @@ -0,0 +1,27 @@ +package mongoclusters + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoClusterRestoreParameters struct { + PointInTimeUTC *string `json:"pointInTimeUTC,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +func (o *MongoClusterRestoreParameters) GetPointInTimeUTCAsTime() (*time.Time, error) { + if o.PointInTimeUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.PointInTimeUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *MongoClusterRestoreParameters) SetPointInTimeUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.PointInTimeUTC = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_mongoclusterupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_mongoclusterupdate.go new file mode 100644 index 000000000000..e452dd9823dd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_mongoclusterupdate.go @@ -0,0 +1,9 @@ +package mongoclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoClusterUpdate struct { + Properties *MongoClusterUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_mongoclusterupdateproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_mongoclusterupdateproperties.go new file mode 100644 index 000000000000..ee47924c3663 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_mongoclusterupdateproperties.go @@ -0,0 +1,16 @@ +package mongoclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoClusterUpdateProperties struct { + Administrator *AdministratorProperties `json:"administrator,omitempty"` + Backup *BackupProperties `json:"backup,omitempty"` + Compute *ComputeProperties `json:"compute,omitempty"` + HighAvailability *HighAvailabilityProperties `json:"highAvailability,omitempty"` + PreviewFeatures *[]PreviewFeature `json:"previewFeatures,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + ServerVersion *string `json:"serverVersion,omitempty"` + Sharding *ShardingProperties `json:"sharding,omitempty"` + Storage *StorageProperties `json:"storage,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_privateendpoint.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_privateendpoint.go new file mode 100644 index 000000000000..2250ebfa9eca --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_privateendpoint.go @@ -0,0 +1,8 @@ +package mongoclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_privateendpointconnection.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_privateendpointconnection.go new file mode 100644 index 000000000000..5dafd446486c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_privateendpointconnection.go @@ -0,0 +1,16 @@ +package mongoclusters + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_privateendpointconnectionproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_privateendpointconnectionproperties.go new file mode 100644 index 000000000000..d428048d9a8c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package mongoclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_privatelinkserviceconnectionstate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_privatelinkserviceconnectionstate.go new file mode 100644 index 000000000000..c38b16c9a311 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package mongoclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_promotereplicarequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_promotereplicarequest.go new file mode 100644 index 000000000000..fc3cc9274502 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_promotereplicarequest.go @@ -0,0 +1,9 @@ +package mongoclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PromoteReplicaRequest struct { + Mode *PromoteMode `json:"mode,omitempty"` + PromoteOption PromoteOption `json:"promoteOption"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_replicationproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_replicationproperties.go new file mode 100644 index 000000000000..09303ead8cf0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_replicationproperties.go @@ -0,0 +1,10 @@ +package mongoclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProperties struct { + ReplicationState *ReplicationState `json:"replicationState,omitempty"` + Role *ReplicationRole `json:"role,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_shardingproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_shardingproperties.go new file mode 100644 index 000000000000..b37690616792 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_shardingproperties.go @@ -0,0 +1,8 @@ +package mongoclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ShardingProperties struct { + ShardCount *int64 `json:"shardCount,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_storageproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_storageproperties.go new file mode 100644 index 000000000000..94d834c45f13 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/model_storageproperties.go @@ -0,0 +1,8 @@ +package mongoclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageProperties struct { + SizeGb *int64 `json:"sizeGb,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/predicates.go new file mode 100644 index 000000000000..2961ccc5ae07 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/predicates.go @@ -0,0 +1,32 @@ +package mongoclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoClusterOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p MongoClusterOperationPredicate) Matches(input MongoCluster) 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/mongocluster/2024-07-01/mongoclusters/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/version.go new file mode 100644 index 000000000000..ad7a56313839 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters/version.go @@ -0,0 +1,10 @@ +package mongoclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/mongoclusters/2024-07-01" +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 2b4b7c2b8c68..14052cf52ae0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -655,6 +655,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/simg github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/simpolicy github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/site github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice +github.com/hashicorp/go-azure-sdk/resource-manager/mongocluster/2024-07-01/mongoclusters github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2017-12-01/servers github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2022-01-01 github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2022-01-01/azureadadministrators diff --git a/website/allowed-subcategories b/website/allowed-subcategories index 76201e303d97..4437409e3289 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -73,6 +73,7 @@ Maps Messaging Mixed Reality Mobile Network +MongoCluster Monitor NGINX NetApp diff --git a/website/docs/r/mongo_cluster.html.markdown b/website/docs/r/mongo_cluster.html.markdown new file mode 100644 index 000000000000..28aa3afd5804 --- /dev/null +++ b/website/docs/r/mongo_cluster.html.markdown @@ -0,0 +1,129 @@ +--- +subcategory: "MongoCluster" +layout: "azurerm" +page_title: "Azure Resource Manager: `azurerm_mongo_cluster" +description: |- + Manages an Azure Cosmos DB for MongoDB vCore. +--- + +# azurerm_mongo_cluster + +Manages an Azure Cosmos DB for MongoDB vCore. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-rg" + location = "East US" +} + +resource "azurerm_mongo_cluster" "example" { + name = "example-mc" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location + administrator_login = "adminTerraform" + administrator_login_password = "QAZwsx123" + shard_count = "1" + compute_tier = "Free" + high_availability_mode = "Disabled" + storage_size_in_gb = "32" +} + +``` + +## Example Usage (Preview feature GeoReplicas) + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-rg" + location = "East US" +} + +resource "azurerm_mongo_cluster" "example" { + name = "example-mc" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location + administrator_login = "adminTerraform" + administrator_login_password = "QAZwsx123" + shard_count = "1" + compute_tier = "M30" + high_availability_mode = "ZoneRedundantPreferred" + storage_size_in_gb = "64" + preview_features = ["GeoReplicas"] +} + +resource "azurerm_mongo_cluster" "example_geo_replica" { + name = "example-mc-geo" + resource_group_name = azurerm_resource_group.example.name + location = "Central US" + source_server_id = azurerm_mongo_cluster.example.id + source_location = azurerm_mongo_cluster.example.location + create_mode = "GeoReplica" + + lifecycle { + ignore_changes = ["administrator_login", "high_availability_mode", "preview_features", "shard_count", "storage_size_in_gb", "compute_tier", "version"] + } +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) The name which should be used for the Azure Cosmos DB for MongoDB vCore. Changing this forces a new resource to be created. + +* `resource_group_name` - (Required) The name of the resource group in which to create the Azure Cosmos DB for MongoDB vCore. Changing this forces a new resource to be created. + +* `location` - (Required) The supported Azure location where the Azure Cosmos DB for MongoDB vCore exists. Changing this forces a new resource to be created. + +* `administrator_login` - (Optional) The administrator username of the Azure Cosmos DB for MongoDB vCore. Changing this forces a new resource to be created. + +* `create_mode` - (Optional) The creation mode for the Azure Cosmos DB for MongoDB vCore. Possibles values are `Default` and `GeoReplica`. Defaults to 'Default'. Changing this forces a new resource to be created. + +-> **Note** The creation mode "GeoReplica" is currently in preview. It is only available when specified via `preview_features`. + +* `preview_features` - (Optional) The preview features that can be enabled on the Azure Cosmos DB for MongoDB vCore. Changing this forces a new resource to be created. + +* `shard_count` - (Optional) The Number of shards to provision on the Azure Cosmos DB for MongoDB vCore. Changing this forces a new resource to be created. + +* `source_location` - (Optional) The location of the source Azure Cosmos DB for MongoDB vCore. Changing this forces a new resource to be created. + +* `source_resource_id` - (Optional) The ID of the replication source Azure Cosmos DB for MongoDB vCore. Changing this forces a new resource to be created. + +* `administrator_login_password` - (Optional) The Password associated with the `administrator_login` for the Azure Cosmos DB for MongoDB vCore. + +* `compute_tier` - (Optional) The compute tier to assign to the Azure Cosmos DB for MongoDB vCore. Possible values are `Free`, `M25`, `M30`, `M40`, `M50`, `M60` and `M80`. + +* `high_availability_mode` - (Optional) The high availability mode for the Azure Cosmos DB for MongoDB vCore. Possibles values are `Disabled` and `ZoneRedundantPreferred`. + +* `public_network_access_enabled` - (Optional) Whether public network access is allowed for the Azure Cosmos DB for MongoDB vCore. Defaults to 'true'. + +* `storage_size_in_gb` - (Optional) The size of the data disk space for the Azure Cosmos DB for MongoDB vCore. + +* `tags` - (Optional) A mapping of tags to assign to the Azure Cosmos DB for MongoDB vCore. + +* `version` - (Optional) The version for the Azure Cosmos DB for MongoDB vCore. Possibles values are `5.0`, `6.0` and `7.0`. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Azure Cosmos DB for MongoDB vCore. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the Azure Cosmos DB for MongoDB vCore. +* `read` - (Defaults to 5 minutes) Used when retrieving the Azure Cosmos DB for MongoDB vCore. +* `update` - (Defaults to 30 minutes) Used when updating the Azure Cosmos DB for MongoDB vCore. +* `delete` - (Defaults to 30 minutes) Used when deleting the Azure Cosmos DB for MongoDB vCore. + +## Import + +Monitor Azure Active Directory Diagnostic Settings can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_mongo_cluster.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster +```