diff --git a/resource-manager/fabric/2023-11-01/client.go b/resource-manager/fabric/2023-11-01/client.go new file mode 100644 index 00000000000..a8702ce914c --- /dev/null +++ b/resource-manager/fabric/2023-11-01/client.go @@ -0,0 +1,28 @@ +package v2023_11_01 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/fabric/2023-11-01/fabriccapacities" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + FabricCapacities *fabriccapacities.FabricCapacitiesClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + fabricCapacitiesClient, err := fabriccapacities.NewFabricCapacitiesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building FabricCapacities client: %+v", err) + } + configureFunc(fabricCapacitiesClient.Client) + + return &Client{ + FabricCapacities: fabricCapacitiesClient, + }, nil +} diff --git a/resource-manager/fabric/2023-11-01/fabriccapacities/README.md b/resource-manager/fabric/2023-11-01/fabriccapacities/README.md new file mode 100644 index 00000000000..369108116d1 --- /dev/null +++ b/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 the Azure Resource Manager Service `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", "locationValue") + +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", "capacityValue") + +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", "capacityValue") + +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", "capacityValue") + +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", "capacityValue") + +// 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", "capacityValue") + +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", "capacityValue") + +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", "capacityValue") + +payload := fabriccapacities.FabricCapacityUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/fabric/2023-11-01/fabriccapacities/client.go b/resource-manager/fabric/2023-11-01/fabriccapacities/client.go new file mode 100644 index 00000000000..e3727d97abd --- /dev/null +++ b/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.NewResourceManagerClient(sdkApi, "fabriccapacities", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating FabricCapacitiesClient: %+v", err) + } + + return &FabricCapacitiesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/fabric/2023-11-01/fabriccapacities/constants.go b/resource-manager/fabric/2023-11-01/fabriccapacities/constants.go new file mode 100644 index 00000000000..969350a0252 --- /dev/null +++ b/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/resource-manager/fabric/2023-11-01/fabriccapacities/id_capacity.go b/resource-manager/fabric/2023-11-01/fabriccapacities/id_capacity.go new file mode 100644 index 00000000000..70eea29dede --- /dev/null +++ b/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", "capacityValue"), + } +} + +// 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/resource-manager/fabric/2023-11-01/fabriccapacities/id_capacity_test.go b/resource-manager/fabric/2023-11-01/fabriccapacities/id_capacity_test.go new file mode 100644 index 00000000000..73859d9afd8 --- /dev/null +++ b/resource-manager/fabric/2023-11-01/fabriccapacities/id_capacity_test.go @@ -0,0 +1,282 @@ +package fabriccapacities + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CapacityId{} + +func TestNewCapacityID(t *testing.T) { + id := NewCapacityID("12345678-1234-9876-4563-123456789012", "example-resource-group", "capacityValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CapacityName != "capacityValue" { + t.Fatalf("Expected %q but got %q for Segment 'CapacityName'", id.CapacityName, "capacityValue") + } +} + +func TestFormatCapacityID(t *testing.T) { + actual := NewCapacityID("12345678-1234-9876-4563-123456789012", "example-resource-group", "capacityValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Fabric/capacities/capacityValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCapacityID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CapacityId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Fabric", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Fabric/capacities", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Fabric/capacities/capacityValue", + Expected: &CapacityId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CapacityName: "capacityValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Fabric/capacities/capacityValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCapacityID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CapacityName != v.Expected.CapacityName { + t.Fatalf("Expected %q but got %q for CapacityName", v.Expected.CapacityName, actual.CapacityName) + } + + } +} + +func TestParseCapacityIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CapacityId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Fabric", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fAbRiC", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Fabric/capacities", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fAbRiC/cApAcItIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Fabric/capacities/capacityValue", + Expected: &CapacityId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CapacityName: "capacityValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Fabric/capacities/capacityValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fAbRiC/cApAcItIeS/cApAcItYvAlUe", + Expected: &CapacityId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CapacityName: "cApAcItYvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fAbRiC/cApAcItIeS/cApAcItYvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCapacityIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CapacityName != v.Expected.CapacityName { + t.Fatalf("Expected %q but got %q for CapacityName", v.Expected.CapacityName, actual.CapacityName) + } + + } +} + +func TestSegmentsForCapacityId(t *testing.T) { + segments := CapacityId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CapacityId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/fabric/2023-11-01/fabriccapacities/id_location.go b/resource-manager/fabric/2023-11-01/fabriccapacities/id_location.go new file mode 100644 index 00000000000..daa1763de4c --- /dev/null +++ b/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", "locationValue"), + } +} + +// 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/resource-manager/fabric/2023-11-01/fabriccapacities/id_location_test.go b/resource-manager/fabric/2023-11-01/fabriccapacities/id_location_test.go new file mode 100644 index 00000000000..990920e5a62 --- /dev/null +++ b/resource-manager/fabric/2023-11-01/fabriccapacities/id_location_test.go @@ -0,0 +1,237 @@ +package fabriccapacities + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Fabric/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Fabric", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Fabric/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Fabric/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Fabric/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Fabric", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.fAbRiC", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Fabric/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.fAbRiC/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Fabric/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Fabric/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.fAbRiC/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.fAbRiC/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/fabric/2023-11-01/fabriccapacities/method_checknameavailability.go b/resource-manager/fabric/2023-11-01/fabriccapacities/method_checknameavailability.go new file mode 100644 index 00000000000..29e0f31aedd --- /dev/null +++ b/resource-manager/fabric/2023-11-01/fabriccapacities/method_checknameavailability.go @@ -0,0 +1,59 @@ +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/resource-manager/fabric/2023-11-01/fabriccapacities/method_createorupdate.go b/resource-manager/fabric/2023-11-01/fabriccapacities/method_createorupdate.go new file mode 100644 index 00000000000..c28db3e5b87 --- /dev/null +++ b/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/resource-manager/fabric/2023-11-01/fabriccapacities/method_delete.go b/resource-manager/fabric/2023-11-01/fabriccapacities/method_delete.go new file mode 100644 index 00000000000..e87cfd96906 --- /dev/null +++ b/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/resource-manager/fabric/2023-11-01/fabriccapacities/method_get.go b/resource-manager/fabric/2023-11-01/fabriccapacities/method_get.go new file mode 100644 index 00000000000..1ee83df5e66 --- /dev/null +++ b/resource-manager/fabric/2023-11-01/fabriccapacities/method_get.go @@ -0,0 +1,54 @@ +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/resource-manager/fabric/2023-11-01/fabriccapacities/method_listbyresourcegroup.go b/resource-manager/fabric/2023-11-01/fabriccapacities/method_listbyresourcegroup.go new file mode 100644 index 00000000000..3f49ade6b32 --- /dev/null +++ b/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/resource-manager/fabric/2023-11-01/fabriccapacities/method_listbysubscription.go b/resource-manager/fabric/2023-11-01/fabriccapacities/method_listbysubscription.go new file mode 100644 index 00000000000..74c2bbe6cc6 --- /dev/null +++ b/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/resource-manager/fabric/2023-11-01/fabriccapacities/method_listskus.go b/resource-manager/fabric/2023-11-01/fabriccapacities/method_listskus.go new file mode 100644 index 00000000000..7604d561cb9 --- /dev/null +++ b/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/resource-manager/fabric/2023-11-01/fabriccapacities/method_listskusforcapacity.go b/resource-manager/fabric/2023-11-01/fabriccapacities/method_listskusforcapacity.go new file mode 100644 index 00000000000..a896be4a69a --- /dev/null +++ b/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/resource-manager/fabric/2023-11-01/fabriccapacities/method_resume.go b/resource-manager/fabric/2023-11-01/fabriccapacities/method_resume.go new file mode 100644 index 00000000000..96a20c6e161 --- /dev/null +++ b/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/resource-manager/fabric/2023-11-01/fabriccapacities/method_suspend.go b/resource-manager/fabric/2023-11-01/fabriccapacities/method_suspend.go new file mode 100644 index 00000000000..004e29bcb93 --- /dev/null +++ b/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/resource-manager/fabric/2023-11-01/fabriccapacities/method_update.go b/resource-manager/fabric/2023-11-01/fabriccapacities/method_update.go new file mode 100644 index 00000000000..4552b51b208 --- /dev/null +++ b/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/resource-manager/fabric/2023-11-01/fabriccapacities/model_capacityadministration.go b/resource-manager/fabric/2023-11-01/fabriccapacities/model_capacityadministration.go new file mode 100644 index 00000000000..5bd94737366 --- /dev/null +++ b/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/resource-manager/fabric/2023-11-01/fabriccapacities/model_checknameavailabilityrequest.go b/resource-manager/fabric/2023-11-01/fabriccapacities/model_checknameavailabilityrequest.go new file mode 100644 index 00000000000..e5a333c98e9 --- /dev/null +++ b/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/resource-manager/fabric/2023-11-01/fabriccapacities/model_checknameavailabilityresponse.go b/resource-manager/fabric/2023-11-01/fabriccapacities/model_checknameavailabilityresponse.go new file mode 100644 index 00000000000..69c97a20815 --- /dev/null +++ b/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/resource-manager/fabric/2023-11-01/fabriccapacities/model_fabriccapacity.go b/resource-manager/fabric/2023-11-01/fabriccapacities/model_fabriccapacity.go new file mode 100644 index 00000000000..6a3cd2e291b --- /dev/null +++ b/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/resource-manager/fabric/2023-11-01/fabriccapacities/model_fabriccapacityproperties.go b/resource-manager/fabric/2023-11-01/fabriccapacities/model_fabriccapacityproperties.go new file mode 100644 index 00000000000..86a50170003 --- /dev/null +++ b/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/resource-manager/fabric/2023-11-01/fabriccapacities/model_fabriccapacityupdate.go b/resource-manager/fabric/2023-11-01/fabriccapacities/model_fabriccapacityupdate.go new file mode 100644 index 00000000000..3ea754687f1 --- /dev/null +++ b/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/resource-manager/fabric/2023-11-01/fabriccapacities/model_fabriccapacityupdateproperties.go b/resource-manager/fabric/2023-11-01/fabriccapacities/model_fabriccapacityupdateproperties.go new file mode 100644 index 00000000000..7fe2afa5643 --- /dev/null +++ b/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/resource-manager/fabric/2023-11-01/fabriccapacities/model_rpsku.go b/resource-manager/fabric/2023-11-01/fabriccapacities/model_rpsku.go new file mode 100644 index 00000000000..9ac6bf5672c --- /dev/null +++ b/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/resource-manager/fabric/2023-11-01/fabriccapacities/model_rpskudetailsforexistingresource.go b/resource-manager/fabric/2023-11-01/fabriccapacities/model_rpskudetailsforexistingresource.go new file mode 100644 index 00000000000..130356492df --- /dev/null +++ b/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/resource-manager/fabric/2023-11-01/fabriccapacities/model_rpskudetailsfornewresource.go b/resource-manager/fabric/2023-11-01/fabriccapacities/model_rpskudetailsfornewresource.go new file mode 100644 index 00000000000..147da331443 --- /dev/null +++ b/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/resource-manager/fabric/2023-11-01/fabriccapacities/predicates.go b/resource-manager/fabric/2023-11-01/fabriccapacities/predicates.go new file mode 100644 index 00000000000..7f552100e83 --- /dev/null +++ b/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/resource-manager/fabric/2023-11-01/fabriccapacities/version.go b/resource-manager/fabric/2023-11-01/fabriccapacities/version.go new file mode 100644 index 00000000000..5e2349a8004 --- /dev/null +++ b/resource-manager/fabric/2023-11-01/fabriccapacities/version.go @@ -0,0 +1,12 @@ +package fabriccapacities + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-11-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/fabriccapacities/%s", defaultApiVersion) +}