diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/client.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/client.go deleted file mode 100644 index 99bdded9cda5..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package databases - -import "github.com/Azure/go-autorest/autorest" - -type DatabasesClient struct { - Client autorest.Client - baseUri string -} - -func NewDatabasesClientWithBaseURI(endpoint string) DatabasesClient { - return DatabasesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/constants.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/constants.go deleted file mode 100644 index c7198f3615f3..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/constants.go +++ /dev/null @@ -1,290 +0,0 @@ -package databases - -import "strings" - -type AccessKeyType string - -const ( - AccessKeyTypePrimary AccessKeyType = "Primary" - AccessKeyTypeSecondary AccessKeyType = "Secondary" -) - -func PossibleValuesForAccessKeyType() []string { - return []string{ - string(AccessKeyTypePrimary), - string(AccessKeyTypeSecondary), - } -} - -func parseAccessKeyType(input string) (*AccessKeyType, error) { - vals := map[string]AccessKeyType{ - "primary": AccessKeyTypePrimary, - "secondary": AccessKeyTypeSecondary, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := AccessKeyType(input) - return &out, nil -} - -type AofFrequency string - -const ( - AofFrequencyAlways AofFrequency = "always" - AofFrequencyOnes AofFrequency = "1s" -) - -func PossibleValuesForAofFrequency() []string { - return []string{ - string(AofFrequencyAlways), - string(AofFrequencyOnes), - } -} - -func parseAofFrequency(input string) (*AofFrequency, error) { - vals := map[string]AofFrequency{ - "always": AofFrequencyAlways, - "1s": AofFrequencyOnes, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := AofFrequency(input) - return &out, nil -} - -type ClusteringPolicy string - -const ( - ClusteringPolicyEnterpriseCluster ClusteringPolicy = "EnterpriseCluster" - ClusteringPolicyOSSCluster ClusteringPolicy = "OSSCluster" -) - -func PossibleValuesForClusteringPolicy() []string { - return []string{ - string(ClusteringPolicyEnterpriseCluster), - string(ClusteringPolicyOSSCluster), - } -} - -func parseClusteringPolicy(input string) (*ClusteringPolicy, error) { - vals := map[string]ClusteringPolicy{ - "enterprisecluster": ClusteringPolicyEnterpriseCluster, - "osscluster": ClusteringPolicyOSSCluster, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ClusteringPolicy(input) - return &out, nil -} - -type EvictionPolicy string - -const ( - EvictionPolicyAllKeysLFU EvictionPolicy = "AllKeysLFU" - EvictionPolicyAllKeysLRU EvictionPolicy = "AllKeysLRU" - EvictionPolicyAllKeysRandom EvictionPolicy = "AllKeysRandom" - EvictionPolicyNoEviction EvictionPolicy = "NoEviction" - EvictionPolicyVolatileLFU EvictionPolicy = "VolatileLFU" - EvictionPolicyVolatileLRU EvictionPolicy = "VolatileLRU" - EvictionPolicyVolatileRandom EvictionPolicy = "VolatileRandom" - EvictionPolicyVolatileTTL EvictionPolicy = "VolatileTTL" -) - -func PossibleValuesForEvictionPolicy() []string { - return []string{ - string(EvictionPolicyAllKeysLFU), - string(EvictionPolicyAllKeysLRU), - string(EvictionPolicyAllKeysRandom), - string(EvictionPolicyNoEviction), - string(EvictionPolicyVolatileLFU), - string(EvictionPolicyVolatileLRU), - string(EvictionPolicyVolatileRandom), - string(EvictionPolicyVolatileTTL), - } -} - -func parseEvictionPolicy(input string) (*EvictionPolicy, error) { - vals := map[string]EvictionPolicy{ - "allkeyslfu": EvictionPolicyAllKeysLFU, - "allkeyslru": EvictionPolicyAllKeysLRU, - "allkeysrandom": EvictionPolicyAllKeysRandom, - "noeviction": EvictionPolicyNoEviction, - "volatilelfu": EvictionPolicyVolatileLFU, - "volatilelru": EvictionPolicyVolatileLRU, - "volatilerandom": EvictionPolicyVolatileRandom, - "volatilettl": EvictionPolicyVolatileTTL, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := EvictionPolicy(input) - return &out, nil -} - -type Protocol string - -const ( - ProtocolEncrypted Protocol = "Encrypted" - ProtocolPlaintext Protocol = "Plaintext" -) - -func PossibleValuesForProtocol() []string { - return []string{ - string(ProtocolEncrypted), - string(ProtocolPlaintext), - } -} - -func parseProtocol(input string) (*Protocol, error) { - vals := map[string]Protocol{ - "encrypted": ProtocolEncrypted, - "plaintext": ProtocolPlaintext, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := Protocol(input) - return &out, nil -} - -type ProvisioningState string - -const ( - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreating ProvisioningState = "Creating" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateFailed ProvisioningState = "Failed" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateUpdating ProvisioningState = "Updating" -) - -func PossibleValuesForProvisioningState() []string { - return []string{ - string(ProvisioningStateCanceled), - string(ProvisioningStateCreating), - string(ProvisioningStateDeleting), - string(ProvisioningStateFailed), - string(ProvisioningStateSucceeded), - string(ProvisioningStateUpdating), - } -} - -func parseProvisioningState(input string) (*ProvisioningState, error) { - vals := map[string]ProvisioningState{ - "canceled": ProvisioningStateCanceled, - "creating": ProvisioningStateCreating, - "deleting": ProvisioningStateDeleting, - "failed": ProvisioningStateFailed, - "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 RdbFrequency string - -const ( - RdbFrequencyOneTwoh RdbFrequency = "12h" - RdbFrequencyOneh RdbFrequency = "1h" - RdbFrequencySixh RdbFrequency = "6h" -) - -func PossibleValuesForRdbFrequency() []string { - return []string{ - string(RdbFrequencyOneTwoh), - string(RdbFrequencyOneh), - string(RdbFrequencySixh), - } -} - -func parseRdbFrequency(input string) (*RdbFrequency, error) { - vals := map[string]RdbFrequency{ - "12h": RdbFrequencyOneTwoh, - "1h": RdbFrequencyOneh, - "6h": RdbFrequencySixh, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := RdbFrequency(input) - return &out, nil -} - -type ResourceState string - -const ( - ResourceStateCreateFailed ResourceState = "CreateFailed" - ResourceStateCreating ResourceState = "Creating" - ResourceStateDeleteFailed ResourceState = "DeleteFailed" - ResourceStateDeleting ResourceState = "Deleting" - ResourceStateDisableFailed ResourceState = "DisableFailed" - ResourceStateDisabled ResourceState = "Disabled" - ResourceStateDisabling ResourceState = "Disabling" - ResourceStateEnableFailed ResourceState = "EnableFailed" - ResourceStateEnabling ResourceState = "Enabling" - ResourceStateRunning ResourceState = "Running" - ResourceStateUpdateFailed ResourceState = "UpdateFailed" - ResourceStateUpdating ResourceState = "Updating" -) - -func PossibleValuesForResourceState() []string { - return []string{ - string(ResourceStateCreateFailed), - string(ResourceStateCreating), - string(ResourceStateDeleteFailed), - string(ResourceStateDeleting), - string(ResourceStateDisableFailed), - string(ResourceStateDisabled), - string(ResourceStateDisabling), - string(ResourceStateEnableFailed), - string(ResourceStateEnabling), - string(ResourceStateRunning), - string(ResourceStateUpdateFailed), - string(ResourceStateUpdating), - } -} - -func parseResourceState(input string) (*ResourceState, error) { - vals := map[string]ResourceState{ - "createfailed": ResourceStateCreateFailed, - "creating": ResourceStateCreating, - "deletefailed": ResourceStateDeleteFailed, - "deleting": ResourceStateDeleting, - "disablefailed": ResourceStateDisableFailed, - "disabled": ResourceStateDisabled, - "disabling": ResourceStateDisabling, - "enablefailed": ResourceStateEnableFailed, - "enabling": ResourceStateEnabling, - "running": ResourceStateRunning, - "updatefailed": ResourceStateUpdateFailed, - "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 -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/id_database.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/id_database.go deleted file mode 100644 index e58344f50094..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/id_database.go +++ /dev/null @@ -1,137 +0,0 @@ -package databases - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = DatabaseId{} - -// DatabaseId is a struct representing the Resource ID for a Database -type DatabaseId struct { - SubscriptionId string - ResourceGroupName string - ClusterName string - DatabaseName string -} - -// NewDatabaseID returns a new DatabaseId struct -func NewDatabaseID(subscriptionId string, resourceGroupName string, clusterName string, databaseName string) DatabaseId { - return DatabaseId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ClusterName: clusterName, - DatabaseName: databaseName, - } -} - -// ParseDatabaseID parses 'input' into a DatabaseId -func ParseDatabaseID(input string) (*DatabaseId, error) { - parser := resourceids.NewParserFromResourceIdType(DatabaseId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := DatabaseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - if id.DatabaseName, ok = parsed.Parsed["databaseName"]; !ok { - return nil, fmt.Errorf("the segment 'databaseName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseDatabaseIDInsensitively parses 'input' case-insensitively into a DatabaseId -// note: this method should only be used for API response data and not user input -func ParseDatabaseIDInsensitively(input string) (*DatabaseId, error) { - parser := resourceids.NewParserFromResourceIdType(DatabaseId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := DatabaseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - if id.DatabaseName, ok = parsed.Parsed["databaseName"]; !ok { - return nil, fmt.Errorf("the segment 'databaseName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateDatabaseID checks that 'input' can be parsed as a Database ID -func ValidateDatabaseID(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 := ParseDatabaseID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Database ID -func (id DatabaseId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Cache/redisEnterprise/%s/databases/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName, id.DatabaseName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Database ID -func (id DatabaseId) 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("staticMicrosoftCache", "Microsoft.Cache", "Microsoft.Cache"), - resourceids.StaticSegment("staticRedisEnterprise", "redisEnterprise", "redisEnterprise"), - resourceids.UserSpecifiedSegment("clusterName", "clusterValue"), - resourceids.StaticSegment("staticDatabases", "databases", "databases"), - resourceids.UserSpecifiedSegment("databaseName", "databaseValue"), - } -} - -// String returns a human-readable description of this Database ID -func (id DatabaseId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Cluster Name: %q", id.ClusterName), - fmt.Sprintf("Database Name: %q", id.DatabaseName), - } - return fmt.Sprintf("Database (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/id_database_test.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/id_database_test.go deleted file mode 100644 index 549a63bf6781..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/id_database_test.go +++ /dev/null @@ -1,324 +0,0 @@ -package databases - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = DatabaseId{} - -func TestNewDatabaseID(t *testing.T) { - id := NewDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue", "databaseValue") - - 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.ClusterName != "clusterValue" { - t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterValue") - } - - if id.DatabaseName != "databaseValue" { - t.Fatalf("Expected %q but got %q for Segment 'DatabaseName'", id.DatabaseName, "databaseValue") - } -} - -func TestFormatDatabaseID(t *testing.T) { - actual := NewDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue", "databaseValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases/databaseValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseDatabaseID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *DatabaseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases/databaseValue", - Expected: &DatabaseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - DatabaseName: "databaseValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases/databaseValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseDatabaseID(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - if actual.DatabaseName != v.Expected.DatabaseName { - t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) - } - - } -} - -func TestParseDatabaseIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *DatabaseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/dAtAbAsEs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases/databaseValue", - Expected: &DatabaseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - DatabaseName: "databaseValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases/databaseValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/dAtAbAsEs/dAtAbAsEvAlUe", - Expected: &DatabaseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ClusterName: "cLuStErVaLuE", - DatabaseName: "dAtAbAsEvAlUe", - }, - }, - { - // 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.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/dAtAbAsEs/dAtAbAsEvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseDatabaseIDInsensitively(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - if actual.DatabaseName != v.Expected.DatabaseName { - t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) - } - - } -} - -func TestSegmentsForDatabaseId(t *testing.T) { - segments := DatabaseId{}.Segments() - if len(segments) == 0 { - t.Fatalf("DatabaseId 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/internal/services/redisenterprise/sdk/2021-08-01/databases/id_redisenterprise.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/id_redisenterprise.go deleted file mode 100644 index b1e6441a79ac..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/id_redisenterprise.go +++ /dev/null @@ -1,124 +0,0 @@ -package databases - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = RedisEnterpriseId{} - -// RedisEnterpriseId is a struct representing the Resource ID for a Redis Enterprise -type RedisEnterpriseId struct { - SubscriptionId string - ResourceGroupName string - ClusterName string -} - -// NewRedisEnterpriseID returns a new RedisEnterpriseId struct -func NewRedisEnterpriseID(subscriptionId string, resourceGroupName string, clusterName string) RedisEnterpriseId { - return RedisEnterpriseId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ClusterName: clusterName, - } -} - -// ParseRedisEnterpriseID parses 'input' into a RedisEnterpriseId -func ParseRedisEnterpriseID(input string) (*RedisEnterpriseId, error) { - parser := resourceids.NewParserFromResourceIdType(RedisEnterpriseId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := RedisEnterpriseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseRedisEnterpriseIDInsensitively parses 'input' case-insensitively into a RedisEnterpriseId -// note: this method should only be used for API response data and not user input -func ParseRedisEnterpriseIDInsensitively(input string) (*RedisEnterpriseId, error) { - parser := resourceids.NewParserFromResourceIdType(RedisEnterpriseId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := RedisEnterpriseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateRedisEnterpriseID checks that 'input' can be parsed as a Redis Enterprise ID -func ValidateRedisEnterpriseID(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 := ParseRedisEnterpriseID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Redis Enterprise ID -func (id RedisEnterpriseId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Cache/redisEnterprise/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Redis Enterprise ID -func (id RedisEnterpriseId) 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("staticMicrosoftCache", "Microsoft.Cache", "Microsoft.Cache"), - resourceids.StaticSegment("staticRedisEnterprise", "redisEnterprise", "redisEnterprise"), - resourceids.UserSpecifiedSegment("clusterName", "clusterValue"), - } -} - -// String returns a human-readable description of this Redis Enterprise ID -func (id RedisEnterpriseId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Cluster Name: %q", id.ClusterName), - } - return fmt.Sprintf("Redis Enterprise (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/id_redisenterprise_test.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/id_redisenterprise_test.go deleted file mode 100644 index f70c796f3f48..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/id_redisenterprise_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package databases - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = RedisEnterpriseId{} - -func TestNewRedisEnterpriseID(t *testing.T) { - id := NewRedisEnterpriseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue") - - 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.ClusterName != "clusterValue" { - t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterValue") - } -} - -func TestFormatRedisEnterpriseID(t *testing.T) { - actual := NewRedisEnterpriseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseRedisEnterpriseID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *RedisEnterpriseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseRedisEnterpriseID(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - } -} - -func TestParseRedisEnterpriseIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *RedisEnterpriseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ClusterName: "cLuStErVaLuE", - }, - }, - { - // 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.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseRedisEnterpriseIDInsensitively(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - } -} - -func TestSegmentsForRedisEnterpriseId(t *testing.T) { - segments := RedisEnterpriseId{}.Segments() - if len(segments) == 0 { - t.Fatalf("RedisEnterpriseId 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/internal/services/redisenterprise/sdk/2021-08-01/databases/method_create_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/method_create_autorest.go deleted file mode 100644 index 8ddb57c8a259..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/method_create_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type CreateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Create ... -func (c DatabasesClient) Create(ctx context.Context, id DatabaseId, input Database) (result CreateResponse, err error) { - req, err := c.preparerForCreate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Create", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Create", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateThenPoll performs Create then polls until it's completed -func (c DatabasesClient) CreateThenPoll(ctx context.Context, id DatabaseId, input Database) error { - result, err := c.Create(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Create: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Create: %+v", err) - } - - return nil -} - -// preparerForCreate prepares the Create request. -func (c DatabasesClient) preparerForCreate(ctx context.Context, id DatabaseId, input Database) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreate sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (c DatabasesClient) senderForCreate(ctx context.Context, req *http.Request) (future CreateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/method_delete_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/method_delete_autorest.go deleted file mode 100644 index b6fb4891ca3b..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/method_delete_autorest.go +++ /dev/null @@ -1,73 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type DeleteResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c DatabasesClient) Delete(ctx context.Context, id DatabaseId) (result DeleteResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c DatabasesClient) DeleteThenPoll(ctx context.Context, id DatabaseId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c DatabasesClient) preparerForDelete(ctx context.Context, id DatabaseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c DatabasesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/method_export_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/method_export_autorest.go deleted file mode 100644 index 181d98d419a7..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/method_export_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type ExportResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Export ... -func (c DatabasesClient) Export(ctx context.Context, id DatabaseId, input ExportClusterParameters) (result ExportResponse, err error) { - req, err := c.preparerForExport(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Export", nil, "Failure preparing request") - return - } - - result, err = c.senderForExport(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Export", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ExportThenPoll performs Export then polls until it's completed -func (c DatabasesClient) ExportThenPoll(ctx context.Context, id DatabaseId, input ExportClusterParameters) error { - result, err := c.Export(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Export: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Export: %+v", err) - } - - return nil -} - -// preparerForExport prepares the Export request. -func (c DatabasesClient) preparerForExport(ctx context.Context, id DatabaseId, input ExportClusterParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/export", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForExport sends the Export request. The method will close the -// http.Response Body if it receives an error. -func (c DatabasesClient) senderForExport(ctx context.Context, req *http.Request) (future ExportResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/method_get_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/method_get_autorest.go deleted file mode 100644 index dee18977683b..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/method_get_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package databases - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type GetResponse struct { - HttpResponse *http.Response - Model *Database -} - -// Get ... -func (c DatabasesClient) Get(ctx context.Context, id DatabaseId) (result GetResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c DatabasesClient) preparerForGet(ctx context.Context, id DatabaseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c DatabasesClient) responderForGet(resp *http.Response) (result GetResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/method_import_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/method_import_autorest.go deleted file mode 100644 index 9b11c5efb62c..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/method_import_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type ImportResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Import ... -func (c DatabasesClient) Import(ctx context.Context, id DatabaseId, input ImportClusterParameters) (result ImportResponse, err error) { - req, err := c.preparerForImport(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Import", nil, "Failure preparing request") - return - } - - result, err = c.senderForImport(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Import", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ImportThenPoll performs Import then polls until it's completed -func (c DatabasesClient) ImportThenPoll(ctx context.Context, id DatabaseId, input ImportClusterParameters) error { - result, err := c.Import(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Import: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Import: %+v", err) - } - - return nil -} - -// preparerForImport prepares the Import request. -func (c DatabasesClient) preparerForImport(ctx context.Context, id DatabaseId, input ImportClusterParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/import", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForImport sends the Import request. The method will close the -// http.Response Body if it receives an error. -func (c DatabasesClient) senderForImport(ctx context.Context, req *http.Request) (future ImportResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/method_listbycluster_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/method_listbycluster_autorest.go deleted file mode 100644 index fccaa65c96d8..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/method_listbycluster_autorest.go +++ /dev/null @@ -1,183 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ListByClusterResponse struct { - HttpResponse *http.Response - Model *[]Database - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByClusterResponse, error) -} - -type ListByClusterCompleteResult struct { - Items []Database -} - -func (r ListByClusterResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByClusterResponse) LoadMore(ctx context.Context) (resp ListByClusterResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByCluster ... -func (c DatabasesClient) ListByCluster(ctx context.Context, id RedisEnterpriseId) (resp ListByClusterResponse, err error) { - req, err := c.preparerForListByCluster(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByCluster", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByCluster", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByCluster(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByCluster", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ListByClusterComplete retrieves all of the results into a single object -func (c DatabasesClient) ListByClusterComplete(ctx context.Context, id RedisEnterpriseId) (ListByClusterCompleteResult, error) { - return c.ListByClusterCompleteMatchingPredicate(ctx, id, DatabasePredicate{}) -} - -// ListByClusterCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DatabasesClient) ListByClusterCompleteMatchingPredicate(ctx context.Context, id RedisEnterpriseId, predicate DatabasePredicate) (resp ListByClusterCompleteResult, err error) { - items := make([]Database, 0) - - page, err := c.ListByCluster(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByClusterCompleteResult{ - Items: items, - } - return out, nil -} - -// preparerForListByCluster prepares the ListByCluster request. -func (c DatabasesClient) preparerForListByCluster(ctx context.Context, id RedisEnterpriseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/databases", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByClusterWithNextLink prepares the ListByCluster request with the given nextLink token. -func (c DatabasesClient) preparerForListByClusterWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByCluster handles the response to the ListByCluster request. The method always -// closes the http.Response Body. -func (c DatabasesClient) responderForListByCluster(resp *http.Response) (result ListByClusterResponse, err error) { - type page struct { - Values []Database `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByClusterResponse, err error) { - req, err := c.preparerForListByClusterWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByCluster", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByCluster", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByCluster(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByCluster", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/method_listkeys_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/method_listkeys_autorest.go deleted file mode 100644 index 76f54586bf3b..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/method_listkeys_autorest.go +++ /dev/null @@ -1,65 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ListKeysResponse struct { - HttpResponse *http.Response - Model *AccessKeys -} - -// ListKeys ... -func (c DatabasesClient) ListKeys(ctx context.Context, id DatabaseId) (result ListKeysResponse, err error) { - req, err := c.preparerForListKeys(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListKeys prepares the ListKeys request. -func (c DatabasesClient) preparerForListKeys(ctx context.Context, id DatabaseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listKeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListKeys handles the response to the ListKeys request. The method always -// closes the http.Response Body. -func (c DatabasesClient) responderForListKeys(resp *http.Response) (result ListKeysResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/method_regeneratekey_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/method_regeneratekey_autorest.go deleted file mode 100644 index f831e8e97e7c..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/method_regeneratekey_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type RegenerateKeyResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// RegenerateKey ... -func (c DatabasesClient) RegenerateKey(ctx context.Context, id DatabaseId, input RegenerateKeyParameters) (result RegenerateKeyResponse, err error) { - req, err := c.preparerForRegenerateKey(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "RegenerateKey", nil, "Failure preparing request") - return - } - - result, err = c.senderForRegenerateKey(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "RegenerateKey", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// RegenerateKeyThenPoll performs RegenerateKey then polls until it's completed -func (c DatabasesClient) RegenerateKeyThenPoll(ctx context.Context, id DatabaseId, input RegenerateKeyParameters) error { - result, err := c.RegenerateKey(ctx, id, input) - if err != nil { - return fmt.Errorf("performing RegenerateKey: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after RegenerateKey: %+v", err) - } - - return nil -} - -// preparerForRegenerateKey prepares the RegenerateKey request. -func (c DatabasesClient) preparerForRegenerateKey(ctx context.Context, id DatabaseId, input RegenerateKeyParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/regenerateKey", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForRegenerateKey sends the RegenerateKey request. The method will close the -// http.Response Body if it receives an error. -func (c DatabasesClient) senderForRegenerateKey(ctx context.Context, req *http.Request) (future RegenerateKeyResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/method_update_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/method_update_autorest.go deleted file mode 100644 index 66516e2346d5..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/method_update_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type UpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Update ... -func (c DatabasesClient) Update(ctx context.Context, id DatabaseId, input DatabaseUpdate) (result UpdateResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c DatabasesClient) UpdateThenPoll(ctx context.Context, id DatabaseId, input DatabaseUpdate) error { - result, err := c.Update(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c DatabasesClient) preparerForUpdate(ctx context.Context, id DatabaseId, input DatabaseUpdate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c DatabasesClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/model_accesskeys.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/model_accesskeys.go deleted file mode 100644 index 356ad75ad012..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/model_accesskeys.go +++ /dev/null @@ -1,6 +0,0 @@ -package databases - -type AccessKeys struct { - PrimaryKey *string `json:"primaryKey,omitempty"` - SecondaryKey *string `json:"secondaryKey,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/model_database.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/model_database.go deleted file mode 100644 index 91c899457e9c..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/model_database.go +++ /dev/null @@ -1,8 +0,0 @@ -package databases - -type Database struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *DatabaseProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/model_databaseproperties.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/model_databaseproperties.go deleted file mode 100644 index 0b33e74dfae2..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/model_databaseproperties.go +++ /dev/null @@ -1,12 +0,0 @@ -package databases - -type DatabaseProperties struct { - ClientProtocol *Protocol `json:"clientProtocol,omitempty"` - ClusteringPolicy *ClusteringPolicy `json:"clusteringPolicy,omitempty"` - EvictionPolicy *EvictionPolicy `json:"evictionPolicy,omitempty"` - Modules *[]Module `json:"modules,omitempty"` - Persistence *Persistence `json:"persistence,omitempty"` - Port *int64 `json:"port,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` - ResourceState *ResourceState `json:"resourceState,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/model_databaseupdate.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/model_databaseupdate.go deleted file mode 100644 index 53f5fa8b86d4..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/model_databaseupdate.go +++ /dev/null @@ -1,5 +0,0 @@ -package databases - -type DatabaseUpdate struct { - Properties *DatabaseProperties `json:"properties,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/model_exportclusterparameters.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/model_exportclusterparameters.go deleted file mode 100644 index 390dd6414dc6..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/model_exportclusterparameters.go +++ /dev/null @@ -1,5 +0,0 @@ -package databases - -type ExportClusterParameters struct { - SasUri string `json:"sasUri"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/model_importclusterparameters.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/model_importclusterparameters.go deleted file mode 100644 index f0207b25b5cc..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/model_importclusterparameters.go +++ /dev/null @@ -1,5 +0,0 @@ -package databases - -type ImportClusterParameters struct { - SasUris []string `json:"sasUris"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/model_module.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/model_module.go deleted file mode 100644 index e23fc2366b8e..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/model_module.go +++ /dev/null @@ -1,7 +0,0 @@ -package databases - -type Module struct { - Args *string `json:"args,omitempty"` - Name string `json:"name"` - Version *string `json:"version,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/model_persistence.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/model_persistence.go deleted file mode 100644 index cadef7b455b3..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/model_persistence.go +++ /dev/null @@ -1,8 +0,0 @@ -package databases - -type Persistence struct { - AofEnabled *bool `json:"aofEnabled,omitempty"` - AofFrequency *AofFrequency `json:"aofFrequency,omitempty"` - RdbEnabled *bool `json:"rdbEnabled,omitempty"` - RdbFrequency *RdbFrequency `json:"rdbFrequency,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/model_regeneratekeyparameters.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/model_regeneratekeyparameters.go deleted file mode 100644 index e5e265d42e25..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/model_regeneratekeyparameters.go +++ /dev/null @@ -1,5 +0,0 @@ -package databases - -type RegenerateKeyParameters struct { - KeyType AccessKeyType `json:"keyType"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/predicates.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/predicates.go deleted file mode 100644 index 8e70d0fdfa34..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/predicates.go +++ /dev/null @@ -1,24 +0,0 @@ -package databases - -type DatabasePredicate struct { - Id *string - Name *string - Type *string -} - -func (p DatabasePredicate) Matches(input Database) bool { - - if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { - return false - } - - if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { - return false - } - - return true -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/databases/version.go b/internal/services/redisenterprise/sdk/2021-08-01/databases/version.go deleted file mode 100644 index 178d02ed0451..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/databases/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package databases - -import "fmt" - -const defaultApiVersion = "2021-08-01" - -func userAgent() string { - return fmt.Sprintf("pandora/databases/%s", defaultApiVersion) -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/client.go b/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/client.go deleted file mode 100644 index 28da68be384f..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package operationsstatus - -import "github.com/Azure/go-autorest/autorest" - -type OperationsStatusClient struct { - Client autorest.Client - baseUri string -} - -func NewOperationsStatusClientWithBaseURI(endpoint string) OperationsStatusClient { - return OperationsStatusClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/id_operationsstatu.go b/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/id_operationsstatu.go deleted file mode 100644 index 5e696c401b50..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/id_operationsstatu.go +++ /dev/null @@ -1,124 +0,0 @@ -package operationsstatus - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = OperationsStatuId{} - -// OperationsStatuId is a struct representing the Resource ID for a Operations Statu -type OperationsStatuId struct { - SubscriptionId string - Location string - OperationId string -} - -// NewOperationsStatuID returns a new OperationsStatuId struct -func NewOperationsStatuID(subscriptionId string, location string, operationId string) OperationsStatuId { - return OperationsStatuId{ - SubscriptionId: subscriptionId, - Location: location, - OperationId: operationId, - } -} - -// ParseOperationsStatuID parses 'input' into a OperationsStatuId -func ParseOperationsStatuID(input string) (*OperationsStatuId, error) { - parser := resourceids.NewParserFromResourceIdType(OperationsStatuId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := OperationsStatuId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.Location, ok = parsed.Parsed["location"]; !ok { - return nil, fmt.Errorf("the segment 'location' was not found in the resource id %q", input) - } - - if id.OperationId, ok = parsed.Parsed["operationId"]; !ok { - return nil, fmt.Errorf("the segment 'operationId' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseOperationsStatuIDInsensitively parses 'input' case-insensitively into a OperationsStatuId -// note: this method should only be used for API response data and not user input -func ParseOperationsStatuIDInsensitively(input string) (*OperationsStatuId, error) { - parser := resourceids.NewParserFromResourceIdType(OperationsStatuId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := OperationsStatuId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.Location, ok = parsed.Parsed["location"]; !ok { - return nil, fmt.Errorf("the segment 'location' was not found in the resource id %q", input) - } - - if id.OperationId, ok = parsed.Parsed["operationId"]; !ok { - return nil, fmt.Errorf("the segment 'operationId' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateOperationsStatuID checks that 'input' can be parsed as a Operations Statu ID -func ValidateOperationsStatuID(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 := ParseOperationsStatuID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Operations Statu ID -func (id OperationsStatuId) ID() string { - fmtString := "/subscriptions/%s/providers/Microsoft.Cache/locations/%s/operationsStatus/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.Location, id.OperationId) -} - -// Segments returns a slice of Resource ID Segments which comprise this Operations Statu ID -func (id OperationsStatuId) 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("staticMicrosoftCache", "Microsoft.Cache", "Microsoft.Cache"), - resourceids.StaticSegment("staticLocations", "locations", "locations"), - resourceids.UserSpecifiedSegment("location", "locationValue"), - resourceids.StaticSegment("staticOperationsStatus", "operationsStatus", "operationsStatus"), - resourceids.UserSpecifiedSegment("operationId", "operationIdValue"), - } -} - -// String returns a human-readable description of this Operations Statu ID -func (id OperationsStatuId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Location: %q", id.Location), - fmt.Sprintf("Operation: %q", id.OperationId), - } - return fmt.Sprintf("Operations Statu (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/id_operationsstatu_test.go b/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/id_operationsstatu_test.go deleted file mode 100644 index e409185725c9..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/id_operationsstatu_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package operationsstatus - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = OperationsStatuId{} - -func TestNewOperationsStatuID(t *testing.T) { - id := NewOperationsStatuID("12345678-1234-9876-4563-123456789012", "locationValue", "operationIdValue") - - 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.Location != "locationValue" { - t.Fatalf("Expected %q but got %q for Segment 'Location'", id.Location, "locationValue") - } - - if id.OperationId != "operationIdValue" { - t.Fatalf("Expected %q but got %q for Segment 'OperationId'", id.OperationId, "operationIdValue") - } -} - -func TestFormatOperationsStatuID(t *testing.T) { - actual := NewOperationsStatuID("12345678-1234-9876-4563-123456789012", "locationValue", "operationIdValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Cache/locations/locationValue/operationsStatus/operationIdValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseOperationsStatuID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *OperationsStatuId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Cache/locations", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Cache/locations/locationValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Cache/locations/locationValue/operationsStatus", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Cache/locations/locationValue/operationsStatus/operationIdValue", - Expected: &OperationsStatuId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - Location: "locationValue", - OperationId: "operationIdValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Cache/locations/locationValue/operationsStatus/operationIdValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseOperationsStatuID(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.Location != v.Expected.Location { - t.Fatalf("Expected %q but got %q for Location", v.Expected.Location, actual.Location) - } - - if actual.OperationId != v.Expected.OperationId { - t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) - } - - } -} - -func TestParseOperationsStatuIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *OperationsStatuId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cAcHe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Cache/locations", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cAcHe/lOcAtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Cache/locations/locationValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cAcHe/lOcAtIoNs/lOcAtIoNvAlUe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Cache/locations/locationValue/operationsStatus", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cAcHe/lOcAtIoNs/lOcAtIoNvAlUe/oPeRaTiOnSsTaTuS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Cache/locations/locationValue/operationsStatus/operationIdValue", - Expected: &OperationsStatuId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - Location: "locationValue", - OperationId: "operationIdValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Cache/locations/locationValue/operationsStatus/operationIdValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cAcHe/lOcAtIoNs/lOcAtIoNvAlUe/oPeRaTiOnSsTaTuS/oPeRaTiOnIdVaLuE", - Expected: &OperationsStatuId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - Location: "lOcAtIoNvAlUe", - OperationId: "oPeRaTiOnIdVaLuE", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cAcHe/lOcAtIoNs/lOcAtIoNvAlUe/oPeRaTiOnSsTaTuS/oPeRaTiOnIdVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseOperationsStatuIDInsensitively(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.Location != v.Expected.Location { - t.Fatalf("Expected %q but got %q for Location", v.Expected.Location, actual.Location) - } - - if actual.OperationId != v.Expected.OperationId { - t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) - } - - } -} - -func TestSegmentsForOperationsStatuId(t *testing.T) { - segments := OperationsStatuId{}.Segments() - if len(segments) == 0 { - t.Fatalf("OperationsStatuId 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/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/method_get_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/method_get_autorest.go deleted file mode 100644 index e88bf254ea78..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/method_get_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package operationsstatus - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type GetResponse struct { - HttpResponse *http.Response - Model *OperationStatus -} - -// Get ... -func (c OperationsStatusClient) Get(ctx context.Context, id OperationsStatuId) (result GetResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "operationsstatus.OperationsStatusClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "operationsstatus.OperationsStatusClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "operationsstatus.OperationsStatusClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c OperationsStatusClient) preparerForGet(ctx context.Context, id OperationsStatuId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c OperationsStatusClient) responderForGet(resp *http.Response) (result GetResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/model_erroradditionalinfo.go b/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/model_erroradditionalinfo.go deleted file mode 100644 index f6b29162c7e5..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/model_erroradditionalinfo.go +++ /dev/null @@ -1,6 +0,0 @@ -package operationsstatus - -type ErrorAdditionalInfo struct { - Info *interface{} `json:"info,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/model_errordetail.go b/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/model_errordetail.go deleted file mode 100644 index d0bdb01dafd7..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/model_errordetail.go +++ /dev/null @@ -1,9 +0,0 @@ -package operationsstatus - -type ErrorDetail struct { - AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` - Code *string `json:"code,omitempty"` - Details *[]ErrorDetail `json:"details,omitempty"` - Message *string `json:"message,omitempty"` - Target *string `json:"target,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/model_errorresponse.go b/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/model_errorresponse.go deleted file mode 100644 index e23110ce5893..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/model_errorresponse.go +++ /dev/null @@ -1,5 +0,0 @@ -package operationsstatus - -type ErrorResponse struct { - Error *ErrorDetail `json:"error,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/model_operationstatus.go b/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/model_operationstatus.go deleted file mode 100644 index 67281f8941da..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/model_operationstatus.go +++ /dev/null @@ -1,10 +0,0 @@ -package operationsstatus - -type OperationStatus struct { - EndTime *string `json:"endTime,omitempty"` - Error *ErrorResponse `json:"error,omitempty"` - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - StartTime *string `json:"startTime,omitempty"` - Status *string `json:"status,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/version.go b/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/version.go deleted file mode 100644 index 6b46d14d6e14..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/operationsstatus/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package operationsstatus - -import "fmt" - -const defaultApiVersion = "2021-08-01" - -func userAgent() string { - return fmt.Sprintf("pandora/operationsstatus/%s", defaultApiVersion) -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/client.go b/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/client.go deleted file mode 100644 index adc4283affb2..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package privateendpointconnections - -import "github.com/Azure/go-autorest/autorest" - -type PrivateEndpointConnectionsClient struct { - Client autorest.Client - baseUri string -} - -func NewPrivateEndpointConnectionsClientWithBaseURI(endpoint string) PrivateEndpointConnectionsClient { - return PrivateEndpointConnectionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/constants.go b/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/constants.go deleted file mode 100644 index 49d0ed483658..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/constants.go +++ /dev/null @@ -1,68 +0,0 @@ -package privateendpointconnections - -import "strings" - -type PrivateEndpointConnectionProvisioningState string - -const ( - PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" - PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" - PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" - PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" -) - -func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { - return []string{ - string(PrivateEndpointConnectionProvisioningStateCreating), - string(PrivateEndpointConnectionProvisioningStateDeleting), - string(PrivateEndpointConnectionProvisioningStateFailed), - string(PrivateEndpointConnectionProvisioningStateSucceeded), - } -} - -func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { - vals := map[string]PrivateEndpointConnectionProvisioningState{ - "creating": PrivateEndpointConnectionProvisioningStateCreating, - "deleting": PrivateEndpointConnectionProvisioningStateDeleting, - "failed": PrivateEndpointConnectionProvisioningStateFailed, - "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointConnectionProvisioningState(input) - return &out, nil -} - -type PrivateEndpointServiceConnectionStatus string - -const ( - PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" - PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" -) - -func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { - return []string{ - string(PrivateEndpointServiceConnectionStatusApproved), - string(PrivateEndpointServiceConnectionStatusPending), - string(PrivateEndpointServiceConnectionStatusRejected), - } -} - -func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { - vals := map[string]PrivateEndpointServiceConnectionStatus{ - "approved": PrivateEndpointServiceConnectionStatusApproved, - "pending": PrivateEndpointServiceConnectionStatusPending, - "rejected": PrivateEndpointServiceConnectionStatusRejected, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointServiceConnectionStatus(input) - return &out, nil -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/id_privateendpointconnection.go b/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/id_privateendpointconnection.go deleted file mode 100644 index 1ebd7ff925da..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/id_privateendpointconnection.go +++ /dev/null @@ -1,137 +0,0 @@ -package privateendpointconnections - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = PrivateEndpointConnectionId{} - -// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection -type PrivateEndpointConnectionId struct { - SubscriptionId string - ResourceGroupName string - ClusterName string - PrivateEndpointConnectionName string -} - -// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct -func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, clusterName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { - return PrivateEndpointConnectionId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ClusterName: clusterName, - PrivateEndpointConnectionName: privateEndpointConnectionName, - } -} - -// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId -func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { - parser := resourceids.NewParserFromResourceIdType(PrivateEndpointConnectionId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := PrivateEndpointConnectionId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - if id.PrivateEndpointConnectionName, ok = parsed.Parsed["privateEndpointConnectionName"]; !ok { - return nil, fmt.Errorf("the segment 'privateEndpointConnectionName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId -// note: this method should only be used for API response data and not user input -func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { - parser := resourceids.NewParserFromResourceIdType(PrivateEndpointConnectionId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := PrivateEndpointConnectionId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - if id.PrivateEndpointConnectionName, ok = parsed.Parsed["privateEndpointConnectionName"]; !ok { - return nil, fmt.Errorf("the segment 'privateEndpointConnectionName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID -func ValidatePrivateEndpointConnectionID(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 := ParsePrivateEndpointConnectionID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Private Endpoint Connection ID -func (id PrivateEndpointConnectionId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Cache/redisEnterprise/%s/privateEndpointConnections/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName, id.PrivateEndpointConnectionName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID -func (id PrivateEndpointConnectionId) 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("staticMicrosoftCache", "Microsoft.Cache", "Microsoft.Cache"), - resourceids.StaticSegment("staticRedisEnterprise", "redisEnterprise", "redisEnterprise"), - resourceids.UserSpecifiedSegment("clusterName", "clusterValue"), - resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), - resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionValue"), - } -} - -// String returns a human-readable description of this Private Endpoint Connection ID -func (id PrivateEndpointConnectionId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Cluster Name: %q", id.ClusterName), - fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), - } - return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/id_privateendpointconnection_test.go b/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/id_privateendpointconnection_test.go deleted file mode 100644 index a2bb836ac79f..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/id_privateendpointconnection_test.go +++ /dev/null @@ -1,324 +0,0 @@ -package privateendpointconnections - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = PrivateEndpointConnectionId{} - -func TestNewPrivateEndpointConnectionID(t *testing.T) { - id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue", "privateEndpointConnectionValue") - - 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.ClusterName != "clusterValue" { - t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterValue") - } - - if id.PrivateEndpointConnectionName != "privateEndpointConnectionValue" { - t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionValue") - } -} - -func TestFormatPrivateEndpointConnectionID(t *testing.T) { - actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue", "privateEndpointConnectionValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/privateEndpointConnections/privateEndpointConnectionValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParsePrivateEndpointConnectionID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateEndpointConnectionId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/privateEndpointConnections", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/privateEndpointConnections/privateEndpointConnectionValue", - Expected: &PrivateEndpointConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - PrivateEndpointConnectionName: "privateEndpointConnectionValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/privateEndpointConnections/privateEndpointConnectionValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateEndpointConnectionID(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { - t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) - } - - } -} - -func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateEndpointConnectionId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/privateEndpointConnections", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/pRiVaTeEnDpOiNtCoNnEcTiOnS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/privateEndpointConnections/privateEndpointConnectionValue", - Expected: &PrivateEndpointConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - PrivateEndpointConnectionName: "privateEndpointConnectionValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/privateEndpointConnections/privateEndpointConnectionValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", - Expected: &PrivateEndpointConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ClusterName: "cLuStErVaLuE", - PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", - }, - }, - { - // 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.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateEndpointConnectionIDInsensitively(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { - t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) - } - - } -} - -func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { - segments := PrivateEndpointConnectionId{}.Segments() - if len(segments) == 0 { - t.Fatalf("PrivateEndpointConnectionId 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/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/id_redisenterprise.go b/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/id_redisenterprise.go deleted file mode 100644 index f70b07e41874..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/id_redisenterprise.go +++ /dev/null @@ -1,124 +0,0 @@ -package privateendpointconnections - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = RedisEnterpriseId{} - -// RedisEnterpriseId is a struct representing the Resource ID for a Redis Enterprise -type RedisEnterpriseId struct { - SubscriptionId string - ResourceGroupName string - ClusterName string -} - -// NewRedisEnterpriseID returns a new RedisEnterpriseId struct -func NewRedisEnterpriseID(subscriptionId string, resourceGroupName string, clusterName string) RedisEnterpriseId { - return RedisEnterpriseId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ClusterName: clusterName, - } -} - -// ParseRedisEnterpriseID parses 'input' into a RedisEnterpriseId -func ParseRedisEnterpriseID(input string) (*RedisEnterpriseId, error) { - parser := resourceids.NewParserFromResourceIdType(RedisEnterpriseId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := RedisEnterpriseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseRedisEnterpriseIDInsensitively parses 'input' case-insensitively into a RedisEnterpriseId -// note: this method should only be used for API response data and not user input -func ParseRedisEnterpriseIDInsensitively(input string) (*RedisEnterpriseId, error) { - parser := resourceids.NewParserFromResourceIdType(RedisEnterpriseId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := RedisEnterpriseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateRedisEnterpriseID checks that 'input' can be parsed as a Redis Enterprise ID -func ValidateRedisEnterpriseID(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 := ParseRedisEnterpriseID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Redis Enterprise ID -func (id RedisEnterpriseId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Cache/redisEnterprise/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Redis Enterprise ID -func (id RedisEnterpriseId) 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("staticMicrosoftCache", "Microsoft.Cache", "Microsoft.Cache"), - resourceids.StaticSegment("staticRedisEnterprise", "redisEnterprise", "redisEnterprise"), - resourceids.UserSpecifiedSegment("clusterName", "clusterValue"), - } -} - -// String returns a human-readable description of this Redis Enterprise ID -func (id RedisEnterpriseId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Cluster Name: %q", id.ClusterName), - } - return fmt.Sprintf("Redis Enterprise (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/id_redisenterprise_test.go b/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/id_redisenterprise_test.go deleted file mode 100644 index e74c26665174..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/id_redisenterprise_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package privateendpointconnections - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = RedisEnterpriseId{} - -func TestNewRedisEnterpriseID(t *testing.T) { - id := NewRedisEnterpriseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue") - - 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.ClusterName != "clusterValue" { - t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterValue") - } -} - -func TestFormatRedisEnterpriseID(t *testing.T) { - actual := NewRedisEnterpriseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseRedisEnterpriseID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *RedisEnterpriseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseRedisEnterpriseID(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - } -} - -func TestParseRedisEnterpriseIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *RedisEnterpriseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ClusterName: "cLuStErVaLuE", - }, - }, - { - // 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.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseRedisEnterpriseIDInsensitively(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - } -} - -func TestSegmentsForRedisEnterpriseId(t *testing.T) { - segments := RedisEnterpriseId{}.Segments() - if len(segments) == 0 { - t.Fatalf("RedisEnterpriseId 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/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/method_delete_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/method_delete_autorest.go deleted file mode 100644 index 1231e4f199fe..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/method_delete_autorest.go +++ /dev/null @@ -1,61 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type DeleteResponse struct { - HttpResponse *http.Response -} - -// Delete ... -func (c PrivateEndpointConnectionsClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c PrivateEndpointConnectionsClient) preparerForDelete(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForDelete(resp *http.Response) (result DeleteResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/method_get_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/method_get_autorest.go deleted file mode 100644 index 10ec2007dc6d..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/method_get_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type GetResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnection -} - -// Get ... -func (c PrivateEndpointConnectionsClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (result GetResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PrivateEndpointConnectionsClient) preparerForGet(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForGet(resp *http.Response) (result GetResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/method_list_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/method_list_autorest.go deleted file mode 100644 index aebdfc8d1693..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/method_list_autorest.go +++ /dev/null @@ -1,65 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ListResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnectionListResult -} - -// List ... -func (c PrivateEndpointConnectionsClient) List(ctx context.Context, id RedisEnterpriseId) (result ListResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForList prepares the List request. -func (c PrivateEndpointConnectionsClient) preparerForList(ctx context.Context, id RedisEnterpriseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateEndpointConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForList(resp *http.Response) (result ListResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/method_put_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/method_put_autorest.go deleted file mode 100644 index ac463ffb3815..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/method_put_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type PutResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Put ... -func (c PrivateEndpointConnectionsClient) Put(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result PutResponse, err error) { - req, err := c.preparerForPut(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Put", nil, "Failure preparing request") - return - } - - result, err = c.senderForPut(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Put", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// PutThenPoll performs Put then polls until it's completed -func (c PrivateEndpointConnectionsClient) PutThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) error { - result, err := c.Put(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Put: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Put: %+v", err) - } - - return nil -} - -// preparerForPut prepares the Put request. -func (c PrivateEndpointConnectionsClient) preparerForPut(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForPut sends the Put request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionsClient) senderForPut(ctx context.Context, req *http.Request) (future PutResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/model_privateendpoint.go b/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/model_privateendpoint.go deleted file mode 100644 index 33ffc888d58a..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/model_privateendpoint.go +++ /dev/null @@ -1,5 +0,0 @@ -package privateendpointconnections - -type PrivateEndpoint struct { - Id *string `json:"id,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/model_privateendpointconnection.go b/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/model_privateendpointconnection.go deleted file mode 100644 index 597d3e71746a..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/model_privateendpointconnection.go +++ /dev/null @@ -1,8 +0,0 @@ -package privateendpointconnections - -type PrivateEndpointConnection struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/model_privateendpointconnectionlistresult.go b/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/model_privateendpointconnectionlistresult.go deleted file mode 100644 index b565022bf4e0..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/model_privateendpointconnectionlistresult.go +++ /dev/null @@ -1,5 +0,0 @@ -package privateendpointconnections - -type PrivateEndpointConnectionListResult struct { - Value *[]PrivateEndpointConnection `json:"value,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/model_privateendpointconnectionproperties.go b/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/model_privateendpointconnectionproperties.go deleted file mode 100644 index 252bd91cbe86..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/model_privateendpointconnectionproperties.go +++ /dev/null @@ -1,7 +0,0 @@ -package privateendpointconnections - -type PrivateEndpointConnectionProperties struct { - PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` - PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` - ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go b/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go deleted file mode 100644 index def138656add..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go +++ /dev/null @@ -1,7 +0,0 @@ -package privateendpointconnections - -type PrivateLinkServiceConnectionState struct { - ActionsRequired *string `json:"actionsRequired,omitempty"` - Description *string `json:"description,omitempty"` - Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/version.go b/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/version.go deleted file mode 100644 index 7947c4cc5d77..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privateendpointconnections/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package privateendpointconnections - -import "fmt" - -const defaultApiVersion = "2021-08-01" - -func userAgent() string { - return fmt.Sprintf("pandora/privateendpointconnections/%s", defaultApiVersion) -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/client.go b/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/client.go deleted file mode 100644 index 3ccc015d4fe1..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package privatelinkresources - -import "github.com/Azure/go-autorest/autorest" - -type PrivateLinkResourcesClient struct { - Client autorest.Client - baseUri string -} - -func NewPrivateLinkResourcesClientWithBaseURI(endpoint string) PrivateLinkResourcesClient { - return PrivateLinkResourcesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/id_redisenterprise.go b/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/id_redisenterprise.go deleted file mode 100644 index 55569e1b866c..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/id_redisenterprise.go +++ /dev/null @@ -1,124 +0,0 @@ -package privatelinkresources - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = RedisEnterpriseId{} - -// RedisEnterpriseId is a struct representing the Resource ID for a Redis Enterprise -type RedisEnterpriseId struct { - SubscriptionId string - ResourceGroupName string - ClusterName string -} - -// NewRedisEnterpriseID returns a new RedisEnterpriseId struct -func NewRedisEnterpriseID(subscriptionId string, resourceGroupName string, clusterName string) RedisEnterpriseId { - return RedisEnterpriseId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ClusterName: clusterName, - } -} - -// ParseRedisEnterpriseID parses 'input' into a RedisEnterpriseId -func ParseRedisEnterpriseID(input string) (*RedisEnterpriseId, error) { - parser := resourceids.NewParserFromResourceIdType(RedisEnterpriseId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := RedisEnterpriseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseRedisEnterpriseIDInsensitively parses 'input' case-insensitively into a RedisEnterpriseId -// note: this method should only be used for API response data and not user input -func ParseRedisEnterpriseIDInsensitively(input string) (*RedisEnterpriseId, error) { - parser := resourceids.NewParserFromResourceIdType(RedisEnterpriseId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := RedisEnterpriseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateRedisEnterpriseID checks that 'input' can be parsed as a Redis Enterprise ID -func ValidateRedisEnterpriseID(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 := ParseRedisEnterpriseID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Redis Enterprise ID -func (id RedisEnterpriseId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Cache/redisEnterprise/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Redis Enterprise ID -func (id RedisEnterpriseId) 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("staticMicrosoftCache", "Microsoft.Cache", "Microsoft.Cache"), - resourceids.StaticSegment("staticRedisEnterprise", "redisEnterprise", "redisEnterprise"), - resourceids.UserSpecifiedSegment("clusterName", "clusterValue"), - } -} - -// String returns a human-readable description of this Redis Enterprise ID -func (id RedisEnterpriseId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Cluster Name: %q", id.ClusterName), - } - return fmt.Sprintf("Redis Enterprise (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/id_redisenterprise_test.go b/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/id_redisenterprise_test.go deleted file mode 100644 index 9db75fddddea..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/id_redisenterprise_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package privatelinkresources - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = RedisEnterpriseId{} - -func TestNewRedisEnterpriseID(t *testing.T) { - id := NewRedisEnterpriseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue") - - 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.ClusterName != "clusterValue" { - t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterValue") - } -} - -func TestFormatRedisEnterpriseID(t *testing.T) { - actual := NewRedisEnterpriseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseRedisEnterpriseID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *RedisEnterpriseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseRedisEnterpriseID(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - } -} - -func TestParseRedisEnterpriseIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *RedisEnterpriseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ClusterName: "cLuStErVaLuE", - }, - }, - { - // 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.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseRedisEnterpriseIDInsensitively(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - } -} - -func TestSegmentsForRedisEnterpriseId(t *testing.T) { - segments := RedisEnterpriseId{}.Segments() - if len(segments) == 0 { - t.Fatalf("RedisEnterpriseId 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/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/method_listbycluster_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/method_listbycluster_autorest.go deleted file mode 100644 index fcf3d727f0ed..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/method_listbycluster_autorest.go +++ /dev/null @@ -1,65 +0,0 @@ -package privatelinkresources - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ListByClusterResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResourceListResult -} - -// ListByCluster ... -func (c PrivateLinkResourcesClient) ListByCluster(ctx context.Context, id RedisEnterpriseId) (result ListByClusterResponse, err error) { - req, err := c.preparerForListByCluster(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByCluster", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByCluster", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByCluster(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByCluster", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByCluster prepares the ListByCluster request. -func (c PrivateLinkResourcesClient) preparerForListByCluster(ctx context.Context, id RedisEnterpriseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateLinkResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByCluster handles the response to the ListByCluster request. The method always -// closes the http.Response Body. -func (c PrivateLinkResourcesClient) responderForListByCluster(resp *http.Response) (result ListByClusterResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/model_privatelinkresource.go b/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/model_privatelinkresource.go deleted file mode 100644 index d3cb62e00811..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/model_privatelinkresource.go +++ /dev/null @@ -1,8 +0,0 @@ -package privatelinkresources - -type PrivateLinkResource struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/model_privatelinkresourcelistresult.go b/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/model_privatelinkresourcelistresult.go deleted file mode 100644 index 19c87bd4a131..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/model_privatelinkresourcelistresult.go +++ /dev/null @@ -1,5 +0,0 @@ -package privatelinkresources - -type PrivateLinkResourceListResult struct { - Value *[]PrivateLinkResource `json:"value,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/model_privatelinkresourceproperties.go b/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/model_privatelinkresourceproperties.go deleted file mode 100644 index 51bc838c1fbd..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/model_privatelinkresourceproperties.go +++ /dev/null @@ -1,7 +0,0 @@ -package privatelinkresources - -type PrivateLinkResourceProperties struct { - GroupId *string `json:"groupId,omitempty"` - RequiredMembers *[]string `json:"requiredMembers,omitempty"` - RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/version.go b/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/version.go deleted file mode 100644 index d3cdf1fff306..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/privatelinkresources/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package privatelinkresources - -import "fmt" - -const defaultApiVersion = "2021-08-01" - -func userAgent() string { - return fmt.Sprintf("pandora/privatelinkresources/%s", defaultApiVersion) -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/client.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/client.go deleted file mode 100644 index e38fe5d733af..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package redisenterprise - -import "github.com/Azure/go-autorest/autorest" - -type RedisEnterpriseClient struct { - Client autorest.Client - baseUri string -} - -func NewRedisEnterpriseClientWithBaseURI(endpoint string) RedisEnterpriseClient { - return RedisEnterpriseClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/constants.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/constants.go deleted file mode 100644 index b266984485e7..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/constants.go +++ /dev/null @@ -1,429 +0,0 @@ -package redisenterprise - -import "strings" - -type AccessKeyType string - -const ( - AccessKeyTypePrimary AccessKeyType = "Primary" - AccessKeyTypeSecondary AccessKeyType = "Secondary" -) - -func PossibleValuesForAccessKeyType() []string { - return []string{ - string(AccessKeyTypePrimary), - string(AccessKeyTypeSecondary), - } -} - -func parseAccessKeyType(input string) (*AccessKeyType, error) { - vals := map[string]AccessKeyType{ - "primary": AccessKeyTypePrimary, - "secondary": AccessKeyTypeSecondary, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := AccessKeyType(input) - return &out, nil -} - -type AofFrequency string - -const ( - AofFrequencyAlways AofFrequency = "always" - AofFrequencyOnes AofFrequency = "1s" -) - -func PossibleValuesForAofFrequency() []string { - return []string{ - string(AofFrequencyAlways), - string(AofFrequencyOnes), - } -} - -func parseAofFrequency(input string) (*AofFrequency, error) { - vals := map[string]AofFrequency{ - "always": AofFrequencyAlways, - "1s": AofFrequencyOnes, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := AofFrequency(input) - return &out, nil -} - -type ClusteringPolicy string - -const ( - ClusteringPolicyEnterpriseCluster ClusteringPolicy = "EnterpriseCluster" - ClusteringPolicyOSSCluster ClusteringPolicy = "OSSCluster" -) - -func PossibleValuesForClusteringPolicy() []string { - return []string{ - string(ClusteringPolicyEnterpriseCluster), - string(ClusteringPolicyOSSCluster), - } -} - -func parseClusteringPolicy(input string) (*ClusteringPolicy, error) { - vals := map[string]ClusteringPolicy{ - "enterprisecluster": ClusteringPolicyEnterpriseCluster, - "osscluster": ClusteringPolicyOSSCluster, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ClusteringPolicy(input) - return &out, nil -} - -type EvictionPolicy string - -const ( - EvictionPolicyAllKeysLFU EvictionPolicy = "AllKeysLFU" - EvictionPolicyAllKeysLRU EvictionPolicy = "AllKeysLRU" - EvictionPolicyAllKeysRandom EvictionPolicy = "AllKeysRandom" - EvictionPolicyNoEviction EvictionPolicy = "NoEviction" - EvictionPolicyVolatileLFU EvictionPolicy = "VolatileLFU" - EvictionPolicyVolatileLRU EvictionPolicy = "VolatileLRU" - EvictionPolicyVolatileRandom EvictionPolicy = "VolatileRandom" - EvictionPolicyVolatileTTL EvictionPolicy = "VolatileTTL" -) - -func PossibleValuesForEvictionPolicy() []string { - return []string{ - string(EvictionPolicyAllKeysLFU), - string(EvictionPolicyAllKeysLRU), - string(EvictionPolicyAllKeysRandom), - string(EvictionPolicyNoEviction), - string(EvictionPolicyVolatileLFU), - string(EvictionPolicyVolatileLRU), - string(EvictionPolicyVolatileRandom), - string(EvictionPolicyVolatileTTL), - } -} - -func parseEvictionPolicy(input string) (*EvictionPolicy, error) { - vals := map[string]EvictionPolicy{ - "allkeyslfu": EvictionPolicyAllKeysLFU, - "allkeyslru": EvictionPolicyAllKeysLRU, - "allkeysrandom": EvictionPolicyAllKeysRandom, - "noeviction": EvictionPolicyNoEviction, - "volatilelfu": EvictionPolicyVolatileLFU, - "volatilelru": EvictionPolicyVolatileLRU, - "volatilerandom": EvictionPolicyVolatileRandom, - "volatilettl": EvictionPolicyVolatileTTL, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := EvictionPolicy(input) - return &out, nil -} - -type PrivateEndpointConnectionProvisioningState string - -const ( - PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" - PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" - PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" - PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" -) - -func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { - return []string{ - string(PrivateEndpointConnectionProvisioningStateCreating), - string(PrivateEndpointConnectionProvisioningStateDeleting), - string(PrivateEndpointConnectionProvisioningStateFailed), - string(PrivateEndpointConnectionProvisioningStateSucceeded), - } -} - -func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { - vals := map[string]PrivateEndpointConnectionProvisioningState{ - "creating": PrivateEndpointConnectionProvisioningStateCreating, - "deleting": PrivateEndpointConnectionProvisioningStateDeleting, - "failed": PrivateEndpointConnectionProvisioningStateFailed, - "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointConnectionProvisioningState(input) - return &out, nil -} - -type PrivateEndpointServiceConnectionStatus string - -const ( - PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" - PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" -) - -func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { - return []string{ - string(PrivateEndpointServiceConnectionStatusApproved), - string(PrivateEndpointServiceConnectionStatusPending), - string(PrivateEndpointServiceConnectionStatusRejected), - } -} - -func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { - vals := map[string]PrivateEndpointServiceConnectionStatus{ - "approved": PrivateEndpointServiceConnectionStatusApproved, - "pending": PrivateEndpointServiceConnectionStatusPending, - "rejected": PrivateEndpointServiceConnectionStatusRejected, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointServiceConnectionStatus(input) - return &out, nil -} - -type Protocol string - -const ( - ProtocolEncrypted Protocol = "Encrypted" - ProtocolPlaintext Protocol = "Plaintext" -) - -func PossibleValuesForProtocol() []string { - return []string{ - string(ProtocolEncrypted), - string(ProtocolPlaintext), - } -} - -func parseProtocol(input string) (*Protocol, error) { - vals := map[string]Protocol{ - "encrypted": ProtocolEncrypted, - "plaintext": ProtocolPlaintext, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := Protocol(input) - return &out, nil -} - -type ProvisioningState string - -const ( - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreating ProvisioningState = "Creating" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateFailed ProvisioningState = "Failed" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateUpdating ProvisioningState = "Updating" -) - -func PossibleValuesForProvisioningState() []string { - return []string{ - string(ProvisioningStateCanceled), - string(ProvisioningStateCreating), - string(ProvisioningStateDeleting), - string(ProvisioningStateFailed), - string(ProvisioningStateSucceeded), - string(ProvisioningStateUpdating), - } -} - -func parseProvisioningState(input string) (*ProvisioningState, error) { - vals := map[string]ProvisioningState{ - "canceled": ProvisioningStateCanceled, - "creating": ProvisioningStateCreating, - "deleting": ProvisioningStateDeleting, - "failed": ProvisioningStateFailed, - "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 RdbFrequency string - -const ( - RdbFrequencyOneTwoh RdbFrequency = "12h" - RdbFrequencyOneh RdbFrequency = "1h" - RdbFrequencySixh RdbFrequency = "6h" -) - -func PossibleValuesForRdbFrequency() []string { - return []string{ - string(RdbFrequencyOneTwoh), - string(RdbFrequencyOneh), - string(RdbFrequencySixh), - } -} - -func parseRdbFrequency(input string) (*RdbFrequency, error) { - vals := map[string]RdbFrequency{ - "12h": RdbFrequencyOneTwoh, - "1h": RdbFrequencyOneh, - "6h": RdbFrequencySixh, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := RdbFrequency(input) - return &out, nil -} - -type ResourceState string - -const ( - ResourceStateCreateFailed ResourceState = "CreateFailed" - ResourceStateCreating ResourceState = "Creating" - ResourceStateDeleteFailed ResourceState = "DeleteFailed" - ResourceStateDeleting ResourceState = "Deleting" - ResourceStateDisableFailed ResourceState = "DisableFailed" - ResourceStateDisabled ResourceState = "Disabled" - ResourceStateDisabling ResourceState = "Disabling" - ResourceStateEnableFailed ResourceState = "EnableFailed" - ResourceStateEnabling ResourceState = "Enabling" - ResourceStateRunning ResourceState = "Running" - ResourceStateUpdateFailed ResourceState = "UpdateFailed" - ResourceStateUpdating ResourceState = "Updating" -) - -func PossibleValuesForResourceState() []string { - return []string{ - string(ResourceStateCreateFailed), - string(ResourceStateCreating), - string(ResourceStateDeleteFailed), - string(ResourceStateDeleting), - string(ResourceStateDisableFailed), - string(ResourceStateDisabled), - string(ResourceStateDisabling), - string(ResourceStateEnableFailed), - string(ResourceStateEnabling), - string(ResourceStateRunning), - string(ResourceStateUpdateFailed), - string(ResourceStateUpdating), - } -} - -func parseResourceState(input string) (*ResourceState, error) { - vals := map[string]ResourceState{ - "createfailed": ResourceStateCreateFailed, - "creating": ResourceStateCreating, - "deletefailed": ResourceStateDeleteFailed, - "deleting": ResourceStateDeleting, - "disablefailed": ResourceStateDisableFailed, - "disabled": ResourceStateDisabled, - "disabling": ResourceStateDisabling, - "enablefailed": ResourceStateEnableFailed, - "enabling": ResourceStateEnabling, - "running": ResourceStateRunning, - "updatefailed": ResourceStateUpdateFailed, - "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 SkuName string - -const ( - SkuNameEnterpriseEFiveZero SkuName = "Enterprise_E50" - SkuNameEnterpriseEOneZero SkuName = "Enterprise_E10" - SkuNameEnterpriseEOneZeroZero SkuName = "Enterprise_E100" - SkuNameEnterpriseETwoZero SkuName = "Enterprise_E20" - SkuNameEnterpriseFlashFOneFiveZeroZero SkuName = "EnterpriseFlash_F1500" - SkuNameEnterpriseFlashFSevenZeroZero SkuName = "EnterpriseFlash_F700" - SkuNameEnterpriseFlashFThreeZeroZero SkuName = "EnterpriseFlash_F300" -) - -func PossibleValuesForSkuName() []string { - return []string{ - string(SkuNameEnterpriseEFiveZero), - string(SkuNameEnterpriseEOneZero), - string(SkuNameEnterpriseEOneZeroZero), - string(SkuNameEnterpriseETwoZero), - string(SkuNameEnterpriseFlashFOneFiveZeroZero), - string(SkuNameEnterpriseFlashFSevenZeroZero), - string(SkuNameEnterpriseFlashFThreeZeroZero), - } -} - -func parseSkuName(input string) (*SkuName, error) { - vals := map[string]SkuName{ - "enterprise_e50": SkuNameEnterpriseEFiveZero, - "enterprise_e10": SkuNameEnterpriseEOneZero, - "enterprise_e100": SkuNameEnterpriseEOneZeroZero, - "enterprise_e20": SkuNameEnterpriseETwoZero, - "enterpriseflash_f1500": SkuNameEnterpriseFlashFOneFiveZeroZero, - "enterpriseflash_f700": SkuNameEnterpriseFlashFSevenZeroZero, - "enterpriseflash_f300": SkuNameEnterpriseFlashFThreeZeroZero, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := SkuName(input) - return &out, nil -} - -type TlsVersion string - -const ( - TlsVersionOnePointOne TlsVersion = "1.1" - TlsVersionOnePointTwo TlsVersion = "1.2" - TlsVersionOnePointZero TlsVersion = "1.0" -) - -func PossibleValuesForTlsVersion() []string { - return []string{ - string(TlsVersionOnePointOne), - string(TlsVersionOnePointTwo), - string(TlsVersionOnePointZero), - } -} - -func parseTlsVersion(input string) (*TlsVersion, error) { - vals := map[string]TlsVersion{ - "1.1": TlsVersionOnePointOne, - "1.2": TlsVersionOnePointTwo, - "1.0": TlsVersionOnePointZero, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := TlsVersion(input) - return &out, nil -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_database.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_database.go deleted file mode 100644 index a44834a9fc21..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_database.go +++ /dev/null @@ -1,137 +0,0 @@ -package redisenterprise - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = DatabaseId{} - -// DatabaseId is a struct representing the Resource ID for a Database -type DatabaseId struct { - SubscriptionId string - ResourceGroupName string - ClusterName string - DatabaseName string -} - -// NewDatabaseID returns a new DatabaseId struct -func NewDatabaseID(subscriptionId string, resourceGroupName string, clusterName string, databaseName string) DatabaseId { - return DatabaseId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ClusterName: clusterName, - DatabaseName: databaseName, - } -} - -// ParseDatabaseID parses 'input' into a DatabaseId -func ParseDatabaseID(input string) (*DatabaseId, error) { - parser := resourceids.NewParserFromResourceIdType(DatabaseId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := DatabaseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - if id.DatabaseName, ok = parsed.Parsed["databaseName"]; !ok { - return nil, fmt.Errorf("the segment 'databaseName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseDatabaseIDInsensitively parses 'input' case-insensitively into a DatabaseId -// note: this method should only be used for API response data and not user input -func ParseDatabaseIDInsensitively(input string) (*DatabaseId, error) { - parser := resourceids.NewParserFromResourceIdType(DatabaseId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := DatabaseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - if id.DatabaseName, ok = parsed.Parsed["databaseName"]; !ok { - return nil, fmt.Errorf("the segment 'databaseName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateDatabaseID checks that 'input' can be parsed as a Database ID -func ValidateDatabaseID(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 := ParseDatabaseID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Database ID -func (id DatabaseId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Cache/redisEnterprise/%s/databases/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName, id.DatabaseName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Database ID -func (id DatabaseId) 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("staticMicrosoftCache", "Microsoft.Cache", "Microsoft.Cache"), - resourceids.StaticSegment("staticRedisEnterprise", "redisEnterprise", "redisEnterprise"), - resourceids.UserSpecifiedSegment("clusterName", "clusterValue"), - resourceids.StaticSegment("staticDatabases", "databases", "databases"), - resourceids.UserSpecifiedSegment("databaseName", "databaseValue"), - } -} - -// String returns a human-readable description of this Database ID -func (id DatabaseId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Cluster Name: %q", id.ClusterName), - fmt.Sprintf("Database Name: %q", id.DatabaseName), - } - return fmt.Sprintf("Database (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_database_test.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_database_test.go deleted file mode 100644 index f22949b1fa2e..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_database_test.go +++ /dev/null @@ -1,324 +0,0 @@ -package redisenterprise - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = DatabaseId{} - -func TestNewDatabaseID(t *testing.T) { - id := NewDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue", "databaseValue") - - 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.ClusterName != "clusterValue" { - t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterValue") - } - - if id.DatabaseName != "databaseValue" { - t.Fatalf("Expected %q but got %q for Segment 'DatabaseName'", id.DatabaseName, "databaseValue") - } -} - -func TestFormatDatabaseID(t *testing.T) { - actual := NewDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue", "databaseValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases/databaseValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseDatabaseID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *DatabaseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases/databaseValue", - Expected: &DatabaseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - DatabaseName: "databaseValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases/databaseValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseDatabaseID(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - if actual.DatabaseName != v.Expected.DatabaseName { - t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) - } - - } -} - -func TestParseDatabaseIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *DatabaseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/dAtAbAsEs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases/databaseValue", - Expected: &DatabaseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - DatabaseName: "databaseValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases/databaseValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/dAtAbAsEs/dAtAbAsEvAlUe", - Expected: &DatabaseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ClusterName: "cLuStErVaLuE", - DatabaseName: "dAtAbAsEvAlUe", - }, - }, - { - // 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.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/dAtAbAsEs/dAtAbAsEvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseDatabaseIDInsensitively(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - if actual.DatabaseName != v.Expected.DatabaseName { - t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) - } - - } -} - -func TestSegmentsForDatabaseId(t *testing.T) { - segments := DatabaseId{}.Segments() - if len(segments) == 0 { - t.Fatalf("DatabaseId 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/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_redisenterprise.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_redisenterprise.go deleted file mode 100644 index 64e4baba8d9c..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_redisenterprise.go +++ /dev/null @@ -1,124 +0,0 @@ -package redisenterprise - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = RedisEnterpriseId{} - -// RedisEnterpriseId is a struct representing the Resource ID for a Redis Enterprise -type RedisEnterpriseId struct { - SubscriptionId string - ResourceGroupName string - ClusterName string -} - -// NewRedisEnterpriseID returns a new RedisEnterpriseId struct -func NewRedisEnterpriseID(subscriptionId string, resourceGroupName string, clusterName string) RedisEnterpriseId { - return RedisEnterpriseId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ClusterName: clusterName, - } -} - -// ParseRedisEnterpriseID parses 'input' into a RedisEnterpriseId -func ParseRedisEnterpriseID(input string) (*RedisEnterpriseId, error) { - parser := resourceids.NewParserFromResourceIdType(RedisEnterpriseId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := RedisEnterpriseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseRedisEnterpriseIDInsensitively parses 'input' case-insensitively into a RedisEnterpriseId -// note: this method should only be used for API response data and not user input -func ParseRedisEnterpriseIDInsensitively(input string) (*RedisEnterpriseId, error) { - parser := resourceids.NewParserFromResourceIdType(RedisEnterpriseId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := RedisEnterpriseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateRedisEnterpriseID checks that 'input' can be parsed as a Redis Enterprise ID -func ValidateRedisEnterpriseID(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 := ParseRedisEnterpriseID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Redis Enterprise ID -func (id RedisEnterpriseId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Cache/redisEnterprise/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Redis Enterprise ID -func (id RedisEnterpriseId) 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("staticMicrosoftCache", "Microsoft.Cache", "Microsoft.Cache"), - resourceids.StaticSegment("staticRedisEnterprise", "redisEnterprise", "redisEnterprise"), - resourceids.UserSpecifiedSegment("clusterName", "clusterValue"), - } -} - -// String returns a human-readable description of this Redis Enterprise ID -func (id RedisEnterpriseId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Cluster Name: %q", id.ClusterName), - } - return fmt.Sprintf("Redis Enterprise (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_redisenterprise_test.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_redisenterprise_test.go deleted file mode 100644 index 4aae3e5b6ed7..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_redisenterprise_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package redisenterprise - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = RedisEnterpriseId{} - -func TestNewRedisEnterpriseID(t *testing.T) { - id := NewRedisEnterpriseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue") - - 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.ClusterName != "clusterValue" { - t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterValue") - } -} - -func TestFormatRedisEnterpriseID(t *testing.T) { - actual := NewRedisEnterpriseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseRedisEnterpriseID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *RedisEnterpriseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseRedisEnterpriseID(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - } -} - -func TestParseRedisEnterpriseIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *RedisEnterpriseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ClusterName: "cLuStErVaLuE", - }, - }, - { - // 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.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseRedisEnterpriseIDInsensitively(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - } -} - -func TestSegmentsForRedisEnterpriseId(t *testing.T) { - segments := RedisEnterpriseId{}.Segments() - if len(segments) == 0 { - t.Fatalf("RedisEnterpriseId 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/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_resourcegroup.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_resourcegroup.go deleted file mode 100644 index a01ae1b25a5c..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_resourcegroup.go +++ /dev/null @@ -1,109 +0,0 @@ -package redisenterprise - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = ResourceGroupId{} - -// ResourceGroupId is a struct representing the Resource ID for a Resource Group -type ResourceGroupId struct { - SubscriptionId string - ResourceGroupName string -} - -// NewResourceGroupID returns a new ResourceGroupId struct -func NewResourceGroupID(subscriptionId string, resourceGroupName string) ResourceGroupId { - return ResourceGroupId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - } -} - -// ParseResourceGroupID parses 'input' into a ResourceGroupId -func ParseResourceGroupID(input string) (*ResourceGroupId, error) { - parser := resourceids.NewParserFromResourceIdType(ResourceGroupId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := ResourceGroupId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseResourceGroupIDInsensitively parses 'input' case-insensitively into a ResourceGroupId -// note: this method should only be used for API response data and not user input -func ParseResourceGroupIDInsensitively(input string) (*ResourceGroupId, error) { - parser := resourceids.NewParserFromResourceIdType(ResourceGroupId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := ResourceGroupId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateResourceGroupID checks that 'input' can be parsed as a Resource Group ID -func ValidateResourceGroupID(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 := ParseResourceGroupID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Resource Group ID -func (id ResourceGroupId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Resource Group ID -func (id ResourceGroupId) 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"), - } -} - -// String returns a human-readable description of this Resource Group ID -func (id ResourceGroupId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - } - return fmt.Sprintf("Resource Group (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_resourcegroup_test.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_resourcegroup_test.go deleted file mode 100644 index f51427ea8e1e..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_resourcegroup_test.go +++ /dev/null @@ -1,204 +0,0 @@ -package redisenterprise - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = ResourceGroupId{} - -func TestNewResourceGroupID(t *testing.T) { - id := NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") - - 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") - } -} - -func TestFormatResourceGroupID(t *testing.T) { - actual := NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseResourceGroupID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ResourceGroupId - }{ - { - // 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, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Expected: &ResourceGroupId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseResourceGroupID(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) - } - - } -} - -func TestParseResourceGroupIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ResourceGroupId - }{ - { - // 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, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Expected: &ResourceGroupId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Expected: &ResourceGroupId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseResourceGroupIDInsensitively(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) - } - - } -} - -func TestSegmentsForResourceGroupId(t *testing.T) { - segments := ResourceGroupId{}.Segments() - if len(segments) == 0 { - t.Fatalf("ResourceGroupId 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/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_subscription.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_subscription.go deleted file mode 100644 index c241b9464964..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_subscription.go +++ /dev/null @@ -1,96 +0,0 @@ -package redisenterprise - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = SubscriptionId{} - -// SubscriptionId is a struct representing the Resource ID for a Subscription -type SubscriptionId struct { - SubscriptionId string -} - -// NewSubscriptionID returns a new SubscriptionId struct -func NewSubscriptionID(subscriptionId string) SubscriptionId { - return SubscriptionId{ - SubscriptionId: subscriptionId, - } -} - -// ParseSubscriptionID parses 'input' into a SubscriptionId -func ParseSubscriptionID(input string) (*SubscriptionId, error) { - parser := resourceids.NewParserFromResourceIdType(SubscriptionId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := SubscriptionId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseSubscriptionIDInsensitively parses 'input' case-insensitively into a SubscriptionId -// note: this method should only be used for API response data and not user input -func ParseSubscriptionIDInsensitively(input string) (*SubscriptionId, error) { - parser := resourceids.NewParserFromResourceIdType(SubscriptionId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := SubscriptionId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateSubscriptionID checks that 'input' can be parsed as a Subscription ID -func ValidateSubscriptionID(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 := ParseSubscriptionID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Subscription ID -func (id SubscriptionId) ID() string { - fmtString := "/subscriptions/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId) -} - -// Segments returns a slice of Resource ID Segments which comprise this Subscription ID -func (id SubscriptionId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - } -} - -// String returns a human-readable description of this Subscription ID -func (id SubscriptionId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - } - return fmt.Sprintf("Subscription (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_subscription_test.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_subscription_test.go deleted file mode 100644 index d3519f392143..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/id_subscription_test.go +++ /dev/null @@ -1,159 +0,0 @@ -package redisenterprise - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = SubscriptionId{} - -func TestNewSubscriptionID(t *testing.T) { - id := NewSubscriptionID("12345678-1234-9876-4563-123456789012") - - 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") - } -} - -func TestFormatSubscriptionID(t *testing.T) { - actual := NewSubscriptionID("12345678-1234-9876-4563-123456789012").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseSubscriptionID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *SubscriptionId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Expected: &SubscriptionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseSubscriptionID(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) - } - - } -} - -func TestParseSubscriptionIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *SubscriptionId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Expected: &SubscriptionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Expected: &SubscriptionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseSubscriptionIDInsensitively(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) - } - - } -} - -func TestSegmentsForSubscriptionId(t *testing.T) { - segments := SubscriptionId{}.Segments() - if len(segments) == 0 { - t.Fatalf("SubscriptionId 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/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_create_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_create_autorest.go deleted file mode 100644 index a55b54cf8adc..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_create_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type CreateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Create ... -func (c RedisEnterpriseClient) Create(ctx context.Context, id RedisEnterpriseId, input Cluster) (result CreateResponse, err error) { - req, err := c.preparerForCreate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "Create", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "Create", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateThenPoll performs Create then polls until it's completed -func (c RedisEnterpriseClient) CreateThenPoll(ctx context.Context, id RedisEnterpriseId, input Cluster) error { - result, err := c.Create(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Create: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Create: %+v", err) - } - - return nil -} - -// preparerForCreate prepares the Create request. -func (c RedisEnterpriseClient) preparerForCreate(ctx context.Context, id RedisEnterpriseId, input Cluster) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreate sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (c RedisEnterpriseClient) senderForCreate(ctx context.Context, req *http.Request) (future CreateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databasescreate_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databasescreate_autorest.go deleted file mode 100644 index da21f43c9188..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databasescreate_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type DatabasesCreateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DatabasesCreate ... -func (c RedisEnterpriseClient) DatabasesCreate(ctx context.Context, id DatabaseId, input Database) (result DatabasesCreateResponse, err error) { - req, err := c.preparerForDatabasesCreate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesCreate", nil, "Failure preparing request") - return - } - - result, err = c.senderForDatabasesCreate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesCreate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DatabasesCreateThenPoll performs DatabasesCreate then polls until it's completed -func (c RedisEnterpriseClient) DatabasesCreateThenPoll(ctx context.Context, id DatabaseId, input Database) error { - result, err := c.DatabasesCreate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing DatabasesCreate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DatabasesCreate: %+v", err) - } - - return nil -} - -// preparerForDatabasesCreate prepares the DatabasesCreate request. -func (c RedisEnterpriseClient) preparerForDatabasesCreate(ctx context.Context, id DatabaseId, input Database) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDatabasesCreate sends the DatabasesCreate request. The method will close the -// http.Response Body if it receives an error. -func (c RedisEnterpriseClient) senderForDatabasesCreate(ctx context.Context, req *http.Request) (future DatabasesCreateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databasesdelete_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databasesdelete_autorest.go deleted file mode 100644 index 9dcac5f4302e..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databasesdelete_autorest.go +++ /dev/null @@ -1,73 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type DatabasesDeleteResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DatabasesDelete ... -func (c RedisEnterpriseClient) DatabasesDelete(ctx context.Context, id DatabaseId) (result DatabasesDeleteResponse, err error) { - req, err := c.preparerForDatabasesDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesDelete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDatabasesDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesDelete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DatabasesDeleteThenPoll performs DatabasesDelete then polls until it's completed -func (c RedisEnterpriseClient) DatabasesDeleteThenPoll(ctx context.Context, id DatabaseId) error { - result, err := c.DatabasesDelete(ctx, id) - if err != nil { - return fmt.Errorf("performing DatabasesDelete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DatabasesDelete: %+v", err) - } - - return nil -} - -// preparerForDatabasesDelete prepares the DatabasesDelete request. -func (c RedisEnterpriseClient) preparerForDatabasesDelete(ctx context.Context, id DatabaseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDatabasesDelete sends the DatabasesDelete request. The method will close the -// http.Response Body if it receives an error. -func (c RedisEnterpriseClient) senderForDatabasesDelete(ctx context.Context, req *http.Request) (future DatabasesDeleteResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databasesexport_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databasesexport_autorest.go deleted file mode 100644 index 18a15e938de3..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databasesexport_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type DatabasesExportResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DatabasesExport ... -func (c RedisEnterpriseClient) DatabasesExport(ctx context.Context, id DatabaseId, input ExportClusterParameters) (result DatabasesExportResponse, err error) { - req, err := c.preparerForDatabasesExport(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesExport", nil, "Failure preparing request") - return - } - - result, err = c.senderForDatabasesExport(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesExport", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DatabasesExportThenPoll performs DatabasesExport then polls until it's completed -func (c RedisEnterpriseClient) DatabasesExportThenPoll(ctx context.Context, id DatabaseId, input ExportClusterParameters) error { - result, err := c.DatabasesExport(ctx, id, input) - if err != nil { - return fmt.Errorf("performing DatabasesExport: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DatabasesExport: %+v", err) - } - - return nil -} - -// preparerForDatabasesExport prepares the DatabasesExport request. -func (c RedisEnterpriseClient) preparerForDatabasesExport(ctx context.Context, id DatabaseId, input ExportClusterParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/export", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDatabasesExport sends the DatabasesExport request. The method will close the -// http.Response Body if it receives an error. -func (c RedisEnterpriseClient) senderForDatabasesExport(ctx context.Context, req *http.Request) (future DatabasesExportResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databasesget_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databasesget_autorest.go deleted file mode 100644 index 708cca55e0fb..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databasesget_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package redisenterprise - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type DatabasesGetResponse struct { - HttpResponse *http.Response - Model *Database -} - -// DatabasesGet ... -func (c RedisEnterpriseClient) DatabasesGet(ctx context.Context, id DatabaseId) (result DatabasesGetResponse, err error) { - req, err := c.preparerForDatabasesGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDatabasesGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDatabasesGet prepares the DatabasesGet request. -func (c RedisEnterpriseClient) preparerForDatabasesGet(ctx context.Context, id DatabaseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDatabasesGet handles the response to the DatabasesGet request. The method always -// closes the http.Response Body. -func (c RedisEnterpriseClient) responderForDatabasesGet(resp *http.Response) (result DatabasesGetResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databasesimport_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databasesimport_autorest.go deleted file mode 100644 index 97fd8b97bc74..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databasesimport_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type DatabasesImportResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DatabasesImport ... -func (c RedisEnterpriseClient) DatabasesImport(ctx context.Context, id DatabaseId, input ImportClusterParameters) (result DatabasesImportResponse, err error) { - req, err := c.preparerForDatabasesImport(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesImport", nil, "Failure preparing request") - return - } - - result, err = c.senderForDatabasesImport(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesImport", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DatabasesImportThenPoll performs DatabasesImport then polls until it's completed -func (c RedisEnterpriseClient) DatabasesImportThenPoll(ctx context.Context, id DatabaseId, input ImportClusterParameters) error { - result, err := c.DatabasesImport(ctx, id, input) - if err != nil { - return fmt.Errorf("performing DatabasesImport: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DatabasesImport: %+v", err) - } - - return nil -} - -// preparerForDatabasesImport prepares the DatabasesImport request. -func (c RedisEnterpriseClient) preparerForDatabasesImport(ctx context.Context, id DatabaseId, input ImportClusterParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/import", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDatabasesImport sends the DatabasesImport request. The method will close the -// http.Response Body if it receives an error. -func (c RedisEnterpriseClient) senderForDatabasesImport(ctx context.Context, req *http.Request) (future DatabasesImportResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databaseslistbycluster_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databaseslistbycluster_autorest.go deleted file mode 100644 index 20a1198b8dde..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databaseslistbycluster_autorest.go +++ /dev/null @@ -1,183 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type DatabasesListByClusterResponse struct { - HttpResponse *http.Response - Model *[]Database - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (DatabasesListByClusterResponse, error) -} - -type DatabasesListByClusterCompleteResult struct { - Items []Database -} - -func (r DatabasesListByClusterResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r DatabasesListByClusterResponse) LoadMore(ctx context.Context) (resp DatabasesListByClusterResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// DatabasesListByCluster ... -func (c RedisEnterpriseClient) DatabasesListByCluster(ctx context.Context, id RedisEnterpriseId) (resp DatabasesListByClusterResponse, err error) { - req, err := c.preparerForDatabasesListByCluster(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesListByCluster", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesListByCluster", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForDatabasesListByCluster(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesListByCluster", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// DatabasesListByClusterComplete retrieves all of the results into a single object -func (c RedisEnterpriseClient) DatabasesListByClusterComplete(ctx context.Context, id RedisEnterpriseId) (DatabasesListByClusterCompleteResult, error) { - return c.DatabasesListByClusterCompleteMatchingPredicate(ctx, id, DatabasePredicate{}) -} - -// DatabasesListByClusterCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c RedisEnterpriseClient) DatabasesListByClusterCompleteMatchingPredicate(ctx context.Context, id RedisEnterpriseId, predicate DatabasePredicate) (resp DatabasesListByClusterCompleteResult, err error) { - items := make([]Database, 0) - - page, err := c.DatabasesListByCluster(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := DatabasesListByClusterCompleteResult{ - Items: items, - } - return out, nil -} - -// preparerForDatabasesListByCluster prepares the DatabasesListByCluster request. -func (c RedisEnterpriseClient) preparerForDatabasesListByCluster(ctx context.Context, id RedisEnterpriseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/databases", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForDatabasesListByClusterWithNextLink prepares the DatabasesListByCluster request with the given nextLink token. -func (c RedisEnterpriseClient) preparerForDatabasesListByClusterWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDatabasesListByCluster handles the response to the DatabasesListByCluster request. The method always -// closes the http.Response Body. -func (c RedisEnterpriseClient) responderForDatabasesListByCluster(resp *http.Response) (result DatabasesListByClusterResponse, err error) { - type page struct { - Values []Database `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result DatabasesListByClusterResponse, err error) { - req, err := c.preparerForDatabasesListByClusterWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesListByCluster", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesListByCluster", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDatabasesListByCluster(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesListByCluster", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databaseslistkeys_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databaseslistkeys_autorest.go deleted file mode 100644 index 0d6ba1e7b2f7..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databaseslistkeys_autorest.go +++ /dev/null @@ -1,65 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type DatabasesListKeysResponse struct { - HttpResponse *http.Response - Model *AccessKeys -} - -// DatabasesListKeys ... -func (c RedisEnterpriseClient) DatabasesListKeys(ctx context.Context, id DatabaseId) (result DatabasesListKeysResponse, err error) { - req, err := c.preparerForDatabasesListKeys(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesListKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesListKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDatabasesListKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesListKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDatabasesListKeys prepares the DatabasesListKeys request. -func (c RedisEnterpriseClient) preparerForDatabasesListKeys(ctx context.Context, id DatabaseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listKeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDatabasesListKeys handles the response to the DatabasesListKeys request. The method always -// closes the http.Response Body. -func (c RedisEnterpriseClient) responderForDatabasesListKeys(resp *http.Response) (result DatabasesListKeysResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databasesregeneratekey_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databasesregeneratekey_autorest.go deleted file mode 100644 index 312b8ca2d129..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databasesregeneratekey_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type DatabasesRegenerateKeyResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DatabasesRegenerateKey ... -func (c RedisEnterpriseClient) DatabasesRegenerateKey(ctx context.Context, id DatabaseId, input RegenerateKeyParameters) (result DatabasesRegenerateKeyResponse, err error) { - req, err := c.preparerForDatabasesRegenerateKey(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesRegenerateKey", nil, "Failure preparing request") - return - } - - result, err = c.senderForDatabasesRegenerateKey(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesRegenerateKey", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DatabasesRegenerateKeyThenPoll performs DatabasesRegenerateKey then polls until it's completed -func (c RedisEnterpriseClient) DatabasesRegenerateKeyThenPoll(ctx context.Context, id DatabaseId, input RegenerateKeyParameters) error { - result, err := c.DatabasesRegenerateKey(ctx, id, input) - if err != nil { - return fmt.Errorf("performing DatabasesRegenerateKey: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DatabasesRegenerateKey: %+v", err) - } - - return nil -} - -// preparerForDatabasesRegenerateKey prepares the DatabasesRegenerateKey request. -func (c RedisEnterpriseClient) preparerForDatabasesRegenerateKey(ctx context.Context, id DatabaseId, input RegenerateKeyParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/regenerateKey", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDatabasesRegenerateKey sends the DatabasesRegenerateKey request. The method will close the -// http.Response Body if it receives an error. -func (c RedisEnterpriseClient) senderForDatabasesRegenerateKey(ctx context.Context, req *http.Request) (future DatabasesRegenerateKeyResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databasesupdate_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databasesupdate_autorest.go deleted file mode 100644 index 7de76bb70b84..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_databasesupdate_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type DatabasesUpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DatabasesUpdate ... -func (c RedisEnterpriseClient) DatabasesUpdate(ctx context.Context, id DatabaseId, input DatabaseUpdate) (result DatabasesUpdateResponse, err error) { - req, err := c.preparerForDatabasesUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForDatabasesUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DatabasesUpdateThenPoll performs DatabasesUpdate then polls until it's completed -func (c RedisEnterpriseClient) DatabasesUpdateThenPoll(ctx context.Context, id DatabaseId, input DatabaseUpdate) error { - result, err := c.DatabasesUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing DatabasesUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DatabasesUpdate: %+v", err) - } - - return nil -} - -// preparerForDatabasesUpdate prepares the DatabasesUpdate request. -func (c RedisEnterpriseClient) preparerForDatabasesUpdate(ctx context.Context, id DatabaseId, input DatabaseUpdate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDatabasesUpdate sends the DatabasesUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c RedisEnterpriseClient) senderForDatabasesUpdate(ctx context.Context, req *http.Request) (future DatabasesUpdateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_delete_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_delete_autorest.go deleted file mode 100644 index 652b809b4f91..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_delete_autorest.go +++ /dev/null @@ -1,73 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type DeleteResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c RedisEnterpriseClient) Delete(ctx context.Context, id RedisEnterpriseId) (result DeleteResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c RedisEnterpriseClient) DeleteThenPoll(ctx context.Context, id RedisEnterpriseId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c RedisEnterpriseClient) preparerForDelete(ctx context.Context, id RedisEnterpriseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c RedisEnterpriseClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_get_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_get_autorest.go deleted file mode 100644 index 4ba661142bd8..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_get_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package redisenterprise - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type GetResponse struct { - HttpResponse *http.Response - Model *Cluster -} - -// Get ... -func (c RedisEnterpriseClient) Get(ctx context.Context, id RedisEnterpriseId) (result GetResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c RedisEnterpriseClient) preparerForGet(ctx context.Context, id RedisEnterpriseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c RedisEnterpriseClient) responderForGet(resp *http.Response) (result GetResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_list_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_list_autorest.go deleted file mode 100644 index adda8bb37d35..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_list_autorest.go +++ /dev/null @@ -1,183 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ListResponse struct { - HttpResponse *http.Response - Model *[]Cluster - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListResponse, error) -} - -type ListCompleteResult struct { - Items []Cluster -} - -func (r ListResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListResponse) LoadMore(ctx context.Context) (resp ListResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c RedisEnterpriseClient) List(ctx context.Context, id SubscriptionId) (resp ListResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c RedisEnterpriseClient) ListComplete(ctx context.Context, id SubscriptionId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, ClusterPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c RedisEnterpriseClient) ListCompleteMatchingPredicate(ctx context.Context, id SubscriptionId, predicate ClusterPredicate) (resp ListCompleteResult, err error) { - items := make([]Cluster, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} - -// preparerForList prepares the List request. -func (c RedisEnterpriseClient) preparerForList(ctx context.Context, id SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Cache/redisEnterprise", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c RedisEnterpriseClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c RedisEnterpriseClient) responderForList(resp *http.Response) (result ListResponse, err error) { - type page struct { - Values []Cluster `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_listbyresourcegroup_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_listbyresourcegroup_autorest.go deleted file mode 100644 index affd5991dd5c..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,183 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ListByResourceGroupResponse struct { - HttpResponse *http.Response - Model *[]Cluster - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []Cluster -} - -func (r ListByResourceGroupResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResourceGroup ... -func (c RedisEnterpriseClient) ListByResourceGroup(ctx context.Context, id ResourceGroupId) (resp ListByResourceGroupResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c RedisEnterpriseClient) ListByResourceGroupComplete(ctx context.Context, id ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ClusterPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c RedisEnterpriseClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id ResourceGroupId, predicate ClusterPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]Cluster, 0) - - page, err := c.ListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c RedisEnterpriseClient) preparerForListByResourceGroup(ctx context.Context, id ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Cache/redisEnterprise", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c RedisEnterpriseClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c RedisEnterpriseClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupResponse, err error) { - type page struct { - Values []Cluster `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_update_autorest.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_update_autorest.go deleted file mode 100644 index b61326972782..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/method_update_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type UpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Update ... -func (c RedisEnterpriseClient) Update(ctx context.Context, id RedisEnterpriseId, input ClusterUpdate) (result UpdateResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c RedisEnterpriseClient) UpdateThenPoll(ctx context.Context, id RedisEnterpriseId, input ClusterUpdate) error { - result, err := c.Update(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c RedisEnterpriseClient) preparerForUpdate(ctx context.Context, id RedisEnterpriseId, input ClusterUpdate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c RedisEnterpriseClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_accesskeys.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_accesskeys.go deleted file mode 100644 index 1df702dd4e7d..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_accesskeys.go +++ /dev/null @@ -1,6 +0,0 @@ -package redisenterprise - -type AccessKeys struct { - PrimaryKey *string `json:"primaryKey,omitempty"` - SecondaryKey *string `json:"secondaryKey,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_cluster.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_cluster.go deleted file mode 100644 index ae1f3ead7753..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_cluster.go +++ /dev/null @@ -1,12 +0,0 @@ -package redisenterprise - -type Cluster struct { - Id *string `json:"id,omitempty"` - Location string `json:"location"` - Name *string `json:"name,omitempty"` - Properties *ClusterProperties `json:"properties,omitempty"` - Sku Sku `json:"sku"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` - Zones *[]string `json:"zones,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_clusterproperties.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_clusterproperties.go deleted file mode 100644 index dc3870ca8650..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_clusterproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package redisenterprise - -type ClusterProperties struct { - HostName *string `json:"hostName,omitempty"` - MinimumTlsVersion *TlsVersion `json:"minimumTlsVersion,omitempty"` - PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` - RedisVersion *string `json:"redisVersion,omitempty"` - ResourceState *ResourceState `json:"resourceState,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_clusterupdate.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_clusterupdate.go deleted file mode 100644 index 1bcb8c42d55e..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_clusterupdate.go +++ /dev/null @@ -1,7 +0,0 @@ -package redisenterprise - -type ClusterUpdate struct { - Properties *ClusterProperties `json:"properties,omitempty"` - Sku *Sku `json:"sku,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_database.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_database.go deleted file mode 100644 index 4b38033a9585..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_database.go +++ /dev/null @@ -1,8 +0,0 @@ -package redisenterprise - -type Database struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *DatabaseProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_databaseproperties.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_databaseproperties.go deleted file mode 100644 index 544786f0cadc..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_databaseproperties.go +++ /dev/null @@ -1,12 +0,0 @@ -package redisenterprise - -type DatabaseProperties struct { - ClientProtocol *Protocol `json:"clientProtocol,omitempty"` - ClusteringPolicy *ClusteringPolicy `json:"clusteringPolicy,omitempty"` - EvictionPolicy *EvictionPolicy `json:"evictionPolicy,omitempty"` - Modules *[]Module `json:"modules,omitempty"` - Persistence *Persistence `json:"persistence,omitempty"` - Port *int64 `json:"port,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` - ResourceState *ResourceState `json:"resourceState,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_databaseupdate.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_databaseupdate.go deleted file mode 100644 index d607de221774..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_databaseupdate.go +++ /dev/null @@ -1,5 +0,0 @@ -package redisenterprise - -type DatabaseUpdate struct { - Properties *DatabaseProperties `json:"properties,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_exportclusterparameters.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_exportclusterparameters.go deleted file mode 100644 index d057282a827a..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_exportclusterparameters.go +++ /dev/null @@ -1,5 +0,0 @@ -package redisenterprise - -type ExportClusterParameters struct { - SasUri string `json:"sasUri"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_importclusterparameters.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_importclusterparameters.go deleted file mode 100644 index a4cddfd19e6b..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_importclusterparameters.go +++ /dev/null @@ -1,5 +0,0 @@ -package redisenterprise - -type ImportClusterParameters struct { - SasUris []string `json:"sasUris"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_module.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_module.go deleted file mode 100644 index eccbce6aff7d..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_module.go +++ /dev/null @@ -1,7 +0,0 @@ -package redisenterprise - -type Module struct { - Args *string `json:"args,omitempty"` - Name string `json:"name"` - Version *string `json:"version,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_persistence.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_persistence.go deleted file mode 100644 index 8666152b6764..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_persistence.go +++ /dev/null @@ -1,8 +0,0 @@ -package redisenterprise - -type Persistence struct { - AofEnabled *bool `json:"aofEnabled,omitempty"` - AofFrequency *AofFrequency `json:"aofFrequency,omitempty"` - RdbEnabled *bool `json:"rdbEnabled,omitempty"` - RdbFrequency *RdbFrequency `json:"rdbFrequency,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_privateendpoint.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_privateendpoint.go deleted file mode 100644 index df570da01647..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_privateendpoint.go +++ /dev/null @@ -1,5 +0,0 @@ -package redisenterprise - -type PrivateEndpoint struct { - Id *string `json:"id,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_privateendpointconnection.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_privateendpointconnection.go deleted file mode 100644 index f4cbd5e47f9b..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_privateendpointconnection.go +++ /dev/null @@ -1,8 +0,0 @@ -package redisenterprise - -type PrivateEndpointConnection struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_privateendpointconnectionproperties.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_privateendpointconnectionproperties.go deleted file mode 100644 index 197d3da189b3..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_privateendpointconnectionproperties.go +++ /dev/null @@ -1,7 +0,0 @@ -package redisenterprise - -type PrivateEndpointConnectionProperties struct { - PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` - PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` - ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_privatelinkserviceconnectionstate.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_privatelinkserviceconnectionstate.go deleted file mode 100644 index 926598e9de8a..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_privatelinkserviceconnectionstate.go +++ /dev/null @@ -1,7 +0,0 @@ -package redisenterprise - -type PrivateLinkServiceConnectionState struct { - ActionsRequired *string `json:"actionsRequired,omitempty"` - Description *string `json:"description,omitempty"` - Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_regeneratekeyparameters.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_regeneratekeyparameters.go deleted file mode 100644 index 55d142131e76..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_regeneratekeyparameters.go +++ /dev/null @@ -1,5 +0,0 @@ -package redisenterprise - -type RegenerateKeyParameters struct { - KeyType AccessKeyType `json:"keyType"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_sku.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_sku.go deleted file mode 100644 index 16e22e0c4f51..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/model_sku.go +++ /dev/null @@ -1,6 +0,0 @@ -package redisenterprise - -type Sku struct { - Capacity *int64 `json:"capacity,omitempty"` - Name SkuName `json:"name"` -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/predicates.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/predicates.go deleted file mode 100644 index 3451ea28bb59..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/predicates.go +++ /dev/null @@ -1,52 +0,0 @@ -package redisenterprise - -type ClusterPredicate struct { - Id *string - Location *string - Name *string - Type *string -} - -func (p ClusterPredicate) Matches(input Cluster) bool { - - if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { - return false - } - - if p.Location != nil && *p.Location != input.Location { - return false - } - - if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { - return false - } - - return true -} - -type DatabasePredicate struct { - Id *string - Name *string - Type *string -} - -func (p DatabasePredicate) Matches(input Database) bool { - - if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { - return false - } - - if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { - return false - } - - return true -} diff --git a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/version.go b/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/version.go deleted file mode 100644 index 492aa5270a39..000000000000 --- a/internal/services/redisenterprise/sdk/2021-08-01/redisenterprise/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package redisenterprise - -import "fmt" - -const defaultApiVersion = "2021-08-01" - -func userAgent() string { - return fmt.Sprintf("pandora/redisenterprise/%s", defaultApiVersion) -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/client.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/client.go deleted file mode 100644 index 99bdded9cda5..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package databases - -import "github.com/Azure/go-autorest/autorest" - -type DatabasesClient struct { - Client autorest.Client - baseUri string -} - -func NewDatabasesClientWithBaseURI(endpoint string) DatabasesClient { - return DatabasesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/constants.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/constants.go deleted file mode 100644 index 5f2000779420..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/constants.go +++ /dev/null @@ -1,327 +0,0 @@ -package databases - -import "strings" - -type AccessKeyType string - -const ( - AccessKeyTypePrimary AccessKeyType = "Primary" - AccessKeyTypeSecondary AccessKeyType = "Secondary" -) - -func PossibleValuesForAccessKeyType() []string { - return []string{ - string(AccessKeyTypePrimary), - string(AccessKeyTypeSecondary), - } -} - -func parseAccessKeyType(input string) (*AccessKeyType, error) { - vals := map[string]AccessKeyType{ - "primary": AccessKeyTypePrimary, - "secondary": AccessKeyTypeSecondary, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := AccessKeyType(input) - return &out, nil -} - -type AofFrequency string - -const ( - AofFrequencyAlways AofFrequency = "always" - AofFrequencyOnes AofFrequency = "1s" -) - -func PossibleValuesForAofFrequency() []string { - return []string{ - string(AofFrequencyAlways), - string(AofFrequencyOnes), - } -} - -func parseAofFrequency(input string) (*AofFrequency, error) { - vals := map[string]AofFrequency{ - "always": AofFrequencyAlways, - "1s": AofFrequencyOnes, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := AofFrequency(input) - return &out, nil -} - -type ClusteringPolicy string - -const ( - ClusteringPolicyEnterpriseCluster ClusteringPolicy = "EnterpriseCluster" - ClusteringPolicyOSSCluster ClusteringPolicy = "OSSCluster" -) - -func PossibleValuesForClusteringPolicy() []string { - return []string{ - string(ClusteringPolicyEnterpriseCluster), - string(ClusteringPolicyOSSCluster), - } -} - -func parseClusteringPolicy(input string) (*ClusteringPolicy, error) { - vals := map[string]ClusteringPolicy{ - "enterprisecluster": ClusteringPolicyEnterpriseCluster, - "osscluster": ClusteringPolicyOSSCluster, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ClusteringPolicy(input) - return &out, nil -} - -type EvictionPolicy string - -const ( - EvictionPolicyAllKeysLFU EvictionPolicy = "AllKeysLFU" - EvictionPolicyAllKeysLRU EvictionPolicy = "AllKeysLRU" - EvictionPolicyAllKeysRandom EvictionPolicy = "AllKeysRandom" - EvictionPolicyNoEviction EvictionPolicy = "NoEviction" - EvictionPolicyVolatileLFU EvictionPolicy = "VolatileLFU" - EvictionPolicyVolatileLRU EvictionPolicy = "VolatileLRU" - EvictionPolicyVolatileRandom EvictionPolicy = "VolatileRandom" - EvictionPolicyVolatileTTL EvictionPolicy = "VolatileTTL" -) - -func PossibleValuesForEvictionPolicy() []string { - return []string{ - string(EvictionPolicyAllKeysLFU), - string(EvictionPolicyAllKeysLRU), - string(EvictionPolicyAllKeysRandom), - string(EvictionPolicyNoEviction), - string(EvictionPolicyVolatileLFU), - string(EvictionPolicyVolatileLRU), - string(EvictionPolicyVolatileRandom), - string(EvictionPolicyVolatileTTL), - } -} - -func parseEvictionPolicy(input string) (*EvictionPolicy, error) { - vals := map[string]EvictionPolicy{ - "allkeyslfu": EvictionPolicyAllKeysLFU, - "allkeyslru": EvictionPolicyAllKeysLRU, - "allkeysrandom": EvictionPolicyAllKeysRandom, - "noeviction": EvictionPolicyNoEviction, - "volatilelfu": EvictionPolicyVolatileLFU, - "volatilelru": EvictionPolicyVolatileLRU, - "volatilerandom": EvictionPolicyVolatileRandom, - "volatilettl": EvictionPolicyVolatileTTL, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := EvictionPolicy(input) - return &out, nil -} - -type LinkState string - -const ( - LinkStateLinkFailed LinkState = "LinkFailed" - LinkStateLinked LinkState = "Linked" - LinkStateLinking LinkState = "Linking" - LinkStateUnlinkFailed LinkState = "UnlinkFailed" - LinkStateUnlinking LinkState = "Unlinking" -) - -func PossibleValuesForLinkState() []string { - return []string{ - string(LinkStateLinkFailed), - string(LinkStateLinked), - string(LinkStateLinking), - string(LinkStateUnlinkFailed), - string(LinkStateUnlinking), - } -} - -func parseLinkState(input string) (*LinkState, error) { - vals := map[string]LinkState{ - "linkfailed": LinkStateLinkFailed, - "linked": LinkStateLinked, - "linking": LinkStateLinking, - "unlinkfailed": LinkStateUnlinkFailed, - "unlinking": LinkStateUnlinking, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := LinkState(input) - return &out, nil -} - -type Protocol string - -const ( - ProtocolEncrypted Protocol = "Encrypted" - ProtocolPlaintext Protocol = "Plaintext" -) - -func PossibleValuesForProtocol() []string { - return []string{ - string(ProtocolEncrypted), - string(ProtocolPlaintext), - } -} - -func parseProtocol(input string) (*Protocol, error) { - vals := map[string]Protocol{ - "encrypted": ProtocolEncrypted, - "plaintext": ProtocolPlaintext, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := Protocol(input) - return &out, nil -} - -type ProvisioningState string - -const ( - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreating ProvisioningState = "Creating" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateFailed ProvisioningState = "Failed" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateUpdating ProvisioningState = "Updating" -) - -func PossibleValuesForProvisioningState() []string { - return []string{ - string(ProvisioningStateCanceled), - string(ProvisioningStateCreating), - string(ProvisioningStateDeleting), - string(ProvisioningStateFailed), - string(ProvisioningStateSucceeded), - string(ProvisioningStateUpdating), - } -} - -func parseProvisioningState(input string) (*ProvisioningState, error) { - vals := map[string]ProvisioningState{ - "canceled": ProvisioningStateCanceled, - "creating": ProvisioningStateCreating, - "deleting": ProvisioningStateDeleting, - "failed": ProvisioningStateFailed, - "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 RdbFrequency string - -const ( - RdbFrequencyOneTwoh RdbFrequency = "12h" - RdbFrequencyOneh RdbFrequency = "1h" - RdbFrequencySixh RdbFrequency = "6h" -) - -func PossibleValuesForRdbFrequency() []string { - return []string{ - string(RdbFrequencyOneTwoh), - string(RdbFrequencyOneh), - string(RdbFrequencySixh), - } -} - -func parseRdbFrequency(input string) (*RdbFrequency, error) { - vals := map[string]RdbFrequency{ - "12h": RdbFrequencyOneTwoh, - "1h": RdbFrequencyOneh, - "6h": RdbFrequencySixh, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := RdbFrequency(input) - return &out, nil -} - -type ResourceState string - -const ( - ResourceStateCreateFailed ResourceState = "CreateFailed" - ResourceStateCreating ResourceState = "Creating" - ResourceStateDeleteFailed ResourceState = "DeleteFailed" - ResourceStateDeleting ResourceState = "Deleting" - ResourceStateDisableFailed ResourceState = "DisableFailed" - ResourceStateDisabled ResourceState = "Disabled" - ResourceStateDisabling ResourceState = "Disabling" - ResourceStateEnableFailed ResourceState = "EnableFailed" - ResourceStateEnabling ResourceState = "Enabling" - ResourceStateRunning ResourceState = "Running" - ResourceStateUpdateFailed ResourceState = "UpdateFailed" - ResourceStateUpdating ResourceState = "Updating" -) - -func PossibleValuesForResourceState() []string { - return []string{ - string(ResourceStateCreateFailed), - string(ResourceStateCreating), - string(ResourceStateDeleteFailed), - string(ResourceStateDeleting), - string(ResourceStateDisableFailed), - string(ResourceStateDisabled), - string(ResourceStateDisabling), - string(ResourceStateEnableFailed), - string(ResourceStateEnabling), - string(ResourceStateRunning), - string(ResourceStateUpdateFailed), - string(ResourceStateUpdating), - } -} - -func parseResourceState(input string) (*ResourceState, error) { - vals := map[string]ResourceState{ - "createfailed": ResourceStateCreateFailed, - "creating": ResourceStateCreating, - "deletefailed": ResourceStateDeleteFailed, - "deleting": ResourceStateDeleting, - "disablefailed": ResourceStateDisableFailed, - "disabled": ResourceStateDisabled, - "disabling": ResourceStateDisabling, - "enablefailed": ResourceStateEnableFailed, - "enabling": ResourceStateEnabling, - "running": ResourceStateRunning, - "updatefailed": ResourceStateUpdateFailed, - "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 -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/id_database.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/id_database.go deleted file mode 100644 index e58344f50094..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/id_database.go +++ /dev/null @@ -1,137 +0,0 @@ -package databases - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = DatabaseId{} - -// DatabaseId is a struct representing the Resource ID for a Database -type DatabaseId struct { - SubscriptionId string - ResourceGroupName string - ClusterName string - DatabaseName string -} - -// NewDatabaseID returns a new DatabaseId struct -func NewDatabaseID(subscriptionId string, resourceGroupName string, clusterName string, databaseName string) DatabaseId { - return DatabaseId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ClusterName: clusterName, - DatabaseName: databaseName, - } -} - -// ParseDatabaseID parses 'input' into a DatabaseId -func ParseDatabaseID(input string) (*DatabaseId, error) { - parser := resourceids.NewParserFromResourceIdType(DatabaseId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := DatabaseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - if id.DatabaseName, ok = parsed.Parsed["databaseName"]; !ok { - return nil, fmt.Errorf("the segment 'databaseName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseDatabaseIDInsensitively parses 'input' case-insensitively into a DatabaseId -// note: this method should only be used for API response data and not user input -func ParseDatabaseIDInsensitively(input string) (*DatabaseId, error) { - parser := resourceids.NewParserFromResourceIdType(DatabaseId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := DatabaseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - if id.DatabaseName, ok = parsed.Parsed["databaseName"]; !ok { - return nil, fmt.Errorf("the segment 'databaseName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateDatabaseID checks that 'input' can be parsed as a Database ID -func ValidateDatabaseID(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 := ParseDatabaseID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Database ID -func (id DatabaseId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Cache/redisEnterprise/%s/databases/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName, id.DatabaseName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Database ID -func (id DatabaseId) 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("staticMicrosoftCache", "Microsoft.Cache", "Microsoft.Cache"), - resourceids.StaticSegment("staticRedisEnterprise", "redisEnterprise", "redisEnterprise"), - resourceids.UserSpecifiedSegment("clusterName", "clusterValue"), - resourceids.StaticSegment("staticDatabases", "databases", "databases"), - resourceids.UserSpecifiedSegment("databaseName", "databaseValue"), - } -} - -// String returns a human-readable description of this Database ID -func (id DatabaseId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Cluster Name: %q", id.ClusterName), - fmt.Sprintf("Database Name: %q", id.DatabaseName), - } - return fmt.Sprintf("Database (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/id_database_test.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/id_database_test.go deleted file mode 100644 index 549a63bf6781..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/id_database_test.go +++ /dev/null @@ -1,324 +0,0 @@ -package databases - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = DatabaseId{} - -func TestNewDatabaseID(t *testing.T) { - id := NewDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue", "databaseValue") - - 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.ClusterName != "clusterValue" { - t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterValue") - } - - if id.DatabaseName != "databaseValue" { - t.Fatalf("Expected %q but got %q for Segment 'DatabaseName'", id.DatabaseName, "databaseValue") - } -} - -func TestFormatDatabaseID(t *testing.T) { - actual := NewDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue", "databaseValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases/databaseValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseDatabaseID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *DatabaseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases/databaseValue", - Expected: &DatabaseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - DatabaseName: "databaseValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases/databaseValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseDatabaseID(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - if actual.DatabaseName != v.Expected.DatabaseName { - t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) - } - - } -} - -func TestParseDatabaseIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *DatabaseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/dAtAbAsEs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases/databaseValue", - Expected: &DatabaseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - DatabaseName: "databaseValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases/databaseValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/dAtAbAsEs/dAtAbAsEvAlUe", - Expected: &DatabaseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ClusterName: "cLuStErVaLuE", - DatabaseName: "dAtAbAsEvAlUe", - }, - }, - { - // 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.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/dAtAbAsEs/dAtAbAsEvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseDatabaseIDInsensitively(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - if actual.DatabaseName != v.Expected.DatabaseName { - t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) - } - - } -} - -func TestSegmentsForDatabaseId(t *testing.T) { - segments := DatabaseId{}.Segments() - if len(segments) == 0 { - t.Fatalf("DatabaseId 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/internal/services/redisenterprise/sdk/2022-01-01/databases/id_redisenterprise.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/id_redisenterprise.go deleted file mode 100644 index b1e6441a79ac..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/id_redisenterprise.go +++ /dev/null @@ -1,124 +0,0 @@ -package databases - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = RedisEnterpriseId{} - -// RedisEnterpriseId is a struct representing the Resource ID for a Redis Enterprise -type RedisEnterpriseId struct { - SubscriptionId string - ResourceGroupName string - ClusterName string -} - -// NewRedisEnterpriseID returns a new RedisEnterpriseId struct -func NewRedisEnterpriseID(subscriptionId string, resourceGroupName string, clusterName string) RedisEnterpriseId { - return RedisEnterpriseId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ClusterName: clusterName, - } -} - -// ParseRedisEnterpriseID parses 'input' into a RedisEnterpriseId -func ParseRedisEnterpriseID(input string) (*RedisEnterpriseId, error) { - parser := resourceids.NewParserFromResourceIdType(RedisEnterpriseId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := RedisEnterpriseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseRedisEnterpriseIDInsensitively parses 'input' case-insensitively into a RedisEnterpriseId -// note: this method should only be used for API response data and not user input -func ParseRedisEnterpriseIDInsensitively(input string) (*RedisEnterpriseId, error) { - parser := resourceids.NewParserFromResourceIdType(RedisEnterpriseId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := RedisEnterpriseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateRedisEnterpriseID checks that 'input' can be parsed as a Redis Enterprise ID -func ValidateRedisEnterpriseID(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 := ParseRedisEnterpriseID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Redis Enterprise ID -func (id RedisEnterpriseId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Cache/redisEnterprise/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Redis Enterprise ID -func (id RedisEnterpriseId) 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("staticMicrosoftCache", "Microsoft.Cache", "Microsoft.Cache"), - resourceids.StaticSegment("staticRedisEnterprise", "redisEnterprise", "redisEnterprise"), - resourceids.UserSpecifiedSegment("clusterName", "clusterValue"), - } -} - -// String returns a human-readable description of this Redis Enterprise ID -func (id RedisEnterpriseId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Cluster Name: %q", id.ClusterName), - } - return fmt.Sprintf("Redis Enterprise (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/id_redisenterprise_test.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/id_redisenterprise_test.go deleted file mode 100644 index f70c796f3f48..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/id_redisenterprise_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package databases - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = RedisEnterpriseId{} - -func TestNewRedisEnterpriseID(t *testing.T) { - id := NewRedisEnterpriseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue") - - 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.ClusterName != "clusterValue" { - t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterValue") - } -} - -func TestFormatRedisEnterpriseID(t *testing.T) { - actual := NewRedisEnterpriseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseRedisEnterpriseID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *RedisEnterpriseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseRedisEnterpriseID(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - } -} - -func TestParseRedisEnterpriseIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *RedisEnterpriseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ClusterName: "cLuStErVaLuE", - }, - }, - { - // 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.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseRedisEnterpriseIDInsensitively(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - } -} - -func TestSegmentsForRedisEnterpriseId(t *testing.T) { - segments := RedisEnterpriseId{}.Segments() - if len(segments) == 0 { - t.Fatalf("RedisEnterpriseId 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/internal/services/redisenterprise/sdk/2022-01-01/databases/method_create_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/method_create_autorest.go deleted file mode 100644 index 8ddb57c8a259..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/method_create_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type CreateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Create ... -func (c DatabasesClient) Create(ctx context.Context, id DatabaseId, input Database) (result CreateResponse, err error) { - req, err := c.preparerForCreate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Create", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Create", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateThenPoll performs Create then polls until it's completed -func (c DatabasesClient) CreateThenPoll(ctx context.Context, id DatabaseId, input Database) error { - result, err := c.Create(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Create: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Create: %+v", err) - } - - return nil -} - -// preparerForCreate prepares the Create request. -func (c DatabasesClient) preparerForCreate(ctx context.Context, id DatabaseId, input Database) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreate sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (c DatabasesClient) senderForCreate(ctx context.Context, req *http.Request) (future CreateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/method_delete_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/method_delete_autorest.go deleted file mode 100644 index d14eb3b2aec0..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/method_delete_autorest.go +++ /dev/null @@ -1,74 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type DeleteResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c DatabasesClient) Delete(ctx context.Context, id DatabaseId) (result DeleteResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c DatabasesClient) DeleteThenPoll(ctx context.Context, id DatabaseId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c DatabasesClient) preparerForDelete(ctx context.Context, id DatabaseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c DatabasesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/method_export_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/method_export_autorest.go deleted file mode 100644 index 181d98d419a7..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/method_export_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type ExportResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Export ... -func (c DatabasesClient) Export(ctx context.Context, id DatabaseId, input ExportClusterParameters) (result ExportResponse, err error) { - req, err := c.preparerForExport(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Export", nil, "Failure preparing request") - return - } - - result, err = c.senderForExport(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Export", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ExportThenPoll performs Export then polls until it's completed -func (c DatabasesClient) ExportThenPoll(ctx context.Context, id DatabaseId, input ExportClusterParameters) error { - result, err := c.Export(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Export: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Export: %+v", err) - } - - return nil -} - -// preparerForExport prepares the Export request. -func (c DatabasesClient) preparerForExport(ctx context.Context, id DatabaseId, input ExportClusterParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/export", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForExport sends the Export request. The method will close the -// http.Response Body if it receives an error. -func (c DatabasesClient) senderForExport(ctx context.Context, req *http.Request) (future ExportResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/method_forceunlink_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/method_forceunlink_autorest.go deleted file mode 100644 index 2d1d84bc2d52..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/method_forceunlink_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type ForceUnlinkResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ForceUnlink ... -func (c DatabasesClient) ForceUnlink(ctx context.Context, id DatabaseId, input ForceUnlinkParameters) (result ForceUnlinkResponse, err error) { - req, err := c.preparerForForceUnlink(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ForceUnlink", nil, "Failure preparing request") - return - } - - result, err = c.senderForForceUnlink(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ForceUnlink", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ForceUnlinkThenPoll performs ForceUnlink then polls until it's completed -func (c DatabasesClient) ForceUnlinkThenPoll(ctx context.Context, id DatabaseId, input ForceUnlinkParameters) error { - result, err := c.ForceUnlink(ctx, id, input) - if err != nil { - return fmt.Errorf("performing ForceUnlink: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ForceUnlink: %+v", err) - } - - return nil -} - -// preparerForForceUnlink prepares the ForceUnlink request. -func (c DatabasesClient) preparerForForceUnlink(ctx context.Context, id DatabaseId, input ForceUnlinkParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/forceUnlink", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForForceUnlink sends the ForceUnlink request. The method will close the -// http.Response Body if it receives an error. -func (c DatabasesClient) senderForForceUnlink(ctx context.Context, req *http.Request) (future ForceUnlinkResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/method_get_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/method_get_autorest.go deleted file mode 100644 index dee18977683b..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/method_get_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package databases - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type GetResponse struct { - HttpResponse *http.Response - Model *Database -} - -// Get ... -func (c DatabasesClient) Get(ctx context.Context, id DatabaseId) (result GetResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c DatabasesClient) preparerForGet(ctx context.Context, id DatabaseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c DatabasesClient) responderForGet(resp *http.Response) (result GetResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/method_import_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/method_import_autorest.go deleted file mode 100644 index 9b11c5efb62c..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/method_import_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type ImportResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Import ... -func (c DatabasesClient) Import(ctx context.Context, id DatabaseId, input ImportClusterParameters) (result ImportResponse, err error) { - req, err := c.preparerForImport(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Import", nil, "Failure preparing request") - return - } - - result, err = c.senderForImport(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Import", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ImportThenPoll performs Import then polls until it's completed -func (c DatabasesClient) ImportThenPoll(ctx context.Context, id DatabaseId, input ImportClusterParameters) error { - result, err := c.Import(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Import: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Import: %+v", err) - } - - return nil -} - -// preparerForImport prepares the Import request. -func (c DatabasesClient) preparerForImport(ctx context.Context, id DatabaseId, input ImportClusterParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/import", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForImport sends the Import request. The method will close the -// http.Response Body if it receives an error. -func (c DatabasesClient) senderForImport(ctx context.Context, req *http.Request) (future ImportResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/method_listbycluster_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/method_listbycluster_autorest.go deleted file mode 100644 index fccaa65c96d8..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/method_listbycluster_autorest.go +++ /dev/null @@ -1,183 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ListByClusterResponse struct { - HttpResponse *http.Response - Model *[]Database - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByClusterResponse, error) -} - -type ListByClusterCompleteResult struct { - Items []Database -} - -func (r ListByClusterResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByClusterResponse) LoadMore(ctx context.Context) (resp ListByClusterResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByCluster ... -func (c DatabasesClient) ListByCluster(ctx context.Context, id RedisEnterpriseId) (resp ListByClusterResponse, err error) { - req, err := c.preparerForListByCluster(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByCluster", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByCluster", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByCluster(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByCluster", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ListByClusterComplete retrieves all of the results into a single object -func (c DatabasesClient) ListByClusterComplete(ctx context.Context, id RedisEnterpriseId) (ListByClusterCompleteResult, error) { - return c.ListByClusterCompleteMatchingPredicate(ctx, id, DatabasePredicate{}) -} - -// ListByClusterCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DatabasesClient) ListByClusterCompleteMatchingPredicate(ctx context.Context, id RedisEnterpriseId, predicate DatabasePredicate) (resp ListByClusterCompleteResult, err error) { - items := make([]Database, 0) - - page, err := c.ListByCluster(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByClusterCompleteResult{ - Items: items, - } - return out, nil -} - -// preparerForListByCluster prepares the ListByCluster request. -func (c DatabasesClient) preparerForListByCluster(ctx context.Context, id RedisEnterpriseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/databases", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByClusterWithNextLink prepares the ListByCluster request with the given nextLink token. -func (c DatabasesClient) preparerForListByClusterWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByCluster handles the response to the ListByCluster request. The method always -// closes the http.Response Body. -func (c DatabasesClient) responderForListByCluster(resp *http.Response) (result ListByClusterResponse, err error) { - type page struct { - Values []Database `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByClusterResponse, err error) { - req, err := c.preparerForListByClusterWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByCluster", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByCluster", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByCluster(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByCluster", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/method_listkeys_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/method_listkeys_autorest.go deleted file mode 100644 index 76f54586bf3b..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/method_listkeys_autorest.go +++ /dev/null @@ -1,65 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ListKeysResponse struct { - HttpResponse *http.Response - Model *AccessKeys -} - -// ListKeys ... -func (c DatabasesClient) ListKeys(ctx context.Context, id DatabaseId) (result ListKeysResponse, err error) { - req, err := c.preparerForListKeys(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListKeys prepares the ListKeys request. -func (c DatabasesClient) preparerForListKeys(ctx context.Context, id DatabaseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listKeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListKeys handles the response to the ListKeys request. The method always -// closes the http.Response Body. -func (c DatabasesClient) responderForListKeys(resp *http.Response) (result ListKeysResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/method_regeneratekey_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/method_regeneratekey_autorest.go deleted file mode 100644 index f831e8e97e7c..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/method_regeneratekey_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type RegenerateKeyResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// RegenerateKey ... -func (c DatabasesClient) RegenerateKey(ctx context.Context, id DatabaseId, input RegenerateKeyParameters) (result RegenerateKeyResponse, err error) { - req, err := c.preparerForRegenerateKey(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "RegenerateKey", nil, "Failure preparing request") - return - } - - result, err = c.senderForRegenerateKey(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "RegenerateKey", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// RegenerateKeyThenPoll performs RegenerateKey then polls until it's completed -func (c DatabasesClient) RegenerateKeyThenPoll(ctx context.Context, id DatabaseId, input RegenerateKeyParameters) error { - result, err := c.RegenerateKey(ctx, id, input) - if err != nil { - return fmt.Errorf("performing RegenerateKey: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after RegenerateKey: %+v", err) - } - - return nil -} - -// preparerForRegenerateKey prepares the RegenerateKey request. -func (c DatabasesClient) preparerForRegenerateKey(ctx context.Context, id DatabaseId, input RegenerateKeyParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/regenerateKey", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForRegenerateKey sends the RegenerateKey request. The method will close the -// http.Response Body if it receives an error. -func (c DatabasesClient) senderForRegenerateKey(ctx context.Context, req *http.Request) (future RegenerateKeyResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/method_update_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/method_update_autorest.go deleted file mode 100644 index 66516e2346d5..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/method_update_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type UpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Update ... -func (c DatabasesClient) Update(ctx context.Context, id DatabaseId, input DatabaseUpdate) (result UpdateResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c DatabasesClient) UpdateThenPoll(ctx context.Context, id DatabaseId, input DatabaseUpdate) error { - result, err := c.Update(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c DatabasesClient) preparerForUpdate(ctx context.Context, id DatabaseId, input DatabaseUpdate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c DatabasesClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_accesskeys.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/model_accesskeys.go deleted file mode 100644 index 356ad75ad012..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_accesskeys.go +++ /dev/null @@ -1,6 +0,0 @@ -package databases - -type AccessKeys struct { - PrimaryKey *string `json:"primaryKey,omitempty"` - SecondaryKey *string `json:"secondaryKey,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_database.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/model_database.go deleted file mode 100644 index 91c899457e9c..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_database.go +++ /dev/null @@ -1,8 +0,0 @@ -package databases - -type Database struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *DatabaseProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_databaseproperties.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/model_databaseproperties.go deleted file mode 100644 index 4bba1ee0df8f..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_databaseproperties.go +++ /dev/null @@ -1,13 +0,0 @@ -package databases - -type DatabaseProperties struct { - ClientProtocol *Protocol `json:"clientProtocol,omitempty"` - ClusteringPolicy *ClusteringPolicy `json:"clusteringPolicy,omitempty"` - EvictionPolicy *EvictionPolicy `json:"evictionPolicy,omitempty"` - GeoReplication *DatabasePropertiesGeoReplication `json:"geoReplication,omitempty"` - Modules *[]Module `json:"modules,omitempty"` - Persistence *Persistence `json:"persistence,omitempty"` - Port *int64 `json:"port,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` - ResourceState *ResourceState `json:"resourceState,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_databasepropertiesgeoreplication.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/model_databasepropertiesgeoreplication.go deleted file mode 100644 index 2f733e0880ad..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_databasepropertiesgeoreplication.go +++ /dev/null @@ -1,6 +0,0 @@ -package databases - -type DatabasePropertiesGeoReplication struct { - GroupNickname *string `json:"groupNickname,omitempty"` - LinkedDatabases *[]LinkedDatabase `json:"linkedDatabases,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_databaseupdate.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/model_databaseupdate.go deleted file mode 100644 index 53f5fa8b86d4..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_databaseupdate.go +++ /dev/null @@ -1,5 +0,0 @@ -package databases - -type DatabaseUpdate struct { - Properties *DatabaseProperties `json:"properties,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_exportclusterparameters.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/model_exportclusterparameters.go deleted file mode 100644 index 390dd6414dc6..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_exportclusterparameters.go +++ /dev/null @@ -1,5 +0,0 @@ -package databases - -type ExportClusterParameters struct { - SasUri string `json:"sasUri"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_forceunlinkparameters.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/model_forceunlinkparameters.go deleted file mode 100644 index b442efa75e57..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_forceunlinkparameters.go +++ /dev/null @@ -1,5 +0,0 @@ -package databases - -type ForceUnlinkParameters struct { - Ids []string `json:"ids"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_importclusterparameters.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/model_importclusterparameters.go deleted file mode 100644 index f0207b25b5cc..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_importclusterparameters.go +++ /dev/null @@ -1,5 +0,0 @@ -package databases - -type ImportClusterParameters struct { - SasUris []string `json:"sasUris"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_linkeddatabase.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/model_linkeddatabase.go deleted file mode 100644 index 02da951e0421..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_linkeddatabase.go +++ /dev/null @@ -1,6 +0,0 @@ -package databases - -type LinkedDatabase struct { - Id *string `json:"id,omitempty"` - State *LinkState `json:"state,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_module.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/model_module.go deleted file mode 100644 index e23fc2366b8e..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_module.go +++ /dev/null @@ -1,7 +0,0 @@ -package databases - -type Module struct { - Args *string `json:"args,omitempty"` - Name string `json:"name"` - Version *string `json:"version,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_persistence.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/model_persistence.go deleted file mode 100644 index cadef7b455b3..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_persistence.go +++ /dev/null @@ -1,8 +0,0 @@ -package databases - -type Persistence struct { - AofEnabled *bool `json:"aofEnabled,omitempty"` - AofFrequency *AofFrequency `json:"aofFrequency,omitempty"` - RdbEnabled *bool `json:"rdbEnabled,omitempty"` - RdbFrequency *RdbFrequency `json:"rdbFrequency,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_regeneratekeyparameters.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/model_regeneratekeyparameters.go deleted file mode 100644 index e5e265d42e25..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/model_regeneratekeyparameters.go +++ /dev/null @@ -1,5 +0,0 @@ -package databases - -type RegenerateKeyParameters struct { - KeyType AccessKeyType `json:"keyType"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/predicates.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/predicates.go deleted file mode 100644 index 8e70d0fdfa34..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/predicates.go +++ /dev/null @@ -1,24 +0,0 @@ -package databases - -type DatabasePredicate struct { - Id *string - Name *string - Type *string -} - -func (p DatabasePredicate) Matches(input Database) bool { - - if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { - return false - } - - if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { - return false - } - - return true -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/databases/version.go b/internal/services/redisenterprise/sdk/2022-01-01/databases/version.go deleted file mode 100644 index 6eb0be5bf2f4..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/databases/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package databases - -import "fmt" - -const defaultApiVersion = "2022-01-01" - -func userAgent() string { - return fmt.Sprintf("pandora/databases/%s", defaultApiVersion) -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/client.go b/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/client.go deleted file mode 100644 index 28da68be384f..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package operationsstatus - -import "github.com/Azure/go-autorest/autorest" - -type OperationsStatusClient struct { - Client autorest.Client - baseUri string -} - -func NewOperationsStatusClientWithBaseURI(endpoint string) OperationsStatusClient { - return OperationsStatusClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/id_operationsstatu.go b/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/id_operationsstatu.go deleted file mode 100644 index 5e696c401b50..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/id_operationsstatu.go +++ /dev/null @@ -1,124 +0,0 @@ -package operationsstatus - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = OperationsStatuId{} - -// OperationsStatuId is a struct representing the Resource ID for a Operations Statu -type OperationsStatuId struct { - SubscriptionId string - Location string - OperationId string -} - -// NewOperationsStatuID returns a new OperationsStatuId struct -func NewOperationsStatuID(subscriptionId string, location string, operationId string) OperationsStatuId { - return OperationsStatuId{ - SubscriptionId: subscriptionId, - Location: location, - OperationId: operationId, - } -} - -// ParseOperationsStatuID parses 'input' into a OperationsStatuId -func ParseOperationsStatuID(input string) (*OperationsStatuId, error) { - parser := resourceids.NewParserFromResourceIdType(OperationsStatuId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := OperationsStatuId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.Location, ok = parsed.Parsed["location"]; !ok { - return nil, fmt.Errorf("the segment 'location' was not found in the resource id %q", input) - } - - if id.OperationId, ok = parsed.Parsed["operationId"]; !ok { - return nil, fmt.Errorf("the segment 'operationId' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseOperationsStatuIDInsensitively parses 'input' case-insensitively into a OperationsStatuId -// note: this method should only be used for API response data and not user input -func ParseOperationsStatuIDInsensitively(input string) (*OperationsStatuId, error) { - parser := resourceids.NewParserFromResourceIdType(OperationsStatuId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := OperationsStatuId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.Location, ok = parsed.Parsed["location"]; !ok { - return nil, fmt.Errorf("the segment 'location' was not found in the resource id %q", input) - } - - if id.OperationId, ok = parsed.Parsed["operationId"]; !ok { - return nil, fmt.Errorf("the segment 'operationId' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateOperationsStatuID checks that 'input' can be parsed as a Operations Statu ID -func ValidateOperationsStatuID(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 := ParseOperationsStatuID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Operations Statu ID -func (id OperationsStatuId) ID() string { - fmtString := "/subscriptions/%s/providers/Microsoft.Cache/locations/%s/operationsStatus/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.Location, id.OperationId) -} - -// Segments returns a slice of Resource ID Segments which comprise this Operations Statu ID -func (id OperationsStatuId) 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("staticMicrosoftCache", "Microsoft.Cache", "Microsoft.Cache"), - resourceids.StaticSegment("staticLocations", "locations", "locations"), - resourceids.UserSpecifiedSegment("location", "locationValue"), - resourceids.StaticSegment("staticOperationsStatus", "operationsStatus", "operationsStatus"), - resourceids.UserSpecifiedSegment("operationId", "operationIdValue"), - } -} - -// String returns a human-readable description of this Operations Statu ID -func (id OperationsStatuId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Location: %q", id.Location), - fmt.Sprintf("Operation: %q", id.OperationId), - } - return fmt.Sprintf("Operations Statu (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/id_operationsstatu_test.go b/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/id_operationsstatu_test.go deleted file mode 100644 index e409185725c9..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/id_operationsstatu_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package operationsstatus - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = OperationsStatuId{} - -func TestNewOperationsStatuID(t *testing.T) { - id := NewOperationsStatuID("12345678-1234-9876-4563-123456789012", "locationValue", "operationIdValue") - - 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.Location != "locationValue" { - t.Fatalf("Expected %q but got %q for Segment 'Location'", id.Location, "locationValue") - } - - if id.OperationId != "operationIdValue" { - t.Fatalf("Expected %q but got %q for Segment 'OperationId'", id.OperationId, "operationIdValue") - } -} - -func TestFormatOperationsStatuID(t *testing.T) { - actual := NewOperationsStatuID("12345678-1234-9876-4563-123456789012", "locationValue", "operationIdValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Cache/locations/locationValue/operationsStatus/operationIdValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseOperationsStatuID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *OperationsStatuId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Cache/locations", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Cache/locations/locationValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Cache/locations/locationValue/operationsStatus", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Cache/locations/locationValue/operationsStatus/operationIdValue", - Expected: &OperationsStatuId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - Location: "locationValue", - OperationId: "operationIdValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Cache/locations/locationValue/operationsStatus/operationIdValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseOperationsStatuID(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.Location != v.Expected.Location { - t.Fatalf("Expected %q but got %q for Location", v.Expected.Location, actual.Location) - } - - if actual.OperationId != v.Expected.OperationId { - t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) - } - - } -} - -func TestParseOperationsStatuIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *OperationsStatuId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cAcHe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Cache/locations", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cAcHe/lOcAtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Cache/locations/locationValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cAcHe/lOcAtIoNs/lOcAtIoNvAlUe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Cache/locations/locationValue/operationsStatus", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cAcHe/lOcAtIoNs/lOcAtIoNvAlUe/oPeRaTiOnSsTaTuS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Cache/locations/locationValue/operationsStatus/operationIdValue", - Expected: &OperationsStatuId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - Location: "locationValue", - OperationId: "operationIdValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Cache/locations/locationValue/operationsStatus/operationIdValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cAcHe/lOcAtIoNs/lOcAtIoNvAlUe/oPeRaTiOnSsTaTuS/oPeRaTiOnIdVaLuE", - Expected: &OperationsStatuId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - Location: "lOcAtIoNvAlUe", - OperationId: "oPeRaTiOnIdVaLuE", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cAcHe/lOcAtIoNs/lOcAtIoNvAlUe/oPeRaTiOnSsTaTuS/oPeRaTiOnIdVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseOperationsStatuIDInsensitively(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.Location != v.Expected.Location { - t.Fatalf("Expected %q but got %q for Location", v.Expected.Location, actual.Location) - } - - if actual.OperationId != v.Expected.OperationId { - t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) - } - - } -} - -func TestSegmentsForOperationsStatuId(t *testing.T) { - segments := OperationsStatuId{}.Segments() - if len(segments) == 0 { - t.Fatalf("OperationsStatuId 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/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/method_get_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/method_get_autorest.go deleted file mode 100644 index e88bf254ea78..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/method_get_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package operationsstatus - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type GetResponse struct { - HttpResponse *http.Response - Model *OperationStatus -} - -// Get ... -func (c OperationsStatusClient) Get(ctx context.Context, id OperationsStatuId) (result GetResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "operationsstatus.OperationsStatusClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "operationsstatus.OperationsStatusClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "operationsstatus.OperationsStatusClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c OperationsStatusClient) preparerForGet(ctx context.Context, id OperationsStatuId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c OperationsStatusClient) responderForGet(resp *http.Response) (result GetResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/model_erroradditionalinfo.go b/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/model_erroradditionalinfo.go deleted file mode 100644 index f6b29162c7e5..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/model_erroradditionalinfo.go +++ /dev/null @@ -1,6 +0,0 @@ -package operationsstatus - -type ErrorAdditionalInfo struct { - Info *interface{} `json:"info,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/model_errordetail.go b/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/model_errordetail.go deleted file mode 100644 index d0bdb01dafd7..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/model_errordetail.go +++ /dev/null @@ -1,9 +0,0 @@ -package operationsstatus - -type ErrorDetail struct { - AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` - Code *string `json:"code,omitempty"` - Details *[]ErrorDetail `json:"details,omitempty"` - Message *string `json:"message,omitempty"` - Target *string `json:"target,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/model_errorresponse.go b/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/model_errorresponse.go deleted file mode 100644 index e23110ce5893..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/model_errorresponse.go +++ /dev/null @@ -1,5 +0,0 @@ -package operationsstatus - -type ErrorResponse struct { - Error *ErrorDetail `json:"error,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/model_operationstatus.go b/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/model_operationstatus.go deleted file mode 100644 index 67281f8941da..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/model_operationstatus.go +++ /dev/null @@ -1,10 +0,0 @@ -package operationsstatus - -type OperationStatus struct { - EndTime *string `json:"endTime,omitempty"` - Error *ErrorResponse `json:"error,omitempty"` - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - StartTime *string `json:"startTime,omitempty"` - Status *string `json:"status,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/version.go b/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/version.go deleted file mode 100644 index 1e0d873c0461..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/operationsstatus/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package operationsstatus - -import "fmt" - -const defaultApiVersion = "2022-01-01" - -func userAgent() string { - return fmt.Sprintf("pandora/operationsstatus/%s", defaultApiVersion) -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/client.go b/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/client.go deleted file mode 100644 index adc4283affb2..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package privateendpointconnections - -import "github.com/Azure/go-autorest/autorest" - -type PrivateEndpointConnectionsClient struct { - Client autorest.Client - baseUri string -} - -func NewPrivateEndpointConnectionsClientWithBaseURI(endpoint string) PrivateEndpointConnectionsClient { - return PrivateEndpointConnectionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/constants.go b/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/constants.go deleted file mode 100644 index 49d0ed483658..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/constants.go +++ /dev/null @@ -1,68 +0,0 @@ -package privateendpointconnections - -import "strings" - -type PrivateEndpointConnectionProvisioningState string - -const ( - PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" - PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" - PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" - PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" -) - -func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { - return []string{ - string(PrivateEndpointConnectionProvisioningStateCreating), - string(PrivateEndpointConnectionProvisioningStateDeleting), - string(PrivateEndpointConnectionProvisioningStateFailed), - string(PrivateEndpointConnectionProvisioningStateSucceeded), - } -} - -func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { - vals := map[string]PrivateEndpointConnectionProvisioningState{ - "creating": PrivateEndpointConnectionProvisioningStateCreating, - "deleting": PrivateEndpointConnectionProvisioningStateDeleting, - "failed": PrivateEndpointConnectionProvisioningStateFailed, - "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointConnectionProvisioningState(input) - return &out, nil -} - -type PrivateEndpointServiceConnectionStatus string - -const ( - PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" - PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" -) - -func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { - return []string{ - string(PrivateEndpointServiceConnectionStatusApproved), - string(PrivateEndpointServiceConnectionStatusPending), - string(PrivateEndpointServiceConnectionStatusRejected), - } -} - -func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { - vals := map[string]PrivateEndpointServiceConnectionStatus{ - "approved": PrivateEndpointServiceConnectionStatusApproved, - "pending": PrivateEndpointServiceConnectionStatusPending, - "rejected": PrivateEndpointServiceConnectionStatusRejected, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointServiceConnectionStatus(input) - return &out, nil -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/id_privateendpointconnection.go b/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/id_privateendpointconnection.go deleted file mode 100644 index 1ebd7ff925da..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/id_privateendpointconnection.go +++ /dev/null @@ -1,137 +0,0 @@ -package privateendpointconnections - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = PrivateEndpointConnectionId{} - -// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection -type PrivateEndpointConnectionId struct { - SubscriptionId string - ResourceGroupName string - ClusterName string - PrivateEndpointConnectionName string -} - -// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct -func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, clusterName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { - return PrivateEndpointConnectionId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ClusterName: clusterName, - PrivateEndpointConnectionName: privateEndpointConnectionName, - } -} - -// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId -func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { - parser := resourceids.NewParserFromResourceIdType(PrivateEndpointConnectionId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := PrivateEndpointConnectionId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - if id.PrivateEndpointConnectionName, ok = parsed.Parsed["privateEndpointConnectionName"]; !ok { - return nil, fmt.Errorf("the segment 'privateEndpointConnectionName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId -// note: this method should only be used for API response data and not user input -func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { - parser := resourceids.NewParserFromResourceIdType(PrivateEndpointConnectionId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := PrivateEndpointConnectionId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - if id.PrivateEndpointConnectionName, ok = parsed.Parsed["privateEndpointConnectionName"]; !ok { - return nil, fmt.Errorf("the segment 'privateEndpointConnectionName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID -func ValidatePrivateEndpointConnectionID(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 := ParsePrivateEndpointConnectionID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Private Endpoint Connection ID -func (id PrivateEndpointConnectionId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Cache/redisEnterprise/%s/privateEndpointConnections/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName, id.PrivateEndpointConnectionName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID -func (id PrivateEndpointConnectionId) 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("staticMicrosoftCache", "Microsoft.Cache", "Microsoft.Cache"), - resourceids.StaticSegment("staticRedisEnterprise", "redisEnterprise", "redisEnterprise"), - resourceids.UserSpecifiedSegment("clusterName", "clusterValue"), - resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), - resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionValue"), - } -} - -// String returns a human-readable description of this Private Endpoint Connection ID -func (id PrivateEndpointConnectionId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Cluster Name: %q", id.ClusterName), - fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), - } - return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/id_privateendpointconnection_test.go b/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/id_privateendpointconnection_test.go deleted file mode 100644 index a2bb836ac79f..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/id_privateendpointconnection_test.go +++ /dev/null @@ -1,324 +0,0 @@ -package privateendpointconnections - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = PrivateEndpointConnectionId{} - -func TestNewPrivateEndpointConnectionID(t *testing.T) { - id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue", "privateEndpointConnectionValue") - - 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.ClusterName != "clusterValue" { - t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterValue") - } - - if id.PrivateEndpointConnectionName != "privateEndpointConnectionValue" { - t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionValue") - } -} - -func TestFormatPrivateEndpointConnectionID(t *testing.T) { - actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue", "privateEndpointConnectionValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/privateEndpointConnections/privateEndpointConnectionValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParsePrivateEndpointConnectionID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateEndpointConnectionId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/privateEndpointConnections", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/privateEndpointConnections/privateEndpointConnectionValue", - Expected: &PrivateEndpointConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - PrivateEndpointConnectionName: "privateEndpointConnectionValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/privateEndpointConnections/privateEndpointConnectionValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateEndpointConnectionID(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { - t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) - } - - } -} - -func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateEndpointConnectionId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/privateEndpointConnections", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/pRiVaTeEnDpOiNtCoNnEcTiOnS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/privateEndpointConnections/privateEndpointConnectionValue", - Expected: &PrivateEndpointConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - PrivateEndpointConnectionName: "privateEndpointConnectionValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/privateEndpointConnections/privateEndpointConnectionValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", - Expected: &PrivateEndpointConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ClusterName: "cLuStErVaLuE", - PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", - }, - }, - { - // 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.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateEndpointConnectionIDInsensitively(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { - t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) - } - - } -} - -func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { - segments := PrivateEndpointConnectionId{}.Segments() - if len(segments) == 0 { - t.Fatalf("PrivateEndpointConnectionId 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/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/id_redisenterprise.go b/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/id_redisenterprise.go deleted file mode 100644 index f70b07e41874..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/id_redisenterprise.go +++ /dev/null @@ -1,124 +0,0 @@ -package privateendpointconnections - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = RedisEnterpriseId{} - -// RedisEnterpriseId is a struct representing the Resource ID for a Redis Enterprise -type RedisEnterpriseId struct { - SubscriptionId string - ResourceGroupName string - ClusterName string -} - -// NewRedisEnterpriseID returns a new RedisEnterpriseId struct -func NewRedisEnterpriseID(subscriptionId string, resourceGroupName string, clusterName string) RedisEnterpriseId { - return RedisEnterpriseId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ClusterName: clusterName, - } -} - -// ParseRedisEnterpriseID parses 'input' into a RedisEnterpriseId -func ParseRedisEnterpriseID(input string) (*RedisEnterpriseId, error) { - parser := resourceids.NewParserFromResourceIdType(RedisEnterpriseId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := RedisEnterpriseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseRedisEnterpriseIDInsensitively parses 'input' case-insensitively into a RedisEnterpriseId -// note: this method should only be used for API response data and not user input -func ParseRedisEnterpriseIDInsensitively(input string) (*RedisEnterpriseId, error) { - parser := resourceids.NewParserFromResourceIdType(RedisEnterpriseId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := RedisEnterpriseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateRedisEnterpriseID checks that 'input' can be parsed as a Redis Enterprise ID -func ValidateRedisEnterpriseID(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 := ParseRedisEnterpriseID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Redis Enterprise ID -func (id RedisEnterpriseId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Cache/redisEnterprise/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Redis Enterprise ID -func (id RedisEnterpriseId) 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("staticMicrosoftCache", "Microsoft.Cache", "Microsoft.Cache"), - resourceids.StaticSegment("staticRedisEnterprise", "redisEnterprise", "redisEnterprise"), - resourceids.UserSpecifiedSegment("clusterName", "clusterValue"), - } -} - -// String returns a human-readable description of this Redis Enterprise ID -func (id RedisEnterpriseId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Cluster Name: %q", id.ClusterName), - } - return fmt.Sprintf("Redis Enterprise (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/id_redisenterprise_test.go b/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/id_redisenterprise_test.go deleted file mode 100644 index e74c26665174..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/id_redisenterprise_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package privateendpointconnections - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = RedisEnterpriseId{} - -func TestNewRedisEnterpriseID(t *testing.T) { - id := NewRedisEnterpriseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue") - - 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.ClusterName != "clusterValue" { - t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterValue") - } -} - -func TestFormatRedisEnterpriseID(t *testing.T) { - actual := NewRedisEnterpriseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseRedisEnterpriseID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *RedisEnterpriseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseRedisEnterpriseID(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - } -} - -func TestParseRedisEnterpriseIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *RedisEnterpriseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ClusterName: "cLuStErVaLuE", - }, - }, - { - // 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.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseRedisEnterpriseIDInsensitively(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - } -} - -func TestSegmentsForRedisEnterpriseId(t *testing.T) { - segments := RedisEnterpriseId{}.Segments() - if len(segments) == 0 { - t.Fatalf("RedisEnterpriseId 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/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/method_delete_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/method_delete_autorest.go deleted file mode 100644 index 1c0bef6e18d9..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/method_delete_autorest.go +++ /dev/null @@ -1,62 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type DeleteResponse struct { - HttpResponse *http.Response -} - -// Delete ... -func (c PrivateEndpointConnectionsClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c PrivateEndpointConnectionsClient) preparerForDelete(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForDelete(resp *http.Response) (result DeleteResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/method_get_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/method_get_autorest.go deleted file mode 100644 index 10ec2007dc6d..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/method_get_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type GetResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnection -} - -// Get ... -func (c PrivateEndpointConnectionsClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (result GetResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PrivateEndpointConnectionsClient) preparerForGet(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForGet(resp *http.Response) (result GetResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/method_list_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/method_list_autorest.go deleted file mode 100644 index aebdfc8d1693..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/method_list_autorest.go +++ /dev/null @@ -1,65 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ListResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnectionListResult -} - -// List ... -func (c PrivateEndpointConnectionsClient) List(ctx context.Context, id RedisEnterpriseId) (result ListResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForList prepares the List request. -func (c PrivateEndpointConnectionsClient) preparerForList(ctx context.Context, id RedisEnterpriseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateEndpointConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForList(resp *http.Response) (result ListResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/method_put_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/method_put_autorest.go deleted file mode 100644 index ac463ffb3815..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/method_put_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type PutResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Put ... -func (c PrivateEndpointConnectionsClient) Put(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result PutResponse, err error) { - req, err := c.preparerForPut(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Put", nil, "Failure preparing request") - return - } - - result, err = c.senderForPut(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Put", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// PutThenPoll performs Put then polls until it's completed -func (c PrivateEndpointConnectionsClient) PutThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) error { - result, err := c.Put(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Put: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Put: %+v", err) - } - - return nil -} - -// preparerForPut prepares the Put request. -func (c PrivateEndpointConnectionsClient) preparerForPut(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForPut sends the Put request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionsClient) senderForPut(ctx context.Context, req *http.Request) (future PutResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/model_privateendpoint.go b/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/model_privateendpoint.go deleted file mode 100644 index 33ffc888d58a..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/model_privateendpoint.go +++ /dev/null @@ -1,5 +0,0 @@ -package privateendpointconnections - -type PrivateEndpoint struct { - Id *string `json:"id,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/model_privateendpointconnection.go b/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/model_privateendpointconnection.go deleted file mode 100644 index 597d3e71746a..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/model_privateendpointconnection.go +++ /dev/null @@ -1,8 +0,0 @@ -package privateendpointconnections - -type PrivateEndpointConnection struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/model_privateendpointconnectionlistresult.go b/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/model_privateendpointconnectionlistresult.go deleted file mode 100644 index b565022bf4e0..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/model_privateendpointconnectionlistresult.go +++ /dev/null @@ -1,5 +0,0 @@ -package privateendpointconnections - -type PrivateEndpointConnectionListResult struct { - Value *[]PrivateEndpointConnection `json:"value,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/model_privateendpointconnectionproperties.go b/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/model_privateendpointconnectionproperties.go deleted file mode 100644 index 252bd91cbe86..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/model_privateendpointconnectionproperties.go +++ /dev/null @@ -1,7 +0,0 @@ -package privateendpointconnections - -type PrivateEndpointConnectionProperties struct { - PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` - PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` - ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go b/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go deleted file mode 100644 index def138656add..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go +++ /dev/null @@ -1,7 +0,0 @@ -package privateendpointconnections - -type PrivateLinkServiceConnectionState struct { - ActionsRequired *string `json:"actionsRequired,omitempty"` - Description *string `json:"description,omitempty"` - Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/version.go b/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/version.go deleted file mode 100644 index 2cc317d62ec5..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privateendpointconnections/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package privateendpointconnections - -import "fmt" - -const defaultApiVersion = "2022-01-01" - -func userAgent() string { - return fmt.Sprintf("pandora/privateendpointconnections/%s", defaultApiVersion) -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/client.go b/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/client.go deleted file mode 100644 index 3ccc015d4fe1..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package privatelinkresources - -import "github.com/Azure/go-autorest/autorest" - -type PrivateLinkResourcesClient struct { - Client autorest.Client - baseUri string -} - -func NewPrivateLinkResourcesClientWithBaseURI(endpoint string) PrivateLinkResourcesClient { - return PrivateLinkResourcesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/id_redisenterprise.go b/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/id_redisenterprise.go deleted file mode 100644 index 55569e1b866c..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/id_redisenterprise.go +++ /dev/null @@ -1,124 +0,0 @@ -package privatelinkresources - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = RedisEnterpriseId{} - -// RedisEnterpriseId is a struct representing the Resource ID for a Redis Enterprise -type RedisEnterpriseId struct { - SubscriptionId string - ResourceGroupName string - ClusterName string -} - -// NewRedisEnterpriseID returns a new RedisEnterpriseId struct -func NewRedisEnterpriseID(subscriptionId string, resourceGroupName string, clusterName string) RedisEnterpriseId { - return RedisEnterpriseId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ClusterName: clusterName, - } -} - -// ParseRedisEnterpriseID parses 'input' into a RedisEnterpriseId -func ParseRedisEnterpriseID(input string) (*RedisEnterpriseId, error) { - parser := resourceids.NewParserFromResourceIdType(RedisEnterpriseId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := RedisEnterpriseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseRedisEnterpriseIDInsensitively parses 'input' case-insensitively into a RedisEnterpriseId -// note: this method should only be used for API response data and not user input -func ParseRedisEnterpriseIDInsensitively(input string) (*RedisEnterpriseId, error) { - parser := resourceids.NewParserFromResourceIdType(RedisEnterpriseId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := RedisEnterpriseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateRedisEnterpriseID checks that 'input' can be parsed as a Redis Enterprise ID -func ValidateRedisEnterpriseID(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 := ParseRedisEnterpriseID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Redis Enterprise ID -func (id RedisEnterpriseId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Cache/redisEnterprise/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Redis Enterprise ID -func (id RedisEnterpriseId) 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("staticMicrosoftCache", "Microsoft.Cache", "Microsoft.Cache"), - resourceids.StaticSegment("staticRedisEnterprise", "redisEnterprise", "redisEnterprise"), - resourceids.UserSpecifiedSegment("clusterName", "clusterValue"), - } -} - -// String returns a human-readable description of this Redis Enterprise ID -func (id RedisEnterpriseId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Cluster Name: %q", id.ClusterName), - } - return fmt.Sprintf("Redis Enterprise (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/id_redisenterprise_test.go b/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/id_redisenterprise_test.go deleted file mode 100644 index 9db75fddddea..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/id_redisenterprise_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package privatelinkresources - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = RedisEnterpriseId{} - -func TestNewRedisEnterpriseID(t *testing.T) { - id := NewRedisEnterpriseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue") - - 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.ClusterName != "clusterValue" { - t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterValue") - } -} - -func TestFormatRedisEnterpriseID(t *testing.T) { - actual := NewRedisEnterpriseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseRedisEnterpriseID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *RedisEnterpriseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseRedisEnterpriseID(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - } -} - -func TestParseRedisEnterpriseIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *RedisEnterpriseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ClusterName: "cLuStErVaLuE", - }, - }, - { - // 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.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseRedisEnterpriseIDInsensitively(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - } -} - -func TestSegmentsForRedisEnterpriseId(t *testing.T) { - segments := RedisEnterpriseId{}.Segments() - if len(segments) == 0 { - t.Fatalf("RedisEnterpriseId 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/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/method_listbycluster_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/method_listbycluster_autorest.go deleted file mode 100644 index fcf3d727f0ed..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/method_listbycluster_autorest.go +++ /dev/null @@ -1,65 +0,0 @@ -package privatelinkresources - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ListByClusterResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResourceListResult -} - -// ListByCluster ... -func (c PrivateLinkResourcesClient) ListByCluster(ctx context.Context, id RedisEnterpriseId) (result ListByClusterResponse, err error) { - req, err := c.preparerForListByCluster(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByCluster", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByCluster", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByCluster(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByCluster", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByCluster prepares the ListByCluster request. -func (c PrivateLinkResourcesClient) preparerForListByCluster(ctx context.Context, id RedisEnterpriseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateLinkResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByCluster handles the response to the ListByCluster request. The method always -// closes the http.Response Body. -func (c PrivateLinkResourcesClient) responderForListByCluster(resp *http.Response) (result ListByClusterResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/model_privatelinkresource.go b/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/model_privatelinkresource.go deleted file mode 100644 index d3cb62e00811..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/model_privatelinkresource.go +++ /dev/null @@ -1,8 +0,0 @@ -package privatelinkresources - -type PrivateLinkResource struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/model_privatelinkresourcelistresult.go b/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/model_privatelinkresourcelistresult.go deleted file mode 100644 index 19c87bd4a131..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/model_privatelinkresourcelistresult.go +++ /dev/null @@ -1,5 +0,0 @@ -package privatelinkresources - -type PrivateLinkResourceListResult struct { - Value *[]PrivateLinkResource `json:"value,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/model_privatelinkresourceproperties.go b/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/model_privatelinkresourceproperties.go deleted file mode 100644 index 51bc838c1fbd..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/model_privatelinkresourceproperties.go +++ /dev/null @@ -1,7 +0,0 @@ -package privatelinkresources - -type PrivateLinkResourceProperties struct { - GroupId *string `json:"groupId,omitempty"` - RequiredMembers *[]string `json:"requiredMembers,omitempty"` - RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/version.go b/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/version.go deleted file mode 100644 index 42526e371156..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/privatelinkresources/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package privatelinkresources - -import "fmt" - -const defaultApiVersion = "2022-01-01" - -func userAgent() string { - return fmt.Sprintf("pandora/privatelinkresources/%s", defaultApiVersion) -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/client.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/client.go deleted file mode 100644 index e38fe5d733af..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package redisenterprise - -import "github.com/Azure/go-autorest/autorest" - -type RedisEnterpriseClient struct { - Client autorest.Client - baseUri string -} - -func NewRedisEnterpriseClientWithBaseURI(endpoint string) RedisEnterpriseClient { - return RedisEnterpriseClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/constants.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/constants.go deleted file mode 100644 index a4a40bd462d5..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/constants.go +++ /dev/null @@ -1,466 +0,0 @@ -package redisenterprise - -import "strings" - -type AccessKeyType string - -const ( - AccessKeyTypePrimary AccessKeyType = "Primary" - AccessKeyTypeSecondary AccessKeyType = "Secondary" -) - -func PossibleValuesForAccessKeyType() []string { - return []string{ - string(AccessKeyTypePrimary), - string(AccessKeyTypeSecondary), - } -} - -func parseAccessKeyType(input string) (*AccessKeyType, error) { - vals := map[string]AccessKeyType{ - "primary": AccessKeyTypePrimary, - "secondary": AccessKeyTypeSecondary, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := AccessKeyType(input) - return &out, nil -} - -type AofFrequency string - -const ( - AofFrequencyAlways AofFrequency = "always" - AofFrequencyOnes AofFrequency = "1s" -) - -func PossibleValuesForAofFrequency() []string { - return []string{ - string(AofFrequencyAlways), - string(AofFrequencyOnes), - } -} - -func parseAofFrequency(input string) (*AofFrequency, error) { - vals := map[string]AofFrequency{ - "always": AofFrequencyAlways, - "1s": AofFrequencyOnes, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := AofFrequency(input) - return &out, nil -} - -type ClusteringPolicy string - -const ( - ClusteringPolicyEnterpriseCluster ClusteringPolicy = "EnterpriseCluster" - ClusteringPolicyOSSCluster ClusteringPolicy = "OSSCluster" -) - -func PossibleValuesForClusteringPolicy() []string { - return []string{ - string(ClusteringPolicyEnterpriseCluster), - string(ClusteringPolicyOSSCluster), - } -} - -func parseClusteringPolicy(input string) (*ClusteringPolicy, error) { - vals := map[string]ClusteringPolicy{ - "enterprisecluster": ClusteringPolicyEnterpriseCluster, - "osscluster": ClusteringPolicyOSSCluster, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ClusteringPolicy(input) - return &out, nil -} - -type EvictionPolicy string - -const ( - EvictionPolicyAllKeysLFU EvictionPolicy = "AllKeysLFU" - EvictionPolicyAllKeysLRU EvictionPolicy = "AllKeysLRU" - EvictionPolicyAllKeysRandom EvictionPolicy = "AllKeysRandom" - EvictionPolicyNoEviction EvictionPolicy = "NoEviction" - EvictionPolicyVolatileLFU EvictionPolicy = "VolatileLFU" - EvictionPolicyVolatileLRU EvictionPolicy = "VolatileLRU" - EvictionPolicyVolatileRandom EvictionPolicy = "VolatileRandom" - EvictionPolicyVolatileTTL EvictionPolicy = "VolatileTTL" -) - -func PossibleValuesForEvictionPolicy() []string { - return []string{ - string(EvictionPolicyAllKeysLFU), - string(EvictionPolicyAllKeysLRU), - string(EvictionPolicyAllKeysRandom), - string(EvictionPolicyNoEviction), - string(EvictionPolicyVolatileLFU), - string(EvictionPolicyVolatileLRU), - string(EvictionPolicyVolatileRandom), - string(EvictionPolicyVolatileTTL), - } -} - -func parseEvictionPolicy(input string) (*EvictionPolicy, error) { - vals := map[string]EvictionPolicy{ - "allkeyslfu": EvictionPolicyAllKeysLFU, - "allkeyslru": EvictionPolicyAllKeysLRU, - "allkeysrandom": EvictionPolicyAllKeysRandom, - "noeviction": EvictionPolicyNoEviction, - "volatilelfu": EvictionPolicyVolatileLFU, - "volatilelru": EvictionPolicyVolatileLRU, - "volatilerandom": EvictionPolicyVolatileRandom, - "volatilettl": EvictionPolicyVolatileTTL, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := EvictionPolicy(input) - return &out, nil -} - -type LinkState string - -const ( - LinkStateLinkFailed LinkState = "LinkFailed" - LinkStateLinked LinkState = "Linked" - LinkStateLinking LinkState = "Linking" - LinkStateUnlinkFailed LinkState = "UnlinkFailed" - LinkStateUnlinking LinkState = "Unlinking" -) - -func PossibleValuesForLinkState() []string { - return []string{ - string(LinkStateLinkFailed), - string(LinkStateLinked), - string(LinkStateLinking), - string(LinkStateUnlinkFailed), - string(LinkStateUnlinking), - } -} - -func parseLinkState(input string) (*LinkState, error) { - vals := map[string]LinkState{ - "linkfailed": LinkStateLinkFailed, - "linked": LinkStateLinked, - "linking": LinkStateLinking, - "unlinkfailed": LinkStateUnlinkFailed, - "unlinking": LinkStateUnlinking, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := LinkState(input) - return &out, nil -} - -type PrivateEndpointConnectionProvisioningState string - -const ( - PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" - PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" - PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" - PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" -) - -func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { - return []string{ - string(PrivateEndpointConnectionProvisioningStateCreating), - string(PrivateEndpointConnectionProvisioningStateDeleting), - string(PrivateEndpointConnectionProvisioningStateFailed), - string(PrivateEndpointConnectionProvisioningStateSucceeded), - } -} - -func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { - vals := map[string]PrivateEndpointConnectionProvisioningState{ - "creating": PrivateEndpointConnectionProvisioningStateCreating, - "deleting": PrivateEndpointConnectionProvisioningStateDeleting, - "failed": PrivateEndpointConnectionProvisioningStateFailed, - "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointConnectionProvisioningState(input) - return &out, nil -} - -type PrivateEndpointServiceConnectionStatus string - -const ( - PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" - PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" -) - -func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { - return []string{ - string(PrivateEndpointServiceConnectionStatusApproved), - string(PrivateEndpointServiceConnectionStatusPending), - string(PrivateEndpointServiceConnectionStatusRejected), - } -} - -func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { - vals := map[string]PrivateEndpointServiceConnectionStatus{ - "approved": PrivateEndpointServiceConnectionStatusApproved, - "pending": PrivateEndpointServiceConnectionStatusPending, - "rejected": PrivateEndpointServiceConnectionStatusRejected, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointServiceConnectionStatus(input) - return &out, nil -} - -type Protocol string - -const ( - ProtocolEncrypted Protocol = "Encrypted" - ProtocolPlaintext Protocol = "Plaintext" -) - -func PossibleValuesForProtocol() []string { - return []string{ - string(ProtocolEncrypted), - string(ProtocolPlaintext), - } -} - -func parseProtocol(input string) (*Protocol, error) { - vals := map[string]Protocol{ - "encrypted": ProtocolEncrypted, - "plaintext": ProtocolPlaintext, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := Protocol(input) - return &out, nil -} - -type ProvisioningState string - -const ( - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreating ProvisioningState = "Creating" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateFailed ProvisioningState = "Failed" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateUpdating ProvisioningState = "Updating" -) - -func PossibleValuesForProvisioningState() []string { - return []string{ - string(ProvisioningStateCanceled), - string(ProvisioningStateCreating), - string(ProvisioningStateDeleting), - string(ProvisioningStateFailed), - string(ProvisioningStateSucceeded), - string(ProvisioningStateUpdating), - } -} - -func parseProvisioningState(input string) (*ProvisioningState, error) { - vals := map[string]ProvisioningState{ - "canceled": ProvisioningStateCanceled, - "creating": ProvisioningStateCreating, - "deleting": ProvisioningStateDeleting, - "failed": ProvisioningStateFailed, - "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 RdbFrequency string - -const ( - RdbFrequencyOneTwoh RdbFrequency = "12h" - RdbFrequencyOneh RdbFrequency = "1h" - RdbFrequencySixh RdbFrequency = "6h" -) - -func PossibleValuesForRdbFrequency() []string { - return []string{ - string(RdbFrequencyOneTwoh), - string(RdbFrequencyOneh), - string(RdbFrequencySixh), - } -} - -func parseRdbFrequency(input string) (*RdbFrequency, error) { - vals := map[string]RdbFrequency{ - "12h": RdbFrequencyOneTwoh, - "1h": RdbFrequencyOneh, - "6h": RdbFrequencySixh, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := RdbFrequency(input) - return &out, nil -} - -type ResourceState string - -const ( - ResourceStateCreateFailed ResourceState = "CreateFailed" - ResourceStateCreating ResourceState = "Creating" - ResourceStateDeleteFailed ResourceState = "DeleteFailed" - ResourceStateDeleting ResourceState = "Deleting" - ResourceStateDisableFailed ResourceState = "DisableFailed" - ResourceStateDisabled ResourceState = "Disabled" - ResourceStateDisabling ResourceState = "Disabling" - ResourceStateEnableFailed ResourceState = "EnableFailed" - ResourceStateEnabling ResourceState = "Enabling" - ResourceStateRunning ResourceState = "Running" - ResourceStateUpdateFailed ResourceState = "UpdateFailed" - ResourceStateUpdating ResourceState = "Updating" -) - -func PossibleValuesForResourceState() []string { - return []string{ - string(ResourceStateCreateFailed), - string(ResourceStateCreating), - string(ResourceStateDeleteFailed), - string(ResourceStateDeleting), - string(ResourceStateDisableFailed), - string(ResourceStateDisabled), - string(ResourceStateDisabling), - string(ResourceStateEnableFailed), - string(ResourceStateEnabling), - string(ResourceStateRunning), - string(ResourceStateUpdateFailed), - string(ResourceStateUpdating), - } -} - -func parseResourceState(input string) (*ResourceState, error) { - vals := map[string]ResourceState{ - "createfailed": ResourceStateCreateFailed, - "creating": ResourceStateCreating, - "deletefailed": ResourceStateDeleteFailed, - "deleting": ResourceStateDeleting, - "disablefailed": ResourceStateDisableFailed, - "disabled": ResourceStateDisabled, - "disabling": ResourceStateDisabling, - "enablefailed": ResourceStateEnableFailed, - "enabling": ResourceStateEnabling, - "running": ResourceStateRunning, - "updatefailed": ResourceStateUpdateFailed, - "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 SkuName string - -const ( - SkuNameEnterpriseEFiveZero SkuName = "Enterprise_E50" - SkuNameEnterpriseEOneZero SkuName = "Enterprise_E10" - SkuNameEnterpriseEOneZeroZero SkuName = "Enterprise_E100" - SkuNameEnterpriseETwoZero SkuName = "Enterprise_E20" - SkuNameEnterpriseFlashFOneFiveZeroZero SkuName = "EnterpriseFlash_F1500" - SkuNameEnterpriseFlashFSevenZeroZero SkuName = "EnterpriseFlash_F700" - SkuNameEnterpriseFlashFThreeZeroZero SkuName = "EnterpriseFlash_F300" -) - -func PossibleValuesForSkuName() []string { - return []string{ - string(SkuNameEnterpriseEFiveZero), - string(SkuNameEnterpriseEOneZero), - string(SkuNameEnterpriseEOneZeroZero), - string(SkuNameEnterpriseETwoZero), - string(SkuNameEnterpriseFlashFOneFiveZeroZero), - string(SkuNameEnterpriseFlashFSevenZeroZero), - string(SkuNameEnterpriseFlashFThreeZeroZero), - } -} - -func parseSkuName(input string) (*SkuName, error) { - vals := map[string]SkuName{ - "enterprise_e50": SkuNameEnterpriseEFiveZero, - "enterprise_e10": SkuNameEnterpriseEOneZero, - "enterprise_e100": SkuNameEnterpriseEOneZeroZero, - "enterprise_e20": SkuNameEnterpriseETwoZero, - "enterpriseflash_f1500": SkuNameEnterpriseFlashFOneFiveZeroZero, - "enterpriseflash_f700": SkuNameEnterpriseFlashFSevenZeroZero, - "enterpriseflash_f300": SkuNameEnterpriseFlashFThreeZeroZero, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := SkuName(input) - return &out, nil -} - -type TlsVersion string - -const ( - TlsVersionOnePointOne TlsVersion = "1.1" - TlsVersionOnePointTwo TlsVersion = "1.2" - TlsVersionOnePointZero TlsVersion = "1.0" -) - -func PossibleValuesForTlsVersion() []string { - return []string{ - string(TlsVersionOnePointOne), - string(TlsVersionOnePointTwo), - string(TlsVersionOnePointZero), - } -} - -func parseTlsVersion(input string) (*TlsVersion, error) { - vals := map[string]TlsVersion{ - "1.1": TlsVersionOnePointOne, - "1.2": TlsVersionOnePointTwo, - "1.0": TlsVersionOnePointZero, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := TlsVersion(input) - return &out, nil -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/id_database.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/id_database.go deleted file mode 100644 index a44834a9fc21..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/id_database.go +++ /dev/null @@ -1,137 +0,0 @@ -package redisenterprise - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = DatabaseId{} - -// DatabaseId is a struct representing the Resource ID for a Database -type DatabaseId struct { - SubscriptionId string - ResourceGroupName string - ClusterName string - DatabaseName string -} - -// NewDatabaseID returns a new DatabaseId struct -func NewDatabaseID(subscriptionId string, resourceGroupName string, clusterName string, databaseName string) DatabaseId { - return DatabaseId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ClusterName: clusterName, - DatabaseName: databaseName, - } -} - -// ParseDatabaseID parses 'input' into a DatabaseId -func ParseDatabaseID(input string) (*DatabaseId, error) { - parser := resourceids.NewParserFromResourceIdType(DatabaseId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := DatabaseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - if id.DatabaseName, ok = parsed.Parsed["databaseName"]; !ok { - return nil, fmt.Errorf("the segment 'databaseName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseDatabaseIDInsensitively parses 'input' case-insensitively into a DatabaseId -// note: this method should only be used for API response data and not user input -func ParseDatabaseIDInsensitively(input string) (*DatabaseId, error) { - parser := resourceids.NewParserFromResourceIdType(DatabaseId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := DatabaseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - if id.DatabaseName, ok = parsed.Parsed["databaseName"]; !ok { - return nil, fmt.Errorf("the segment 'databaseName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateDatabaseID checks that 'input' can be parsed as a Database ID -func ValidateDatabaseID(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 := ParseDatabaseID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Database ID -func (id DatabaseId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Cache/redisEnterprise/%s/databases/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName, id.DatabaseName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Database ID -func (id DatabaseId) 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("staticMicrosoftCache", "Microsoft.Cache", "Microsoft.Cache"), - resourceids.StaticSegment("staticRedisEnterprise", "redisEnterprise", "redisEnterprise"), - resourceids.UserSpecifiedSegment("clusterName", "clusterValue"), - resourceids.StaticSegment("staticDatabases", "databases", "databases"), - resourceids.UserSpecifiedSegment("databaseName", "databaseValue"), - } -} - -// String returns a human-readable description of this Database ID -func (id DatabaseId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Cluster Name: %q", id.ClusterName), - fmt.Sprintf("Database Name: %q", id.DatabaseName), - } - return fmt.Sprintf("Database (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/id_database_test.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/id_database_test.go deleted file mode 100644 index f22949b1fa2e..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/id_database_test.go +++ /dev/null @@ -1,324 +0,0 @@ -package redisenterprise - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = DatabaseId{} - -func TestNewDatabaseID(t *testing.T) { - id := NewDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue", "databaseValue") - - 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.ClusterName != "clusterValue" { - t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterValue") - } - - if id.DatabaseName != "databaseValue" { - t.Fatalf("Expected %q but got %q for Segment 'DatabaseName'", id.DatabaseName, "databaseValue") - } -} - -func TestFormatDatabaseID(t *testing.T) { - actual := NewDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue", "databaseValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases/databaseValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseDatabaseID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *DatabaseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases/databaseValue", - Expected: &DatabaseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - DatabaseName: "databaseValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases/databaseValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseDatabaseID(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - if actual.DatabaseName != v.Expected.DatabaseName { - t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) - } - - } -} - -func TestParseDatabaseIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *DatabaseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/dAtAbAsEs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases/databaseValue", - Expected: &DatabaseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - DatabaseName: "databaseValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/databases/databaseValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/dAtAbAsEs/dAtAbAsEvAlUe", - Expected: &DatabaseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ClusterName: "cLuStErVaLuE", - DatabaseName: "dAtAbAsEvAlUe", - }, - }, - { - // 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.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/dAtAbAsEs/dAtAbAsEvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseDatabaseIDInsensitively(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - if actual.DatabaseName != v.Expected.DatabaseName { - t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) - } - - } -} - -func TestSegmentsForDatabaseId(t *testing.T) { - segments := DatabaseId{}.Segments() - if len(segments) == 0 { - t.Fatalf("DatabaseId 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/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/id_redisenterprise.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/id_redisenterprise.go deleted file mode 100644 index 64e4baba8d9c..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/id_redisenterprise.go +++ /dev/null @@ -1,124 +0,0 @@ -package redisenterprise - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = RedisEnterpriseId{} - -// RedisEnterpriseId is a struct representing the Resource ID for a Redis Enterprise -type RedisEnterpriseId struct { - SubscriptionId string - ResourceGroupName string - ClusterName string -} - -// NewRedisEnterpriseID returns a new RedisEnterpriseId struct -func NewRedisEnterpriseID(subscriptionId string, resourceGroupName string, clusterName string) RedisEnterpriseId { - return RedisEnterpriseId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ClusterName: clusterName, - } -} - -// ParseRedisEnterpriseID parses 'input' into a RedisEnterpriseId -func ParseRedisEnterpriseID(input string) (*RedisEnterpriseId, error) { - parser := resourceids.NewParserFromResourceIdType(RedisEnterpriseId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := RedisEnterpriseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseRedisEnterpriseIDInsensitively parses 'input' case-insensitively into a RedisEnterpriseId -// note: this method should only be used for API response data and not user input -func ParseRedisEnterpriseIDInsensitively(input string) (*RedisEnterpriseId, error) { - parser := resourceids.NewParserFromResourceIdType(RedisEnterpriseId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := RedisEnterpriseId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ClusterName, ok = parsed.Parsed["clusterName"]; !ok { - return nil, fmt.Errorf("the segment 'clusterName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateRedisEnterpriseID checks that 'input' can be parsed as a Redis Enterprise ID -func ValidateRedisEnterpriseID(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 := ParseRedisEnterpriseID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Redis Enterprise ID -func (id RedisEnterpriseId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Cache/redisEnterprise/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Redis Enterprise ID -func (id RedisEnterpriseId) 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("staticMicrosoftCache", "Microsoft.Cache", "Microsoft.Cache"), - resourceids.StaticSegment("staticRedisEnterprise", "redisEnterprise", "redisEnterprise"), - resourceids.UserSpecifiedSegment("clusterName", "clusterValue"), - } -} - -// String returns a human-readable description of this Redis Enterprise ID -func (id RedisEnterpriseId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Cluster Name: %q", id.ClusterName), - } - return fmt.Sprintf("Redis Enterprise (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/id_redisenterprise_test.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/id_redisenterprise_test.go deleted file mode 100644 index 4aae3e5b6ed7..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/id_redisenterprise_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package redisenterprise - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = RedisEnterpriseId{} - -func TestNewRedisEnterpriseID(t *testing.T) { - id := NewRedisEnterpriseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue") - - 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.ClusterName != "clusterValue" { - t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterValue") - } -} - -func TestFormatRedisEnterpriseID(t *testing.T) { - actual := NewRedisEnterpriseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseRedisEnterpriseID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *RedisEnterpriseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseRedisEnterpriseID(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - } -} - -func TestParseRedisEnterpriseIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *RedisEnterpriseId - }{ - { - // 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.Cache", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Cache/redisEnterprise/clusterValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE", - Expected: &RedisEnterpriseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ClusterName: "cLuStErVaLuE", - }, - }, - { - // 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.cAcHe/rEdIsEnTeRpRiSe/cLuStErVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseRedisEnterpriseIDInsensitively(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.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - } -} - -func TestSegmentsForRedisEnterpriseId(t *testing.T) { - segments := RedisEnterpriseId{}.Segments() - if len(segments) == 0 { - t.Fatalf("RedisEnterpriseId 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/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_create_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_create_autorest.go deleted file mode 100644 index a55b54cf8adc..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_create_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type CreateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Create ... -func (c RedisEnterpriseClient) Create(ctx context.Context, id RedisEnterpriseId, input Cluster) (result CreateResponse, err error) { - req, err := c.preparerForCreate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "Create", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "Create", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateThenPoll performs Create then polls until it's completed -func (c RedisEnterpriseClient) CreateThenPoll(ctx context.Context, id RedisEnterpriseId, input Cluster) error { - result, err := c.Create(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Create: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Create: %+v", err) - } - - return nil -} - -// preparerForCreate prepares the Create request. -func (c RedisEnterpriseClient) preparerForCreate(ctx context.Context, id RedisEnterpriseId, input Cluster) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreate sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (c RedisEnterpriseClient) senderForCreate(ctx context.Context, req *http.Request) (future CreateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasescreate_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasescreate_autorest.go deleted file mode 100644 index da21f43c9188..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasescreate_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type DatabasesCreateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DatabasesCreate ... -func (c RedisEnterpriseClient) DatabasesCreate(ctx context.Context, id DatabaseId, input Database) (result DatabasesCreateResponse, err error) { - req, err := c.preparerForDatabasesCreate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesCreate", nil, "Failure preparing request") - return - } - - result, err = c.senderForDatabasesCreate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesCreate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DatabasesCreateThenPoll performs DatabasesCreate then polls until it's completed -func (c RedisEnterpriseClient) DatabasesCreateThenPoll(ctx context.Context, id DatabaseId, input Database) error { - result, err := c.DatabasesCreate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing DatabasesCreate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DatabasesCreate: %+v", err) - } - - return nil -} - -// preparerForDatabasesCreate prepares the DatabasesCreate request. -func (c RedisEnterpriseClient) preparerForDatabasesCreate(ctx context.Context, id DatabaseId, input Database) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDatabasesCreate sends the DatabasesCreate request. The method will close the -// http.Response Body if it receives an error. -func (c RedisEnterpriseClient) senderForDatabasesCreate(ctx context.Context, req *http.Request) (future DatabasesCreateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasesdelete_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasesdelete_autorest.go deleted file mode 100644 index ef8ce6deb342..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasesdelete_autorest.go +++ /dev/null @@ -1,74 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type DatabasesDeleteResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DatabasesDelete ... -func (c RedisEnterpriseClient) DatabasesDelete(ctx context.Context, id DatabaseId) (result DatabasesDeleteResponse, err error) { - req, err := c.preparerForDatabasesDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesDelete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDatabasesDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesDelete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DatabasesDeleteThenPoll performs DatabasesDelete then polls until it's completed -func (c RedisEnterpriseClient) DatabasesDeleteThenPoll(ctx context.Context, id DatabaseId) error { - result, err := c.DatabasesDelete(ctx, id) - if err != nil { - return fmt.Errorf("performing DatabasesDelete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DatabasesDelete: %+v", err) - } - - return nil -} - -// preparerForDatabasesDelete prepares the DatabasesDelete request. -func (c RedisEnterpriseClient) preparerForDatabasesDelete(ctx context.Context, id DatabaseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDatabasesDelete sends the DatabasesDelete request. The method will close the -// http.Response Body if it receives an error. -func (c RedisEnterpriseClient) senderForDatabasesDelete(ctx context.Context, req *http.Request) (future DatabasesDeleteResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasesexport_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasesexport_autorest.go deleted file mode 100644 index 18a15e938de3..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasesexport_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type DatabasesExportResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DatabasesExport ... -func (c RedisEnterpriseClient) DatabasesExport(ctx context.Context, id DatabaseId, input ExportClusterParameters) (result DatabasesExportResponse, err error) { - req, err := c.preparerForDatabasesExport(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesExport", nil, "Failure preparing request") - return - } - - result, err = c.senderForDatabasesExport(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesExport", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DatabasesExportThenPoll performs DatabasesExport then polls until it's completed -func (c RedisEnterpriseClient) DatabasesExportThenPoll(ctx context.Context, id DatabaseId, input ExportClusterParameters) error { - result, err := c.DatabasesExport(ctx, id, input) - if err != nil { - return fmt.Errorf("performing DatabasesExport: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DatabasesExport: %+v", err) - } - - return nil -} - -// preparerForDatabasesExport prepares the DatabasesExport request. -func (c RedisEnterpriseClient) preparerForDatabasesExport(ctx context.Context, id DatabaseId, input ExportClusterParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/export", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDatabasesExport sends the DatabasesExport request. The method will close the -// http.Response Body if it receives an error. -func (c RedisEnterpriseClient) senderForDatabasesExport(ctx context.Context, req *http.Request) (future DatabasesExportResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasesforceunlink_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasesforceunlink_autorest.go deleted file mode 100644 index dac2a5a072b2..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasesforceunlink_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type DatabasesForceUnlinkResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DatabasesForceUnlink ... -func (c RedisEnterpriseClient) DatabasesForceUnlink(ctx context.Context, id DatabaseId, input ForceUnlinkParameters) (result DatabasesForceUnlinkResponse, err error) { - req, err := c.preparerForDatabasesForceUnlink(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesForceUnlink", nil, "Failure preparing request") - return - } - - result, err = c.senderForDatabasesForceUnlink(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesForceUnlink", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DatabasesForceUnlinkThenPoll performs DatabasesForceUnlink then polls until it's completed -func (c RedisEnterpriseClient) DatabasesForceUnlinkThenPoll(ctx context.Context, id DatabaseId, input ForceUnlinkParameters) error { - result, err := c.DatabasesForceUnlink(ctx, id, input) - if err != nil { - return fmt.Errorf("performing DatabasesForceUnlink: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DatabasesForceUnlink: %+v", err) - } - - return nil -} - -// preparerForDatabasesForceUnlink prepares the DatabasesForceUnlink request. -func (c RedisEnterpriseClient) preparerForDatabasesForceUnlink(ctx context.Context, id DatabaseId, input ForceUnlinkParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/forceUnlink", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDatabasesForceUnlink sends the DatabasesForceUnlink request. The method will close the -// http.Response Body if it receives an error. -func (c RedisEnterpriseClient) senderForDatabasesForceUnlink(ctx context.Context, req *http.Request) (future DatabasesForceUnlinkResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasesget_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasesget_autorest.go deleted file mode 100644 index 708cca55e0fb..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasesget_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package redisenterprise - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type DatabasesGetResponse struct { - HttpResponse *http.Response - Model *Database -} - -// DatabasesGet ... -func (c RedisEnterpriseClient) DatabasesGet(ctx context.Context, id DatabaseId) (result DatabasesGetResponse, err error) { - req, err := c.preparerForDatabasesGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDatabasesGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDatabasesGet prepares the DatabasesGet request. -func (c RedisEnterpriseClient) preparerForDatabasesGet(ctx context.Context, id DatabaseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDatabasesGet handles the response to the DatabasesGet request. The method always -// closes the http.Response Body. -func (c RedisEnterpriseClient) responderForDatabasesGet(resp *http.Response) (result DatabasesGetResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasesimport_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasesimport_autorest.go deleted file mode 100644 index 97fd8b97bc74..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasesimport_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type DatabasesImportResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DatabasesImport ... -func (c RedisEnterpriseClient) DatabasesImport(ctx context.Context, id DatabaseId, input ImportClusterParameters) (result DatabasesImportResponse, err error) { - req, err := c.preparerForDatabasesImport(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesImport", nil, "Failure preparing request") - return - } - - result, err = c.senderForDatabasesImport(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesImport", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DatabasesImportThenPoll performs DatabasesImport then polls until it's completed -func (c RedisEnterpriseClient) DatabasesImportThenPoll(ctx context.Context, id DatabaseId, input ImportClusterParameters) error { - result, err := c.DatabasesImport(ctx, id, input) - if err != nil { - return fmt.Errorf("performing DatabasesImport: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DatabasesImport: %+v", err) - } - - return nil -} - -// preparerForDatabasesImport prepares the DatabasesImport request. -func (c RedisEnterpriseClient) preparerForDatabasesImport(ctx context.Context, id DatabaseId, input ImportClusterParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/import", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDatabasesImport sends the DatabasesImport request. The method will close the -// http.Response Body if it receives an error. -func (c RedisEnterpriseClient) senderForDatabasesImport(ctx context.Context, req *http.Request) (future DatabasesImportResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databaseslistbycluster_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databaseslistbycluster_autorest.go deleted file mode 100644 index 20a1198b8dde..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databaseslistbycluster_autorest.go +++ /dev/null @@ -1,183 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type DatabasesListByClusterResponse struct { - HttpResponse *http.Response - Model *[]Database - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (DatabasesListByClusterResponse, error) -} - -type DatabasesListByClusterCompleteResult struct { - Items []Database -} - -func (r DatabasesListByClusterResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r DatabasesListByClusterResponse) LoadMore(ctx context.Context) (resp DatabasesListByClusterResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// DatabasesListByCluster ... -func (c RedisEnterpriseClient) DatabasesListByCluster(ctx context.Context, id RedisEnterpriseId) (resp DatabasesListByClusterResponse, err error) { - req, err := c.preparerForDatabasesListByCluster(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesListByCluster", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesListByCluster", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForDatabasesListByCluster(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesListByCluster", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// DatabasesListByClusterComplete retrieves all of the results into a single object -func (c RedisEnterpriseClient) DatabasesListByClusterComplete(ctx context.Context, id RedisEnterpriseId) (DatabasesListByClusterCompleteResult, error) { - return c.DatabasesListByClusterCompleteMatchingPredicate(ctx, id, DatabasePredicate{}) -} - -// DatabasesListByClusterCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c RedisEnterpriseClient) DatabasesListByClusterCompleteMatchingPredicate(ctx context.Context, id RedisEnterpriseId, predicate DatabasePredicate) (resp DatabasesListByClusterCompleteResult, err error) { - items := make([]Database, 0) - - page, err := c.DatabasesListByCluster(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := DatabasesListByClusterCompleteResult{ - Items: items, - } - return out, nil -} - -// preparerForDatabasesListByCluster prepares the DatabasesListByCluster request. -func (c RedisEnterpriseClient) preparerForDatabasesListByCluster(ctx context.Context, id RedisEnterpriseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/databases", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForDatabasesListByClusterWithNextLink prepares the DatabasesListByCluster request with the given nextLink token. -func (c RedisEnterpriseClient) preparerForDatabasesListByClusterWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDatabasesListByCluster handles the response to the DatabasesListByCluster request. The method always -// closes the http.Response Body. -func (c RedisEnterpriseClient) responderForDatabasesListByCluster(resp *http.Response) (result DatabasesListByClusterResponse, err error) { - type page struct { - Values []Database `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result DatabasesListByClusterResponse, err error) { - req, err := c.preparerForDatabasesListByClusterWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesListByCluster", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesListByCluster", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDatabasesListByCluster(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesListByCluster", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databaseslistkeys_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databaseslistkeys_autorest.go deleted file mode 100644 index 0d6ba1e7b2f7..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databaseslistkeys_autorest.go +++ /dev/null @@ -1,65 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type DatabasesListKeysResponse struct { - HttpResponse *http.Response - Model *AccessKeys -} - -// DatabasesListKeys ... -func (c RedisEnterpriseClient) DatabasesListKeys(ctx context.Context, id DatabaseId) (result DatabasesListKeysResponse, err error) { - req, err := c.preparerForDatabasesListKeys(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesListKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesListKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDatabasesListKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesListKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDatabasesListKeys prepares the DatabasesListKeys request. -func (c RedisEnterpriseClient) preparerForDatabasesListKeys(ctx context.Context, id DatabaseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listKeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDatabasesListKeys handles the response to the DatabasesListKeys request. The method always -// closes the http.Response Body. -func (c RedisEnterpriseClient) responderForDatabasesListKeys(resp *http.Response) (result DatabasesListKeysResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasesregeneratekey_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasesregeneratekey_autorest.go deleted file mode 100644 index 312b8ca2d129..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasesregeneratekey_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type DatabasesRegenerateKeyResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DatabasesRegenerateKey ... -func (c RedisEnterpriseClient) DatabasesRegenerateKey(ctx context.Context, id DatabaseId, input RegenerateKeyParameters) (result DatabasesRegenerateKeyResponse, err error) { - req, err := c.preparerForDatabasesRegenerateKey(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesRegenerateKey", nil, "Failure preparing request") - return - } - - result, err = c.senderForDatabasesRegenerateKey(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesRegenerateKey", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DatabasesRegenerateKeyThenPoll performs DatabasesRegenerateKey then polls until it's completed -func (c RedisEnterpriseClient) DatabasesRegenerateKeyThenPoll(ctx context.Context, id DatabaseId, input RegenerateKeyParameters) error { - result, err := c.DatabasesRegenerateKey(ctx, id, input) - if err != nil { - return fmt.Errorf("performing DatabasesRegenerateKey: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DatabasesRegenerateKey: %+v", err) - } - - return nil -} - -// preparerForDatabasesRegenerateKey prepares the DatabasesRegenerateKey request. -func (c RedisEnterpriseClient) preparerForDatabasesRegenerateKey(ctx context.Context, id DatabaseId, input RegenerateKeyParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/regenerateKey", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDatabasesRegenerateKey sends the DatabasesRegenerateKey request. The method will close the -// http.Response Body if it receives an error. -func (c RedisEnterpriseClient) senderForDatabasesRegenerateKey(ctx context.Context, req *http.Request) (future DatabasesRegenerateKeyResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasesupdate_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasesupdate_autorest.go deleted file mode 100644 index 7de76bb70b84..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_databasesupdate_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type DatabasesUpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DatabasesUpdate ... -func (c RedisEnterpriseClient) DatabasesUpdate(ctx context.Context, id DatabaseId, input DatabaseUpdate) (result DatabasesUpdateResponse, err error) { - req, err := c.preparerForDatabasesUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForDatabasesUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "DatabasesUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DatabasesUpdateThenPoll performs DatabasesUpdate then polls until it's completed -func (c RedisEnterpriseClient) DatabasesUpdateThenPoll(ctx context.Context, id DatabaseId, input DatabaseUpdate) error { - result, err := c.DatabasesUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing DatabasesUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DatabasesUpdate: %+v", err) - } - - return nil -} - -// preparerForDatabasesUpdate prepares the DatabasesUpdate request. -func (c RedisEnterpriseClient) preparerForDatabasesUpdate(ctx context.Context, id DatabaseId, input DatabaseUpdate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDatabasesUpdate sends the DatabasesUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c RedisEnterpriseClient) senderForDatabasesUpdate(ctx context.Context, req *http.Request) (future DatabasesUpdateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_delete_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_delete_autorest.go deleted file mode 100644 index c38cbc3ff879..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_delete_autorest.go +++ /dev/null @@ -1,74 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type DeleteResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c RedisEnterpriseClient) Delete(ctx context.Context, id RedisEnterpriseId) (result DeleteResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c RedisEnterpriseClient) DeleteThenPoll(ctx context.Context, id RedisEnterpriseId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c RedisEnterpriseClient) preparerForDelete(ctx context.Context, id RedisEnterpriseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c RedisEnterpriseClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_get_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_get_autorest.go deleted file mode 100644 index 4ba661142bd8..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_get_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package redisenterprise - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type GetResponse struct { - HttpResponse *http.Response - Model *Cluster -} - -// Get ... -func (c RedisEnterpriseClient) Get(ctx context.Context, id RedisEnterpriseId) (result GetResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c RedisEnterpriseClient) preparerForGet(ctx context.Context, id RedisEnterpriseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c RedisEnterpriseClient) responderForGet(resp *http.Response) (result GetResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_list_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_list_autorest.go deleted file mode 100644 index fb696c68d532..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_list_autorest.go +++ /dev/null @@ -1,184 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -type ListResponse struct { - HttpResponse *http.Response - Model *[]Cluster - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListResponse, error) -} - -type ListCompleteResult struct { - Items []Cluster -} - -func (r ListResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListResponse) LoadMore(ctx context.Context) (resp ListResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c RedisEnterpriseClient) List(ctx context.Context, id commonids.SubscriptionId) (resp ListResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c RedisEnterpriseClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, ClusterPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c RedisEnterpriseClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ClusterPredicate) (resp ListCompleteResult, err error) { - items := make([]Cluster, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} - -// preparerForList prepares the List request. -func (c RedisEnterpriseClient) preparerForList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Cache/redisEnterprise", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c RedisEnterpriseClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c RedisEnterpriseClient) responderForList(resp *http.Response) (result ListResponse, err error) { - type page struct { - Values []Cluster `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_listbyresourcegroup_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_listbyresourcegroup_autorest.go deleted file mode 100644 index 7d5b3d751e75..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,184 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -type ListByResourceGroupResponse struct { - HttpResponse *http.Response - Model *[]Cluster - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []Cluster -} - -func (r ListByResourceGroupResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResourceGroup ... -func (c RedisEnterpriseClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c RedisEnterpriseClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ClusterPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c RedisEnterpriseClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ClusterPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]Cluster, 0) - - page, err := c.ListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c RedisEnterpriseClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Cache/redisEnterprise", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c RedisEnterpriseClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c RedisEnterpriseClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupResponse, err error) { - type page struct { - Values []Cluster `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_update_autorest.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_update_autorest.go deleted file mode 100644 index b61326972782..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/method_update_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package redisenterprise - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -type UpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Update ... -func (c RedisEnterpriseClient) Update(ctx context.Context, id RedisEnterpriseId, input ClusterUpdate) (result UpdateResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "redisenterprise.RedisEnterpriseClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c RedisEnterpriseClient) UpdateThenPoll(ctx context.Context, id RedisEnterpriseId, input ClusterUpdate) error { - result, err := c.Update(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c RedisEnterpriseClient) preparerForUpdate(ctx context.Context, id RedisEnterpriseId, input ClusterUpdate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c RedisEnterpriseClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_accesskeys.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_accesskeys.go deleted file mode 100644 index 1df702dd4e7d..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_accesskeys.go +++ /dev/null @@ -1,6 +0,0 @@ -package redisenterprise - -type AccessKeys struct { - PrimaryKey *string `json:"primaryKey,omitempty"` - SecondaryKey *string `json:"secondaryKey,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_cluster.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_cluster.go deleted file mode 100644 index ae1f3ead7753..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_cluster.go +++ /dev/null @@ -1,12 +0,0 @@ -package redisenterprise - -type Cluster struct { - Id *string `json:"id,omitempty"` - Location string `json:"location"` - Name *string `json:"name,omitempty"` - Properties *ClusterProperties `json:"properties,omitempty"` - Sku Sku `json:"sku"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` - Zones *[]string `json:"zones,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_clusterproperties.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_clusterproperties.go deleted file mode 100644 index dc3870ca8650..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_clusterproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package redisenterprise - -type ClusterProperties struct { - HostName *string `json:"hostName,omitempty"` - MinimumTlsVersion *TlsVersion `json:"minimumTlsVersion,omitempty"` - PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` - RedisVersion *string `json:"redisVersion,omitempty"` - ResourceState *ResourceState `json:"resourceState,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_clusterupdate.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_clusterupdate.go deleted file mode 100644 index 1bcb8c42d55e..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_clusterupdate.go +++ /dev/null @@ -1,7 +0,0 @@ -package redisenterprise - -type ClusterUpdate struct { - Properties *ClusterProperties `json:"properties,omitempty"` - Sku *Sku `json:"sku,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_database.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_database.go deleted file mode 100644 index 4b38033a9585..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_database.go +++ /dev/null @@ -1,8 +0,0 @@ -package redisenterprise - -type Database struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *DatabaseProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_databaseproperties.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_databaseproperties.go deleted file mode 100644 index 92bc7a5377bb..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_databaseproperties.go +++ /dev/null @@ -1,13 +0,0 @@ -package redisenterprise - -type DatabaseProperties struct { - ClientProtocol *Protocol `json:"clientProtocol,omitempty"` - ClusteringPolicy *ClusteringPolicy `json:"clusteringPolicy,omitempty"` - EvictionPolicy *EvictionPolicy `json:"evictionPolicy,omitempty"` - GeoReplication *DatabasePropertiesGeoReplication `json:"geoReplication,omitempty"` - Modules *[]Module `json:"modules,omitempty"` - Persistence *Persistence `json:"persistence,omitempty"` - Port *int64 `json:"port,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` - ResourceState *ResourceState `json:"resourceState,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_databasepropertiesgeoreplication.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_databasepropertiesgeoreplication.go deleted file mode 100644 index eaf52f7fb463..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_databasepropertiesgeoreplication.go +++ /dev/null @@ -1,6 +0,0 @@ -package redisenterprise - -type DatabasePropertiesGeoReplication struct { - GroupNickname *string `json:"groupNickname,omitempty"` - LinkedDatabases *[]LinkedDatabase `json:"linkedDatabases,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_databaseupdate.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_databaseupdate.go deleted file mode 100644 index d607de221774..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_databaseupdate.go +++ /dev/null @@ -1,5 +0,0 @@ -package redisenterprise - -type DatabaseUpdate struct { - Properties *DatabaseProperties `json:"properties,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_exportclusterparameters.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_exportclusterparameters.go deleted file mode 100644 index d057282a827a..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_exportclusterparameters.go +++ /dev/null @@ -1,5 +0,0 @@ -package redisenterprise - -type ExportClusterParameters struct { - SasUri string `json:"sasUri"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_forceunlinkparameters.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_forceunlinkparameters.go deleted file mode 100644 index 7d11d396b540..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_forceunlinkparameters.go +++ /dev/null @@ -1,5 +0,0 @@ -package redisenterprise - -type ForceUnlinkParameters struct { - Ids []string `json:"ids"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_importclusterparameters.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_importclusterparameters.go deleted file mode 100644 index a4cddfd19e6b..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_importclusterparameters.go +++ /dev/null @@ -1,5 +0,0 @@ -package redisenterprise - -type ImportClusterParameters struct { - SasUris []string `json:"sasUris"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_linkeddatabase.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_linkeddatabase.go deleted file mode 100644 index c216b10106f0..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_linkeddatabase.go +++ /dev/null @@ -1,6 +0,0 @@ -package redisenterprise - -type LinkedDatabase struct { - Id *string `json:"id,omitempty"` - State *LinkState `json:"state,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_module.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_module.go deleted file mode 100644 index eccbce6aff7d..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_module.go +++ /dev/null @@ -1,7 +0,0 @@ -package redisenterprise - -type Module struct { - Args *string `json:"args,omitempty"` - Name string `json:"name"` - Version *string `json:"version,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_persistence.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_persistence.go deleted file mode 100644 index 8666152b6764..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_persistence.go +++ /dev/null @@ -1,8 +0,0 @@ -package redisenterprise - -type Persistence struct { - AofEnabled *bool `json:"aofEnabled,omitempty"` - AofFrequency *AofFrequency `json:"aofFrequency,omitempty"` - RdbEnabled *bool `json:"rdbEnabled,omitempty"` - RdbFrequency *RdbFrequency `json:"rdbFrequency,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_privateendpoint.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_privateendpoint.go deleted file mode 100644 index df570da01647..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_privateendpoint.go +++ /dev/null @@ -1,5 +0,0 @@ -package redisenterprise - -type PrivateEndpoint struct { - Id *string `json:"id,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_privateendpointconnection.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_privateendpointconnection.go deleted file mode 100644 index f4cbd5e47f9b..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_privateendpointconnection.go +++ /dev/null @@ -1,8 +0,0 @@ -package redisenterprise - -type PrivateEndpointConnection struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_privateendpointconnectionproperties.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_privateendpointconnectionproperties.go deleted file mode 100644 index 197d3da189b3..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_privateendpointconnectionproperties.go +++ /dev/null @@ -1,7 +0,0 @@ -package redisenterprise - -type PrivateEndpointConnectionProperties struct { - PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` - PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` - ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_privatelinkserviceconnectionstate.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_privatelinkserviceconnectionstate.go deleted file mode 100644 index 926598e9de8a..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_privatelinkserviceconnectionstate.go +++ /dev/null @@ -1,7 +0,0 @@ -package redisenterprise - -type PrivateLinkServiceConnectionState struct { - ActionsRequired *string `json:"actionsRequired,omitempty"` - Description *string `json:"description,omitempty"` - Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_regeneratekeyparameters.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_regeneratekeyparameters.go deleted file mode 100644 index 55d142131e76..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_regeneratekeyparameters.go +++ /dev/null @@ -1,5 +0,0 @@ -package redisenterprise - -type RegenerateKeyParameters struct { - KeyType AccessKeyType `json:"keyType"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_sku.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_sku.go deleted file mode 100644 index 16e22e0c4f51..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/model_sku.go +++ /dev/null @@ -1,6 +0,0 @@ -package redisenterprise - -type Sku struct { - Capacity *int64 `json:"capacity,omitempty"` - Name SkuName `json:"name"` -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/predicates.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/predicates.go deleted file mode 100644 index 3451ea28bb59..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/predicates.go +++ /dev/null @@ -1,52 +0,0 @@ -package redisenterprise - -type ClusterPredicate struct { - Id *string - Location *string - Name *string - Type *string -} - -func (p ClusterPredicate) Matches(input Cluster) bool { - - if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { - return false - } - - if p.Location != nil && *p.Location != input.Location { - return false - } - - if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { - return false - } - - return true -} - -type DatabasePredicate struct { - Id *string - Name *string - Type *string -} - -func (p DatabasePredicate) Matches(input Database) bool { - - if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { - return false - } - - if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { - return false - } - - return true -} diff --git a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/version.go b/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/version.go deleted file mode 100644 index c7dd7fdab50d..000000000000 --- a/internal/services/redisenterprise/sdk/2022-01-01/redisenterprise/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package redisenterprise - -import "fmt" - -const defaultApiVersion = "2022-01-01" - -func userAgent() string { - return fmt.Sprintf("pandora/redisenterprise/%s", defaultApiVersion) -}