From b646fce3d625535b5c3bb02a8fbd8a61ecf782f1 Mon Sep 17 00:00:00 2001 From: sinbai Date: Thu, 21 Nov 2024 16:04:21 +0800 Subject: [PATCH 1/6] support new resource azurerm_fabric_capacity --- .github/labeler-issue-triage.yml | 2 +- .teamcity/components/generated/services.kt | 1 + go.mod | 1 + go.sum | 3 +- internal/clients/client.go | 5 + internal/provider/services.go | 2 + internal/services/fabric/client/client.go | 24 ++ .../fabric/fabric_capacity_resource.go | 318 ++++++++++++++++++ .../fabric/fabric_capacity_resource_test.go | 203 +++++++++++ internal/services/fabric/registration.go | 33 ++ .../2023-11-01/fabriccapacities/README.md | 196 +++++++++++ .../2023-11-01/fabriccapacities/client.go | 26 ++ .../2023-11-01/fabriccapacities/constants.go | 213 ++++++++++++ .../fabriccapacities/id_capacity.go | 130 +++++++ .../fabriccapacities/id_location.go | 121 +++++++ .../method_checknameavailability.go | 58 ++++ .../fabriccapacities/method_createorupdate.go | 75 +++++ .../fabriccapacities/method_delete.go | 70 ++++ .../2023-11-01/fabriccapacities/method_get.go | 53 +++ .../method_listbyresourcegroup.go | 106 ++++++ .../method_listbysubscription.go | 106 ++++++ .../fabriccapacities/method_listskus.go | 106 ++++++ .../method_listskusforcapacity.go | 105 ++++++ .../fabriccapacities/method_resume.go | 70 ++++ .../fabriccapacities/method_suspend.go | 70 ++++ .../fabriccapacities/method_update.go | 75 +++++ .../model_capacityadministration.go | 8 + .../model_checknameavailabilityrequest.go | 9 + .../model_checknameavailabilityresponse.go | 10 + .../fabriccapacities/model_fabriccapacity.go | 19 ++ .../model_fabriccapacityproperties.go | 10 + .../model_fabriccapacityupdate.go | 10 + .../model_fabriccapacityupdateproperties.go | 8 + .../fabriccapacities/model_rpsku.go | 9 + .../model_rpskudetailsforexistingresource.go | 9 + .../model_rpskudetailsfornewresource.go | 10 + .../2023-11-01/fabriccapacities/predicates.go | 63 ++++ .../2023-11-01/fabriccapacities/version.go | 10 + vendor/modules.txt | 3 + website/allowed-subcategories | 1 + website/docs/r/fabric_capacity.html.markdown | 86 +++++ 41 files changed, 2435 insertions(+), 2 deletions(-) create mode 100644 internal/services/fabric/client/client.go create mode 100644 internal/services/fabric/fabric_capacity_resource.go create mode 100644 internal/services/fabric/fabric_capacity_resource_test.go create mode 100644 internal/services/fabric/registration.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/id_capacity.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/id_location.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_checknameavailability.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_listbyresourcegroup.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_listbysubscription.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_listskus.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_listskusforcapacity.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_resume.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_suspend.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_update.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_capacityadministration.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_checknameavailabilityrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_checknameavailabilityresponse.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_fabriccapacity.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_fabriccapacityproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_fabriccapacityupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_fabriccapacityupdateproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_rpsku.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_rpskudetailsforexistingresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_rpskudetailsfornewresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/version.go create mode 100644 website/docs/r/fabric_capacity.html.markdown diff --git a/.github/labeler-issue-triage.yml b/.github/labeler-issue-triage.yml index ba97f5f93250..725e09949278 100644 --- a/.github/labeler-issue-triage.yml +++ b/.github/labeler-issue-triage.yml @@ -144,7 +144,7 @@ service/event-hubs: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_eventhub((.|\n)*)###' service/extended-location: - - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_extended_custom_location((.|\n)*)###' + - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_(extended_custom_location|fabric_capacity)((.|\n)*)###' service/firewall: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_firewall((.|\n)*)###' diff --git a/.teamcity/components/generated/services.kt b/.teamcity/components/generated/services.kt index e6d7678a75f5..9d296b6a355b 100644 --- a/.teamcity/components/generated/services.kt +++ b/.teamcity/components/generated/services.kt @@ -54,6 +54,7 @@ var services = mapOf( "eventgrid" to "EventGrid", "eventhub" to "EventHub", "extendedlocation" to "ExtendedLocation", + "fabric" to "Fabric", "firewall" to "Firewall", "fluidrelay" to "Fluid Relay", "frontdoor" to "FrontDoor", diff --git a/go.mod b/go.mod index 15678ac262d7..88ba57f50151 100644 --- a/go.mod +++ b/go.mod @@ -68,6 +68,7 @@ require ( github.com/hashicorp/terraform-svchost v0.1.1 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/kr/pretty v0.3.0 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect diff --git a/go.sum b/go.sum index d0d9c3b47270..cb4ce02acf9e 100644 --- a/go.sum +++ b/go.sum @@ -169,8 +169,9 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/magodo/terraform-provider-azurerm-example-gen v0.0.0-20220407025246-3a3ee0ab24a8 h1:HHSqLmPZaa8U66U7N2Gtx3gYptSHrUB/rB5t+6fZTkQ= github.com/magodo/terraform-provider-azurerm-example-gen v0.0.0-20220407025246-3a3ee0ab24a8/go.mod h1:iMzpAzVr2v/NUVie/apAYtZlFZYFndPcp6/E0VLxgAM= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= diff --git a/internal/clients/client.go b/internal/clients/client.go index 69d254488c8c..b0e70441bc05 100644 --- a/internal/clients/client.go +++ b/internal/clients/client.go @@ -73,6 +73,7 @@ import ( eventgrid "github.com/hashicorp/terraform-provider-azurerm/internal/services/eventgrid/client" eventhub "github.com/hashicorp/terraform-provider-azurerm/internal/services/eventhub/client" extendedlocation "github.com/hashicorp/terraform-provider-azurerm/internal/services/extendedlocation/client" + fabric "github.com/hashicorp/terraform-provider-azurerm/internal/services/fabric/client" fluidrelay "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/client" frontdoor "github.com/hashicorp/terraform-provider-azurerm/internal/services/frontdoor/client" graph "github.com/hashicorp/terraform-provider-azurerm/internal/services/graphservices/client" @@ -208,6 +209,7 @@ type Client struct { EventGrid *eventgrid.Client Eventhub *eventhub.Client ExtendedLocation *extendedlocation.Client + Fabric *fabric.Client FluidRelay *fluidrelay_2022_05_26.Client Frontdoor *frontdoor.Client Graph *graph.Client @@ -447,6 +449,9 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error if client.ExtendedLocation, err = extendedlocation.NewClient(o); err != nil { return fmt.Errorf("building clients for ExtendedLocation: %+v", err) } + if client.Fabric, err = fabric.NewClient(o); err != nil { + return fmt.Errorf("building clients for Fabric: %+v", err) + } if client.FluidRelay, err = fluidrelay.NewClient(o); err != nil { return fmt.Errorf("building clients for FluidRelay: %+v", err) } diff --git a/internal/provider/services.go b/internal/provider/services.go index de9df155216f..bff94ac5f891 100644 --- a/internal/provider/services.go +++ b/internal/provider/services.go @@ -55,6 +55,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/services/eventgrid" "github.com/hashicorp/terraform-provider-azurerm/internal/services/eventhub" "github.com/hashicorp/terraform-provider-azurerm/internal/services/extendedlocation" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/fabric" "github.com/hashicorp/terraform-provider-azurerm/internal/services/firewall" "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay" "github.com/hashicorp/terraform-provider-azurerm/internal/services/frontdoor" @@ -173,6 +174,7 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration { eventgrid.Registration{}, eventhub.Registration{}, extendedlocation.Registration{}, + fabric.Registration{}, fluidrelay.Registration{}, graphservices.Registration{}, hybridcompute.Registration{}, diff --git a/internal/services/fabric/client/client.go b/internal/services/fabric/client/client.go new file mode 100644 index 000000000000..c36321ee6256 --- /dev/null +++ b/internal/services/fabric/client/client.go @@ -0,0 +1,24 @@ +package client + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities" + "github.com/hashicorp/terraform-provider-azurerm/internal/common" +) + +type Client struct { + FabricCapacitiesClient *fabriccapacities.FabricCapacitiesClient +} + +func NewClient(o *common.ClientOptions) (*Client, error) { + fabricCapacitiesClient, err := fabriccapacities.NewFabricCapacitiesClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building fabric client: %+v", err) + } + o.Configure(fabricCapacitiesClient.Client, o.Authorizers.ResourceManager) + + return &Client{ + FabricCapacitiesClient: fabricCapacitiesClient, + }, nil +} diff --git a/internal/services/fabric/fabric_capacity_resource.go b/internal/services/fabric/fabric_capacity_resource.go new file mode 100644 index 000000000000..e061efd994ab --- /dev/null +++ b/internal/services/fabric/fabric_capacity_resource.go @@ -0,0 +1,318 @@ +package fabric + +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/fabric/2023-11-01/fabriccapacities" + "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 FabricCapacityResource struct{} + +var _ sdk.ResourceWithUpdate = FabricCapacityResource{} + +var _ sdk.ResourceWithCustomizeDiff = FabricCapacityResource{} + +type FabricCapacityResourceModel struct { + Name string `tfschema:"name"` + ResourceGroupName string `tfschema:"resource_group_name"` + AdministrationMembers []string `tfschema:"administration_members"` + Location string `tfschema:"location"` + Sku []SkuModel `tfschema:"sku"` + Tags map[string]string `tfschema:"tags"` +} + +type SkuModel struct { + Name string `tfschema:"name"` + Tier string `tfschema:"tier"` +} + +func (r FabricCapacityResource) ModelObject() interface{} { + return &FabricCapacityResource{} +} + +func (r FabricCapacityResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return fabriccapacities.ValidateCapacityID +} + +func (r FabricCapacityResource) ResourceType() string { + return "azurerm_fabric_capacity" +} + +func (r FabricCapacityResource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringMatch( + regexp.MustCompile(`^[a-z]([a-z\d]{1,61}[a-z\d])$`), + "`name` must be between 3 and 63 characters. It can contain only lowercase letters and numbers. It must start with a lowercase letter.", + ), + }, + + "location": commonschema.Location(), + + "resource_group_name": commonschema.ResourceGroupName(), + + "sku": { + Type: pluginsdk.TypeList, + Required: true, + MaxItems: 1, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "tier": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(fabriccapacities.RpSkuTierFabric), + }, false), + }, + }, + }, + }, + + "administration_members": { + Type: pluginsdk.TypeList, + Optional: true, + MaxItems: 1, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + ValidateFunc: validation.StringIsNotEmpty, + }, + }, + + "tags": commonschema.Tags(), + } +} + +func (r FabricCapacityResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{} +} + +func (r FabricCapacityResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.Fabric.FabricCapacitiesClient + subscriptionId := metadata.Client.Account.SubscriptionId + + var model FabricCapacityResourceModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + id := fabriccapacities.NewCapacityID(subscriptionId, model.ResourceGroupName, model.Name) + existing, err := client.Get(ctx, id) + if err != nil && !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for existing %s: %+v", id, err) + } + + if !response.WasNotFound(existing.HttpResponse) { + return metadata.ResourceRequiresImport(r.ResourceType(), id) + } + + properties := fabriccapacities.FabricCapacity{ + Location: location.Normalize(model.Location), + Properties: fabriccapacities.FabricCapacityProperties{}, + } + + if len(model.AdministrationMembers) == 0 { + return fmt.Errorf("`administration_members` is required when creating a fabric capacity") + } + + properties.Properties.Administration = pointer.From(expandCapacityAdministrationModel(model.AdministrationMembers)) + + properties.Sku = pointer.From(expandSkuModel(model.Sku)) + + if model.Tags != nil { + properties.Tags = pointer.To(model.Tags) + } + + if err := client.CreateOrUpdateThenPoll(ctx, id, properties); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + return nil + }, + } +} + +func (r FabricCapacityResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.Fabric.FabricCapacitiesClient + + id, err := fabriccapacities.ParseCapacityID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + var model FabricCapacityResourceModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + existing, err := client.Get(ctx, *id) + if err != nil { + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + if existing.Model == nil { + return fmt.Errorf("retrieving %s: `model` was nil", *id) + } + + payload := existing.Model + if metadata.ResourceData.HasChange("administration_members") { + payload.Properties.Administration = pointer.From(expandCapacityAdministrationModel(model.AdministrationMembers)) + } + + if metadata.ResourceData.HasChange("sku") { + payload.Sku = pointer.From(expandSkuModel(model.Sku)) + } + + if metadata.ResourceData.HasChange("tags") { + payload.Tags = pointer.To(model.Tags) + } + + if err := client.CreateOrUpdateThenPoll(ctx, *id, *payload); err != nil { + return fmt.Errorf("updating %s: %+v", *id, err) + } + + return nil + }, + } +} + +func (r FabricCapacityResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.Fabric.FabricCapacitiesClient + + id, err := fabriccapacities.ParseCapacityID(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 := FabricCapacityResourceModel{ + Name: id.CapacityName, + ResourceGroupName: id.ResourceGroupName, + } + + if model := resp.Model; model != nil { + state.Location = location.Normalize(model.Location) + state.AdministrationMembers = model.Properties.Administration.Members + state.Sku = flattenSkuModel(&model.Sku) + state.Tags = pointer.From(model.Tags) + } + + return metadata.Encode(&state) + }, + } +} + +func (r FabricCapacityResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.Fabric.FabricCapacitiesClient + + id, err := fabriccapacities.ParseCapacityID(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 FabricCapacityResource) CustomizeDiff() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + var state FabricCapacityResourceModel + if err := metadata.DecodeDiff(&state); err != nil { + return fmt.Errorf("DecodeDiff: %+v", err) + } + + if len(state.AdministrationMembers) > 0 { + existing := make(map[string]bool) + for _, str := range state.AdministrationMembers { + if existing[str] { + return fmt.Errorf("`administration_members` contains the duplicate value %q", str) + } + existing[str] = true + } + } + + return nil + }, + } +} + +func expandCapacityAdministrationModel(inputList []string) *fabriccapacities.CapacityAdministration { + if len(inputList) == 0 { + return nil + } + + return &fabriccapacities.CapacityAdministration{ + Members: inputList, + } +} + +func expandSkuModel(inputList []SkuModel) *fabriccapacities.RpSku { + if len(inputList) == 0 { + return nil + } + + input := &inputList[0] + return &fabriccapacities.RpSku{ + Name: input.Name, + Tier: fabriccapacities.RpSkuTier(input.Tier), + } +} + +func flattenSkuModel(input *fabriccapacities.RpSku) []SkuModel { + var outputList []SkuModel + if input == nil { + return outputList + } + output := SkuModel{ + Name: input.Name, + Tier: string(input.Tier), + } + + return append(outputList, output) +} diff --git a/internal/services/fabric/fabric_capacity_resource_test.go b/internal/services/fabric/fabric_capacity_resource_test.go new file mode 100644 index 000000000000..8ae32b4ab463 --- /dev/null +++ b/internal/services/fabric/fabric_capacity_resource_test.go @@ -0,0 +1,203 @@ +package fabric_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities" + "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 FabricFabricCapacityResource struct{} + +func TestAccFabricFabricCapacity_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_fabric_capacity", "test") + r := FabricFabricCapacityResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccFabricFabricCapacity_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_fabric_capacity", "test") + r := FabricFabricCapacityResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func TestAccFabricFabricCapacity_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_fabric_capacity", "test") + r := FabricFabricCapacityResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccFabricFabricCapacity_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_fabric_capacity", "test") + r := FabricFabricCapacityResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.update(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func (r FabricFabricCapacityResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := fabriccapacities.ParseCapacityID(state.ID) + if err != nil { + return nil, err + } + + client := clients.Fabric.FabricCapacitiesClient + resp, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return pointer.To(false), nil + } + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) + } + return pointer.To(resp.Model != nil), nil +} + +func (r FabricFabricCapacityResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +data "azurerm_client_config" "current" {} + +resource "azurerm_resource_group" "test" { + name = "acctest-rg-%d" + location = "%s" +} +`, data.RandomInteger, data.Locations.Primary) +} + +func (r FabricFabricCapacityResource) basic(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +%s + +resource "azurerm_fabric_capacity" "test" { + name = "acctestffc%d" + resource_group_name = azurerm_resource_group.test.name + location = "%s" + administration_members = [data.azurerm_client_config.current.object_id] + + sku { + name = "F32" + tier = "Fabric" + } +} +`, template, data.RandomInteger, data.Locations.Primary) +} + +func (r FabricFabricCapacityResource) requiresImport(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_fabric_capacity" "import" { + name = azurerm_fabric_capacity.test.name + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + administration_members = azurerm_fabric_capacity.test.administration_members + + sku { + name = azurerm_fabric_capacity.test.sku[0].name + tier = azurerm_fabric_capacity.test.sku[0].tier + } +} +`, r.basic(data)) +} + +func (r FabricFabricCapacityResource) complete(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +%s + +resource "azurerm_fabric_capacity" "test" { + name = "acctestffc%d" + resource_group_name = azurerm_resource_group.test.name + location = "%s" + + administration_members = [data.azurerm_client_config.current.object_id] + + sku { + name = "F32" + tier = "Fabric" + } + + tags = { + environment = "test" + } +} +`, template, data.RandomInteger, data.Locations.Primary) +} + +func (r FabricFabricCapacityResource) update(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +%s + +resource "azurerm_fabric_capacity" "test" { + name = "acctestffc%d" + resource_group_name = azurerm_resource_group.test.name + location = "%s" + + sku { + name = "F64" + tier = "Fabric" + } + + tags = { + environment = "test1" + environment = "test2" + } +} +`, template, data.RandomInteger, data.Locations.Primary) +} diff --git a/internal/services/fabric/registration.go b/internal/services/fabric/registration.go new file mode 100644 index 000000000000..515eec2a318b --- /dev/null +++ b/internal/services/fabric/registration.go @@ -0,0 +1,33 @@ +package fabric + +import ( + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" +) + +type Registration struct{} + +var _ sdk.TypedServiceRegistration = Registration{} + +// Name is the name of this Service +func (r Registration) Name() string { + return "Fabric" +} + +// 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{ + FabricCapacityResource{}, + } +} + +// WebsiteCategories returns a list of categories which can be used for the sidebar +func (r Registration) WebsiteCategories() []string { + return []string{ + "Fabric", + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/README.md new file mode 100644 index 000000000000..9f4cbe1ad0a3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/README.md @@ -0,0 +1,196 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities` Documentation + +The `fabriccapacities` SDK allows for interaction with Azure Resource Manager `fabric` (API Version `2023-11-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/fabric/2023-11-01/fabriccapacities" +``` + + +### Client Initialization + +```go +client := fabriccapacities.NewFabricCapacitiesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `FabricCapacitiesClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := fabriccapacities.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := fabriccapacities.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: `FabricCapacitiesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := fabriccapacities.NewCapacityID("12345678-1234-9876-4563-123456789012", "example-resource-group", "capacityName") + +payload := fabriccapacities.FabricCapacity{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `FabricCapacitiesClient.Delete` + +```go +ctx := context.TODO() +id := fabriccapacities.NewCapacityID("12345678-1234-9876-4563-123456789012", "example-resource-group", "capacityName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `FabricCapacitiesClient.Get` + +```go +ctx := context.TODO() +id := fabriccapacities.NewCapacityID("12345678-1234-9876-4563-123456789012", "example-resource-group", "capacityName") + +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: `FabricCapacitiesClient.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: `FabricCapacitiesClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `FabricCapacitiesClient.ListSkus` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListSkus(ctx, id)` can be used to do batched pagination +items, err := client.ListSkusComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `FabricCapacitiesClient.ListSkusForCapacity` + +```go +ctx := context.TODO() +id := fabriccapacities.NewCapacityID("12345678-1234-9876-4563-123456789012", "example-resource-group", "capacityName") + +// alternatively `client.ListSkusForCapacity(ctx, id)` can be used to do batched pagination +items, err := client.ListSkusForCapacityComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `FabricCapacitiesClient.Resume` + +```go +ctx := context.TODO() +id := fabriccapacities.NewCapacityID("12345678-1234-9876-4563-123456789012", "example-resource-group", "capacityName") + +if err := client.ResumeThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `FabricCapacitiesClient.Suspend` + +```go +ctx := context.TODO() +id := fabriccapacities.NewCapacityID("12345678-1234-9876-4563-123456789012", "example-resource-group", "capacityName") + +if err := client.SuspendThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `FabricCapacitiesClient.Update` + +```go +ctx := context.TODO() +id := fabriccapacities.NewCapacityID("12345678-1234-9876-4563-123456789012", "example-resource-group", "capacityName") + +payload := fabriccapacities.FabricCapacityUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/client.go new file mode 100644 index 000000000000..124528c4394f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/client.go @@ -0,0 +1,26 @@ +package fabriccapacities + +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 FabricCapacitiesClient struct { + Client *resourcemanager.Client +} + +func NewFabricCapacitiesClientWithBaseURI(sdkApi sdkEnv.Api) (*FabricCapacitiesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "fabriccapacities", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating FabricCapacitiesClient: %+v", err) + } + + return &FabricCapacitiesClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/constants.go new file mode 100644 index 000000000000..969350a02521 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/constants.go @@ -0,0 +1,213 @@ +package fabriccapacities + +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 ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateProvisioning), + 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, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "provisioning": ProvisioningStateProvisioning, + "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 ResourceState string + +const ( + ResourceStateActive ResourceState = "Active" + ResourceStateDeleting ResourceState = "Deleting" + ResourceStateFailed ResourceState = "Failed" + ResourceStatePaused ResourceState = "Paused" + ResourceStatePausing ResourceState = "Pausing" + ResourceStatePreparing ResourceState = "Preparing" + ResourceStateProvisioning ResourceState = "Provisioning" + ResourceStateResuming ResourceState = "Resuming" + ResourceStateScaling ResourceState = "Scaling" + ResourceStateSuspended ResourceState = "Suspended" + ResourceStateSuspending ResourceState = "Suspending" + ResourceStateUpdating ResourceState = "Updating" +) + +func PossibleValuesForResourceState() []string { + return []string{ + string(ResourceStateActive), + string(ResourceStateDeleting), + string(ResourceStateFailed), + string(ResourceStatePaused), + string(ResourceStatePausing), + string(ResourceStatePreparing), + string(ResourceStateProvisioning), + string(ResourceStateResuming), + string(ResourceStateScaling), + string(ResourceStateSuspended), + string(ResourceStateSuspending), + string(ResourceStateUpdating), + } +} + +func (s *ResourceState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceState(input string) (*ResourceState, error) { + vals := map[string]ResourceState{ + "active": ResourceStateActive, + "deleting": ResourceStateDeleting, + "failed": ResourceStateFailed, + "paused": ResourceStatePaused, + "pausing": ResourceStatePausing, + "preparing": ResourceStatePreparing, + "provisioning": ResourceStateProvisioning, + "resuming": ResourceStateResuming, + "scaling": ResourceStateScaling, + "suspended": ResourceStateSuspended, + "suspending": ResourceStateSuspending, + "updating": ResourceStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceState(input) + return &out, nil +} + +type RpSkuTier string + +const ( + RpSkuTierFabric RpSkuTier = "Fabric" +) + +func PossibleValuesForRpSkuTier() []string { + return []string{ + string(RpSkuTierFabric), + } +} + +func (s *RpSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRpSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRpSkuTier(input string) (*RpSkuTier, error) { + vals := map[string]RpSkuTier{ + "fabric": RpSkuTierFabric, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RpSkuTier(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/id_capacity.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/id_capacity.go new file mode 100644 index 000000000000..9c01442e7dad --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/id_capacity.go @@ -0,0 +1,130 @@ +package fabriccapacities + +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(&CapacityId{}) +} + +var _ resourceids.ResourceId = &CapacityId{} + +// CapacityId is a struct representing the Resource ID for a Capacity +type CapacityId struct { + SubscriptionId string + ResourceGroupName string + CapacityName string +} + +// NewCapacityID returns a new CapacityId struct +func NewCapacityID(subscriptionId string, resourceGroupName string, capacityName string) CapacityId { + return CapacityId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CapacityName: capacityName, + } +} + +// ParseCapacityID parses 'input' into a CapacityId +func ParseCapacityID(input string) (*CapacityId, error) { + parser := resourceids.NewParserFromResourceIdType(&CapacityId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CapacityId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCapacityIDInsensitively parses 'input' case-insensitively into a CapacityId +// note: this method should only be used for API response data and not user input +func ParseCapacityIDInsensitively(input string) (*CapacityId, error) { + parser := resourceids.NewParserFromResourceIdType(&CapacityId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CapacityId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CapacityId) 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.CapacityName, ok = input.Parsed["capacityName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "capacityName", input) + } + + return nil +} + +// ValidateCapacityID checks that 'input' can be parsed as a Capacity ID +func ValidateCapacityID(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 := ParseCapacityID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Capacity ID +func (id CapacityId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Fabric/capacities/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CapacityName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Capacity ID +func (id CapacityId) 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("staticMicrosoftFabric", "Microsoft.Fabric", "Microsoft.Fabric"), + resourceids.StaticSegment("staticCapacities", "capacities", "capacities"), + resourceids.UserSpecifiedSegment("capacityName", "capacityName"), + } +} + +// String returns a human-readable description of this Capacity ID +func (id CapacityId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Capacity Name: %q", id.CapacityName), + } + return fmt.Sprintf("Capacity (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/id_location.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/id_location.go new file mode 100644 index 000000000000..ae114a983d95 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/id_location.go @@ -0,0 +1,121 @@ +package fabriccapacities + +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.Fabric/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("staticMicrosoftFabric", "Microsoft.Fabric", "Microsoft.Fabric"), + 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/fabric/2023-11-01/fabriccapacities/method_checknameavailability.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_checknameavailability.go new file mode 100644 index 000000000000..ae37788515f5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_checknameavailability.go @@ -0,0 +1,58 @@ +package fabriccapacities + +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 FabricCapacitiesClient) 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/checkNameAvailability", 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/fabric/2023-11-01/fabriccapacities/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_createorupdate.go new file mode 100644 index 000000000000..c28db3e5b878 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_createorupdate.go @@ -0,0 +1,75 @@ +package fabriccapacities + +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 *FabricCapacity +} + +// CreateOrUpdate ... +func (c FabricCapacitiesClient) CreateOrUpdate(ctx context.Context, id CapacityId, input FabricCapacity) (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 FabricCapacitiesClient) CreateOrUpdateThenPoll(ctx context.Context, id CapacityId, input FabricCapacity) 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/fabric/2023-11-01/fabriccapacities/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_delete.go new file mode 100644 index 000000000000..e87cfd96906a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_delete.go @@ -0,0 +1,70 @@ +package fabriccapacities + +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 FabricCapacitiesClient) Delete(ctx context.Context, id CapacityId) (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 FabricCapacitiesClient) DeleteThenPoll(ctx context.Context, id CapacityId) 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/fabric/2023-11-01/fabriccapacities/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_get.go new file mode 100644 index 000000000000..5afecf413b02 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_get.go @@ -0,0 +1,53 @@ +package fabriccapacities + +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 *FabricCapacity +} + +// Get ... +func (c FabricCapacitiesClient) Get(ctx context.Context, id CapacityId) (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 FabricCapacity + 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/fabric/2023-11-01/fabriccapacities/method_listbyresourcegroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_listbyresourcegroup.go new file mode 100644 index 000000000000..3f49ade6b327 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package fabriccapacities + +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 *[]FabricCapacity +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []FabricCapacity +} + +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 FabricCapacitiesClient) 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.Fabric/capacities", 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 *[]FabricCapacity `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 FabricCapacitiesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, FabricCapacityOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c FabricCapacitiesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate FabricCapacityOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]FabricCapacity, 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/fabric/2023-11-01/fabriccapacities/method_listbysubscription.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_listbysubscription.go new file mode 100644 index 000000000000..74c2bbe6cc6d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_listbysubscription.go @@ -0,0 +1,106 @@ +package fabriccapacities + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FabricCapacity +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []FabricCapacity +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c FabricCapacitiesClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Fabric/capacities", 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 *[]FabricCapacity `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c FabricCapacitiesClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, FabricCapacityOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c FabricCapacitiesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate FabricCapacityOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]FabricCapacity, 0) + + resp, err := c.ListBySubscription(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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_listskus.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_listskus.go new file mode 100644 index 000000000000..7604d561cb97 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_listskus.go @@ -0,0 +1,106 @@ +package fabriccapacities + +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 ListSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RpSkuDetailsForNewResource +} + +type ListSkusCompleteResult struct { + LatestHttpResponse *http.Response + Items []RpSkuDetailsForNewResource +} + +type ListSkusCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSkusCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSkus ... +func (c FabricCapacitiesClient) ListSkus(ctx context.Context, id commonids.SubscriptionId) (result ListSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSkusCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Fabric/skus", 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 *[]RpSkuDetailsForNewResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSkusComplete retrieves all the results into a single object +func (c FabricCapacitiesClient) ListSkusComplete(ctx context.Context, id commonids.SubscriptionId) (ListSkusCompleteResult, error) { + return c.ListSkusCompleteMatchingPredicate(ctx, id, RpSkuDetailsForNewResourceOperationPredicate{}) +} + +// ListSkusCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c FabricCapacitiesClient) ListSkusCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate RpSkuDetailsForNewResourceOperationPredicate) (result ListSkusCompleteResult, err error) { + items := make([]RpSkuDetailsForNewResource, 0) + + resp, err := c.ListSkus(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 = ListSkusCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_listskusforcapacity.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_listskusforcapacity.go new file mode 100644 index 000000000000..a896be4a69a6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_listskusforcapacity.go @@ -0,0 +1,105 @@ +package fabriccapacities + +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 ListSkusForCapacityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RpSkuDetailsForExistingResource +} + +type ListSkusForCapacityCompleteResult struct { + LatestHttpResponse *http.Response + Items []RpSkuDetailsForExistingResource +} + +type ListSkusForCapacityCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSkusForCapacityCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSkusForCapacity ... +func (c FabricCapacitiesClient) ListSkusForCapacity(ctx context.Context, id CapacityId) (result ListSkusForCapacityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSkusForCapacityCustomPager{}, + Path: fmt.Sprintf("%s/skus", 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 *[]RpSkuDetailsForExistingResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSkusForCapacityComplete retrieves all the results into a single object +func (c FabricCapacitiesClient) ListSkusForCapacityComplete(ctx context.Context, id CapacityId) (ListSkusForCapacityCompleteResult, error) { + return c.ListSkusForCapacityCompleteMatchingPredicate(ctx, id, RpSkuDetailsForExistingResourceOperationPredicate{}) +} + +// ListSkusForCapacityCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c FabricCapacitiesClient) ListSkusForCapacityCompleteMatchingPredicate(ctx context.Context, id CapacityId, predicate RpSkuDetailsForExistingResourceOperationPredicate) (result ListSkusForCapacityCompleteResult, err error) { + items := make([]RpSkuDetailsForExistingResource, 0) + + resp, err := c.ListSkusForCapacity(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 = ListSkusForCapacityCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_resume.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_resume.go new file mode 100644 index 000000000000..96a20c6e161c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_resume.go @@ -0,0 +1,70 @@ +package fabriccapacities + +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 ResumeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Resume ... +func (c FabricCapacitiesClient) Resume(ctx context.Context, id CapacityId) (result ResumeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resume", 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 +} + +// ResumeThenPoll performs Resume then polls until it's completed +func (c FabricCapacitiesClient) ResumeThenPoll(ctx context.Context, id CapacityId) error { + result, err := c.Resume(ctx, id) + if err != nil { + return fmt.Errorf("performing Resume: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Resume: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_suspend.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_suspend.go new file mode 100644 index 000000000000..004e29bcb93e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_suspend.go @@ -0,0 +1,70 @@ +package fabriccapacities + +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 SuspendOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Suspend ... +func (c FabricCapacitiesClient) Suspend(ctx context.Context, id CapacityId) (result SuspendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/suspend", 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 +} + +// SuspendThenPoll performs Suspend then polls until it's completed +func (c FabricCapacitiesClient) SuspendThenPoll(ctx context.Context, id CapacityId) error { + result, err := c.Suspend(ctx, id) + if err != nil { + return fmt.Errorf("performing Suspend: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Suspend: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_update.go new file mode 100644 index 000000000000..4552b51b2084 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/method_update.go @@ -0,0 +1,75 @@ +package fabriccapacities + +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 *FabricCapacity +} + +// Update ... +func (c FabricCapacitiesClient) Update(ctx context.Context, id CapacityId, input FabricCapacityUpdate) (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 FabricCapacitiesClient) UpdateThenPoll(ctx context.Context, id CapacityId, input FabricCapacityUpdate) 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/fabric/2023-11-01/fabriccapacities/model_capacityadministration.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_capacityadministration.go new file mode 100644 index 000000000000..5bd94737366c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_capacityadministration.go @@ -0,0 +1,8 @@ +package fabriccapacities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CapacityAdministration struct { + Members []string `json:"members"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_checknameavailabilityrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_checknameavailabilityrequest.go new file mode 100644 index 000000000000..e5a333c98e9c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_checknameavailabilityrequest.go @@ -0,0 +1,9 @@ +package fabriccapacities + +// 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/fabric/2023-11-01/fabriccapacities/model_checknameavailabilityresponse.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_checknameavailabilityresponse.go new file mode 100644 index 000000000000..69c97a208157 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_checknameavailabilityresponse.go @@ -0,0 +1,10 @@ +package fabriccapacities + +// 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/fabric/2023-11-01/fabriccapacities/model_fabriccapacity.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_fabriccapacity.go new file mode 100644 index 000000000000..6a3cd2e291ba --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_fabriccapacity.go @@ -0,0 +1,19 @@ +package fabriccapacities + +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 FabricCapacity struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties FabricCapacityProperties `json:"properties"` + Sku RpSku `json:"sku"` + 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/fabric/2023-11-01/fabriccapacities/model_fabriccapacityproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_fabriccapacityproperties.go new file mode 100644 index 000000000000..86a501700032 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_fabriccapacityproperties.go @@ -0,0 +1,10 @@ +package fabriccapacities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FabricCapacityProperties struct { + Administration CapacityAdministration `json:"administration"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + State *ResourceState `json:"state,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_fabriccapacityupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_fabriccapacityupdate.go new file mode 100644 index 000000000000..3ea754687f11 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_fabriccapacityupdate.go @@ -0,0 +1,10 @@ +package fabriccapacities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FabricCapacityUpdate struct { + Properties *FabricCapacityUpdateProperties `json:"properties,omitempty"` + Sku *RpSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_fabriccapacityupdateproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_fabriccapacityupdateproperties.go new file mode 100644 index 000000000000..7fe2afa5643e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_fabriccapacityupdateproperties.go @@ -0,0 +1,8 @@ +package fabriccapacities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FabricCapacityUpdateProperties struct { + Administration *CapacityAdministration `json:"administration,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_rpsku.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_rpsku.go new file mode 100644 index 000000000000..9ac6bf5672c3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_rpsku.go @@ -0,0 +1,9 @@ +package fabriccapacities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RpSku struct { + Name string `json:"name"` + Tier RpSkuTier `json:"tier"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_rpskudetailsforexistingresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_rpskudetailsforexistingresource.go new file mode 100644 index 000000000000..130356492df6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_rpskudetailsforexistingresource.go @@ -0,0 +1,9 @@ +package fabriccapacities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RpSkuDetailsForExistingResource struct { + ResourceType string `json:"resourceType"` + Sku RpSku `json:"sku"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_rpskudetailsfornewresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_rpskudetailsfornewresource.go new file mode 100644 index 000000000000..147da3314435 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/model_rpskudetailsfornewresource.go @@ -0,0 +1,10 @@ +package fabriccapacities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RpSkuDetailsForNewResource struct { + Locations []string `json:"locations"` + Name string `json:"name"` + ResourceType string `json:"resourceType"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/predicates.go new file mode 100644 index 000000000000..7f552100e83d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/predicates.go @@ -0,0 +1,63 @@ +package fabriccapacities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FabricCapacityOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p FabricCapacityOperationPredicate) Matches(input FabricCapacity) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type RpSkuDetailsForExistingResourceOperationPredicate struct { + ResourceType *string +} + +func (p RpSkuDetailsForExistingResourceOperationPredicate) Matches(input RpSkuDetailsForExistingResource) bool { + + if p.ResourceType != nil && *p.ResourceType != input.ResourceType { + return false + } + + return true +} + +type RpSkuDetailsForNewResourceOperationPredicate struct { + Name *string + ResourceType *string +} + +func (p RpSkuDetailsForNewResourceOperationPredicate) Matches(input RpSkuDetailsForNewResource) bool { + + if p.Name != nil && *p.Name != input.Name { + return false + } + + if p.ResourceType != nil && *p.ResourceType != input.ResourceType { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/version.go new file mode 100644 index 000000000000..9107b1143b56 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities/version.go @@ -0,0 +1,10 @@ +package fabriccapacities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/fabriccapacities/2023-11-01" +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 152e1ce13e29..a151c06f91b1 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -539,6 +539,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/eventhub/2021-11-01/networkru github.com/hashicorp/go-azure-sdk/resource-manager/eventhub/2021-11-01/schemaregistry github.com/hashicorp/go-azure-sdk/resource-manager/eventhub/2022-01-01-preview/namespaces github.com/hashicorp/go-azure-sdk/resource-manager/extendedlocation/2021-08-15/customlocations +github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26 github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelaycontainers github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers @@ -1387,6 +1388,8 @@ github.com/jackofallops/kermit/sdk/web/2022-09-01/web github.com/jackofallops/kermit/version # github.com/kr/pretty v0.3.0 ## explicit; go 1.12 +# github.com/kylelemons/godebug v1.1.0 +## explicit; go 1.11 # github.com/magodo/terraform-provider-azurerm-example-gen v0.0.0-20220407025246-3a3ee0ab24a8 ## explicit; go 1.16 github.com/magodo/terraform-provider-azurerm-example-gen/examplegen diff --git a/website/allowed-subcategories b/website/allowed-subcategories index fa46a484f3dc..0823ef43eadd 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -52,6 +52,7 @@ Dynatrace Elastic Elastic SAN Extended Location +Fabric Fluid Relay Graph Services HDInsight diff --git a/website/docs/r/fabric_capacity.html.markdown b/website/docs/r/fabric_capacity.html.markdown new file mode 100644 index 000000000000..699bff10048e --- /dev/null +++ b/website/docs/r/fabric_capacity.html.markdown @@ -0,0 +1,86 @@ +--- +subcategory: "Fabric" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_fabric_capacity" +description: |- + Manages a Fabric Capacity. +--- + +# azurerm_fabric_capacity + +Manages a Fabric Capacity. + +## Example Usage + +```hcl +data "azurerm_client_config" "current" {} + +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_fabric_capacity" "example" { + name = "example-ffc" + resource_group_name = azurerm_resource_group.example.name + location = "West Europe" + + administration_members = [data.azurerm_client_config.current.object_id] + + sku { + name = "F32" + tier = "Fabric" + } + + tags = { + environment = "test" + } +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) The name which should be used for the Fabric Capacity. Changing this forces a new resource to be created. + +* `location` - (Required) The supported Azure location where the Fabric Capacity exists. Changing this forces a new resource to be created. + +* `resource_group_name` - (Required) The name of the Resource Group in which to create the Fabric Capacity. Changing this forces a new resource to be created. + +* `sku` - (Required) A `sku` block as defined below. + +* `administration_members` - (Optional) An array of administrator user identities. The member must be a member user or a service principal. + +* `tags` - (Optional) A mapping of tags to assign to the Fabric Capacity. + +--- + +A `sku` block supports the following: + +* `name` - (Required) The name of the SKU to use for the Fabric Capacity. + +* `tier` - (Required) The tier of the SKU to use for the Fabric Capacity. Possible value is `Fabric`. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Fabric Capacity. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the Fabric Capacity. +* `read` - (Defaults to 5 minutes) Used when retrieving the Fabric Capacity. +* `update` - (Defaults to 30 minutes) Used when updating the Fabric Capacity. +* `delete` - (Defaults to 30 minutes) Used when deleting the Fabric Capacity. + +## Import + +Fabric Capacity can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_fabric_capacity.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.Fabric/capacities/capacity1 +``` From bef6853fa8c6b8e51899b73f0ef04f4c7bfbda74 Mon Sep 17 00:00:00 2001 From: sinbai Date: Tue, 26 Nov 2024 15:27:36 +0800 Subject: [PATCH 2/6] fix comments --- internal/services/fabric/client/client.go | 2 +- .../fabric/fabric_capacity_resource.go | 36 ++++++++----------- .../fabric/fabric_capacity_resource_test.go | 24 +------------ website/docs/r/fabric_capacity.html.markdown | 4 +-- 4 files changed, 18 insertions(+), 48 deletions(-) diff --git a/internal/services/fabric/client/client.go b/internal/services/fabric/client/client.go index c36321ee6256..54722afe074d 100644 --- a/internal/services/fabric/client/client.go +++ b/internal/services/fabric/client/client.go @@ -14,7 +14,7 @@ type Client struct { func NewClient(o *common.ClientOptions) (*Client, error) { fabricCapacitiesClient, err := fabriccapacities.NewFabricCapacitiesClientWithBaseURI(o.Environment.ResourceManager) if err != nil { - return nil, fmt.Errorf("building fabric client: %+v", err) + return nil, fmt.Errorf("building fabric client: %+v", err) } o.Configure(fabricCapacitiesClient.Client, o.Authorizers.ResourceManager) diff --git a/internal/services/fabric/fabric_capacity_resource.go b/internal/services/fabric/fabric_capacity_resource.go index e061efd994ab..f17ef047c248 100644 --- a/internal/services/fabric/fabric_capacity_resource.go +++ b/internal/services/fabric/fabric_capacity_resource.go @@ -55,7 +55,7 @@ func (r FabricCapacityResource) Arguments() map[string]*pluginsdk.Schema { Required: true, ForceNew: true, ValidateFunc: validation.StringMatch( - regexp.MustCompile(`^[a-z]([a-z\d]{1,61}[a-z\d])$`), + regexp.MustCompile(`^[a-z]([a-z\d]{2,62})$`), "`name` must be between 3 and 63 characters. It can contain only lowercase letters and numbers. It must start with a lowercase letter.", ), }, @@ -90,7 +90,6 @@ func (r FabricCapacityResource) Arguments() map[string]*pluginsdk.Schema { "administration_members": { Type: pluginsdk.TypeList, Optional: true, - MaxItems: 1, Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, ValidateFunc: validation.StringIsNotEmpty, @@ -127,18 +126,19 @@ func (r FabricCapacityResource) Create() sdk.ResourceFunc { return metadata.ResourceRequiresImport(r.ResourceType(), id) } - properties := fabriccapacities.FabricCapacity{ - Location: location.Normalize(model.Location), - Properties: fabriccapacities.FabricCapacityProperties{}, - } - if len(model.AdministrationMembers) == 0 { return fmt.Errorf("`administration_members` is required when creating a fabric capacity") } - properties.Properties.Administration = pointer.From(expandCapacityAdministrationModel(model.AdministrationMembers)) - - properties.Sku = pointer.From(expandSkuModel(model.Sku)) + properties := fabriccapacities.FabricCapacity{ + Location: location.Normalize(model.Location), + Properties: fabriccapacities.FabricCapacityProperties{ + Administration: fabriccapacities.CapacityAdministration{ + Members: model.AdministrationMembers, + }, + }, + Sku: pointer.From(expandSkuModel(model.Sku)), + } if model.Tags != nil { properties.Tags = pointer.To(model.Tags) @@ -181,7 +181,9 @@ func (r FabricCapacityResource) Update() sdk.ResourceFunc { payload := existing.Model if metadata.ResourceData.HasChange("administration_members") { - payload.Properties.Administration = pointer.From(expandCapacityAdministrationModel(model.AdministrationMembers)) + payload.Properties.Administration = fabriccapacities.CapacityAdministration{ + Members: model.AdministrationMembers, + } } if metadata.ResourceData.HasChange("sku") { @@ -282,16 +284,6 @@ func (r FabricCapacityResource) CustomizeDiff() sdk.ResourceFunc { } } -func expandCapacityAdministrationModel(inputList []string) *fabriccapacities.CapacityAdministration { - if len(inputList) == 0 { - return nil - } - - return &fabriccapacities.CapacityAdministration{ - Members: inputList, - } -} - func expandSkuModel(inputList []SkuModel) *fabriccapacities.RpSku { if len(inputList) == 0 { return nil @@ -305,7 +297,7 @@ func expandSkuModel(inputList []SkuModel) *fabriccapacities.RpSku { } func flattenSkuModel(input *fabriccapacities.RpSku) []SkuModel { - var outputList []SkuModel + outputList := make([]SkuModel, 0) if input == nil { return outputList } diff --git a/internal/services/fabric/fabric_capacity_resource_test.go b/internal/services/fabric/fabric_capacity_resource_test.go index 8ae32b4ab463..01a6e303c8f0 100644 --- a/internal/services/fabric/fabric_capacity_resource_test.go +++ b/internal/services/fabric/fabric_capacity_resource_test.go @@ -70,7 +70,7 @@ func TestAccFabricFabricCapacity_update(t *testing.T) { }, data.ImportStep(), { - Config: r.update(data), + Config: r.basic(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), @@ -167,28 +167,6 @@ resource "azurerm_fabric_capacity" "test" { administration_members = [data.azurerm_client_config.current.object_id] - sku { - name = "F32" - tier = "Fabric" - } - - tags = { - environment = "test" - } -} -`, template, data.RandomInteger, data.Locations.Primary) -} - -func (r FabricFabricCapacityResource) update(data acceptance.TestData) string { - template := r.template(data) - return fmt.Sprintf(` -%s - -resource "azurerm_fabric_capacity" "test" { - name = "acctestffc%d" - resource_group_name = azurerm_resource_group.test.name - location = "%s" - sku { name = "F64" tier = "Fabric" diff --git a/website/docs/r/fabric_capacity.html.markdown b/website/docs/r/fabric_capacity.html.markdown index 699bff10048e..5a70d9c38618 100644 --- a/website/docs/r/fabric_capacity.html.markdown +++ b/website/docs/r/fabric_capacity.html.markdown @@ -60,7 +60,7 @@ A `sku` block supports the following: * `name` - (Required) The name of the SKU to use for the Fabric Capacity. -* `tier` - (Required) The tier of the SKU to use for the Fabric Capacity. Possible value is `Fabric`. +* `tier` - (Required) The tier of the SKU to use for the Fabric Capacity. The only possible value is `Fabric`. ## Attributes Reference @@ -79,7 +79,7 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/d ## Import -Fabric Capacity can be imported using the `resource id`, e.g. +Fabric Capacities can be imported using the `resource id`, e.g. ```shell terraform import azurerm_fabric_capacity.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.Fabric/capacities/capacity1 From 13b9ed35c6f19f6ebf8b58e2749580a5fc46b0c2 Mon Sep 17 00:00:00 2001 From: sinbai Date: Wed, 27 Nov 2024 16:06:32 +0800 Subject: [PATCH 3/6] fix comments --- .../fabric/fabric_capacity_resource_test.go | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/internal/services/fabric/fabric_capacity_resource_test.go b/internal/services/fabric/fabric_capacity_resource_test.go index 01a6e303c8f0..d160cd5bd083 100644 --- a/internal/services/fabric/fabric_capacity_resource_test.go +++ b/internal/services/fabric/fabric_capacity_resource_test.go @@ -69,6 +69,13 @@ func TestAccFabricFabricCapacity_update(t *testing.T) { ), }, data.ImportStep(), + { + Config: r.update(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), { Config: r.basic(data), Check: acceptance.ComposeTestCheckFunc( @@ -167,6 +174,30 @@ resource "azurerm_fabric_capacity" "test" { administration_members = [data.azurerm_client_config.current.object_id] + sku { + name = "F32" + tier = "Fabric" + } + + tags = { + environment = "test" + } +} +`, template, data.RandomInteger, data.Locations.Primary) +} + +func (r FabricFabricCapacityResource) update(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +%s + +resource "azurerm_fabric_capacity" "test" { + name = "acctestffc%d" + resource_group_name = azurerm_resource_group.test.name + location = "%s" + + administration_members = [] + sku { name = "F64" tier = "Fabric" From 9fe5c10b6e45eeb218f403277a691423a475c68f Mon Sep 17 00:00:00 2001 From: sinbai Date: Fri, 29 Nov 2024 13:49:14 +0800 Subject: [PATCH 4/6] fix comments --- .github/labeler-issue-triage.yml | 5 +- .github/labeler-pull-request-triage.yml | 5 ++ internal/services/fabric/client/client.go | 2 +- .../fabric/fabric_capacity_resource.go | 66 +++++++------------ .../fabric/fabric_capacity_resource_test.go | 7 +- internal/services/fabric/registration.go | 4 ++ website/docs/r/fabric_capacity.html.markdown | 2 +- 7 files changed, 38 insertions(+), 53 deletions(-) diff --git a/.github/labeler-issue-triage.yml b/.github/labeler-issue-triage.yml index 725e09949278..7c2cb3082606 100644 --- a/.github/labeler-issue-triage.yml +++ b/.github/labeler-issue-triage.yml @@ -144,7 +144,10 @@ service/event-hubs: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_eventhub((.|\n)*)###' service/extended-location: - - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_(extended_custom_location|fabric_capacity)((.|\n)*)###' + - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_extended_custom_location((.|\n)*)###' + +service/fabric: + - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_fabric_capacity((.|\n)*)###' service/firewall: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_firewall((.|\n)*)###' diff --git a/.github/labeler-pull-request-triage.yml b/.github/labeler-pull-request-triage.yml index 154f12cb7ac8..40edc1b20a7b 100644 --- a/.github/labeler-pull-request-triage.yml +++ b/.github/labeler-pull-request-triage.yml @@ -244,6 +244,11 @@ service/extended-location: - any-glob-to-any-file: - internal/services/extendedlocation/**/* +service/fabric: +- changed-files: + - any-glob-to-any-file: + - internal/services/fabric/**/* + service/firewall: - changed-files: - any-glob-to-any-file: diff --git a/internal/services/fabric/client/client.go b/internal/services/fabric/client/client.go index 54722afe074d..4c76ede7df91 100644 --- a/internal/services/fabric/client/client.go +++ b/internal/services/fabric/client/client.go @@ -14,7 +14,7 @@ type Client struct { func NewClient(o *common.ClientOptions) (*Client, error) { fabricCapacitiesClient, err := fabriccapacities.NewFabricCapacitiesClientWithBaseURI(o.Environment.ResourceManager) if err != nil { - return nil, fmt.Errorf("building fabric client: %+v", err) + return nil, fmt.Errorf("building capacities client: %+v", err) } o.Configure(fabricCapacitiesClient.Client, o.Authorizers.ResourceManager) diff --git a/internal/services/fabric/fabric_capacity_resource.go b/internal/services/fabric/fabric_capacity_resource.go index f17ef047c248..b28d285b331e 100644 --- a/internal/services/fabric/fabric_capacity_resource.go +++ b/internal/services/fabric/fabric_capacity_resource.go @@ -20,8 +20,6 @@ type FabricCapacityResource struct{} var _ sdk.ResourceWithUpdate = FabricCapacityResource{} -var _ sdk.ResourceWithCustomizeDiff = FabricCapacityResource{} - type FabricCapacityResourceModel struct { Name string `tfschema:"name"` ResourceGroupName string `tfschema:"resource_group_name"` @@ -71,11 +69,22 @@ func (r FabricCapacityResource) Arguments() map[string]*pluginsdk.Schema { Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ "name": { - Type: pluginsdk.TypeString, - Required: true, - ValidateFunc: validation.StringIsNotEmpty, + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + "F2", + "F4", + "F8", + "F16", + "F32", + "F64", + "F128", + "F256", + "F512", + "F1024", + "F2048", + }, false), }, - "tier": { Type: pluginsdk.TypeString, Required: true, @@ -88,7 +97,7 @@ func (r FabricCapacityResource) Arguments() map[string]*pluginsdk.Schema { }, "administration_members": { - Type: pluginsdk.TypeList, + Type: pluginsdk.TypeSet, Optional: true, Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, @@ -137,7 +146,7 @@ func (r FabricCapacityResource) Create() sdk.ResourceFunc { Members: model.AdministrationMembers, }, }, - Sku: pointer.From(expandSkuModel(model.Sku)), + Sku: expandSkuModel(model.Sku), } if model.Tags != nil { @@ -187,7 +196,7 @@ func (r FabricCapacityResource) Update() sdk.ResourceFunc { } if metadata.ResourceData.HasChange("sku") { - payload.Sku = pointer.From(expandSkuModel(model.Sku)) + payload.Sku = expandSkuModel(model.Sku) } if metadata.ResourceData.HasChange("tags") { @@ -231,7 +240,7 @@ func (r FabricCapacityResource) Read() sdk.ResourceFunc { if model := resp.Model; model != nil { state.Location = location.Normalize(model.Location) state.AdministrationMembers = model.Properties.Administration.Members - state.Sku = flattenSkuModel(&model.Sku) + state.Sku = flattenSkuModel(model.Sku) state.Tags = pointer.From(model.Tags) } @@ -260,47 +269,16 @@ func (r FabricCapacityResource) Delete() sdk.ResourceFunc { } } -func (r FabricCapacityResource) CustomizeDiff() sdk.ResourceFunc { - return sdk.ResourceFunc{ - Timeout: 5 * time.Minute, - Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { - var state FabricCapacityResourceModel - if err := metadata.DecodeDiff(&state); err != nil { - return fmt.Errorf("DecodeDiff: %+v", err) - } - - if len(state.AdministrationMembers) > 0 { - existing := make(map[string]bool) - for _, str := range state.AdministrationMembers { - if existing[str] { - return fmt.Errorf("`administration_members` contains the duplicate value %q", str) - } - existing[str] = true - } - } - - return nil - }, - } -} - -func expandSkuModel(inputList []SkuModel) *fabriccapacities.RpSku { - if len(inputList) == 0 { - return nil - } - +func expandSkuModel(inputList []SkuModel) fabriccapacities.RpSku { input := &inputList[0] - return &fabriccapacities.RpSku{ + return fabriccapacities.RpSku{ Name: input.Name, Tier: fabriccapacities.RpSkuTier(input.Tier), } } -func flattenSkuModel(input *fabriccapacities.RpSku) []SkuModel { +func flattenSkuModel(input fabriccapacities.RpSku) []SkuModel { outputList := make([]SkuModel, 0) - if input == nil { - return outputList - } output := SkuModel{ Name: input.Name, Tier: string(input.Tier), diff --git a/internal/services/fabric/fabric_capacity_resource_test.go b/internal/services/fabric/fabric_capacity_resource_test.go index d160cd5bd083..64e98a71c77e 100644 --- a/internal/services/fabric/fabric_capacity_resource_test.go +++ b/internal/services/fabric/fabric_capacity_resource_test.go @@ -6,7 +6,6 @@ import ( "testing" "github.com/hashicorp/go-azure-helpers/lang/pointer" - "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" @@ -99,12 +98,8 @@ func (r FabricFabricCapacityResource) Exists(ctx context.Context, clients *clien return nil, err } - client := clients.Fabric.FabricCapacitiesClient - resp, err := client.Get(ctx, *id) + resp, err := clients.Fabric.FabricCapacitiesClient.Get(ctx, *id) if err != nil { - if response.WasNotFound(resp.HttpResponse) { - return pointer.To(false), nil - } return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } return pointer.To(resp.Model != nil), nil diff --git a/internal/services/fabric/registration.go b/internal/services/fabric/registration.go index 515eec2a318b..e4b3280d638b 100644 --- a/internal/services/fabric/registration.go +++ b/internal/services/fabric/registration.go @@ -8,6 +8,10 @@ type Registration struct{} var _ sdk.TypedServiceRegistration = Registration{} +func (r Registration) AssociatedGitHubLabel() string { + return "service/fabric" +} + // Name is the name of this Service func (r Registration) Name() string { return "Fabric" diff --git a/website/docs/r/fabric_capacity.html.markdown b/website/docs/r/fabric_capacity.html.markdown index 5a70d9c38618..fff591c84ded 100644 --- a/website/docs/r/fabric_capacity.html.markdown +++ b/website/docs/r/fabric_capacity.html.markdown @@ -58,7 +58,7 @@ The following arguments are supported: A `sku` block supports the following: -* `name` - (Required) The name of the SKU to use for the Fabric Capacity. +* `name` - (Required) The name of the SKU to use for the Fabric Capacity. Possible values are `F2`, `F4`, `F8`, `F16`, `F32`, `F64`, `F128`, `F256`, `F512`, `F1024`, `F2048`. * `tier` - (Required) The tier of the SKU to use for the Fabric Capacity. The only possible value is `Fabric`. From 853f2fd371fc465b6174de7635c9054722920007 Mon Sep 17 00:00:00 2001 From: sinbai Date: Tue, 3 Dec 2024 18:34:30 +0800 Subject: [PATCH 5/6] fix comments --- .../fabric/fabric_capacity_resource_test.go | 30 +++++++++---------- website/docs/r/fabric_capacity.html.markdown | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/internal/services/fabric/fabric_capacity_resource_test.go b/internal/services/fabric/fabric_capacity_resource_test.go index 64e98a71c77e..023202fe23e4 100644 --- a/internal/services/fabric/fabric_capacity_resource_test.go +++ b/internal/services/fabric/fabric_capacity_resource_test.go @@ -13,11 +13,11 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) -type FabricFabricCapacityResource struct{} +type FabricCapacityResource struct{} -func TestAccFabricFabricCapacity_basic(t *testing.T) { +func TestAccFabricCapacity_basic(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_fabric_capacity", "test") - r := FabricFabricCapacityResource{} + r := FabricCapacityResource{} data.ResourceTest(t, r, []acceptance.TestStep{ { Config: r.basic(data), @@ -29,9 +29,9 @@ func TestAccFabricFabricCapacity_basic(t *testing.T) { }) } -func TestAccFabricFabricCapacity_requiresImport(t *testing.T) { +func TestAccFabricCapacity_requiresImport(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_fabric_capacity", "test") - r := FabricFabricCapacityResource{} + r := FabricCapacityResource{} data.ResourceTest(t, r, []acceptance.TestStep{ { Config: r.basic(data), @@ -43,9 +43,9 @@ func TestAccFabricFabricCapacity_requiresImport(t *testing.T) { }) } -func TestAccFabricFabricCapacity_complete(t *testing.T) { +func TestAccFabricCapacity_complete(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_fabric_capacity", "test") - r := FabricFabricCapacityResource{} + r := FabricCapacityResource{} data.ResourceTest(t, r, []acceptance.TestStep{ { Config: r.complete(data), @@ -57,9 +57,9 @@ func TestAccFabricFabricCapacity_complete(t *testing.T) { }) } -func TestAccFabricFabricCapacity_update(t *testing.T) { +func TestAccFabricCapacity_update(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_fabric_capacity", "test") - r := FabricFabricCapacityResource{} + r := FabricCapacityResource{} data.ResourceTest(t, r, []acceptance.TestStep{ { Config: r.complete(data), @@ -92,7 +92,7 @@ func TestAccFabricFabricCapacity_update(t *testing.T) { }) } -func (r FabricFabricCapacityResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { +func (r FabricCapacityResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { id, err := fabriccapacities.ParseCapacityID(state.ID) if err != nil { return nil, err @@ -105,7 +105,7 @@ func (r FabricFabricCapacityResource) Exists(ctx context.Context, clients *clien return pointer.To(resp.Model != nil), nil } -func (r FabricFabricCapacityResource) template(data acceptance.TestData) string { +func (r FabricCapacityResource) template(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { features {} @@ -120,7 +120,7 @@ resource "azurerm_resource_group" "test" { `, data.RandomInteger, data.Locations.Primary) } -func (r FabricFabricCapacityResource) basic(data acceptance.TestData) string { +func (r FabricCapacityResource) basic(data acceptance.TestData) string { template := r.template(data) return fmt.Sprintf(` %s @@ -139,7 +139,7 @@ resource "azurerm_fabric_capacity" "test" { `, template, data.RandomInteger, data.Locations.Primary) } -func (r FabricFabricCapacityResource) requiresImport(data acceptance.TestData) string { +func (r FabricCapacityResource) requiresImport(data acceptance.TestData) string { return fmt.Sprintf(` %s @@ -157,7 +157,7 @@ resource "azurerm_fabric_capacity" "import" { `, r.basic(data)) } -func (r FabricFabricCapacityResource) complete(data acceptance.TestData) string { +func (r FabricCapacityResource) complete(data acceptance.TestData) string { template := r.template(data) return fmt.Sprintf(` %s @@ -181,7 +181,7 @@ resource "azurerm_fabric_capacity" "test" { `, template, data.RandomInteger, data.Locations.Primary) } -func (r FabricFabricCapacityResource) update(data acceptance.TestData) string { +func (r FabricCapacityResource) update(data acceptance.TestData) string { template := r.template(data) return fmt.Sprintf(` %s diff --git a/website/docs/r/fabric_capacity.html.markdown b/website/docs/r/fabric_capacity.html.markdown index fff591c84ded..f29e68a6ecd3 100644 --- a/website/docs/r/fabric_capacity.html.markdown +++ b/website/docs/r/fabric_capacity.html.markdown @@ -50,7 +50,7 @@ The following arguments are supported: * `sku` - (Required) A `sku` block as defined below. -* `administration_members` - (Optional) An array of administrator user identities. The member must be a member user or a service principal. +* `administration_members` - (Optional) An array of administrator user identities. The member must be an Entra member user or a service principal. * `tags` - (Optional) A mapping of tags to assign to the Fabric Capacity. From ce09193e1ae7b446beb0d3a34f83383ce3c66f96 Mon Sep 17 00:00:00 2001 From: sinbai Date: Wed, 4 Dec 2024 09:32:48 +0800 Subject: [PATCH 6/6] fix comments --- internal/services/fabric/fabric_capacity_resource_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/services/fabric/fabric_capacity_resource_test.go b/internal/services/fabric/fabric_capacity_resource_test.go index 023202fe23e4..7917e7e4bd7a 100644 --- a/internal/services/fabric/fabric_capacity_resource_test.go +++ b/internal/services/fabric/fabric_capacity_resource_test.go @@ -132,7 +132,7 @@ resource "azurerm_fabric_capacity" "test" { administration_members = [data.azurerm_client_config.current.object_id] sku { - name = "F32" + name = "F2" tier = "Fabric" } } @@ -170,7 +170,7 @@ resource "azurerm_fabric_capacity" "test" { administration_members = [data.azurerm_client_config.current.object_id] sku { - name = "F32" + name = "F2" tier = "Fabric" } @@ -194,7 +194,7 @@ resource "azurerm_fabric_capacity" "test" { administration_members = [] sku { - name = "F64" + name = "F4" tier = "Fabric" }