From 8e9809bc6573c5fcf577999c3b4445a3d70b9276 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Sat, 25 Jun 2022 06:33:46 +0200 Subject: [PATCH] vmware: removing the embedded sdk --- .../sdk/2020-03-20/authorizations/client.go | 15 - .../2020-03-20/authorizations/constants.go | 34 -- .../authorizations/id_authorization.go | 137 -------- .../authorizations/id_authorization_test.go | 324 ------------------ .../authorizations/id_privatecloud.go | 124 ------- .../authorizations/id_privatecloud_test.go | 279 --------------- .../method_createorupdate_autorest.go | 75 ---- .../authorizations/method_delete_autorest.go | 73 ---- .../authorizations/method_get_autorest.go | 64 ---- .../authorizations/method_list_autorest.go | 183 ---------- .../model_expressrouteauthorization.go | 8 - ...del_expressrouteauthorizationproperties.go | 7 - .../2020-03-20/authorizations/predicates.go | 24 -- .../sdk/2020-03-20/authorizations/version.go | 9 - .../vmware/sdk/2020-03-20/clusters/client.go | 15 - .../sdk/2020-03-20/clusters/constants.go | 40 --- .../sdk/2020-03-20/clusters/id_cluster.go | 137 -------- .../2020-03-20/clusters/id_cluster_test.go | 324 ------------------ .../2020-03-20/clusters/id_privatecloud.go | 124 ------- .../clusters/id_privatecloud_test.go | 279 --------------- .../method_createorupdate_autorest.go | 75 ---- .../clusters/method_delete_autorest.go | 73 ---- .../clusters/method_get_autorest.go | 64 ---- .../clusters/method_list_autorest.go | 183 ---------- .../clusters/method_update_autorest.go | 75 ---- .../sdk/2020-03-20/clusters/model_cluster.go | 9 - .../clusters/model_clusterproperties.go | 8 - .../clusters/model_clusterupdate.go | 5 - .../clusters/model_clusterupdateproperties.go | 5 - .../sdk/2020-03-20/clusters/model_sku.go | 5 - .../sdk/2020-03-20/clusters/predicates.go | 24 -- .../vmware/sdk/2020-03-20/clusters/version.go | 9 - .../2020-03-20/hcxenterprisesites/client.go | 15 - .../hcxenterprisesites/constants.go | 37 -- .../id_hcxenterprisesite.go | 137 -------- .../id_hcxenterprisesite_test.go | 324 ------------------ .../hcxenterprisesites/id_privatecloud.go | 124 ------- .../id_privatecloud_test.go | 279 --------------- .../method_createorupdate_autorest.go | 65 ---- .../method_delete_autorest.go | 61 ---- .../hcxenterprisesites/method_get_autorest.go | 64 ---- .../method_list_autorest.go | 183 ---------- .../model_hcxenterprisesite.go | 8 - .../model_hcxenterprisesiteproperties.go | 6 - .../hcxenterprisesites/predicates.go | 24 -- .../2020-03-20/hcxenterprisesites/version.go | 9 - .../vmware/sdk/2020-03-20/locations/client.go | 15 - .../sdk/2020-03-20/locations/constants.go | 62 ---- .../sdk/2020-03-20/locations/id_location.go | 111 ------ .../2020-03-20/locations/id_location_test.go | 234 ------------- .../method_checkquotaavailability_autorest.go | 65 ---- .../method_checktrialavailability_autorest.go | 65 ---- .../sdk/2020-03-20/locations/model_quota.go | 6 - .../sdk/2020-03-20/locations/model_trial.go | 6 - .../sdk/2020-03-20/locations/version.go | 9 - .../sdk/2020-03-20/privateclouds/client.go | 15 - .../sdk/2020-03-20/privateclouds/constants.go | 139 -------- .../privateclouds/id_privatecloud.go | 124 ------- .../privateclouds/id_privatecloud_test.go | 279 --------------- .../privateclouds/id_resourcegroup.go | 109 ------ .../privateclouds/id_resourcegroup_test.go | 204 ----------- .../privateclouds/id_subscription.go | 96 ------ .../privateclouds/id_subscription_test.go | 159 --------- .../method_createorupdate_autorest.go | 75 ---- .../privateclouds/method_delete_autorest.go | 73 ---- .../privateclouds/method_get_autorest.go | 64 ---- .../privateclouds/method_list_autorest.go | 183 ---------- .../method_listadmincredentials_autorest.go | 65 ---- .../method_listinsubscription_autorest.go | 183 ---------- .../privateclouds/method_update_autorest.go | 75 ---- .../privateclouds/model_admincredentials.go | 8 - .../2020-03-20/privateclouds/model_circuit.go | 8 - .../privateclouds/model_endpoints.go | 7 - .../privateclouds/model_identitysource.go | 14 - .../privateclouds/model_managementcluster.go | 8 - .../privateclouds/model_privatecloud.go | 11 - .../model_privatecloudproperties.go | 18 - .../privateclouds/model_privatecloudupdate.go | 6 - .../model_privatecloudupdateproperties.go | 7 - .../sdk/2020-03-20/privateclouds/model_sku.go | 5 - .../2020-03-20/privateclouds/predicates.go | 29 -- .../sdk/2020-03-20/privateclouds/version.go | 9 - 82 files changed, 6692 deletions(-) delete mode 100644 internal/services/vmware/sdk/2020-03-20/authorizations/client.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/authorizations/constants.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/authorizations/id_authorization.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/authorizations/id_authorization_test.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/authorizations/id_privatecloud.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/authorizations/id_privatecloud_test.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/authorizations/method_createorupdate_autorest.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/authorizations/method_delete_autorest.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/authorizations/method_get_autorest.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/authorizations/method_list_autorest.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/authorizations/model_expressrouteauthorization.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/authorizations/model_expressrouteauthorizationproperties.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/authorizations/predicates.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/authorizations/version.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/clusters/client.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/clusters/constants.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/clusters/id_cluster.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/clusters/id_cluster_test.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/clusters/id_privatecloud.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/clusters/id_privatecloud_test.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/clusters/method_createorupdate_autorest.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/clusters/method_delete_autorest.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/clusters/method_get_autorest.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/clusters/method_list_autorest.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/clusters/method_update_autorest.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/clusters/model_cluster.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/clusters/model_clusterproperties.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/clusters/model_clusterupdate.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/clusters/model_clusterupdateproperties.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/clusters/model_sku.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/clusters/predicates.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/clusters/version.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/client.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/constants.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/id_hcxenterprisesite.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/id_hcxenterprisesite_test.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/id_privatecloud.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/id_privatecloud_test.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/method_createorupdate_autorest.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/method_delete_autorest.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/method_get_autorest.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/method_list_autorest.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/model_hcxenterprisesite.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/model_hcxenterprisesiteproperties.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/predicates.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/version.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/locations/client.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/locations/constants.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/locations/id_location.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/locations/id_location_test.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/locations/method_checkquotaavailability_autorest.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/locations/method_checktrialavailability_autorest.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/locations/model_quota.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/locations/model_trial.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/locations/version.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/client.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/constants.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/id_privatecloud.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/id_privatecloud_test.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/id_resourcegroup.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/id_resourcegroup_test.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/id_subscription.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/id_subscription_test.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/method_createorupdate_autorest.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/method_delete_autorest.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/method_get_autorest.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/method_list_autorest.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/method_listadmincredentials_autorest.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/method_listinsubscription_autorest.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/method_update_autorest.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/model_admincredentials.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/model_circuit.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/model_endpoints.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/model_identitysource.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/model_managementcluster.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/model_privatecloud.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/model_privatecloudproperties.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/model_privatecloudupdate.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/model_privatecloudupdateproperties.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/model_sku.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/predicates.go delete mode 100644 internal/services/vmware/sdk/2020-03-20/privateclouds/version.go diff --git a/internal/services/vmware/sdk/2020-03-20/authorizations/client.go b/internal/services/vmware/sdk/2020-03-20/authorizations/client.go deleted file mode 100644 index 248c6f51e882..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/authorizations/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package authorizations - -import "github.com/Azure/go-autorest/autorest" - -type AuthorizationsClient struct { - Client autorest.Client - baseUri string -} - -func NewAuthorizationsClientWithBaseURI(endpoint string) AuthorizationsClient { - return AuthorizationsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/vmware/sdk/2020-03-20/authorizations/constants.go b/internal/services/vmware/sdk/2020-03-20/authorizations/constants.go deleted file mode 100644 index e7202db9a387..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/authorizations/constants.go +++ /dev/null @@ -1,34 +0,0 @@ -package authorizations - -import "strings" - -type ExpressRouteAuthorizationProvisioningState string - -const ( - ExpressRouteAuthorizationProvisioningStateFailed ExpressRouteAuthorizationProvisioningState = "Failed" - ExpressRouteAuthorizationProvisioningStateSucceeded ExpressRouteAuthorizationProvisioningState = "Succeeded" - ExpressRouteAuthorizationProvisioningStateUpdating ExpressRouteAuthorizationProvisioningState = "Updating" -) - -func PossibleValuesForExpressRouteAuthorizationProvisioningState() []string { - return []string{ - string(ExpressRouteAuthorizationProvisioningStateFailed), - string(ExpressRouteAuthorizationProvisioningStateSucceeded), - string(ExpressRouteAuthorizationProvisioningStateUpdating), - } -} - -func parseExpressRouteAuthorizationProvisioningState(input string) (*ExpressRouteAuthorizationProvisioningState, error) { - vals := map[string]ExpressRouteAuthorizationProvisioningState{ - "failed": ExpressRouteAuthorizationProvisioningStateFailed, - "succeeded": ExpressRouteAuthorizationProvisioningStateSucceeded, - "updating": ExpressRouteAuthorizationProvisioningStateUpdating, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ExpressRouteAuthorizationProvisioningState(input) - return &out, nil -} diff --git a/internal/services/vmware/sdk/2020-03-20/authorizations/id_authorization.go b/internal/services/vmware/sdk/2020-03-20/authorizations/id_authorization.go deleted file mode 100644 index 338465da99b4..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/authorizations/id_authorization.go +++ /dev/null @@ -1,137 +0,0 @@ -package authorizations - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = AuthorizationId{} - -// AuthorizationId is a struct representing the Resource ID for a Authorization -type AuthorizationId struct { - SubscriptionId string - ResourceGroupName string - PrivateCloudName string - AuthorizationName string -} - -// NewAuthorizationID returns a new AuthorizationId struct -func NewAuthorizationID(subscriptionId string, resourceGroupName string, privateCloudName string, authorizationName string) AuthorizationId { - return AuthorizationId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - PrivateCloudName: privateCloudName, - AuthorizationName: authorizationName, - } -} - -// ParseAuthorizationID parses 'input' into a AuthorizationId -func ParseAuthorizationID(input string) (*AuthorizationId, error) { - parser := resourceids.NewParserFromResourceIdType(AuthorizationId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := AuthorizationId{} - - 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.PrivateCloudName, ok = parsed.Parsed["privateCloudName"]; !ok { - return nil, fmt.Errorf("the segment 'privateCloudName' was not found in the resource id %q", input) - } - - if id.AuthorizationName, ok = parsed.Parsed["authorizationName"]; !ok { - return nil, fmt.Errorf("the segment 'authorizationName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseAuthorizationIDInsensitively parses 'input' case-insensitively into a AuthorizationId -// note: this method should only be used for API response data and not user input -func ParseAuthorizationIDInsensitively(input string) (*AuthorizationId, error) { - parser := resourceids.NewParserFromResourceIdType(AuthorizationId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := AuthorizationId{} - - 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.PrivateCloudName, ok = parsed.Parsed["privateCloudName"]; !ok { - return nil, fmt.Errorf("the segment 'privateCloudName' was not found in the resource id %q", input) - } - - if id.AuthorizationName, ok = parsed.Parsed["authorizationName"]; !ok { - return nil, fmt.Errorf("the segment 'authorizationName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateAuthorizationID checks that 'input' can be parsed as a Authorization ID -func ValidateAuthorizationID(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 := ParseAuthorizationID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Authorization ID -func (id AuthorizationId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.AVS/privateClouds/%s/authorizations/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PrivateCloudName, id.AuthorizationName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Authorization ID -func (id AuthorizationId) 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("staticMicrosoftAVS", "Microsoft.AVS", "Microsoft.AVS"), - resourceids.StaticSegment("staticPrivateClouds", "privateClouds", "privateClouds"), - resourceids.UserSpecifiedSegment("privateCloudName", "privateCloudValue"), - resourceids.StaticSegment("staticAuthorizations", "authorizations", "authorizations"), - resourceids.UserSpecifiedSegment("authorizationName", "authorizationValue"), - } -} - -// String returns a human-readable description of this Authorization ID -func (id AuthorizationId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Private Cloud Name: %q", id.PrivateCloudName), - fmt.Sprintf("Authorization Name: %q", id.AuthorizationName), - } - return fmt.Sprintf("Authorization (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/vmware/sdk/2020-03-20/authorizations/id_authorization_test.go b/internal/services/vmware/sdk/2020-03-20/authorizations/id_authorization_test.go deleted file mode 100644 index 18231844615a..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/authorizations/id_authorization_test.go +++ /dev/null @@ -1,324 +0,0 @@ -package authorizations - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = AuthorizationId{} - -func TestNewAuthorizationID(t *testing.T) { - id := NewAuthorizationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateCloudValue", "authorizationValue") - - 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.PrivateCloudName != "privateCloudValue" { - t.Fatalf("Expected %q but got %q for Segment 'PrivateCloudName'", id.PrivateCloudName, "privateCloudValue") - } - - if id.AuthorizationName != "authorizationValue" { - t.Fatalf("Expected %q but got %q for Segment 'AuthorizationName'", id.AuthorizationName, "authorizationValue") - } -} - -func TestFormatAuthorizationID(t *testing.T) { - actual := NewAuthorizationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateCloudValue", "authorizationValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/authorizations/authorizationValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", actual, expected) - } -} - -func TestParseAuthorizationID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *AuthorizationId - }{ - { - // 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.AVS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/authorizations", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/authorizations/authorizationValue", - Expected: &AuthorizationId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - PrivateCloudName: "privateCloudValue", - AuthorizationName: "authorizationValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/authorizations/authorizationValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseAuthorizationID(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.PrivateCloudName != v.Expected.PrivateCloudName { - t.Fatalf("Expected %q but got %q for PrivateCloudName", v.Expected.PrivateCloudName, actual.PrivateCloudName) - } - - if actual.AuthorizationName != v.Expected.AuthorizationName { - t.Fatalf("Expected %q but got %q for AuthorizationName", v.Expected.AuthorizationName, actual.AuthorizationName) - } - - } -} - -func TestParseAuthorizationIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *AuthorizationId - }{ - { - // 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.AVS", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs/pRiVaTeClOuDs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs/pRiVaTeClOuDs/pRiVaTeClOuDvAlUe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/authorizations", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs/pRiVaTeClOuDs/pRiVaTeClOuDvAlUe/aUtHoRiZaTiOnS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/authorizations/authorizationValue", - Expected: &AuthorizationId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - PrivateCloudName: "privateCloudValue", - AuthorizationName: "authorizationValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/authorizations/authorizationValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs/pRiVaTeClOuDs/pRiVaTeClOuDvAlUe/aUtHoRiZaTiOnS/aUtHoRiZaTiOnVaLuE", - Expected: &AuthorizationId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - PrivateCloudName: "pRiVaTeClOuDvAlUe", - AuthorizationName: "aUtHoRiZaTiOnVaLuE", - }, - }, - { - // 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.aVs/pRiVaTeClOuDs/pRiVaTeClOuDvAlUe/aUtHoRiZaTiOnS/aUtHoRiZaTiOnVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseAuthorizationIDInsensitively(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.PrivateCloudName != v.Expected.PrivateCloudName { - t.Fatalf("Expected %q but got %q for PrivateCloudName", v.Expected.PrivateCloudName, actual.PrivateCloudName) - } - - if actual.AuthorizationName != v.Expected.AuthorizationName { - t.Fatalf("Expected %q but got %q for AuthorizationName", v.Expected.AuthorizationName, actual.AuthorizationName) - } - - } -} - -func TestSegmentsForAuthorizationId(t *testing.T) { - segments := AuthorizationId{}.Segments() - if len(segments) == 0 { - t.Fatalf("AuthorizationId 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/vmware/sdk/2020-03-20/authorizations/id_privatecloud.go b/internal/services/vmware/sdk/2020-03-20/authorizations/id_privatecloud.go deleted file mode 100644 index b3edc5f94e20..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/authorizations/id_privatecloud.go +++ /dev/null @@ -1,124 +0,0 @@ -package authorizations - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = PrivateCloudId{} - -// PrivateCloudId is a struct representing the Resource ID for a Private Cloud -type PrivateCloudId struct { - SubscriptionId string - ResourceGroupName string - PrivateCloudName string -} - -// NewPrivateCloudID returns a new PrivateCloudId struct -func NewPrivateCloudID(subscriptionId string, resourceGroupName string, privateCloudName string) PrivateCloudId { - return PrivateCloudId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - PrivateCloudName: privateCloudName, - } -} - -// ParsePrivateCloudID parses 'input' into a PrivateCloudId -func ParsePrivateCloudID(input string) (*PrivateCloudId, error) { - parser := resourceids.NewParserFromResourceIdType(PrivateCloudId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := PrivateCloudId{} - - 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.PrivateCloudName, ok = parsed.Parsed["privateCloudName"]; !ok { - return nil, fmt.Errorf("the segment 'privateCloudName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParsePrivateCloudIDInsensitively parses 'input' case-insensitively into a PrivateCloudId -// note: this method should only be used for API response data and not user input -func ParsePrivateCloudIDInsensitively(input string) (*PrivateCloudId, error) { - parser := resourceids.NewParserFromResourceIdType(PrivateCloudId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := PrivateCloudId{} - - 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.PrivateCloudName, ok = parsed.Parsed["privateCloudName"]; !ok { - return nil, fmt.Errorf("the segment 'privateCloudName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidatePrivateCloudID checks that 'input' can be parsed as a Private Cloud ID -func ValidatePrivateCloudID(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 := ParsePrivateCloudID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Private Cloud ID -func (id PrivateCloudId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.AVS/privateClouds/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PrivateCloudName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Private Cloud ID -func (id PrivateCloudId) 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("staticMicrosoftAVS", "Microsoft.AVS", "Microsoft.AVS"), - resourceids.StaticSegment("staticPrivateClouds", "privateClouds", "privateClouds"), - resourceids.UserSpecifiedSegment("privateCloudName", "privateCloudValue"), - } -} - -// String returns a human-readable description of this Private Cloud ID -func (id PrivateCloudId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Private Cloud Name: %q", id.PrivateCloudName), - } - return fmt.Sprintf("Private Cloud (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/vmware/sdk/2020-03-20/authorizations/id_privatecloud_test.go b/internal/services/vmware/sdk/2020-03-20/authorizations/id_privatecloud_test.go deleted file mode 100644 index 0d903dcfa290..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/authorizations/id_privatecloud_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package authorizations - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = PrivateCloudId{} - -func TestNewPrivateCloudID(t *testing.T) { - id := NewPrivateCloudID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateCloudValue") - - 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.PrivateCloudName != "privateCloudValue" { - t.Fatalf("Expected %q but got %q for Segment 'PrivateCloudName'", id.PrivateCloudName, "privateCloudValue") - } -} - -func TestFormatPrivateCloudID(t *testing.T) { - actual := NewPrivateCloudID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateCloudValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", actual, expected) - } -} - -func TestParsePrivateCloudID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateCloudId - }{ - { - // 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.AVS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue", - Expected: &PrivateCloudId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - PrivateCloudName: "privateCloudValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateCloudID(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.PrivateCloudName != v.Expected.PrivateCloudName { - t.Fatalf("Expected %q but got %q for PrivateCloudName", v.Expected.PrivateCloudName, actual.PrivateCloudName) - } - - } -} - -func TestParsePrivateCloudIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateCloudId - }{ - { - // 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.AVS", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs/pRiVaTeClOuDs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue", - Expected: &PrivateCloudId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - PrivateCloudName: "privateCloudValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs/pRiVaTeClOuDs/pRiVaTeClOuDvAlUe", - Expected: &PrivateCloudId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - PrivateCloudName: "pRiVaTeClOuDvAlUe", - }, - }, - { - // 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.aVs/pRiVaTeClOuDs/pRiVaTeClOuDvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateCloudIDInsensitively(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.PrivateCloudName != v.Expected.PrivateCloudName { - t.Fatalf("Expected %q but got %q for PrivateCloudName", v.Expected.PrivateCloudName, actual.PrivateCloudName) - } - - } -} - -func TestSegmentsForPrivateCloudId(t *testing.T) { - segments := PrivateCloudId{}.Segments() - if len(segments) == 0 { - t.Fatalf("PrivateCloudId 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/vmware/sdk/2020-03-20/authorizations/method_createorupdate_autorest.go b/internal/services/vmware/sdk/2020-03-20/authorizations/method_createorupdate_autorest.go deleted file mode 100644 index 08bbc7b509b0..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/authorizations/method_createorupdate_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package authorizations - -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 CreateOrUpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c AuthorizationsClient) CreateOrUpdate(ctx context.Context, id AuthorizationId, input ExpressRouteAuthorization) (result CreateOrUpdateResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizations.AuthorizationsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizations.AuthorizationsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c AuthorizationsClient) CreateOrUpdateThenPoll(ctx context.Context, id AuthorizationId, input ExpressRouteAuthorization) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c AuthorizationsClient) preparerForCreateOrUpdate(ctx context.Context, id AuthorizationId, input ExpressRouteAuthorization) (*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)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c AuthorizationsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateResponse, 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/vmware/sdk/2020-03-20/authorizations/method_delete_autorest.go b/internal/services/vmware/sdk/2020-03-20/authorizations/method_delete_autorest.go deleted file mode 100644 index 477644dfd6b3..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/authorizations/method_delete_autorest.go +++ /dev/null @@ -1,73 +0,0 @@ -package authorizations - -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 AuthorizationsClient) Delete(ctx context.Context, id AuthorizationId) (result DeleteResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizations.AuthorizationsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizations.AuthorizationsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c AuthorizationsClient) DeleteThenPoll(ctx context.Context, id AuthorizationId) 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 AuthorizationsClient) preparerForDelete(ctx context.Context, id AuthorizationId) (*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 AuthorizationsClient) 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/vmware/sdk/2020-03-20/authorizations/method_get_autorest.go b/internal/services/vmware/sdk/2020-03-20/authorizations/method_get_autorest.go deleted file mode 100644 index 77991631579a..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/authorizations/method_get_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package authorizations - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type GetResponse struct { - HttpResponse *http.Response - Model *ExpressRouteAuthorization -} - -// Get ... -func (c AuthorizationsClient) Get(ctx context.Context, id AuthorizationId) (result GetResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizations.AuthorizationsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizations.AuthorizationsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizations.AuthorizationsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c AuthorizationsClient) preparerForGet(ctx context.Context, id AuthorizationId) (*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 AuthorizationsClient) 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/vmware/sdk/2020-03-20/authorizations/method_list_autorest.go b/internal/services/vmware/sdk/2020-03-20/authorizations/method_list_autorest.go deleted file mode 100644 index a94c91a1daf6..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/authorizations/method_list_autorest.go +++ /dev/null @@ -1,183 +0,0 @@ -package authorizations - -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 *[]ExpressRouteAuthorization - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListResponse, error) -} - -type ListCompleteResult struct { - Items []ExpressRouteAuthorization -} - -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 AuthorizationsClient) List(ctx context.Context, id PrivateCloudId) (resp ListResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizations.AuthorizationsClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizations.AuthorizationsClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizations.AuthorizationsClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c AuthorizationsClient) ListComplete(ctx context.Context, id PrivateCloudId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, ExpressRouteAuthorizationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AuthorizationsClient) ListCompleteMatchingPredicate(ctx context.Context, id PrivateCloudId, predicate ExpressRouteAuthorizationPredicate) (resp ListCompleteResult, err error) { - items := make([]ExpressRouteAuthorization, 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 AuthorizationsClient) preparerForList(ctx context.Context, id PrivateCloudId) (*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/authorizations", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c AuthorizationsClient) 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 AuthorizationsClient) responderForList(resp *http.Response) (result ListResponse, err error) { - type page struct { - Values []ExpressRouteAuthorization `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, "authorizations.AuthorizationsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizations.AuthorizationsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizations.AuthorizationsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/vmware/sdk/2020-03-20/authorizations/model_expressrouteauthorization.go b/internal/services/vmware/sdk/2020-03-20/authorizations/model_expressrouteauthorization.go deleted file mode 100644 index 9b6b85594796..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/authorizations/model_expressrouteauthorization.go +++ /dev/null @@ -1,8 +0,0 @@ -package authorizations - -type ExpressRouteAuthorization struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *ExpressRouteAuthorizationProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/vmware/sdk/2020-03-20/authorizations/model_expressrouteauthorizationproperties.go b/internal/services/vmware/sdk/2020-03-20/authorizations/model_expressrouteauthorizationproperties.go deleted file mode 100644 index 33abee839b83..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/authorizations/model_expressrouteauthorizationproperties.go +++ /dev/null @@ -1,7 +0,0 @@ -package authorizations - -type ExpressRouteAuthorizationProperties struct { - ExpressRouteAuthorizationId *string `json:"expressRouteAuthorizationId,omitempty"` - ExpressRouteAuthorizationKey *string `json:"expressRouteAuthorizationKey,omitempty"` - ProvisioningState *ExpressRouteAuthorizationProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/internal/services/vmware/sdk/2020-03-20/authorizations/predicates.go b/internal/services/vmware/sdk/2020-03-20/authorizations/predicates.go deleted file mode 100644 index c15ae8929084..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/authorizations/predicates.go +++ /dev/null @@ -1,24 +0,0 @@ -package authorizations - -type ExpressRouteAuthorizationPredicate struct { - Id *string - Name *string - Type *string -} - -func (p ExpressRouteAuthorizationPredicate) Matches(input ExpressRouteAuthorization) 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/vmware/sdk/2020-03-20/authorizations/version.go b/internal/services/vmware/sdk/2020-03-20/authorizations/version.go deleted file mode 100644 index 10b72ecbf1ed..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/authorizations/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package authorizations - -import "fmt" - -const defaultApiVersion = "2020-03-20" - -func userAgent() string { - return fmt.Sprintf("pandora/authorizations/%s", defaultApiVersion) -} diff --git a/internal/services/vmware/sdk/2020-03-20/clusters/client.go b/internal/services/vmware/sdk/2020-03-20/clusters/client.go deleted file mode 100644 index bffcbaa761b8..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/clusters/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package clusters - -import "github.com/Azure/go-autorest/autorest" - -type ClustersClient struct { - Client autorest.Client - baseUri string -} - -func NewClustersClientWithBaseURI(endpoint string) ClustersClient { - return ClustersClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/vmware/sdk/2020-03-20/clusters/constants.go b/internal/services/vmware/sdk/2020-03-20/clusters/constants.go deleted file mode 100644 index 6b09f491a56c..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/clusters/constants.go +++ /dev/null @@ -1,40 +0,0 @@ -package clusters - -import "strings" - -type ClusterProvisioningState string - -const ( - ClusterProvisioningStateCancelled ClusterProvisioningState = "Cancelled" - ClusterProvisioningStateDeleting ClusterProvisioningState = "Deleting" - ClusterProvisioningStateFailed ClusterProvisioningState = "Failed" - ClusterProvisioningStateSucceeded ClusterProvisioningState = "Succeeded" - ClusterProvisioningStateUpdating ClusterProvisioningState = "Updating" -) - -func PossibleValuesForClusterProvisioningState() []string { - return []string{ - string(ClusterProvisioningStateCancelled), - string(ClusterProvisioningStateDeleting), - string(ClusterProvisioningStateFailed), - string(ClusterProvisioningStateSucceeded), - string(ClusterProvisioningStateUpdating), - } -} - -func parseClusterProvisioningState(input string) (*ClusterProvisioningState, error) { - vals := map[string]ClusterProvisioningState{ - "cancelled": ClusterProvisioningStateCancelled, - "deleting": ClusterProvisioningStateDeleting, - "failed": ClusterProvisioningStateFailed, - "succeeded": ClusterProvisioningStateSucceeded, - "updating": ClusterProvisioningStateUpdating, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ClusterProvisioningState(input) - return &out, nil -} diff --git a/internal/services/vmware/sdk/2020-03-20/clusters/id_cluster.go b/internal/services/vmware/sdk/2020-03-20/clusters/id_cluster.go deleted file mode 100644 index 00e5edf64d89..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/clusters/id_cluster.go +++ /dev/null @@ -1,137 +0,0 @@ -package clusters - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = ClusterId{} - -// ClusterId is a struct representing the Resource ID for a Cluster -type ClusterId struct { - SubscriptionId string - ResourceGroupName string - PrivateCloudName string - ClusterName string -} - -// NewClusterID returns a new ClusterId struct -func NewClusterID(subscriptionId string, resourceGroupName string, privateCloudName string, clusterName string) ClusterId { - return ClusterId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - PrivateCloudName: privateCloudName, - ClusterName: clusterName, - } -} - -// ParseClusterID parses 'input' into a ClusterId -func ParseClusterID(input string) (*ClusterId, error) { - parser := resourceids.NewParserFromResourceIdType(ClusterId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := ClusterId{} - - 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.PrivateCloudName, ok = parsed.Parsed["privateCloudName"]; !ok { - return nil, fmt.Errorf("the segment 'privateCloudName' 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 -} - -// ParseClusterIDInsensitively parses 'input' case-insensitively into a ClusterId -// note: this method should only be used for API response data and not user input -func ParseClusterIDInsensitively(input string) (*ClusterId, error) { - parser := resourceids.NewParserFromResourceIdType(ClusterId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := ClusterId{} - - 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.PrivateCloudName, ok = parsed.Parsed["privateCloudName"]; !ok { - return nil, fmt.Errorf("the segment 'privateCloudName' 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 -} - -// ValidateClusterID checks that 'input' can be parsed as a Cluster ID -func ValidateClusterID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseClusterID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Cluster ID -func (id ClusterId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.AVS/privateClouds/%s/clusters/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PrivateCloudName, id.ClusterName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Cluster ID -func (id ClusterId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftAVS", "Microsoft.AVS", "Microsoft.AVS"), - resourceids.StaticSegment("staticPrivateClouds", "privateClouds", "privateClouds"), - resourceids.UserSpecifiedSegment("privateCloudName", "privateCloudValue"), - resourceids.StaticSegment("staticClusters", "clusters", "clusters"), - resourceids.UserSpecifiedSegment("clusterName", "clusterValue"), - } -} - -// String returns a human-readable description of this Cluster ID -func (id ClusterId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Private Cloud Name: %q", id.PrivateCloudName), - fmt.Sprintf("Cluster Name: %q", id.ClusterName), - } - return fmt.Sprintf("Cluster (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/vmware/sdk/2020-03-20/clusters/id_cluster_test.go b/internal/services/vmware/sdk/2020-03-20/clusters/id_cluster_test.go deleted file mode 100644 index 24530ae10c62..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/clusters/id_cluster_test.go +++ /dev/null @@ -1,324 +0,0 @@ -package clusters - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = ClusterId{} - -func TestNewClusterID(t *testing.T) { - id := NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateCloudValue", "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.PrivateCloudName != "privateCloudValue" { - t.Fatalf("Expected %q but got %q for Segment 'PrivateCloudName'", id.PrivateCloudName, "privateCloudValue") - } - - if id.ClusterName != "clusterValue" { - t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterValue") - } -} - -func TestFormatClusterID(t *testing.T) { - actual := NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateCloudValue", "clusterValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/clusters/clusterValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", actual, expected) - } -} - -func TestParseClusterID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ClusterId - }{ - { - // 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.AVS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/clusters", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/clusters/clusterValue", - Expected: &ClusterId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - PrivateCloudName: "privateCloudValue", - ClusterName: "clusterValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/clusters/clusterValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseClusterID(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.PrivateCloudName != v.Expected.PrivateCloudName { - t.Fatalf("Expected %q but got %q for PrivateCloudName", v.Expected.PrivateCloudName, actual.PrivateCloudName) - } - - if actual.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - } -} - -func TestParseClusterIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ClusterId - }{ - { - // 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.AVS", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs/pRiVaTeClOuDs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs/pRiVaTeClOuDs/pRiVaTeClOuDvAlUe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/clusters", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs/pRiVaTeClOuDs/pRiVaTeClOuDvAlUe/cLuStErS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/clusters/clusterValue", - Expected: &ClusterId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - PrivateCloudName: "privateCloudValue", - ClusterName: "clusterValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/clusters/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.aVs/pRiVaTeClOuDs/pRiVaTeClOuDvAlUe/cLuStErS/cLuStErVaLuE", - Expected: &ClusterId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - PrivateCloudName: "pRiVaTeClOuDvAlUe", - 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.aVs/pRiVaTeClOuDs/pRiVaTeClOuDvAlUe/cLuStErS/cLuStErVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseClusterIDInsensitively(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.PrivateCloudName != v.Expected.PrivateCloudName { - t.Fatalf("Expected %q but got %q for PrivateCloudName", v.Expected.PrivateCloudName, actual.PrivateCloudName) - } - - if actual.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) - } - - } -} - -func TestSegmentsForClusterId(t *testing.T) { - segments := ClusterId{}.Segments() - if len(segments) == 0 { - t.Fatalf("ClusterId 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/vmware/sdk/2020-03-20/clusters/id_privatecloud.go b/internal/services/vmware/sdk/2020-03-20/clusters/id_privatecloud.go deleted file mode 100644 index 0a2a00c61809..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/clusters/id_privatecloud.go +++ /dev/null @@ -1,124 +0,0 @@ -package clusters - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = PrivateCloudId{} - -// PrivateCloudId is a struct representing the Resource ID for a Private Cloud -type PrivateCloudId struct { - SubscriptionId string - ResourceGroupName string - PrivateCloudName string -} - -// NewPrivateCloudID returns a new PrivateCloudId struct -func NewPrivateCloudID(subscriptionId string, resourceGroupName string, privateCloudName string) PrivateCloudId { - return PrivateCloudId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - PrivateCloudName: privateCloudName, - } -} - -// ParsePrivateCloudID parses 'input' into a PrivateCloudId -func ParsePrivateCloudID(input string) (*PrivateCloudId, error) { - parser := resourceids.NewParserFromResourceIdType(PrivateCloudId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := PrivateCloudId{} - - 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.PrivateCloudName, ok = parsed.Parsed["privateCloudName"]; !ok { - return nil, fmt.Errorf("the segment 'privateCloudName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParsePrivateCloudIDInsensitively parses 'input' case-insensitively into a PrivateCloudId -// note: this method should only be used for API response data and not user input -func ParsePrivateCloudIDInsensitively(input string) (*PrivateCloudId, error) { - parser := resourceids.NewParserFromResourceIdType(PrivateCloudId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := PrivateCloudId{} - - 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.PrivateCloudName, ok = parsed.Parsed["privateCloudName"]; !ok { - return nil, fmt.Errorf("the segment 'privateCloudName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidatePrivateCloudID checks that 'input' can be parsed as a Private Cloud ID -func ValidatePrivateCloudID(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 := ParsePrivateCloudID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Private Cloud ID -func (id PrivateCloudId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.AVS/privateClouds/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PrivateCloudName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Private Cloud ID -func (id PrivateCloudId) 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("staticMicrosoftAVS", "Microsoft.AVS", "Microsoft.AVS"), - resourceids.StaticSegment("staticPrivateClouds", "privateClouds", "privateClouds"), - resourceids.UserSpecifiedSegment("privateCloudName", "privateCloudValue"), - } -} - -// String returns a human-readable description of this Private Cloud ID -func (id PrivateCloudId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Private Cloud Name: %q", id.PrivateCloudName), - } - return fmt.Sprintf("Private Cloud (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/vmware/sdk/2020-03-20/clusters/id_privatecloud_test.go b/internal/services/vmware/sdk/2020-03-20/clusters/id_privatecloud_test.go deleted file mode 100644 index a6a0cb5c8a37..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/clusters/id_privatecloud_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package clusters - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = PrivateCloudId{} - -func TestNewPrivateCloudID(t *testing.T) { - id := NewPrivateCloudID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateCloudValue") - - 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.PrivateCloudName != "privateCloudValue" { - t.Fatalf("Expected %q but got %q for Segment 'PrivateCloudName'", id.PrivateCloudName, "privateCloudValue") - } -} - -func TestFormatPrivateCloudID(t *testing.T) { - actual := NewPrivateCloudID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateCloudValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", actual, expected) - } -} - -func TestParsePrivateCloudID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateCloudId - }{ - { - // 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.AVS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue", - Expected: &PrivateCloudId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - PrivateCloudName: "privateCloudValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateCloudID(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.PrivateCloudName != v.Expected.PrivateCloudName { - t.Fatalf("Expected %q but got %q for PrivateCloudName", v.Expected.PrivateCloudName, actual.PrivateCloudName) - } - - } -} - -func TestParsePrivateCloudIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateCloudId - }{ - { - // 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.AVS", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs/pRiVaTeClOuDs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue", - Expected: &PrivateCloudId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - PrivateCloudName: "privateCloudValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs/pRiVaTeClOuDs/pRiVaTeClOuDvAlUe", - Expected: &PrivateCloudId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - PrivateCloudName: "pRiVaTeClOuDvAlUe", - }, - }, - { - // 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.aVs/pRiVaTeClOuDs/pRiVaTeClOuDvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateCloudIDInsensitively(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.PrivateCloudName != v.Expected.PrivateCloudName { - t.Fatalf("Expected %q but got %q for PrivateCloudName", v.Expected.PrivateCloudName, actual.PrivateCloudName) - } - - } -} - -func TestSegmentsForPrivateCloudId(t *testing.T) { - segments := PrivateCloudId{}.Segments() - if len(segments) == 0 { - t.Fatalf("PrivateCloudId 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/vmware/sdk/2020-03-20/clusters/method_createorupdate_autorest.go b/internal/services/vmware/sdk/2020-03-20/clusters/method_createorupdate_autorest.go deleted file mode 100644 index c6e259ecc019..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/clusters/method_createorupdate_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package clusters - -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 CreateOrUpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c ClustersClient) CreateOrUpdate(ctx context.Context, id ClusterId, input Cluster) (result CreateOrUpdateResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "clusters.ClustersClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "clusters.ClustersClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c ClustersClient) CreateOrUpdateThenPoll(ctx context.Context, id ClusterId, input Cluster) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ClustersClient) preparerForCreateOrUpdate(ctx context.Context, id ClusterId, 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)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c ClustersClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateResponse, 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/vmware/sdk/2020-03-20/clusters/method_delete_autorest.go b/internal/services/vmware/sdk/2020-03-20/clusters/method_delete_autorest.go deleted file mode 100644 index a46806abefbc..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/clusters/method_delete_autorest.go +++ /dev/null @@ -1,73 +0,0 @@ -package clusters - -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 ClustersClient) Delete(ctx context.Context, id ClusterId) (result DeleteResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "clusters.ClustersClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "clusters.ClustersClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c ClustersClient) DeleteThenPoll(ctx context.Context, id ClusterId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c ClustersClient) preparerForDelete(ctx context.Context, id ClusterId) (*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 ClustersClient) 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/vmware/sdk/2020-03-20/clusters/method_get_autorest.go b/internal/services/vmware/sdk/2020-03-20/clusters/method_get_autorest.go deleted file mode 100644 index 4fec5b178323..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/clusters/method_get_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package clusters - -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 ClustersClient) Get(ctx context.Context, id ClusterId) (result GetResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "clusters.ClustersClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "clusters.ClustersClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "clusters.ClustersClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ClustersClient) preparerForGet(ctx context.Context, id ClusterId) (*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 ClustersClient) 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/vmware/sdk/2020-03-20/clusters/method_list_autorest.go b/internal/services/vmware/sdk/2020-03-20/clusters/method_list_autorest.go deleted file mode 100644 index fc22e028790e..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/clusters/method_list_autorest.go +++ /dev/null @@ -1,183 +0,0 @@ -package clusters - -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 ClustersClient) List(ctx context.Context, id PrivateCloudId) (resp ListResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "clusters.ClustersClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "clusters.ClustersClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "clusters.ClustersClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c ClustersClient) ListComplete(ctx context.Context, id PrivateCloudId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, ClusterPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ClustersClient) ListCompleteMatchingPredicate(ctx context.Context, id PrivateCloudId, 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 ClustersClient) preparerForList(ctx context.Context, id PrivateCloudId) (*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/clusters", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c ClustersClient) 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 ClustersClient) 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, "clusters.ClustersClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "clusters.ClustersClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "clusters.ClustersClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/vmware/sdk/2020-03-20/clusters/method_update_autorest.go b/internal/services/vmware/sdk/2020-03-20/clusters/method_update_autorest.go deleted file mode 100644 index 32c520f7c291..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/clusters/method_update_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package clusters - -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 ClustersClient) Update(ctx context.Context, id ClusterId, input ClusterUpdate) (result UpdateResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "clusters.ClustersClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "clusters.ClustersClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c ClustersClient) UpdateThenPoll(ctx context.Context, id ClusterId, 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 ClustersClient) preparerForUpdate(ctx context.Context, id ClusterId, 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 ClustersClient) 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/vmware/sdk/2020-03-20/clusters/model_cluster.go b/internal/services/vmware/sdk/2020-03-20/clusters/model_cluster.go deleted file mode 100644 index 8da5844830c7..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/clusters/model_cluster.go +++ /dev/null @@ -1,9 +0,0 @@ -package clusters - -type Cluster struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties ClusterProperties `json:"properties"` - Sku Sku `json:"sku"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/vmware/sdk/2020-03-20/clusters/model_clusterproperties.go b/internal/services/vmware/sdk/2020-03-20/clusters/model_clusterproperties.go deleted file mode 100644 index 8106a5ca72bc..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/clusters/model_clusterproperties.go +++ /dev/null @@ -1,8 +0,0 @@ -package clusters - -type ClusterProperties struct { - ClusterId *int64 `json:"clusterId,omitempty"` - ClusterSize int64 `json:"clusterSize"` - Hosts *[]string `json:"hosts,omitempty"` - ProvisioningState *ClusterProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/internal/services/vmware/sdk/2020-03-20/clusters/model_clusterupdate.go b/internal/services/vmware/sdk/2020-03-20/clusters/model_clusterupdate.go deleted file mode 100644 index 98c3c77d64d0..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/clusters/model_clusterupdate.go +++ /dev/null @@ -1,5 +0,0 @@ -package clusters - -type ClusterUpdate struct { - Properties *ClusterUpdateProperties `json:"properties,omitempty"` -} diff --git a/internal/services/vmware/sdk/2020-03-20/clusters/model_clusterupdateproperties.go b/internal/services/vmware/sdk/2020-03-20/clusters/model_clusterupdateproperties.go deleted file mode 100644 index c0c1b4d28445..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/clusters/model_clusterupdateproperties.go +++ /dev/null @@ -1,5 +0,0 @@ -package clusters - -type ClusterUpdateProperties struct { - ClusterSize *int64 `json:"clusterSize,omitempty"` -} diff --git a/internal/services/vmware/sdk/2020-03-20/clusters/model_sku.go b/internal/services/vmware/sdk/2020-03-20/clusters/model_sku.go deleted file mode 100644 index 733246681688..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/clusters/model_sku.go +++ /dev/null @@ -1,5 +0,0 @@ -package clusters - -type Sku struct { - Name string `json:"name"` -} diff --git a/internal/services/vmware/sdk/2020-03-20/clusters/predicates.go b/internal/services/vmware/sdk/2020-03-20/clusters/predicates.go deleted file mode 100644 index e542c0c7d56d..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/clusters/predicates.go +++ /dev/null @@ -1,24 +0,0 @@ -package clusters - -type ClusterPredicate struct { - Id *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.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/vmware/sdk/2020-03-20/clusters/version.go b/internal/services/vmware/sdk/2020-03-20/clusters/version.go deleted file mode 100644 index e198e3076788..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/clusters/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package clusters - -import "fmt" - -const defaultApiVersion = "2020-03-20" - -func userAgent() string { - return fmt.Sprintf("pandora/clusters/%s", defaultApiVersion) -} diff --git a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/client.go b/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/client.go deleted file mode 100644 index 990e055ce033..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package hcxenterprisesites - -import "github.com/Azure/go-autorest/autorest" - -type HcxEnterpriseSitesClient struct { - Client autorest.Client - baseUri string -} - -func NewHcxEnterpriseSitesClientWithBaseURI(endpoint string) HcxEnterpriseSitesClient { - return HcxEnterpriseSitesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/constants.go b/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/constants.go deleted file mode 100644 index 42bb60ce71ba..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/constants.go +++ /dev/null @@ -1,37 +0,0 @@ -package hcxenterprisesites - -import "strings" - -type HcxEnterpriseSiteStatus string - -const ( - HcxEnterpriseSiteStatusAvailable HcxEnterpriseSiteStatus = "Available" - HcxEnterpriseSiteStatusConsumed HcxEnterpriseSiteStatus = "Consumed" - HcxEnterpriseSiteStatusDeactivated HcxEnterpriseSiteStatus = "Deactivated" - HcxEnterpriseSiteStatusDeleted HcxEnterpriseSiteStatus = "Deleted" -) - -func PossibleValuesForHcxEnterpriseSiteStatus() []string { - return []string{ - string(HcxEnterpriseSiteStatusAvailable), - string(HcxEnterpriseSiteStatusConsumed), - string(HcxEnterpriseSiteStatusDeactivated), - string(HcxEnterpriseSiteStatusDeleted), - } -} - -func parseHcxEnterpriseSiteStatus(input string) (*HcxEnterpriseSiteStatus, error) { - vals := map[string]HcxEnterpriseSiteStatus{ - "available": HcxEnterpriseSiteStatusAvailable, - "consumed": HcxEnterpriseSiteStatusConsumed, - "deactivated": HcxEnterpriseSiteStatusDeactivated, - "deleted": HcxEnterpriseSiteStatusDeleted, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := HcxEnterpriseSiteStatus(input) - return &out, nil -} diff --git a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/id_hcxenterprisesite.go b/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/id_hcxenterprisesite.go deleted file mode 100644 index a4d5ca2d0c11..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/id_hcxenterprisesite.go +++ /dev/null @@ -1,137 +0,0 @@ -package hcxenterprisesites - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = HcxEnterpriseSiteId{} - -// HcxEnterpriseSiteId is a struct representing the Resource ID for a Hcx Enterprise Site -type HcxEnterpriseSiteId struct { - SubscriptionId string - ResourceGroupName string - PrivateCloudName string - HcxEnterpriseSiteName string -} - -// NewHcxEnterpriseSiteID returns a new HcxEnterpriseSiteId struct -func NewHcxEnterpriseSiteID(subscriptionId string, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) HcxEnterpriseSiteId { - return HcxEnterpriseSiteId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - PrivateCloudName: privateCloudName, - HcxEnterpriseSiteName: hcxEnterpriseSiteName, - } -} - -// ParseHcxEnterpriseSiteID parses 'input' into a HcxEnterpriseSiteId -func ParseHcxEnterpriseSiteID(input string) (*HcxEnterpriseSiteId, error) { - parser := resourceids.NewParserFromResourceIdType(HcxEnterpriseSiteId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := HcxEnterpriseSiteId{} - - 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.PrivateCloudName, ok = parsed.Parsed["privateCloudName"]; !ok { - return nil, fmt.Errorf("the segment 'privateCloudName' was not found in the resource id %q", input) - } - - if id.HcxEnterpriseSiteName, ok = parsed.Parsed["hcxEnterpriseSiteName"]; !ok { - return nil, fmt.Errorf("the segment 'hcxEnterpriseSiteName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseHcxEnterpriseSiteIDInsensitively parses 'input' case-insensitively into a HcxEnterpriseSiteId -// note: this method should only be used for API response data and not user input -func ParseHcxEnterpriseSiteIDInsensitively(input string) (*HcxEnterpriseSiteId, error) { - parser := resourceids.NewParserFromResourceIdType(HcxEnterpriseSiteId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := HcxEnterpriseSiteId{} - - 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.PrivateCloudName, ok = parsed.Parsed["privateCloudName"]; !ok { - return nil, fmt.Errorf("the segment 'privateCloudName' was not found in the resource id %q", input) - } - - if id.HcxEnterpriseSiteName, ok = parsed.Parsed["hcxEnterpriseSiteName"]; !ok { - return nil, fmt.Errorf("the segment 'hcxEnterpriseSiteName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateHcxEnterpriseSiteID checks that 'input' can be parsed as a Hcx Enterprise Site ID -func ValidateHcxEnterpriseSiteID(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 := ParseHcxEnterpriseSiteID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Hcx Enterprise Site ID -func (id HcxEnterpriseSiteId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.AVS/privateClouds/%s/hcxEnterpriseSites/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PrivateCloudName, id.HcxEnterpriseSiteName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Hcx Enterprise Site ID -func (id HcxEnterpriseSiteId) 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("staticMicrosoftAVS", "Microsoft.AVS", "Microsoft.AVS"), - resourceids.StaticSegment("staticPrivateClouds", "privateClouds", "privateClouds"), - resourceids.UserSpecifiedSegment("privateCloudName", "privateCloudValue"), - resourceids.StaticSegment("staticHcxEnterpriseSites", "hcxEnterpriseSites", "hcxEnterpriseSites"), - resourceids.UserSpecifiedSegment("hcxEnterpriseSiteName", "hcxEnterpriseSiteValue"), - } -} - -// String returns a human-readable description of this Hcx Enterprise Site ID -func (id HcxEnterpriseSiteId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Private Cloud Name: %q", id.PrivateCloudName), - fmt.Sprintf("Hcx Enterprise Site Name: %q", id.HcxEnterpriseSiteName), - } - return fmt.Sprintf("Hcx Enterprise Site (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/id_hcxenterprisesite_test.go b/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/id_hcxenterprisesite_test.go deleted file mode 100644 index 71abc0690f11..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/id_hcxenterprisesite_test.go +++ /dev/null @@ -1,324 +0,0 @@ -package hcxenterprisesites - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = HcxEnterpriseSiteId{} - -func TestNewHcxEnterpriseSiteID(t *testing.T) { - id := NewHcxEnterpriseSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateCloudValue", "hcxEnterpriseSiteValue") - - 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.PrivateCloudName != "privateCloudValue" { - t.Fatalf("Expected %q but got %q for Segment 'PrivateCloudName'", id.PrivateCloudName, "privateCloudValue") - } - - if id.HcxEnterpriseSiteName != "hcxEnterpriseSiteValue" { - t.Fatalf("Expected %q but got %q for Segment 'HcxEnterpriseSiteName'", id.HcxEnterpriseSiteName, "hcxEnterpriseSiteValue") - } -} - -func TestFormatHcxEnterpriseSiteID(t *testing.T) { - actual := NewHcxEnterpriseSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateCloudValue", "hcxEnterpriseSiteValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/hcxEnterpriseSites/hcxEnterpriseSiteValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", actual, expected) - } -} - -func TestParseHcxEnterpriseSiteID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *HcxEnterpriseSiteId - }{ - { - // 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.AVS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/hcxEnterpriseSites", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/hcxEnterpriseSites/hcxEnterpriseSiteValue", - Expected: &HcxEnterpriseSiteId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - PrivateCloudName: "privateCloudValue", - HcxEnterpriseSiteName: "hcxEnterpriseSiteValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/hcxEnterpriseSites/hcxEnterpriseSiteValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseHcxEnterpriseSiteID(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.PrivateCloudName != v.Expected.PrivateCloudName { - t.Fatalf("Expected %q but got %q for PrivateCloudName", v.Expected.PrivateCloudName, actual.PrivateCloudName) - } - - if actual.HcxEnterpriseSiteName != v.Expected.HcxEnterpriseSiteName { - t.Fatalf("Expected %q but got %q for HcxEnterpriseSiteName", v.Expected.HcxEnterpriseSiteName, actual.HcxEnterpriseSiteName) - } - - } -} - -func TestParseHcxEnterpriseSiteIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *HcxEnterpriseSiteId - }{ - { - // 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.AVS", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs/pRiVaTeClOuDs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs/pRiVaTeClOuDs/pRiVaTeClOuDvAlUe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/hcxEnterpriseSites", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs/pRiVaTeClOuDs/pRiVaTeClOuDvAlUe/hCxEnTeRpRiSeSiTeS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/hcxEnterpriseSites/hcxEnterpriseSiteValue", - Expected: &HcxEnterpriseSiteId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - PrivateCloudName: "privateCloudValue", - HcxEnterpriseSiteName: "hcxEnterpriseSiteValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/hcxEnterpriseSites/hcxEnterpriseSiteValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs/pRiVaTeClOuDs/pRiVaTeClOuDvAlUe/hCxEnTeRpRiSeSiTeS/hCxEnTeRpRiSeSiTeVaLuE", - Expected: &HcxEnterpriseSiteId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - PrivateCloudName: "pRiVaTeClOuDvAlUe", - HcxEnterpriseSiteName: "hCxEnTeRpRiSeSiTeVaLuE", - }, - }, - { - // 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.aVs/pRiVaTeClOuDs/pRiVaTeClOuDvAlUe/hCxEnTeRpRiSeSiTeS/hCxEnTeRpRiSeSiTeVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseHcxEnterpriseSiteIDInsensitively(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.PrivateCloudName != v.Expected.PrivateCloudName { - t.Fatalf("Expected %q but got %q for PrivateCloudName", v.Expected.PrivateCloudName, actual.PrivateCloudName) - } - - if actual.HcxEnterpriseSiteName != v.Expected.HcxEnterpriseSiteName { - t.Fatalf("Expected %q but got %q for HcxEnterpriseSiteName", v.Expected.HcxEnterpriseSiteName, actual.HcxEnterpriseSiteName) - } - - } -} - -func TestSegmentsForHcxEnterpriseSiteId(t *testing.T) { - segments := HcxEnterpriseSiteId{}.Segments() - if len(segments) == 0 { - t.Fatalf("HcxEnterpriseSiteId 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/vmware/sdk/2020-03-20/hcxenterprisesites/id_privatecloud.go b/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/id_privatecloud.go deleted file mode 100644 index db0de22fd132..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/id_privatecloud.go +++ /dev/null @@ -1,124 +0,0 @@ -package hcxenterprisesites - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = PrivateCloudId{} - -// PrivateCloudId is a struct representing the Resource ID for a Private Cloud -type PrivateCloudId struct { - SubscriptionId string - ResourceGroupName string - PrivateCloudName string -} - -// NewPrivateCloudID returns a new PrivateCloudId struct -func NewPrivateCloudID(subscriptionId string, resourceGroupName string, privateCloudName string) PrivateCloudId { - return PrivateCloudId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - PrivateCloudName: privateCloudName, - } -} - -// ParsePrivateCloudID parses 'input' into a PrivateCloudId -func ParsePrivateCloudID(input string) (*PrivateCloudId, error) { - parser := resourceids.NewParserFromResourceIdType(PrivateCloudId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := PrivateCloudId{} - - 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.PrivateCloudName, ok = parsed.Parsed["privateCloudName"]; !ok { - return nil, fmt.Errorf("the segment 'privateCloudName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParsePrivateCloudIDInsensitively parses 'input' case-insensitively into a PrivateCloudId -// note: this method should only be used for API response data and not user input -func ParsePrivateCloudIDInsensitively(input string) (*PrivateCloudId, error) { - parser := resourceids.NewParserFromResourceIdType(PrivateCloudId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := PrivateCloudId{} - - 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.PrivateCloudName, ok = parsed.Parsed["privateCloudName"]; !ok { - return nil, fmt.Errorf("the segment 'privateCloudName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidatePrivateCloudID checks that 'input' can be parsed as a Private Cloud ID -func ValidatePrivateCloudID(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 := ParsePrivateCloudID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Private Cloud ID -func (id PrivateCloudId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.AVS/privateClouds/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PrivateCloudName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Private Cloud ID -func (id PrivateCloudId) 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("staticMicrosoftAVS", "Microsoft.AVS", "Microsoft.AVS"), - resourceids.StaticSegment("staticPrivateClouds", "privateClouds", "privateClouds"), - resourceids.UserSpecifiedSegment("privateCloudName", "privateCloudValue"), - } -} - -// String returns a human-readable description of this Private Cloud ID -func (id PrivateCloudId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Private Cloud Name: %q", id.PrivateCloudName), - } - return fmt.Sprintf("Private Cloud (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/id_privatecloud_test.go b/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/id_privatecloud_test.go deleted file mode 100644 index 02c4081733f8..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/id_privatecloud_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package hcxenterprisesites - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = PrivateCloudId{} - -func TestNewPrivateCloudID(t *testing.T) { - id := NewPrivateCloudID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateCloudValue") - - 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.PrivateCloudName != "privateCloudValue" { - t.Fatalf("Expected %q but got %q for Segment 'PrivateCloudName'", id.PrivateCloudName, "privateCloudValue") - } -} - -func TestFormatPrivateCloudID(t *testing.T) { - actual := NewPrivateCloudID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateCloudValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", actual, expected) - } -} - -func TestParsePrivateCloudID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateCloudId - }{ - { - // 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.AVS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue", - Expected: &PrivateCloudId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - PrivateCloudName: "privateCloudValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateCloudID(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.PrivateCloudName != v.Expected.PrivateCloudName { - t.Fatalf("Expected %q but got %q for PrivateCloudName", v.Expected.PrivateCloudName, actual.PrivateCloudName) - } - - } -} - -func TestParsePrivateCloudIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateCloudId - }{ - { - // 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.AVS", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs/pRiVaTeClOuDs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue", - Expected: &PrivateCloudId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - PrivateCloudName: "privateCloudValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs/pRiVaTeClOuDs/pRiVaTeClOuDvAlUe", - Expected: &PrivateCloudId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - PrivateCloudName: "pRiVaTeClOuDvAlUe", - }, - }, - { - // 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.aVs/pRiVaTeClOuDs/pRiVaTeClOuDvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateCloudIDInsensitively(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.PrivateCloudName != v.Expected.PrivateCloudName { - t.Fatalf("Expected %q but got %q for PrivateCloudName", v.Expected.PrivateCloudName, actual.PrivateCloudName) - } - - } -} - -func TestSegmentsForPrivateCloudId(t *testing.T) { - segments := PrivateCloudId{}.Segments() - if len(segments) == 0 { - t.Fatalf("PrivateCloudId 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/vmware/sdk/2020-03-20/hcxenterprisesites/method_createorupdate_autorest.go b/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/method_createorupdate_autorest.go deleted file mode 100644 index 272b3f156b12..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/method_createorupdate_autorest.go +++ /dev/null @@ -1,65 +0,0 @@ -package hcxenterprisesites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type CreateOrUpdateResponse struct { - HttpResponse *http.Response - Model *HcxEnterpriseSite -} - -// CreateOrUpdate ... -func (c HcxEnterpriseSitesClient) CreateOrUpdate(ctx context.Context, id HcxEnterpriseSiteId, input HcxEnterpriseSite) (result CreateOrUpdateResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "hcxenterprisesites.HcxEnterpriseSitesClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hcxenterprisesites.HcxEnterpriseSitesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hcxenterprisesites.HcxEnterpriseSitesClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c HcxEnterpriseSitesClient) preparerForCreateOrUpdate(ctx context.Context, id HcxEnterpriseSiteId, input HcxEnterpriseSite) (*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)) -} - -// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (c HcxEnterpriseSitesClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/method_delete_autorest.go b/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/method_delete_autorest.go deleted file mode 100644 index 2a137eb7911c..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/method_delete_autorest.go +++ /dev/null @@ -1,61 +0,0 @@ -package hcxenterprisesites - -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 HcxEnterpriseSitesClient) Delete(ctx context.Context, id HcxEnterpriseSiteId) (result DeleteResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "hcxenterprisesites.HcxEnterpriseSitesClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hcxenterprisesites.HcxEnterpriseSitesClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hcxenterprisesites.HcxEnterpriseSitesClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c HcxEnterpriseSitesClient) preparerForDelete(ctx context.Context, id HcxEnterpriseSiteId) (*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 HcxEnterpriseSitesClient) 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/vmware/sdk/2020-03-20/hcxenterprisesites/method_get_autorest.go b/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/method_get_autorest.go deleted file mode 100644 index b939bcacc13d..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/method_get_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package hcxenterprisesites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type GetResponse struct { - HttpResponse *http.Response - Model *HcxEnterpriseSite -} - -// Get ... -func (c HcxEnterpriseSitesClient) Get(ctx context.Context, id HcxEnterpriseSiteId) (result GetResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "hcxenterprisesites.HcxEnterpriseSitesClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hcxenterprisesites.HcxEnterpriseSitesClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hcxenterprisesites.HcxEnterpriseSitesClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c HcxEnterpriseSitesClient) preparerForGet(ctx context.Context, id HcxEnterpriseSiteId) (*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 HcxEnterpriseSitesClient) 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/vmware/sdk/2020-03-20/hcxenterprisesites/method_list_autorest.go b/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/method_list_autorest.go deleted file mode 100644 index 5aebcec842dd..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/method_list_autorest.go +++ /dev/null @@ -1,183 +0,0 @@ -package hcxenterprisesites - -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 *[]HcxEnterpriseSite - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListResponse, error) -} - -type ListCompleteResult struct { - Items []HcxEnterpriseSite -} - -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 HcxEnterpriseSitesClient) List(ctx context.Context, id PrivateCloudId) (resp ListResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "hcxenterprisesites.HcxEnterpriseSitesClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hcxenterprisesites.HcxEnterpriseSitesClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hcxenterprisesites.HcxEnterpriseSitesClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c HcxEnterpriseSitesClient) ListComplete(ctx context.Context, id PrivateCloudId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, HcxEnterpriseSitePredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c HcxEnterpriseSitesClient) ListCompleteMatchingPredicate(ctx context.Context, id PrivateCloudId, predicate HcxEnterpriseSitePredicate) (resp ListCompleteResult, err error) { - items := make([]HcxEnterpriseSite, 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 HcxEnterpriseSitesClient) preparerForList(ctx context.Context, id PrivateCloudId) (*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/hcxEnterpriseSites", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c HcxEnterpriseSitesClient) 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 HcxEnterpriseSitesClient) responderForList(resp *http.Response) (result ListResponse, err error) { - type page struct { - Values []HcxEnterpriseSite `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, "hcxenterprisesites.HcxEnterpriseSitesClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hcxenterprisesites.HcxEnterpriseSitesClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hcxenterprisesites.HcxEnterpriseSitesClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/model_hcxenterprisesite.go b/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/model_hcxenterprisesite.go deleted file mode 100644 index 51ab5653b201..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/model_hcxenterprisesite.go +++ /dev/null @@ -1,8 +0,0 @@ -package hcxenterprisesites - -type HcxEnterpriseSite struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *HcxEnterpriseSiteProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/model_hcxenterprisesiteproperties.go b/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/model_hcxenterprisesiteproperties.go deleted file mode 100644 index f18b4eb9c34b..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/model_hcxenterprisesiteproperties.go +++ /dev/null @@ -1,6 +0,0 @@ -package hcxenterprisesites - -type HcxEnterpriseSiteProperties struct { - ActivationKey *string `json:"activationKey,omitempty"` - Status *HcxEnterpriseSiteStatus `json:"status,omitempty"` -} diff --git a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/predicates.go b/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/predicates.go deleted file mode 100644 index fb7d5edf1db5..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/predicates.go +++ /dev/null @@ -1,24 +0,0 @@ -package hcxenterprisesites - -type HcxEnterpriseSitePredicate struct { - Id *string - Name *string - Type *string -} - -func (p HcxEnterpriseSitePredicate) Matches(input HcxEnterpriseSite) 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/vmware/sdk/2020-03-20/hcxenterprisesites/version.go b/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/version.go deleted file mode 100644 index b2fc96749ca6..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/hcxenterprisesites/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package hcxenterprisesites - -import "fmt" - -const defaultApiVersion = "2020-03-20" - -func userAgent() string { - return fmt.Sprintf("pandora/hcxenterprisesites/%s", defaultApiVersion) -} diff --git a/internal/services/vmware/sdk/2020-03-20/locations/client.go b/internal/services/vmware/sdk/2020-03-20/locations/client.go deleted file mode 100644 index e3648c22a0bb..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/locations/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package locations - -import "github.com/Azure/go-autorest/autorest" - -type LocationsClient struct { - Client autorest.Client - baseUri string -} - -func NewLocationsClientWithBaseURI(endpoint string) LocationsClient { - return LocationsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/vmware/sdk/2020-03-20/locations/constants.go b/internal/services/vmware/sdk/2020-03-20/locations/constants.go deleted file mode 100644 index 46930b0bebab..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/locations/constants.go +++ /dev/null @@ -1,62 +0,0 @@ -package locations - -import "strings" - -type QuotaEnabled string - -const ( - QuotaEnabledDisabled QuotaEnabled = "Disabled" - QuotaEnabledEnabled QuotaEnabled = "Enabled" -) - -func PossibleValuesForQuotaEnabled() []string { - return []string{ - string(QuotaEnabledDisabled), - string(QuotaEnabledEnabled), - } -} - -func parseQuotaEnabled(input string) (*QuotaEnabled, error) { - vals := map[string]QuotaEnabled{ - "disabled": QuotaEnabledDisabled, - "enabled": QuotaEnabledEnabled, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := QuotaEnabled(input) - return &out, nil -} - -type TrialStatus string - -const ( - TrialStatusTrialAvailable TrialStatus = "TrialAvailable" - TrialStatusTrialDisabled TrialStatus = "TrialDisabled" - TrialStatusTrialUsed TrialStatus = "TrialUsed" -) - -func PossibleValuesForTrialStatus() []string { - return []string{ - string(TrialStatusTrialAvailable), - string(TrialStatusTrialDisabled), - string(TrialStatusTrialUsed), - } -} - -func parseTrialStatus(input string) (*TrialStatus, error) { - vals := map[string]TrialStatus{ - "trialavailable": TrialStatusTrialAvailable, - "trialdisabled": TrialStatusTrialDisabled, - "trialused": TrialStatusTrialUsed, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := TrialStatus(input) - return &out, nil -} diff --git a/internal/services/vmware/sdk/2020-03-20/locations/id_location.go b/internal/services/vmware/sdk/2020-03-20/locations/id_location.go deleted file mode 100644 index ddc2c7cfcd52..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/locations/id_location.go +++ /dev/null @@ -1,111 +0,0 @@ -package locations - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = LocationId{} - -// LocationId is a struct representing the Resource ID for a Location -type LocationId struct { - SubscriptionId string - Location string -} - -// NewLocationID returns a new LocationId struct -func NewLocationID(subscriptionId string, location string) LocationId { - return LocationId{ - SubscriptionId: subscriptionId, - Location: location, - } -} - -// ParseLocationID parses 'input' into a LocationId -func ParseLocationID(input string) (*LocationId, error) { - parser := resourceids.NewParserFromResourceIdType(LocationId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := LocationId{} - - 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) - } - - return &id, nil -} - -// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId -// note: this method should only be used for API response data and not user input -func ParseLocationIDInsensitively(input string) (*LocationId, error) { - parser := resourceids.NewParserFromResourceIdType(LocationId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := LocationId{} - - 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) - } - - return &id, nil -} - -// ValidateLocationID checks that 'input' can be parsed as a Location ID -func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseLocationID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Location ID -func (id LocationId) ID() string { - fmtString := "/subscriptions/%s/providers/Microsoft.AVS/locations/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.Location) -} - -// Segments returns a slice of Resource ID Segments which comprise this Location ID -func (id LocationId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftAVS", "Microsoft.AVS", "Microsoft.AVS"), - resourceids.StaticSegment("staticLocations", "locations", "locations"), - resourceids.UserSpecifiedSegment("location", "locationValue"), - } -} - -// String returns a human-readable description of this Location ID -func (id LocationId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Location: %q", id.Location), - } - return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/vmware/sdk/2020-03-20/locations/id_location_test.go b/internal/services/vmware/sdk/2020-03-20/locations/id_location_test.go deleted file mode 100644 index 3029217e324e..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/locations/id_location_test.go +++ /dev/null @@ -1,234 +0,0 @@ -package locations - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = LocationId{} - -func TestNewLocationID(t *testing.T) { - id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.Location != "locationValue" { - t.Fatalf("Expected %q but got %q for Segment 'Location'", id.Location, "locationValue") - } -} - -func TestFormatLocationID(t *testing.T) { - actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.AVS/locations/locationValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", actual, expected) - } -} - -func TestParseLocationID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *LocationId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.AVS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.AVS/locations", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.AVS/locations/locationValue", - Expected: &LocationId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - Location: "locationValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.AVS/locations/locationValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseLocationID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.Location != v.Expected.Location { - t.Fatalf("Expected %q but got %q for Location", v.Expected.Location, actual.Location) - } - - } -} - -func TestParseLocationIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *LocationId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.AVS", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aVs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.AVS/locations", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aVs/lOcAtIoNs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.AVS/locations/locationValue", - Expected: &LocationId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - Location: "locationValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.AVS/locations/locationValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aVs/lOcAtIoNs/lOcAtIoNvAlUe", - Expected: &LocationId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - Location: "lOcAtIoNvAlUe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aVs/lOcAtIoNs/lOcAtIoNvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseLocationIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.Location != v.Expected.Location { - t.Fatalf("Expected %q but got %q for Location", v.Expected.Location, actual.Location) - } - - } -} - -func TestSegmentsForLocationId(t *testing.T) { - segments := LocationId{}.Segments() - if len(segments) == 0 { - t.Fatalf("LocationId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/internal/services/vmware/sdk/2020-03-20/locations/method_checkquotaavailability_autorest.go b/internal/services/vmware/sdk/2020-03-20/locations/method_checkquotaavailability_autorest.go deleted file mode 100644 index 3237df800c9e..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/locations/method_checkquotaavailability_autorest.go +++ /dev/null @@ -1,65 +0,0 @@ -package locations - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type CheckQuotaAvailabilityResponse struct { - HttpResponse *http.Response - Model *Quota -} - -// CheckQuotaAvailability ... -func (c LocationsClient) CheckQuotaAvailability(ctx context.Context, id LocationId) (result CheckQuotaAvailabilityResponse, err error) { - req, err := c.preparerForCheckQuotaAvailability(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "locations.LocationsClient", "CheckQuotaAvailability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "locations.LocationsClient", "CheckQuotaAvailability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckQuotaAvailability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "locations.LocationsClient", "CheckQuotaAvailability", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckQuotaAvailability prepares the CheckQuotaAvailability request. -func (c LocationsClient) preparerForCheckQuotaAvailability(ctx context.Context, id LocationId) (*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/checkQuotaAvailability", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckQuotaAvailability handles the response to the CheckQuotaAvailability request. The method always -// closes the http.Response Body. -func (c LocationsClient) responderForCheckQuotaAvailability(resp *http.Response) (result CheckQuotaAvailabilityResponse, 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/vmware/sdk/2020-03-20/locations/method_checktrialavailability_autorest.go b/internal/services/vmware/sdk/2020-03-20/locations/method_checktrialavailability_autorest.go deleted file mode 100644 index b0d3ce07926d..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/locations/method_checktrialavailability_autorest.go +++ /dev/null @@ -1,65 +0,0 @@ -package locations - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type CheckTrialAvailabilityResponse struct { - HttpResponse *http.Response - Model *Trial -} - -// CheckTrialAvailability ... -func (c LocationsClient) CheckTrialAvailability(ctx context.Context, id LocationId) (result CheckTrialAvailabilityResponse, err error) { - req, err := c.preparerForCheckTrialAvailability(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "locations.LocationsClient", "CheckTrialAvailability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "locations.LocationsClient", "CheckTrialAvailability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckTrialAvailability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "locations.LocationsClient", "CheckTrialAvailability", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckTrialAvailability prepares the CheckTrialAvailability request. -func (c LocationsClient) preparerForCheckTrialAvailability(ctx context.Context, id LocationId) (*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/checkTrialAvailability", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckTrialAvailability handles the response to the CheckTrialAvailability request. The method always -// closes the http.Response Body. -func (c LocationsClient) responderForCheckTrialAvailability(resp *http.Response) (result CheckTrialAvailabilityResponse, 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/vmware/sdk/2020-03-20/locations/model_quota.go b/internal/services/vmware/sdk/2020-03-20/locations/model_quota.go deleted file mode 100644 index df5d2c6ebf40..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/locations/model_quota.go +++ /dev/null @@ -1,6 +0,0 @@ -package locations - -type Quota struct { - HostsRemaining *map[string]int64 `json:"hostsRemaining,omitempty"` - QuotaEnabled *QuotaEnabled `json:"quotaEnabled,omitempty"` -} diff --git a/internal/services/vmware/sdk/2020-03-20/locations/model_trial.go b/internal/services/vmware/sdk/2020-03-20/locations/model_trial.go deleted file mode 100644 index fae05bad5481..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/locations/model_trial.go +++ /dev/null @@ -1,6 +0,0 @@ -package locations - -type Trial struct { - AvailableHosts *int64 `json:"availableHosts,omitempty"` - Status *TrialStatus `json:"status,omitempty"` -} diff --git a/internal/services/vmware/sdk/2020-03-20/locations/version.go b/internal/services/vmware/sdk/2020-03-20/locations/version.go deleted file mode 100644 index 39ca89a498a7..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/locations/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package locations - -import "fmt" - -const defaultApiVersion = "2020-03-20" - -func userAgent() string { - return fmt.Sprintf("pandora/locations/%s", defaultApiVersion) -} diff --git a/internal/services/vmware/sdk/2020-03-20/privateclouds/client.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/client.go deleted file mode 100644 index 3cc08488596a..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package privateclouds - -import "github.com/Azure/go-autorest/autorest" - -type PrivateCloudsClient struct { - Client autorest.Client - baseUri string -} - -func NewPrivateCloudsClientWithBaseURI(endpoint string) PrivateCloudsClient { - return PrivateCloudsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/vmware/sdk/2020-03-20/privateclouds/constants.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/constants.go deleted file mode 100644 index 357739d656ec..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/constants.go +++ /dev/null @@ -1,139 +0,0 @@ -package privateclouds - -import "strings" - -type ClusterProvisioningState string - -const ( - ClusterProvisioningStateCancelled ClusterProvisioningState = "Cancelled" - ClusterProvisioningStateDeleting ClusterProvisioningState = "Deleting" - ClusterProvisioningStateFailed ClusterProvisioningState = "Failed" - ClusterProvisioningStateSucceeded ClusterProvisioningState = "Succeeded" - ClusterProvisioningStateUpdating ClusterProvisioningState = "Updating" -) - -func PossibleValuesForClusterProvisioningState() []string { - return []string{ - string(ClusterProvisioningStateCancelled), - string(ClusterProvisioningStateDeleting), - string(ClusterProvisioningStateFailed), - string(ClusterProvisioningStateSucceeded), - string(ClusterProvisioningStateUpdating), - } -} - -func parseClusterProvisioningState(input string) (*ClusterProvisioningState, error) { - vals := map[string]ClusterProvisioningState{ - "cancelled": ClusterProvisioningStateCancelled, - "deleting": ClusterProvisioningStateDeleting, - "failed": ClusterProvisioningStateFailed, - "succeeded": ClusterProvisioningStateSucceeded, - "updating": ClusterProvisioningStateUpdating, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ClusterProvisioningState(input) - return &out, nil -} - -type InternetEnum string - -const ( - InternetEnumDisabled InternetEnum = "Disabled" - InternetEnumEnabled InternetEnum = "Enabled" -) - -func PossibleValuesForInternetEnum() []string { - return []string{ - string(InternetEnumDisabled), - string(InternetEnumEnabled), - } -} - -func parseInternetEnum(input string) (*InternetEnum, error) { - vals := map[string]InternetEnum{ - "disabled": InternetEnumDisabled, - "enabled": InternetEnumEnabled, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := InternetEnum(input) - return &out, nil -} - -type PrivateCloudProvisioningState string - -const ( - PrivateCloudProvisioningStateBuilding PrivateCloudProvisioningState = "Building" - PrivateCloudProvisioningStateCancelled PrivateCloudProvisioningState = "Cancelled" - PrivateCloudProvisioningStateDeleting PrivateCloudProvisioningState = "Deleting" - PrivateCloudProvisioningStateFailed PrivateCloudProvisioningState = "Failed" - PrivateCloudProvisioningStatePending PrivateCloudProvisioningState = "Pending" - PrivateCloudProvisioningStateSucceeded PrivateCloudProvisioningState = "Succeeded" - PrivateCloudProvisioningStateUpdating PrivateCloudProvisioningState = "Updating" -) - -func PossibleValuesForPrivateCloudProvisioningState() []string { - return []string{ - string(PrivateCloudProvisioningStateBuilding), - string(PrivateCloudProvisioningStateCancelled), - string(PrivateCloudProvisioningStateDeleting), - string(PrivateCloudProvisioningStateFailed), - string(PrivateCloudProvisioningStatePending), - string(PrivateCloudProvisioningStateSucceeded), - string(PrivateCloudProvisioningStateUpdating), - } -} - -func parsePrivateCloudProvisioningState(input string) (*PrivateCloudProvisioningState, error) { - vals := map[string]PrivateCloudProvisioningState{ - "building": PrivateCloudProvisioningStateBuilding, - "cancelled": PrivateCloudProvisioningStateCancelled, - "deleting": PrivateCloudProvisioningStateDeleting, - "failed": PrivateCloudProvisioningStateFailed, - "pending": PrivateCloudProvisioningStatePending, - "succeeded": PrivateCloudProvisioningStateSucceeded, - "updating": PrivateCloudProvisioningStateUpdating, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateCloudProvisioningState(input) - return &out, nil -} - -type SslEnum string - -const ( - SslEnumDisabled SslEnum = "Disabled" - SslEnumEnabled SslEnum = "Enabled" -) - -func PossibleValuesForSslEnum() []string { - return []string{ - string(SslEnumDisabled), - string(SslEnumEnabled), - } -} - -func parseSslEnum(input string) (*SslEnum, error) { - vals := map[string]SslEnum{ - "disabled": SslEnumDisabled, - "enabled": SslEnumEnabled, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := SslEnum(input) - return &out, nil -} diff --git a/internal/services/vmware/sdk/2020-03-20/privateclouds/id_privatecloud.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/id_privatecloud.go deleted file mode 100644 index 76867727cbf9..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/id_privatecloud.go +++ /dev/null @@ -1,124 +0,0 @@ -package privateclouds - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = PrivateCloudId{} - -// PrivateCloudId is a struct representing the Resource ID for a Private Cloud -type PrivateCloudId struct { - SubscriptionId string - ResourceGroupName string - PrivateCloudName string -} - -// NewPrivateCloudID returns a new PrivateCloudId struct -func NewPrivateCloudID(subscriptionId string, resourceGroupName string, privateCloudName string) PrivateCloudId { - return PrivateCloudId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - PrivateCloudName: privateCloudName, - } -} - -// ParsePrivateCloudID parses 'input' into a PrivateCloudId -func ParsePrivateCloudID(input string) (*PrivateCloudId, error) { - parser := resourceids.NewParserFromResourceIdType(PrivateCloudId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := PrivateCloudId{} - - 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.PrivateCloudName, ok = parsed.Parsed["privateCloudName"]; !ok { - return nil, fmt.Errorf("the segment 'privateCloudName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParsePrivateCloudIDInsensitively parses 'input' case-insensitively into a PrivateCloudId -// note: this method should only be used for API response data and not user input -func ParsePrivateCloudIDInsensitively(input string) (*PrivateCloudId, error) { - parser := resourceids.NewParserFromResourceIdType(PrivateCloudId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := PrivateCloudId{} - - 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.PrivateCloudName, ok = parsed.Parsed["privateCloudName"]; !ok { - return nil, fmt.Errorf("the segment 'privateCloudName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidatePrivateCloudID checks that 'input' can be parsed as a Private Cloud ID -func ValidatePrivateCloudID(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 := ParsePrivateCloudID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Private Cloud ID -func (id PrivateCloudId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.AVS/privateClouds/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PrivateCloudName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Private Cloud ID -func (id PrivateCloudId) 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("staticMicrosoftAVS", "Microsoft.AVS", "Microsoft.AVS"), - resourceids.StaticSegment("staticPrivateClouds", "privateClouds", "privateClouds"), - resourceids.UserSpecifiedSegment("privateCloudName", "privateCloudValue"), - } -} - -// String returns a human-readable description of this Private Cloud ID -func (id PrivateCloudId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Private Cloud Name: %q", id.PrivateCloudName), - } - return fmt.Sprintf("Private Cloud (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/vmware/sdk/2020-03-20/privateclouds/id_privatecloud_test.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/id_privatecloud_test.go deleted file mode 100644 index 79845f32c84a..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/id_privatecloud_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package privateclouds - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = PrivateCloudId{} - -func TestNewPrivateCloudID(t *testing.T) { - id := NewPrivateCloudID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateCloudValue") - - 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.PrivateCloudName != "privateCloudValue" { - t.Fatalf("Expected %q but got %q for Segment 'PrivateCloudName'", id.PrivateCloudName, "privateCloudValue") - } -} - -func TestFormatPrivateCloudID(t *testing.T) { - actual := NewPrivateCloudID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateCloudValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", actual, expected) - } -} - -func TestParsePrivateCloudID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateCloudId - }{ - { - // 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.AVS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue", - Expected: &PrivateCloudId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - PrivateCloudName: "privateCloudValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateCloudID(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.PrivateCloudName != v.Expected.PrivateCloudName { - t.Fatalf("Expected %q but got %q for PrivateCloudName", v.Expected.PrivateCloudName, actual.PrivateCloudName) - } - - } -} - -func TestParsePrivateCloudIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateCloudId - }{ - { - // 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.AVS", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs/pRiVaTeClOuDs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue", - Expected: &PrivateCloudId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - PrivateCloudName: "privateCloudValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AVS/privateClouds/privateCloudValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aVs/pRiVaTeClOuDs/pRiVaTeClOuDvAlUe", - Expected: &PrivateCloudId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - PrivateCloudName: "pRiVaTeClOuDvAlUe", - }, - }, - { - // 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.aVs/pRiVaTeClOuDs/pRiVaTeClOuDvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateCloudIDInsensitively(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.PrivateCloudName != v.Expected.PrivateCloudName { - t.Fatalf("Expected %q but got %q for PrivateCloudName", v.Expected.PrivateCloudName, actual.PrivateCloudName) - } - - } -} - -func TestSegmentsForPrivateCloudId(t *testing.T) { - segments := PrivateCloudId{}.Segments() - if len(segments) == 0 { - t.Fatalf("PrivateCloudId 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/vmware/sdk/2020-03-20/privateclouds/id_resourcegroup.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/id_resourcegroup.go deleted file mode 100644 index e77f90e6b46c..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/id_resourcegroup.go +++ /dev/null @@ -1,109 +0,0 @@ -package privateclouds - -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/vmware/sdk/2020-03-20/privateclouds/id_resourcegroup_test.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/id_resourcegroup_test.go deleted file mode 100644 index 40d9830a8118..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/id_resourcegroup_test.go +++ /dev/null @@ -1,204 +0,0 @@ -package privateclouds - -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", actual, expected) - } -} - -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/vmware/sdk/2020-03-20/privateclouds/id_subscription.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/id_subscription.go deleted file mode 100644 index 4b724a528c23..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/id_subscription.go +++ /dev/null @@ -1,96 +0,0 @@ -package privateclouds - -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/vmware/sdk/2020-03-20/privateclouds/id_subscription_test.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/id_subscription_test.go deleted file mode 100644 index b1c106ebe639..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/id_subscription_test.go +++ /dev/null @@ -1,159 +0,0 @@ -package privateclouds - -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", actual, expected) - } -} - -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/vmware/sdk/2020-03-20/privateclouds/method_createorupdate_autorest.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/method_createorupdate_autorest.go deleted file mode 100644 index 6cfa82837c8e..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/method_createorupdate_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package privateclouds - -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 CreateOrUpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c PrivateCloudsClient) CreateOrUpdate(ctx context.Context, id PrivateCloudId, input PrivateCloud) (result CreateOrUpdateResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c PrivateCloudsClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateCloudId, input PrivateCloud) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c PrivateCloudsClient) preparerForCreateOrUpdate(ctx context.Context, id PrivateCloudId, input PrivateCloud) (*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)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateCloudsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateResponse, 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/vmware/sdk/2020-03-20/privateclouds/method_delete_autorest.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/method_delete_autorest.go deleted file mode 100644 index 3a6931707eea..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/method_delete_autorest.go +++ /dev/null @@ -1,73 +0,0 @@ -package privateclouds - -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 PrivateCloudsClient) Delete(ctx context.Context, id PrivateCloudId) (result DeleteResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c PrivateCloudsClient) DeleteThenPoll(ctx context.Context, id PrivateCloudId) 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 PrivateCloudsClient) preparerForDelete(ctx context.Context, id PrivateCloudId) (*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 PrivateCloudsClient) 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/vmware/sdk/2020-03-20/privateclouds/method_get_autorest.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/method_get_autorest.go deleted file mode 100644 index db14aaf54b87..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/method_get_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package privateclouds - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type GetResponse struct { - HttpResponse *http.Response - Model *PrivateCloud -} - -// Get ... -func (c PrivateCloudsClient) Get(ctx context.Context, id PrivateCloudId) (result GetResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PrivateCloudsClient) preparerForGet(ctx context.Context, id PrivateCloudId) (*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 PrivateCloudsClient) 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/vmware/sdk/2020-03-20/privateclouds/method_list_autorest.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/method_list_autorest.go deleted file mode 100644 index 954a71bbe8b1..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/method_list_autorest.go +++ /dev/null @@ -1,183 +0,0 @@ -package privateclouds - -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 *[]PrivateCloud - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListResponse, error) -} - -type ListCompleteResult struct { - Items []PrivateCloud -} - -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 PrivateCloudsClient) List(ctx context.Context, id ResourceGroupId) (resp ListResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c PrivateCloudsClient) ListComplete(ctx context.Context, id ResourceGroupId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, PrivateCloudPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c PrivateCloudsClient) ListCompleteMatchingPredicate(ctx context.Context, id ResourceGroupId, predicate PrivateCloudPredicate) (resp ListCompleteResult, err error) { - items := make([]PrivateCloud, 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 PrivateCloudsClient) preparerForList(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.AVS/privateClouds", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c PrivateCloudsClient) 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 PrivateCloudsClient) responderForList(resp *http.Response) (result ListResponse, err error) { - type page struct { - Values []PrivateCloud `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, "privateclouds.PrivateCloudsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/vmware/sdk/2020-03-20/privateclouds/method_listadmincredentials_autorest.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/method_listadmincredentials_autorest.go deleted file mode 100644 index cb252ccc6d54..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/method_listadmincredentials_autorest.go +++ /dev/null @@ -1,65 +0,0 @@ -package privateclouds - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ListAdminCredentialsResponse struct { - HttpResponse *http.Response - Model *AdminCredentials -} - -// ListAdminCredentials ... -func (c PrivateCloudsClient) ListAdminCredentials(ctx context.Context, id PrivateCloudId) (result ListAdminCredentialsResponse, err error) { - req, err := c.preparerForListAdminCredentials(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "ListAdminCredentials", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "ListAdminCredentials", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListAdminCredentials(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "ListAdminCredentials", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListAdminCredentials prepares the ListAdminCredentials request. -func (c PrivateCloudsClient) preparerForListAdminCredentials(ctx context.Context, id PrivateCloudId) (*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/listAdminCredentials", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListAdminCredentials handles the response to the ListAdminCredentials request. The method always -// closes the http.Response Body. -func (c PrivateCloudsClient) responderForListAdminCredentials(resp *http.Response) (result ListAdminCredentialsResponse, 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/vmware/sdk/2020-03-20/privateclouds/method_listinsubscription_autorest.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/method_listinsubscription_autorest.go deleted file mode 100644 index 2671b8f12d41..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/method_listinsubscription_autorest.go +++ /dev/null @@ -1,183 +0,0 @@ -package privateclouds - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ListInSubscriptionResponse struct { - HttpResponse *http.Response - Model *[]PrivateCloud - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListInSubscriptionResponse, error) -} - -type ListInSubscriptionCompleteResult struct { - Items []PrivateCloud -} - -func (r ListInSubscriptionResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListInSubscriptionResponse) LoadMore(ctx context.Context) (resp ListInSubscriptionResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListInSubscription ... -func (c PrivateCloudsClient) ListInSubscription(ctx context.Context, id SubscriptionId) (resp ListInSubscriptionResponse, err error) { - req, err := c.preparerForListInSubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "ListInSubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "ListInSubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListInSubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "ListInSubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ListInSubscriptionComplete retrieves all of the results into a single object -func (c PrivateCloudsClient) ListInSubscriptionComplete(ctx context.Context, id SubscriptionId) (ListInSubscriptionCompleteResult, error) { - return c.ListInSubscriptionCompleteMatchingPredicate(ctx, id, PrivateCloudPredicate{}) -} - -// ListInSubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c PrivateCloudsClient) ListInSubscriptionCompleteMatchingPredicate(ctx context.Context, id SubscriptionId, predicate PrivateCloudPredicate) (resp ListInSubscriptionCompleteResult, err error) { - items := make([]PrivateCloud, 0) - - page, err := c.ListInSubscription(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 := ListInSubscriptionCompleteResult{ - Items: items, - } - return out, nil -} - -// preparerForListInSubscription prepares the ListInSubscription request. -func (c PrivateCloudsClient) preparerForListInSubscription(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.AVS/privateClouds", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListInSubscriptionWithNextLink prepares the ListInSubscription request with the given nextLink token. -func (c PrivateCloudsClient) preparerForListInSubscriptionWithNextLink(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)) -} - -// responderForListInSubscription handles the response to the ListInSubscription request. The method always -// closes the http.Response Body. -func (c PrivateCloudsClient) responderForListInSubscription(resp *http.Response) (result ListInSubscriptionResponse, err error) { - type page struct { - Values []PrivateCloud `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 ListInSubscriptionResponse, err error) { - req, err := c.preparerForListInSubscriptionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "ListInSubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "ListInSubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListInSubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "ListInSubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/vmware/sdk/2020-03-20/privateclouds/method_update_autorest.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/method_update_autorest.go deleted file mode 100644 index 48a719bb86f9..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/method_update_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package privateclouds - -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 PrivateCloudsClient) Update(ctx context.Context, id PrivateCloudId, input PrivateCloudUpdate) (result UpdateResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateclouds.PrivateCloudsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c PrivateCloudsClient) UpdateThenPoll(ctx context.Context, id PrivateCloudId, input PrivateCloudUpdate) 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 PrivateCloudsClient) preparerForUpdate(ctx context.Context, id PrivateCloudId, input PrivateCloudUpdate) (*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 PrivateCloudsClient) 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/vmware/sdk/2020-03-20/privateclouds/model_admincredentials.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/model_admincredentials.go deleted file mode 100644 index 23e94e70b4c0..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/model_admincredentials.go +++ /dev/null @@ -1,8 +0,0 @@ -package privateclouds - -type AdminCredentials struct { - NsxtPassword *string `json:"nsxtPassword,omitempty"` - NsxtUsername *string `json:"nsxtUsername,omitempty"` - VcenterPassword *string `json:"vcenterPassword,omitempty"` - VcenterUsername *string `json:"vcenterUsername,omitempty"` -} diff --git a/internal/services/vmware/sdk/2020-03-20/privateclouds/model_circuit.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/model_circuit.go deleted file mode 100644 index f7cf9cb4332a..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/model_circuit.go +++ /dev/null @@ -1,8 +0,0 @@ -package privateclouds - -type Circuit struct { - ExpressRouteID *string `json:"expressRouteID,omitempty"` - ExpressRoutePrivatePeeringID *string `json:"expressRoutePrivatePeeringID,omitempty"` - PrimarySubnet *string `json:"primarySubnet,omitempty"` - SecondarySubnet *string `json:"secondarySubnet,omitempty"` -} diff --git a/internal/services/vmware/sdk/2020-03-20/privateclouds/model_endpoints.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/model_endpoints.go deleted file mode 100644 index 5dc872d28f43..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/model_endpoints.go +++ /dev/null @@ -1,7 +0,0 @@ -package privateclouds - -type Endpoints struct { - HcxCloudManager *string `json:"hcxCloudManager,omitempty"` - NsxtManager *string `json:"nsxtManager,omitempty"` - Vcsa *string `json:"vcsa,omitempty"` -} diff --git a/internal/services/vmware/sdk/2020-03-20/privateclouds/model_identitysource.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/model_identitysource.go deleted file mode 100644 index 928e501c918e..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/model_identitysource.go +++ /dev/null @@ -1,14 +0,0 @@ -package privateclouds - -type IdentitySource struct { - Alias *string `json:"alias,omitempty"` - BaseGroupDN *string `json:"baseGroupDN,omitempty"` - BaseUserDN *string `json:"baseUserDN,omitempty"` - Domain *string `json:"domain,omitempty"` - Name *string `json:"name,omitempty"` - Password *string `json:"password,omitempty"` - PrimaryServer *string `json:"primaryServer,omitempty"` - SecondaryServer *string `json:"secondaryServer,omitempty"` - Ssl *SslEnum `json:"ssl,omitempty"` - Username *string `json:"username,omitempty"` -} diff --git a/internal/services/vmware/sdk/2020-03-20/privateclouds/model_managementcluster.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/model_managementcluster.go deleted file mode 100644 index b88575596f3f..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/model_managementcluster.go +++ /dev/null @@ -1,8 +0,0 @@ -package privateclouds - -type ManagementCluster struct { - ClusterId *int64 `json:"clusterId,omitempty"` - ClusterSize int64 `json:"clusterSize"` - Hosts *[]string `json:"hosts,omitempty"` - ProvisioningState *ClusterProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/internal/services/vmware/sdk/2020-03-20/privateclouds/model_privatecloud.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/model_privatecloud.go deleted file mode 100644 index 9a8e2349bdcb..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/model_privatecloud.go +++ /dev/null @@ -1,11 +0,0 @@ -package privateclouds - -type PrivateCloud struct { - Id *string `json:"id,omitempty"` - Location string `json:"location"` - Name *string `json:"name,omitempty"` - Properties PrivateCloudProperties `json:"properties"` - Sku Sku `json:"sku"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/vmware/sdk/2020-03-20/privateclouds/model_privatecloudproperties.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/model_privatecloudproperties.go deleted file mode 100644 index 4048f429bad1..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/model_privatecloudproperties.go +++ /dev/null @@ -1,18 +0,0 @@ -package privateclouds - -type PrivateCloudProperties struct { - Circuit *Circuit `json:"circuit,omitempty"` - Endpoints *Endpoints `json:"endpoints,omitempty"` - IdentitySources *[]IdentitySource `json:"identitySources,omitempty"` - Internet *InternetEnum `json:"internet,omitempty"` - ManagementCluster ManagementCluster `json:"managementCluster"` - ManagementNetwork *string `json:"managementNetwork,omitempty"` - NetworkBlock string `json:"networkBlock"` - NsxtCertificateThumbprint *string `json:"nsxtCertificateThumbprint,omitempty"` - NsxtPassword *string `json:"nsxtPassword,omitempty"` - ProvisioningNetwork *string `json:"provisioningNetwork,omitempty"` - ProvisioningState *PrivateCloudProvisioningState `json:"provisioningState,omitempty"` - VcenterCertificateThumbprint *string `json:"vcenterCertificateThumbprint,omitempty"` - VcenterPassword *string `json:"vcenterPassword,omitempty"` - VmotionNetwork *string `json:"vmotionNetwork,omitempty"` -} diff --git a/internal/services/vmware/sdk/2020-03-20/privateclouds/model_privatecloudupdate.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/model_privatecloudupdate.go deleted file mode 100644 index 9755b429e103..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/model_privatecloudupdate.go +++ /dev/null @@ -1,6 +0,0 @@ -package privateclouds - -type PrivateCloudUpdate struct { - Properties *PrivateCloudUpdateProperties `json:"properties,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/internal/services/vmware/sdk/2020-03-20/privateclouds/model_privatecloudupdateproperties.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/model_privatecloudupdateproperties.go deleted file mode 100644 index b7db34cd0c17..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/model_privatecloudupdateproperties.go +++ /dev/null @@ -1,7 +0,0 @@ -package privateclouds - -type PrivateCloudUpdateProperties struct { - IdentitySources *[]IdentitySource `json:"identitySources,omitempty"` - Internet *InternetEnum `json:"internet,omitempty"` - ManagementCluster *ManagementCluster `json:"managementCluster,omitempty"` -} diff --git a/internal/services/vmware/sdk/2020-03-20/privateclouds/model_sku.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/model_sku.go deleted file mode 100644 index 1a8e88fa7753..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/model_sku.go +++ /dev/null @@ -1,5 +0,0 @@ -package privateclouds - -type Sku struct { - Name string `json:"name"` -} diff --git a/internal/services/vmware/sdk/2020-03-20/privateclouds/predicates.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/predicates.go deleted file mode 100644 index e605fb11783b..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/predicates.go +++ /dev/null @@ -1,29 +0,0 @@ -package privateclouds - -type PrivateCloudPredicate struct { - Id *string - Location *string - Name *string - Type *string -} - -func (p PrivateCloudPredicate) Matches(input PrivateCloud) bool { - - if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { - return false - } - - if p.Location != nil && *p.Location != input.Location { - return false - } - - if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { - return false - } - - return true -} diff --git a/internal/services/vmware/sdk/2020-03-20/privateclouds/version.go b/internal/services/vmware/sdk/2020-03-20/privateclouds/version.go deleted file mode 100644 index 8df2dfa07ef3..000000000000 --- a/internal/services/vmware/sdk/2020-03-20/privateclouds/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package privateclouds - -import "fmt" - -const defaultApiVersion = "2020-03-20" - -func userAgent() string { - return fmt.Sprintf("pandora/privateclouds/%s", defaultApiVersion) -}