From db86e7a33c7c5d8d6a8b76b94fa4317c66a2bcd5 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Thu, 4 May 2023 16:06:26 +0200 Subject: [PATCH 1/9] internal/resourceproviders: updating to cache the API Response & use API Version `2022-09-01` This PR supersedes both https://github.com/hashicorp/terraform-provider-azurerm/pull/20050 and https://github.com/hashicorp/go-azure-helpers/pull/158 by refactoring this to use a cache and then migrating this across to `hashicorp/go-azure-sdk`, since this needs to be migrated away from using `Azure/azure-sdk-for-go` anyway. --- internal/acceptance/required_test.go | 39 +++++------ internal/clients/builder.go | 7 +- internal/provider/provider.go | 15 +---- internal/resourceproviders/azure.go | 28 -------- internal/resourceproviders/cache.go | 59 +++++++++++++++-- internal/resourceproviders/registration.go | 66 ++++++++++++++++--- internal/resourceproviders/required.go | 2 +- .../requiring_registration.go | 28 ++++++++ internal/services/resource/client/client.go | 16 +++-- 9 files changed, 174 insertions(+), 86 deletions(-) delete mode 100644 internal/resourceproviders/azure.go create mode 100644 internal/resourceproviders/requiring_registration.go diff --git a/internal/acceptance/required_test.go b/internal/acceptance/required_test.go index b081da245b4f..c7c139569fdb 100644 --- a/internal/acceptance/required_test.go +++ b/internal/acceptance/required_test.go @@ -6,9 +6,9 @@ import ( "testing" "github.com/davecgh/go-spew/spew" - "github.com/hashicorp/go-azure-helpers/resourceproviders" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - rmResourceProviders "github.com/hashicorp/terraform-provider-azurerm/internal/resourceproviders" + "github.com/hashicorp/terraform-provider-azurerm/internal/resourceproviders" ) // since this depends on GetAuthConfig which lives in this package @@ -35,32 +35,27 @@ func TestAccEnsureRequiredResourceProvidersAreRegistered(t *testing.T) { t.Fatalf("Error building ARM Client: %+v", err) } - client := armClient.Resource.ProvidersClient + client := armClient.Resource.ResourceProvidersClient ctx := armClient.StopContext - providerList, err := client.List(ctx, nil, "") - if err != nil { - t.Fatalf("Unable to list provider registration status, it is possible that this is due to invalid "+ - "credentials or the service principal does not have permission to use the Resource Manager API, Azure "+ - "error: %s", err) - } - availableResourceProviders := providerList.Values() - requiredResourceProviders := rmResourceProviders.Required() - err = rmResourceProviders.EnsureRegistered(ctx, *client, availableResourceProviders, requiredResourceProviders) - if err != nil { + requiredResourceProviders := resourceproviders.Required() + subscriptionId := commonids.NewSubscriptionID(armClient.Account.SubscriptionId) + + if err = resourceproviders.EnsureRegistered(ctx, client, subscriptionId, requiredResourceProviders); err != nil { t.Fatalf("Error registering Resource Providers: %+v", err) } - // refresh the list now things have been re-registered - providerList, err = client.List(ctx, nil, "") - if err != nil { - t.Fatalf("Unable to list provider registration status, it is possible that this is due to invalid "+ - "credentials or the service principal does not have permission to use the Resource Manager API, Azure "+ - "error: %s", err) + // refresh the cache now things have been re-registered + resourceproviders.ClearCache() + if err := resourceproviders.CacheSupportedProviders(ctx, client, subscriptionId); err != nil { + t.Fatalf("re-caching Resource Providers: %+v", err) } - stillRequiringRegistration := resourceproviders.DetermineResourceProvidersRequiringRegistration(providerList.Values(), requiredResourceProviders) - if len(stillRequiringRegistration) > 0 { - t.Fatalf("'%d' Resource Providers are still Pending Registration: %s", len(stillRequiringRegistration), spew.Sprint(stillRequiringRegistration)) + stillRequiringRegistration, err := resourceproviders.DetermineWhichRequiredResourceProvidersRequireRegistration(requiredResourceProviders) + if err != nil { + t.Fatalf("determining which Resource Providers still require Registration: %+v", err) + } + if len(*stillRequiringRegistration) > 0 { + t.Fatalf("'%d' Resource Providers are still Pending Registration: %s", len(*stillRequiringRegistration), spew.Sprint(stillRequiringRegistration)) } } diff --git a/internal/clients/builder.go b/internal/clients/builder.go index b8b02e95c498..213da056df3c 100644 --- a/internal/clients/builder.go +++ b/internal/clients/builder.go @@ -3,6 +3,7 @@ package clients import ( "context" "fmt" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "log" "strings" @@ -157,8 +158,12 @@ func Build(ctx context.Context, builder ClientBuilder) (*Client, error) { } if features.EnhancedValidationEnabled() { + subscriptionId := commonids.NewSubscriptionID(client.Account.SubscriptionId) + location.CacheSupportedLocations(ctx, *resourceManagerEndpoint) - resourceproviders.CacheSupportedProviders(ctx, client.Resource.ProvidersClient) + if err := resourceproviders.CacheSupportedProviders(ctx, client.Resource.ResourceProvidersClient, subscriptionId); err != nil { + log.Printf("[DEBUG] error retrieving providers: %s. Enhanced validation will be unavailable", err) + } } return &client, nil diff --git a/internal/provider/provider.go b/internal/provider/provider.go index a9a51053c401..b7ec6f40d657 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -4,6 +4,7 @@ import ( "context" "encoding/base64" "fmt" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "log" "os" "strings" @@ -455,19 +456,9 @@ func buildClient(ctx context.Context, p *schema.Provider, d *schema.ResourceData client.StopContext = stopCtx if !skipProviderRegistration { - // List all the available providers and their registration state to avoid unnecessary - // requests. This also lets us check if the provider credentials are correct. - providerList, err := client.Resource.ProvidersClient.List(ctx, nil, "") - if err != nil { - return nil, diag.Errorf("Unable to list provider registration status, it is possible that this is due to invalid "+ - "credentials or the service principal does not have permission to use the Resource Manager API, Azure "+ - "error: %s", err) - } - - availableResourceProviders := providerList.Values() + subscriptionId := commonids.NewSubscriptionID(client.Account.SubscriptionId) requiredResourceProviders := resourceproviders.Required() - - if err := resourceproviders.EnsureRegistered(ctx, *client.Resource.ProvidersClient, availableResourceProviders, requiredResourceProviders); err != nil { + if err := resourceproviders.EnsureRegistered(ctx, client.Resource.ResourceProvidersClient, subscriptionId, requiredResourceProviders); err != nil { return nil, diag.Errorf(resourceProviderRegistrationErrorFmt, err) } } diff --git a/internal/resourceproviders/azure.go b/internal/resourceproviders/azure.go deleted file mode 100644 index 9f4584901001..000000000000 --- a/internal/resourceproviders/azure.go +++ /dev/null @@ -1,28 +0,0 @@ -package resourceproviders - -import ( - "context" - "fmt" - - "github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources" -) - -func availableResourceProviders(ctx context.Context, client *resources.ProvidersClient) (*[]string, error) { - providerNames := make([]string, 0) - providers, err := client.ListComplete(ctx, nil, "") - if err != nil { - return nil, fmt.Errorf("listing Resource Providers: %+v", err) - } - for providers.NotDone() { - provider := providers.Value() - if provider.Namespace != nil { - providerNames = append(providerNames, *provider.Namespace) - } - - if err := providers.NextWithContext(ctx); err != nil { - return nil, err - } - } - - return &providerNames, nil -} diff --git a/internal/resourceproviders/cache.go b/internal/resourceproviders/cache.go index 37088100d1a8..6f92e9bff927 100644 --- a/internal/resourceproviders/cache.go +++ b/internal/resourceproviders/cache.go @@ -2,22 +2,67 @@ package resourceproviders import ( "context" - "log" + "fmt" + "strings" + "sync" - "github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers" ) // cachedResourceProviders can be (validly) nil - as such this shouldn't be relied on var cachedResourceProviders *[]string +var registeredResourceProviders *map[string]struct{} +var unregisteredResourceProviders *map[string]struct{} + +var cacheLock = sync.Mutex{} // CacheSupportedProviders attempts to retrieve the supported Resource Providers from the Resource Manager API // and caches them, for used in enhanced validation -func CacheSupportedProviders(ctx context.Context, client *resources.ProvidersClient) { - providers, err := availableResourceProviders(ctx, client) +func CacheSupportedProviders(ctx context.Context, client *providers.ProvidersClient, subscriptionId commonids.SubscriptionId) error { + if err := populateCache(ctx, client, subscriptionId); err != nil { + return fmt.Errorf("populating cache: %+v", err) + } + + return nil +} + +func ClearCache() { + cacheLock.Lock() + cachedResourceProviders = nil + registeredResourceProviders = nil + unregisteredResourceProviders = nil + cacheLock.Unlock() +} + +func populateCache(ctx context.Context, client *providers.ProvidersClient, subscriptionId commonids.SubscriptionId) error { + cacheLock.Lock() + defer cacheLock.Unlock() + + providers, err := client.ListComplete(ctx, subscriptionId, providers.DefaultListOperationOptions()) if err != nil { - log.Printf("[DEBUG] error retrieving providers: %s. Enhanced validation will be unavailable", err) - return + return fmt.Errorf("listing Resource Providers: %+v", err) + } + + providerNames := make([]string, 0) + registeredProviders := make(map[string]struct{}, 0) + unregisteredProviders := make(map[string]struct{}, 0) + for _, provider := range providers.Items { + if provider.Namespace == nil { + continue + } + + providerNames = append(providerNames, *provider.Namespace) + registered := provider.RegistrationState != nil && strings.EqualFold(*provider.RegistrationState, "registered") + if registered { + registeredProviders[*provider.Namespace] = struct{}{} + } else { + unregisteredProviders[*provider.Namespace] = struct{}{} + } } - cachedResourceProviders = providers + cachedResourceProviders = &providerNames + registeredResourceProviders = ®isteredProviders + unregisteredResourceProviders = &unregisteredProviders + return nil } diff --git a/internal/resourceproviders/registration.go b/internal/resourceproviders/registration.go index cb39fbe1fc09..528d6f1af580 100644 --- a/internal/resourceproviders/registration.go +++ b/internal/resourceproviders/registration.go @@ -2,19 +2,30 @@ package resourceproviders import ( "context" + "fmt" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers" "log" - - "github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources" - "github.com/hashicorp/go-azure-helpers/resourceproviders" + "strings" + "sync" ) -func EnsureRegistered(ctx context.Context, client resources.ProvidersClient, availableRPs []resources.Provider, requiredRPs map[string]struct{}) error { +func EnsureRegistered(ctx context.Context, client *providers.ProvidersClient, subscriptionId commonids.SubscriptionId, requiredRPs map[string]struct{}) error { + if registeredResourceProviders == nil || unregisteredResourceProviders == nil { + if err := populateCache(ctx, client, subscriptionId); err != nil { + return fmt.Errorf("populating Resource Provider cache: %+v", err) + } + } + log.Printf("[DEBUG] Determining which Resource Providers require Registration") - providersToRegister := resourceproviders.DetermineResourceProvidersRequiringRegistration(availableRPs, requiredRPs) + providersToRegister, err := DetermineWhichRequiredResourceProvidersRequireRegistration(requiredRPs) + if err != nil { + return fmt.Errorf("determining which Required Resource Providers require registration: %+v", err) + } - if len(providersToRegister) > 0 { - log.Printf("[DEBUG] Registering %d Resource Providers", len(providersToRegister)) - if err := resourceproviders.RegisterForSubscription(ctx, client, providersToRegister); err != nil { + if len(*providersToRegister) > 0 { + log.Printf("[DEBUG] Registering %d Resource Providers", len(*providersToRegister)) + if err := registerForSubscription(ctx, client, subscriptionId, *providersToRegister); err != nil { return err } } else { @@ -23,3 +34,42 @@ func EnsureRegistered(ctx context.Context, client resources.ProvidersClient, ava return nil } + +// registerForSubscription registers the specified Resource Providers in the current Subscription +func registerForSubscription(ctx context.Context, client *providers.ProvidersClient, subscriptionId commonids.SubscriptionId, providersToRegister []string) error { + var err error + var failedProviders []string + var wg sync.WaitGroup + wg.Add(len(providersToRegister)) + + for _, providerName := range providersToRegister { + go func(p string) { + defer wg.Done() + log.Printf("[DEBUG] Registering Resource Provider %q with namespace", p) + if innerErr := registerWithSubscription(ctx, client, subscriptionId, p); innerErr != nil { + failedProviders = append(failedProviders, p) + if err == nil { + err = innerErr + } else { + err = fmt.Errorf("%s\n%s", err, innerErr) + } + } + }(providerName) + } + + wg.Wait() + + if len(failedProviders) > 0 { + err = fmt.Errorf("Cannot register providers: %s. Errors were: %s", strings.Join(failedProviders, ", "), err) + } + return err +} + +func registerWithSubscription(ctx context.Context, client *providers.ProvidersClient, subscriptionId commonids.SubscriptionId, providerName string) error { + providerId := providers.NewSubscriptionProviderID(subscriptionId.SubscriptionId, providerName) + if _, err := client.Register(ctx, providerId, providers.ProviderRegistrationRequest{}); err != nil { + return fmt.Errorf("Cannot register provider %s with Azure Resource Manager: %s.", providerName, err) + } + + return nil +} diff --git a/internal/resourceproviders/required.go b/internal/resourceproviders/required.go index eef1a28b0c5b..af812952aad3 100644 --- a/internal/resourceproviders/required.go +++ b/internal/resourceproviders/required.go @@ -1,6 +1,6 @@ package resourceproviders -// RequiredResourceProviders returns all of the Resource Providers used by the AzureRM Provider +// Required returns all of the Resource Providers used by the AzureRM Provider // whilst all may not be used by every user - the intention is that we determine which should be // registered such that we can avoid obscure errors where Resource Providers aren't registered. // new Resource Providers should be added to this list as they're used in the Provider diff --git a/internal/resourceproviders/requiring_registration.go b/internal/resourceproviders/requiring_registration.go new file mode 100644 index 000000000000..6eb5d07a7819 --- /dev/null +++ b/internal/resourceproviders/requiring_registration.go @@ -0,0 +1,28 @@ +package resourceproviders + +import ( + "fmt" +) + +// DetermineWhichRequiredResourceProvidersRequireRegistration determines which Resource Providers require registration to be able to be used +func DetermineWhichRequiredResourceProvidersRequireRegistration(requiredResourceProviders map[string]struct{}) (*[]string, error) { + if registeredResourceProviders == nil || unregisteredResourceProviders == nil { + return nil, fmt.Errorf("internal-error: the registered/unregistered Resource Provider cache isn't populated") + } + + requiringRegistration := make([]string, 0) + for providerName := range requiredResourceProviders { + if _, isRegistered := (*registeredResourceProviders)[providerName]; isRegistered { + continue + } + + if _, isUnregistered := (*unregisteredResourceProviders)[providerName]; !isUnregistered { + // this is likely a typo in the Required Resource Providers list, so we should surface this + return nil, fmt.Errorf("the required Resource Provider %q wasn't returned from the Azure API", providerName) + } + + requiringRegistration = append(requiringRegistration, providerName) + } + + return &requiringRegistration, nil +} diff --git a/internal/services/resource/client/client.go b/internal/services/resource/client/client.go index 737a2e634fd0..7dd321c36aa2 100644 --- a/internal/services/resource/client/client.go +++ b/internal/services/resource/client/client.go @@ -1,12 +1,13 @@ package client import ( - providers "github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources" + resourcesProfile "github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources" "github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2019-06-01-preview/templatespecs" // nolint: staticcheck "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2015-12-01/features" // nolint: staticcheck "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-06-01/resources" // nolint: staticcheck "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks" "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-10-01/deploymentscripts" + "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers" "github.com/hashicorp/terraform-provider-azurerm/internal/common" ) @@ -16,12 +17,14 @@ type Client struct { FeaturesClient *features.Client GroupsClient *resources.GroupsClient LocksClient *managementlocks.ManagementLocksClient - ProvidersClient *providers.ProvidersClient - ResourceProvidersClient *resources.ProvidersClient + ResourceProvidersClient *providers.ProvidersClient ResourcesClient *resources.Client TagsClient *resources.TagsClient TemplateSpecsVersionsClient *templatespecs.VersionsClient + // TODO: update usages of this to use `hashicorp/go-azure-sdk` (available as ResourceProvidersClient) + ProvidersClient *resourcesProfile.ProvidersClient + options *common.ClientOptions } @@ -41,12 +44,10 @@ func NewClient(o *common.ClientOptions) *Client { locksClient := managementlocks.NewManagementLocksClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&locksClient.Client, o.ResourceManagerAuthorizer) - // this has to come from the Profile since this is shared with Stack - providersClient := providers.NewProvidersClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + providersClient := resourcesProfile.NewProvidersClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&providersClient.Client, o.ResourceManagerAuthorizer) - // add a secondary ProvidersClient to use latest resources sdk - resourceProvidersClient := resources.NewProvidersClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + resourceProvidersClient := providers.NewProvidersClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&resourceProvidersClient.Client, o.ResourceManagerAuthorizer) resourcesClient := resources.NewClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) @@ -75,6 +76,7 @@ func NewClient(o *common.ClientOptions) *Client { } func (c Client) TagsClientForSubscription(subscriptionID string) *resources.TagsClient { + // TODO: this method can be removed once this is moved to using `hashicorp/go-azure-sdk` tagsClient := resources.NewTagsClientWithBaseURI(c.options.ResourceManagerEndpoint, subscriptionID) c.options.ConfigureClient(&tagsClient.Client, c.options.ResourceManagerAuthorizer) return &tagsClient From e6a238601381e5bb5ee15022cb72194005f61bd5 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Thu, 4 May 2023 16:08:38 +0200 Subject: [PATCH 2/9] go mod tidy / go mod vendor --- .../resourceproviders/registration.go | 73 ------ .../resources/2022-09-01/providers/README.md | 171 ++++++++++++++ .../resources/2022-09-01/providers/client.go | 18 ++ .../2022-09-01/providers/constants.go | 173 ++++++++++++++ .../2022-09-01/providers/id_provider.go | 99 ++++++++ .../2022-09-01/providers/id_providers2.go | 114 +++++++++ .../providers/id_subscriptionprovider.go | 112 +++++++++ .../providers/method_get_autorest.go | 97 ++++++++ .../method_getattenantscope_autorest.go | 97 ++++++++ .../providers/method_list_autorest.go | 216 ++++++++++++++++++ .../method_listattenantscope_autorest.go | 215 +++++++++++++++++ .../method_providerpermissions_autorest.go | 69 ++++++ ...thod_providerresourcetypeslist_autorest.go | 98 ++++++++ .../providers/method_register_autorest.go | 70 ++++++ ...registeratmanagementgroupscope_autorest.go | 67 ++++++ .../providers/method_unregister_autorest.go | 69 ++++++ .../2022-09-01/providers/model_alias.go | 13 ++ .../2022-09-01/providers/model_aliaspath.go | 11 + .../providers/model_aliaspathmetadata.go | 9 + .../providers/model_aliaspattern.go | 10 + .../2022-09-01/providers/model_apiprofile.go | 9 + .../2022-09-01/providers/model_permission.go | 11 + .../2022-09-01/providers/model_provider.go | 13 ++ .../model_providerconsentdefinition.go | 8 + .../model_providerextendedlocation.go | 10 + .../providers/model_providerpermission.go | 11 + .../model_providerpermissionlistresult.go | 9 + .../model_providerregistrationrequest.go | 8 + .../providers/model_providerresourcetype.go | 17 ++ .../model_providerresourcetypelistresult.go | 9 + .../providers/model_roledefinition.go | 12 + .../2022-09-01/providers/model_zonemapping.go | 13 ++ .../2022-09-01/providers/predicates.go | 32 +++ .../resources/2022-09-01/providers/version.go | 12 + vendor/modules.txt | 2 +- 35 files changed, 1903 insertions(+), 74 deletions(-) delete mode 100644 vendor/github.com/hashicorp/go-azure-helpers/resourceproviders/registration.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/id_provider.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/id_providers2.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/id_subscriptionprovider.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_get_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_getattenantscope_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_list_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_listattenantscope_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_providerpermissions_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_providerresourcetypeslist_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_register_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_registeratmanagementgroupscope_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_unregister_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_alias.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_aliaspath.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_aliaspathmetadata.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_aliaspattern.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_apiprofile.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_permission.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_provider.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerconsentdefinition.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerextendedlocation.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerpermission.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerpermissionlistresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerregistrationrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerresourcetype.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerresourcetypelistresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_roledefinition.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_zonemapping.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/version.go diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourceproviders/registration.go b/vendor/github.com/hashicorp/go-azure-helpers/resourceproviders/registration.go deleted file mode 100644 index 85b825e1de3a..000000000000 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourceproviders/registration.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package resourceproviders - -import ( - "context" - "fmt" - "log" - "strings" - "sync" - - "github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources" -) - -// DetermineResourceProvidersRequiringRegistration determines which Resource Providers require registration to be able to be used -func DetermineResourceProvidersRequiringRegistration(availableResourceProviders []resources.Provider, requiredResourceProviders map[string]struct{}) map[string]struct{} { - providers := make(map[string]struct{}) - - // filter out any providers already registered and not in the required list. - for _, p := range availableResourceProviders { - // Skip it if it's not in the required list. - if _, ok := requiredResourceProviders[*p.Namespace]; !ok { - continue - } - - // If it's in the required list but not registered. - if strings.ToLower(*p.RegistrationState) != "registered" { - log.Printf("[DEBUG] Adding provider registration for namespace %s\n", *p.Namespace) - providers[*p.Namespace] = requiredResourceProviders[*p.Namespace] - } - } - - return providers -} - -// RegisterForSubscription registers the specified Resource Providers in the current Subscription -func RegisterForSubscription(ctx context.Context, client resources.ProvidersClient, providersToRegister map[string]struct{}) error { - var err error - var failedProviders []string - var wg sync.WaitGroup - wg.Add(len(providersToRegister)) - - for providerName := range providersToRegister { - go func(p string) { - defer wg.Done() - log.Printf("[DEBUG] Registering Resource Provider %q with namespace", p) - if innerErr := registerWithSubscription(ctx, p, client); innerErr != nil { - failedProviders = append(failedProviders, p) - if err == nil { - err = innerErr - } else { - err = fmt.Errorf("%s\n%s", err, innerErr) - } - } - }(providerName) - } - - wg.Wait() - - if len(failedProviders) > 0 { - err = fmt.Errorf("Cannnot register providers: %s. Errors were: %s", strings.Join(failedProviders, ", "), err) - } - return err -} - -func registerWithSubscription(ctx context.Context, providerName string, client resources.ProvidersClient) error { - if _, err := client.Register(ctx, providerName); err != nil { - return fmt.Errorf("Cannot register provider %s with Azure Resource Manager: %s.", providerName, err) - } - - return nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/README.md new file mode 100644 index 000000000000..d285112a68e5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/README.md @@ -0,0 +1,171 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers` Documentation + +The `providers` SDK allows for interaction with the Azure Resource Manager Service `resources` (API Version `2022-09-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers" +``` + + +### Client Initialization + +```go +client := providers.NewProvidersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ProvidersClient.Get` + +```go +ctx := context.TODO() +id := providers.NewSubscriptionProviderID("12345678-1234-9876-4563-123456789012", "providerValue") + +read, err := client.Get(ctx, id, providers.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProvidersClient.GetAtTenantScope` + +```go +ctx := context.TODO() +id := providers.NewProviderID("providerValue") + +read, err := client.GetAtTenantScope(ctx, id, providers.DefaultGetAtTenantScopeOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProvidersClient.List` + +```go +ctx := context.TODO() +id := providers.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id, providers.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, providers.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ProvidersClient.ListAtTenantScope` + +```go +ctx := context.TODO() + + +// alternatively `client.ListAtTenantScope(ctx, providers.DefaultListAtTenantScopeOperationOptions())` can be used to do batched pagination +items, err := client.ListAtTenantScopeComplete(ctx, providers.DefaultListAtTenantScopeOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ProvidersClient.ProviderPermissions` + +```go +ctx := context.TODO() +id := providers.NewSubscriptionProviderID("12345678-1234-9876-4563-123456789012", "providerValue") + +read, err := client.ProviderPermissions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProvidersClient.ProviderResourceTypesList` + +```go +ctx := context.TODO() +id := providers.NewSubscriptionProviderID("12345678-1234-9876-4563-123456789012", "providerValue") + +read, err := client.ProviderResourceTypesList(ctx, id, providers.DefaultProviderResourceTypesListOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProvidersClient.Register` + +```go +ctx := context.TODO() +id := providers.NewSubscriptionProviderID("12345678-1234-9876-4563-123456789012", "providerValue") + +payload := providers.ProviderRegistrationRequest{ + // ... +} + + +read, err := client.Register(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProvidersClient.RegisterAtManagementGroupScope` + +```go +ctx := context.TODO() +id := providers.NewProviders2ID("groupIdValue", "providerValue") + +read, err := client.RegisterAtManagementGroupScope(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProvidersClient.Unregister` + +```go +ctx := context.TODO() +id := providers.NewSubscriptionProviderID("12345678-1234-9876-4563-123456789012", "providerValue") + +read, err := client.Unregister(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/client.go new file mode 100644 index 000000000000..f728f9fc9c29 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/client.go @@ -0,0 +1,18 @@ +package providers + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvidersClient struct { + Client autorest.Client + baseUri string +} + +func NewProvidersClientWithBaseURI(endpoint string) ProvidersClient { + return ProvidersClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/constants.go new file mode 100644 index 000000000000..c2a3b18615c4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/constants.go @@ -0,0 +1,173 @@ +package providers + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AliasPathAttributes string + +const ( + AliasPathAttributesModifiable AliasPathAttributes = "Modifiable" + AliasPathAttributesNone AliasPathAttributes = "None" +) + +func PossibleValuesForAliasPathAttributes() []string { + return []string{ + string(AliasPathAttributesModifiable), + string(AliasPathAttributesNone), + } +} + +func parseAliasPathAttributes(input string) (*AliasPathAttributes, error) { + vals := map[string]AliasPathAttributes{ + "modifiable": AliasPathAttributesModifiable, + "none": AliasPathAttributesNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AliasPathAttributes(input) + return &out, nil +} + +type AliasPathTokenType string + +const ( + AliasPathTokenTypeAny AliasPathTokenType = "Any" + AliasPathTokenTypeArray AliasPathTokenType = "Array" + AliasPathTokenTypeBoolean AliasPathTokenType = "Boolean" + AliasPathTokenTypeInteger AliasPathTokenType = "Integer" + AliasPathTokenTypeNotSpecified AliasPathTokenType = "NotSpecified" + AliasPathTokenTypeNumber AliasPathTokenType = "Number" + AliasPathTokenTypeObject AliasPathTokenType = "Object" + AliasPathTokenTypeString AliasPathTokenType = "String" +) + +func PossibleValuesForAliasPathTokenType() []string { + return []string{ + string(AliasPathTokenTypeAny), + string(AliasPathTokenTypeArray), + string(AliasPathTokenTypeBoolean), + string(AliasPathTokenTypeInteger), + string(AliasPathTokenTypeNotSpecified), + string(AliasPathTokenTypeNumber), + string(AliasPathTokenTypeObject), + string(AliasPathTokenTypeString), + } +} + +func parseAliasPathTokenType(input string) (*AliasPathTokenType, error) { + vals := map[string]AliasPathTokenType{ + "any": AliasPathTokenTypeAny, + "array": AliasPathTokenTypeArray, + "boolean": AliasPathTokenTypeBoolean, + "integer": AliasPathTokenTypeInteger, + "notspecified": AliasPathTokenTypeNotSpecified, + "number": AliasPathTokenTypeNumber, + "object": AliasPathTokenTypeObject, + "string": AliasPathTokenTypeString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AliasPathTokenType(input) + return &out, nil +} + +type AliasPatternType string + +const ( + AliasPatternTypeExtract AliasPatternType = "Extract" + AliasPatternTypeNotSpecified AliasPatternType = "NotSpecified" +) + +func PossibleValuesForAliasPatternType() []string { + return []string{ + string(AliasPatternTypeExtract), + string(AliasPatternTypeNotSpecified), + } +} + +func parseAliasPatternType(input string) (*AliasPatternType, error) { + vals := map[string]AliasPatternType{ + "extract": AliasPatternTypeExtract, + "notspecified": AliasPatternTypeNotSpecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AliasPatternType(input) + return &out, nil +} + +type AliasType string + +const ( + AliasTypeMask AliasType = "Mask" + AliasTypeNotSpecified AliasType = "NotSpecified" + AliasTypePlainText AliasType = "PlainText" +) + +func PossibleValuesForAliasType() []string { + return []string{ + string(AliasTypeMask), + string(AliasTypeNotSpecified), + string(AliasTypePlainText), + } +} + +func parseAliasType(input string) (*AliasType, error) { + vals := map[string]AliasType{ + "mask": AliasTypeMask, + "notspecified": AliasTypeNotSpecified, + "plaintext": AliasTypePlainText, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AliasType(input) + return &out, nil +} + +type ProviderAuthorizationConsentState string + +const ( + ProviderAuthorizationConsentStateConsented ProviderAuthorizationConsentState = "Consented" + ProviderAuthorizationConsentStateNotRequired ProviderAuthorizationConsentState = "NotRequired" + ProviderAuthorizationConsentStateNotSpecified ProviderAuthorizationConsentState = "NotSpecified" + ProviderAuthorizationConsentStateRequired ProviderAuthorizationConsentState = "Required" +) + +func PossibleValuesForProviderAuthorizationConsentState() []string { + return []string{ + string(ProviderAuthorizationConsentStateConsented), + string(ProviderAuthorizationConsentStateNotRequired), + string(ProviderAuthorizationConsentStateNotSpecified), + string(ProviderAuthorizationConsentStateRequired), + } +} + +func parseProviderAuthorizationConsentState(input string) (*ProviderAuthorizationConsentState, error) { + vals := map[string]ProviderAuthorizationConsentState{ + "consented": ProviderAuthorizationConsentStateConsented, + "notrequired": ProviderAuthorizationConsentStateNotRequired, + "notspecified": ProviderAuthorizationConsentStateNotSpecified, + "required": ProviderAuthorizationConsentStateRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProviderAuthorizationConsentState(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/id_provider.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/id_provider.go new file mode 100644 index 000000000000..882d08c95501 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/id_provider.go @@ -0,0 +1,99 @@ +package providers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = ProviderId{} + +// ProviderId is a struct representing the Resource ID for a Provider +type ProviderId struct { + ProviderName string +} + +// NewProviderID returns a new ProviderId struct +func NewProviderID(providerName string) ProviderId { + return ProviderId{ + ProviderName: providerName, + } +} + +// ParseProviderID parses 'input' into a ProviderId +func ParseProviderID(input string) (*ProviderId, error) { + parser := resourceids.NewParserFromResourceIdType(ProviderId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ProviderId{} + + if id.ProviderName, ok = parsed.Parsed["providerName"]; !ok { + return nil, fmt.Errorf("the segment 'providerName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseProviderIDInsensitively parses 'input' case-insensitively into a ProviderId +// note: this method should only be used for API response data and not user input +func ParseProviderIDInsensitively(input string) (*ProviderId, error) { + parser := resourceids.NewParserFromResourceIdType(ProviderId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ProviderId{} + + if id.ProviderName, ok = parsed.Parsed["providerName"]; !ok { + return nil, fmt.Errorf("the segment 'providerName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateProviderID checks that 'input' can be parsed as a Provider ID +func ValidateProviderID(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 := ParseProviderID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider ID +func (id ProviderId) ID() string { + fmtString := "/providers/%s" + return fmt.Sprintf(fmtString, id.ProviderName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider ID +func (id ProviderId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.UserSpecifiedSegment("providerName", "providerValue"), + } +} + +// String returns a human-readable description of this Provider ID +func (id ProviderId) String() string { + components := []string{ + fmt.Sprintf("Provider Name: %q", id.ProviderName), + } + return fmt.Sprintf("Provider (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/id_providers2.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/id_providers2.go new file mode 100644 index 000000000000..679c232ce36e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/id_providers2.go @@ -0,0 +1,114 @@ +package providers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = Providers2Id{} + +// Providers2Id is a struct representing the Resource ID for a Providers 2 +type Providers2Id struct { + GroupId string + ProviderName string +} + +// NewProviders2ID returns a new Providers2Id struct +func NewProviders2ID(groupId string, providerName string) Providers2Id { + return Providers2Id{ + GroupId: groupId, + ProviderName: providerName, + } +} + +// ParseProviders2ID parses 'input' into a Providers2Id +func ParseProviders2ID(input string) (*Providers2Id, error) { + parser := resourceids.NewParserFromResourceIdType(Providers2Id{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := Providers2Id{} + + if id.GroupId, ok = parsed.Parsed["groupId"]; !ok { + return nil, fmt.Errorf("the segment 'groupId' was not found in the resource id %q", input) + } + + if id.ProviderName, ok = parsed.Parsed["providerName"]; !ok { + return nil, fmt.Errorf("the segment 'providerName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseProviders2IDInsensitively parses 'input' case-insensitively into a Providers2Id +// note: this method should only be used for API response data and not user input +func ParseProviders2IDInsensitively(input string) (*Providers2Id, error) { + parser := resourceids.NewParserFromResourceIdType(Providers2Id{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := Providers2Id{} + + if id.GroupId, ok = parsed.Parsed["groupId"]; !ok { + return nil, fmt.Errorf("the segment 'groupId' was not found in the resource id %q", input) + } + + if id.ProviderName, ok = parsed.Parsed["providerName"]; !ok { + return nil, fmt.Errorf("the segment 'providerName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateProviders2ID checks that 'input' can be parsed as a Providers 2 ID +func ValidateProviders2ID(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 := ParseProviders2ID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Providers 2 ID +func (id Providers2Id) ID() string { + fmtString := "/providers/Microsoft.Management/managementGroups/%s/providers/%s" + return fmt.Sprintf(fmtString, id.GroupId, id.ProviderName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Providers 2 ID +func (id Providers2Id) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftManagement", "Microsoft.Management", "Microsoft.Management"), + resourceids.StaticSegment("staticManagementGroups", "managementGroups", "managementGroups"), + resourceids.UserSpecifiedSegment("groupId", "groupIdValue"), + resourceids.StaticSegment("staticProviders2", "providers", "providers"), + resourceids.UserSpecifiedSegment("providerName", "providerValue"), + } +} + +// String returns a human-readable description of this Providers 2 ID +func (id Providers2Id) String() string { + components := []string{ + fmt.Sprintf("Group: %q", id.GroupId), + fmt.Sprintf("Provider Name: %q", id.ProviderName), + } + return fmt.Sprintf("Providers 2 (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/id_subscriptionprovider.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/id_subscriptionprovider.go new file mode 100644 index 000000000000..96f65defddbb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/id_subscriptionprovider.go @@ -0,0 +1,112 @@ +package providers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = SubscriptionProviderId{} + +// SubscriptionProviderId is a struct representing the Resource ID for a Subscription Provider +type SubscriptionProviderId struct { + SubscriptionId string + ProviderName string +} + +// NewSubscriptionProviderID returns a new SubscriptionProviderId struct +func NewSubscriptionProviderID(subscriptionId string, providerName string) SubscriptionProviderId { + return SubscriptionProviderId{ + SubscriptionId: subscriptionId, + ProviderName: providerName, + } +} + +// ParseSubscriptionProviderID parses 'input' into a SubscriptionProviderId +func ParseSubscriptionProviderID(input string) (*SubscriptionProviderId, error) { + parser := resourceids.NewParserFromResourceIdType(SubscriptionProviderId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := SubscriptionProviderId{} + + 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.ProviderName, ok = parsed.Parsed["providerName"]; !ok { + return nil, fmt.Errorf("the segment 'providerName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseSubscriptionProviderIDInsensitively parses 'input' case-insensitively into a SubscriptionProviderId +// note: this method should only be used for API response data and not user input +func ParseSubscriptionProviderIDInsensitively(input string) (*SubscriptionProviderId, error) { + parser := resourceids.NewParserFromResourceIdType(SubscriptionProviderId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := SubscriptionProviderId{} + + 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.ProviderName, ok = parsed.Parsed["providerName"]; !ok { + return nil, fmt.Errorf("the segment 'providerName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateSubscriptionProviderID checks that 'input' can be parsed as a Subscription Provider ID +func ValidateSubscriptionProviderID(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 := ParseSubscriptionProviderID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Subscription Provider ID +func (id SubscriptionProviderId) ID() string { + fmtString := "/subscriptions/%s/providers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ProviderName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Subscription Provider ID +func (id SubscriptionProviderId) 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.UserSpecifiedSegment("providerName", "providerValue"), + } +} + +// String returns a human-readable description of this Subscription Provider ID +func (id SubscriptionProviderId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Provider Name: %q", id.ProviderName), + } + return fmt.Sprintf("Subscription Provider (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_get_autorest.go new file mode 100644 index 000000000000..9214f86007f3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_get_autorest.go @@ -0,0 +1,97 @@ +package providers + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *Provider +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o GetOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Expand != nil { + out["$expand"] = *o.Expand + } + + return out +} + +// Get ... +func (c ProvidersClient) Get(ctx context.Context, id SubscriptionProviderId, options GetOperationOptions) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c ProvidersClient) preparerForGet(ctx context.Context, id SubscriptionProviderId, options GetOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + 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 ProvidersClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_getattenantscope_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_getattenantscope_autorest.go new file mode 100644 index 000000000000..d27d5f96ad6d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_getattenantscope_autorest.go @@ -0,0 +1,97 @@ +package providers + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAtTenantScopeOperationResponse struct { + HttpResponse *http.Response + Model *Provider +} + +type GetAtTenantScopeOperationOptions struct { + Expand *string +} + +func DefaultGetAtTenantScopeOperationOptions() GetAtTenantScopeOperationOptions { + return GetAtTenantScopeOperationOptions{} +} + +func (o GetAtTenantScopeOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o GetAtTenantScopeOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Expand != nil { + out["$expand"] = *o.Expand + } + + return out +} + +// GetAtTenantScope ... +func (c ProvidersClient) GetAtTenantScope(ctx context.Context, id ProviderId, options GetAtTenantScopeOperationOptions) (result GetAtTenantScopeOperationResponse, err error) { + req, err := c.preparerForGetAtTenantScope(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "GetAtTenantScope", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "GetAtTenantScope", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGetAtTenantScope(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "GetAtTenantScope", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGetAtTenantScope prepares the GetAtTenantScope request. +func (c ProvidersClient) preparerForGetAtTenantScope(ctx context.Context, id ProviderId, options GetAtTenantScopeOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGetAtTenantScope handles the response to the GetAtTenantScope request. The method always +// closes the http.Response Body. +func (c ProvidersClient) responderForGetAtTenantScope(resp *http.Response) (result GetAtTenantScopeOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_list_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_list_autorest.go new file mode 100644 index 000000000000..78c285df6818 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_list_autorest.go @@ -0,0 +1,216 @@ +package providers + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + Model *[]Provider + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []Provider +} + +func (r ListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListOperationOptions struct { + Expand *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Expand != nil { + out["$expand"] = *o.Expand + } + + return out +} + +// List ... +func (c ProvidersClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c ProvidersClient) preparerForList(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/providers", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c ProvidersClient) 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 ProvidersClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []Provider `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 ListOperationResponse, err error) { + req, err := c.preparerForListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c ProvidersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ProviderOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c ProvidersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate ProviderOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]Provider, 0) + + page, err := c.List(ctx, id, options) + 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 +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_listattenantscope_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_listattenantscope_autorest.go new file mode 100644 index 000000000000..ef2b49ac79f5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_listattenantscope_autorest.go @@ -0,0 +1,215 @@ +package providers + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAtTenantScopeOperationResponse struct { + HttpResponse *http.Response + Model *[]Provider + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListAtTenantScopeOperationResponse, error) +} + +type ListAtTenantScopeCompleteResult struct { + Items []Provider +} + +func (r ListAtTenantScopeOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListAtTenantScopeOperationResponse) LoadMore(ctx context.Context) (resp ListAtTenantScopeOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListAtTenantScopeOperationOptions struct { + Expand *string +} + +func DefaultListAtTenantScopeOperationOptions() ListAtTenantScopeOperationOptions { + return ListAtTenantScopeOperationOptions{} +} + +func (o ListAtTenantScopeOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListAtTenantScopeOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Expand != nil { + out["$expand"] = *o.Expand + } + + return out +} + +// ListAtTenantScope ... +func (c ProvidersClient) ListAtTenantScope(ctx context.Context, options ListAtTenantScopeOperationOptions) (resp ListAtTenantScopeOperationResponse, err error) { + req, err := c.preparerForListAtTenantScope(ctx, options) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "ListAtTenantScope", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "ListAtTenantScope", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListAtTenantScope(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "ListAtTenantScope", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForListAtTenantScope prepares the ListAtTenantScope request. +func (c ProvidersClient) preparerForListAtTenantScope(ctx context.Context, options ListAtTenantScopeOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath("/providers"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListAtTenantScopeWithNextLink prepares the ListAtTenantScope request with the given nextLink token. +func (c ProvidersClient) preparerForListAtTenantScopeWithNextLink(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)) +} + +// responderForListAtTenantScope handles the response to the ListAtTenantScope request. The method always +// closes the http.Response Body. +func (c ProvidersClient) responderForListAtTenantScope(resp *http.Response) (result ListAtTenantScopeOperationResponse, err error) { + type page struct { + Values []Provider `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 ListAtTenantScopeOperationResponse, err error) { + req, err := c.preparerForListAtTenantScopeWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "ListAtTenantScope", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "ListAtTenantScope", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListAtTenantScope(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "ListAtTenantScope", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListAtTenantScopeComplete retrieves all of the results into a single object +func (c ProvidersClient) ListAtTenantScopeComplete(ctx context.Context, options ListAtTenantScopeOperationOptions) (ListAtTenantScopeCompleteResult, error) { + return c.ListAtTenantScopeCompleteMatchingPredicate(ctx, options, ProviderOperationPredicate{}) +} + +// ListAtTenantScopeCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c ProvidersClient) ListAtTenantScopeCompleteMatchingPredicate(ctx context.Context, options ListAtTenantScopeOperationOptions, predicate ProviderOperationPredicate) (resp ListAtTenantScopeCompleteResult, err error) { + items := make([]Provider, 0) + + page, err := c.ListAtTenantScope(ctx, options) + 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 := ListAtTenantScopeCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_providerpermissions_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_providerpermissions_autorest.go new file mode 100644 index 000000000000..9acc5cb9ae2c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_providerpermissions_autorest.go @@ -0,0 +1,69 @@ +package providers + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProviderPermissionsOperationResponse struct { + HttpResponse *http.Response + Model *ProviderPermissionListResult +} + +// ProviderPermissions ... +func (c ProvidersClient) ProviderPermissions(ctx context.Context, id SubscriptionProviderId) (result ProviderPermissionsOperationResponse, err error) { + req, err := c.preparerForProviderPermissions(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "ProviderPermissions", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "ProviderPermissions", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForProviderPermissions(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "ProviderPermissions", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForProviderPermissions prepares the ProviderPermissions request. +func (c ProvidersClient) preparerForProviderPermissions(ctx context.Context, id SubscriptionProviderId) (*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/providerPermissions", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForProviderPermissions handles the response to the ProviderPermissions request. The method always +// closes the http.Response Body. +func (c ProvidersClient) responderForProviderPermissions(resp *http.Response) (result ProviderPermissionsOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_providerresourcetypeslist_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_providerresourcetypeslist_autorest.go new file mode 100644 index 000000000000..6e0a6dada124 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_providerresourcetypeslist_autorest.go @@ -0,0 +1,98 @@ +package providers + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProviderResourceTypesListOperationResponse struct { + HttpResponse *http.Response + Model *ProviderResourceTypeListResult +} + +type ProviderResourceTypesListOperationOptions struct { + Expand *string +} + +func DefaultProviderResourceTypesListOperationOptions() ProviderResourceTypesListOperationOptions { + return ProviderResourceTypesListOperationOptions{} +} + +func (o ProviderResourceTypesListOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ProviderResourceTypesListOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Expand != nil { + out["$expand"] = *o.Expand + } + + return out +} + +// ProviderResourceTypesList ... +func (c ProvidersClient) ProviderResourceTypesList(ctx context.Context, id SubscriptionProviderId, options ProviderResourceTypesListOperationOptions) (result ProviderResourceTypesListOperationResponse, err error) { + req, err := c.preparerForProviderResourceTypesList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "ProviderResourceTypesList", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "ProviderResourceTypesList", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForProviderResourceTypesList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "ProviderResourceTypesList", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForProviderResourceTypesList prepares the ProviderResourceTypesList request. +func (c ProvidersClient) preparerForProviderResourceTypesList(ctx context.Context, id SubscriptionProviderId, options ProviderResourceTypesListOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/resourceTypes", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForProviderResourceTypesList handles the response to the ProviderResourceTypesList request. The method always +// closes the http.Response Body. +func (c ProvidersClient) responderForProviderResourceTypesList(resp *http.Response) (result ProviderResourceTypesListOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_register_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_register_autorest.go new file mode 100644 index 000000000000..44a16c578c22 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_register_autorest.go @@ -0,0 +1,70 @@ +package providers + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegisterOperationResponse struct { + HttpResponse *http.Response + Model *Provider +} + +// Register ... +func (c ProvidersClient) Register(ctx context.Context, id SubscriptionProviderId, input ProviderRegistrationRequest) (result RegisterOperationResponse, err error) { + req, err := c.preparerForRegister(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "Register", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "Register", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForRegister(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "Register", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForRegister prepares the Register request. +func (c ProvidersClient) preparerForRegister(ctx context.Context, id SubscriptionProviderId, input ProviderRegistrationRequest) (*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/register", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForRegister handles the response to the Register request. The method always +// closes the http.Response Body. +func (c ProvidersClient) responderForRegister(resp *http.Response) (result RegisterOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_registeratmanagementgroupscope_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_registeratmanagementgroupscope_autorest.go new file mode 100644 index 000000000000..a0d85a9cf6a5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_registeratmanagementgroupscope_autorest.go @@ -0,0 +1,67 @@ +package providers + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegisterAtManagementGroupScopeOperationResponse struct { + HttpResponse *http.Response +} + +// RegisterAtManagementGroupScope ... +func (c ProvidersClient) RegisterAtManagementGroupScope(ctx context.Context, id Providers2Id) (result RegisterAtManagementGroupScopeOperationResponse, err error) { + req, err := c.preparerForRegisterAtManagementGroupScope(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "RegisterAtManagementGroupScope", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "RegisterAtManagementGroupScope", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForRegisterAtManagementGroupScope(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "RegisterAtManagementGroupScope", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForRegisterAtManagementGroupScope prepares the RegisterAtManagementGroupScope request. +func (c ProvidersClient) preparerForRegisterAtManagementGroupScope(ctx context.Context, id Providers2Id) (*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/register", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForRegisterAtManagementGroupScope handles the response to the RegisterAtManagementGroupScope request. The method always +// closes the http.Response Body. +func (c ProvidersClient) responderForRegisterAtManagementGroupScope(resp *http.Response) (result RegisterAtManagementGroupScopeOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_unregister_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_unregister_autorest.go new file mode 100644 index 000000000000..6560f4b3c0be --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/method_unregister_autorest.go @@ -0,0 +1,69 @@ +package providers + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnregisterOperationResponse struct { + HttpResponse *http.Response + Model *Provider +} + +// Unregister ... +func (c ProvidersClient) Unregister(ctx context.Context, id SubscriptionProviderId) (result UnregisterOperationResponse, err error) { + req, err := c.preparerForUnregister(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "Unregister", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "Unregister", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForUnregister(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "providers.ProvidersClient", "Unregister", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForUnregister prepares the Unregister request. +func (c ProvidersClient) preparerForUnregister(ctx context.Context, id SubscriptionProviderId) (*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/unregister", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForUnregister handles the response to the Unregister request. The method always +// closes the http.Response Body. +func (c ProvidersClient) responderForUnregister(resp *http.Response) (result UnregisterOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_alias.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_alias.go new file mode 100644 index 000000000000..c5310c681b4d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_alias.go @@ -0,0 +1,13 @@ +package providers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Alias struct { + DefaultMetadata *AliasPathMetadata `json:"defaultMetadata,omitempty"` + DefaultPath *string `json:"defaultPath,omitempty"` + DefaultPattern *AliasPattern `json:"defaultPattern,omitempty"` + Name *string `json:"name,omitempty"` + Paths *[]AliasPath `json:"paths,omitempty"` + Type *AliasType `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_aliaspath.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_aliaspath.go new file mode 100644 index 000000000000..56135bfcb6d8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_aliaspath.go @@ -0,0 +1,11 @@ +package providers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AliasPath struct { + ApiVersions *[]string `json:"apiVersions,omitempty"` + Metadata *AliasPathMetadata `json:"metadata,omitempty"` + Path *string `json:"path,omitempty"` + Pattern *AliasPattern `json:"pattern,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_aliaspathmetadata.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_aliaspathmetadata.go new file mode 100644 index 000000000000..2c61145cb3b8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_aliaspathmetadata.go @@ -0,0 +1,9 @@ +package providers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AliasPathMetadata struct { + Attributes *AliasPathAttributes `json:"attributes,omitempty"` + Type *AliasPathTokenType `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_aliaspattern.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_aliaspattern.go new file mode 100644 index 000000000000..cd67c3d713ac --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_aliaspattern.go @@ -0,0 +1,10 @@ +package providers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AliasPattern struct { + Phrase *string `json:"phrase,omitempty"` + Type *AliasPatternType `json:"type,omitempty"` + Variable *string `json:"variable,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_apiprofile.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_apiprofile.go new file mode 100644 index 000000000000..cd402753bfc7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_apiprofile.go @@ -0,0 +1,9 @@ +package providers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiProfile struct { + ApiVersion *string `json:"apiVersion,omitempty"` + ProfileVersion *string `json:"profileVersion,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_permission.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_permission.go new file mode 100644 index 000000000000..1ef9d80d6b61 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_permission.go @@ -0,0 +1,11 @@ +package providers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Permission struct { + Actions *[]string `json:"actions,omitempty"` + DataActions *[]string `json:"dataActions,omitempty"` + NotActions *[]string `json:"notActions,omitempty"` + NotDataActions *[]string `json:"notDataActions,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_provider.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_provider.go new file mode 100644 index 000000000000..2f14f379d955 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_provider.go @@ -0,0 +1,13 @@ +package providers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Provider struct { + Id *string `json:"id,omitempty"` + Namespace *string `json:"namespace,omitempty"` + ProviderAuthorizationConsentState *ProviderAuthorizationConsentState `json:"providerAuthorizationConsentState,omitempty"` + RegistrationPolicy *string `json:"registrationPolicy,omitempty"` + RegistrationState *string `json:"registrationState,omitempty"` + ResourceTypes *[]ProviderResourceType `json:"resourceTypes,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerconsentdefinition.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerconsentdefinition.go new file mode 100644 index 000000000000..9d720d4eded5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerconsentdefinition.go @@ -0,0 +1,8 @@ +package providers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProviderConsentDefinition struct { + ConsentToAuthorization *bool `json:"consentToAuthorization,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerextendedlocation.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerextendedlocation.go new file mode 100644 index 000000000000..4b8d25ac0236 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerextendedlocation.go @@ -0,0 +1,10 @@ +package providers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProviderExtendedLocation struct { + ExtendedLocations *[]string `json:"extendedLocations,omitempty"` + Location *string `json:"location,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerpermission.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerpermission.go new file mode 100644 index 000000000000..2c50f300e505 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerpermission.go @@ -0,0 +1,11 @@ +package providers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProviderPermission struct { + ApplicationId *string `json:"applicationId,omitempty"` + ManagedByRoleDefinition *RoleDefinition `json:"managedByRoleDefinition,omitempty"` + ProviderAuthorizationConsentState *ProviderAuthorizationConsentState `json:"providerAuthorizationConsentState,omitempty"` + RoleDefinition *RoleDefinition `json:"roleDefinition,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerpermissionlistresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerpermissionlistresult.go new file mode 100644 index 000000000000..d34e7c0665c5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerpermissionlistresult.go @@ -0,0 +1,9 @@ +package providers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProviderPermissionListResult struct { + NextLink *string `json:"nextLink,omitempty"` + Value *[]ProviderPermission `json:"value,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerregistrationrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerregistrationrequest.go new file mode 100644 index 000000000000..43935de225ee --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerregistrationrequest.go @@ -0,0 +1,8 @@ +package providers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProviderRegistrationRequest struct { + ThirdPartyProviderConsent *ProviderConsentDefinition `json:"thirdPartyProviderConsent,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerresourcetype.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerresourcetype.go new file mode 100644 index 000000000000..fa3f581d7cb3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerresourcetype.go @@ -0,0 +1,17 @@ +package providers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProviderResourceType struct { + Aliases *[]Alias `json:"aliases,omitempty"` + ApiProfiles *[]ApiProfile `json:"apiProfiles,omitempty"` + ApiVersions *[]string `json:"apiVersions,omitempty"` + Capabilities *string `json:"capabilities,omitempty"` + DefaultApiVersion *string `json:"defaultApiVersion,omitempty"` + LocationMappings *[]ProviderExtendedLocation `json:"locationMappings,omitempty"` + Locations *[]string `json:"locations,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + ZoneMappings *[]ZoneMapping `json:"zoneMappings,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerresourcetypelistresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerresourcetypelistresult.go new file mode 100644 index 000000000000..5981405f98c3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_providerresourcetypelistresult.go @@ -0,0 +1,9 @@ +package providers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProviderResourceTypeListResult struct { + NextLink *string `json:"nextLink,omitempty"` + Value *[]ProviderResourceType `json:"value,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_roledefinition.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_roledefinition.go new file mode 100644 index 000000000000..a4a432ddaf8b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_roledefinition.go @@ -0,0 +1,12 @@ +package providers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoleDefinition struct { + Id *string `json:"id,omitempty"` + IsServiceRole *bool `json:"isServiceRole,omitempty"` + Name *string `json:"name,omitempty"` + Permissions *[]Permission `json:"permissions,omitempty"` + Scopes *[]string `json:"scopes,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_zonemapping.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_zonemapping.go new file mode 100644 index 000000000000..d491263d1fd5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/model_zonemapping.go @@ -0,0 +1,13 @@ +package providers + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ZoneMapping struct { + Location *string `json:"location,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/predicates.go new file mode 100644 index 000000000000..fff4f09e0d3d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/predicates.go @@ -0,0 +1,32 @@ +package providers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProviderOperationPredicate struct { + Id *string + Namespace *string + RegistrationPolicy *string + RegistrationState *string +} + +func (p ProviderOperationPredicate) Matches(input Provider) bool { + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Namespace != nil && (input.Namespace == nil && *p.Namespace != *input.Namespace) { + return false + } + + if p.RegistrationPolicy != nil && (input.RegistrationPolicy == nil && *p.RegistrationPolicy != *input.RegistrationPolicy) { + return false + } + + if p.RegistrationState != nil && (input.RegistrationState == nil && *p.RegistrationState != *input.RegistrationState) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/version.go new file mode 100644 index 000000000000..4162fd2dcb64 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers/version.go @@ -0,0 +1,12 @@ +package providers + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2022-09-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/providers/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index b2cae71d3bb5..cce4c227cb86 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -139,7 +139,6 @@ github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata github.com/hashicorp/go-azure-helpers/resourcemanager/tags github.com/hashicorp/go-azure-helpers/resourcemanager/zones -github.com/hashicorp/go-azure-helpers/resourceproviders github.com/hashicorp/go-azure-helpers/sender github.com/hashicorp/go-azure-helpers/storage # github.com/hashicorp/go-azure-sdk v0.20230503.1140953 @@ -538,6 +537,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/relay/2017-04-01/namespaces github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-10-01/deploymentscripts github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-06-01/policyassignments +github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers github.com/hashicorp/go-azure-sdk/resource-manager/search/2022-09-01/adminkeys github.com/hashicorp/go-azure-sdk/resource-manager/search/2022-09-01/querykeys github.com/hashicorp/go-azure-sdk/resource-manager/search/2022-09-01/services From 021174f34e182b527680a4de083ae66e7883326f Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 5 May 2023 12:43:25 +0200 Subject: [PATCH 3/9] making the lock a pointer --- internal/resourceproviders/cache.go | 2 +- internal/resourceproviders/registration.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/resourceproviders/cache.go b/internal/resourceproviders/cache.go index 6f92e9bff927..bf41711196a7 100644 --- a/internal/resourceproviders/cache.go +++ b/internal/resourceproviders/cache.go @@ -15,7 +15,7 @@ var cachedResourceProviders *[]string var registeredResourceProviders *map[string]struct{} var unregisteredResourceProviders *map[string]struct{} -var cacheLock = sync.Mutex{} +var cacheLock = &sync.Mutex{} // CacheSupportedProviders attempts to retrieve the supported Resource Providers from the Resource Manager API // and caches them, for used in enhanced validation diff --git a/internal/resourceproviders/registration.go b/internal/resourceproviders/registration.go index 528d6f1af580..875045bf9273 100644 --- a/internal/resourceproviders/registration.go +++ b/internal/resourceproviders/registration.go @@ -3,11 +3,12 @@ package resourceproviders import ( "context" "fmt" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" - "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers" "log" "strings" "sync" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers" ) func EnsureRegistered(ctx context.Context, client *providers.ProvidersClient, subscriptionId commonids.SubscriptionId, requiredRPs map[string]struct{}) error { From ec2db569ff79a3925f14067923c18a0eba06096e Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 5 May 2023 15:21:29 +0200 Subject: [PATCH 4/9] resource: refactoring to use `hashicorp/go-azure-sdk` --- internal/services/resource/client/client.go | 8 - .../resource_provider_register_poller.go | 47 ++++ .../resource_provider_unregister_poller.go | 47 ++++ ...urce_group_template_deployment_resource.go | 2 +- ...resource_provider_registration_resource.go | 256 ++++++++---------- ...rce_provider_registration_resource_test.go | 72 +++-- .../resource/template_deployment_common.go | 36 +-- 7 files changed, 259 insertions(+), 209 deletions(-) create mode 100644 internal/services/resource/custompollers/resource_provider_register_poller.go create mode 100644 internal/services/resource/custompollers/resource_provider_unregister_poller.go diff --git a/internal/services/resource/client/client.go b/internal/services/resource/client/client.go index 7dd321c36aa2..395b64c1b511 100644 --- a/internal/services/resource/client/client.go +++ b/internal/services/resource/client/client.go @@ -1,7 +1,6 @@ package client import ( - resourcesProfile "github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources" "github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2019-06-01-preview/templatespecs" // nolint: staticcheck "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2015-12-01/features" // nolint: staticcheck "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-06-01/resources" // nolint: staticcheck @@ -22,9 +21,6 @@ type Client struct { TagsClient *resources.TagsClient TemplateSpecsVersionsClient *templatespecs.VersionsClient - // TODO: update usages of this to use `hashicorp/go-azure-sdk` (available as ResourceProvidersClient) - ProvidersClient *resourcesProfile.ProvidersClient - options *common.ClientOptions } @@ -44,9 +40,6 @@ func NewClient(o *common.ClientOptions) *Client { locksClient := managementlocks.NewManagementLocksClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&locksClient.Client, o.ResourceManagerAuthorizer) - providersClient := resourcesProfile.NewProvidersClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&providersClient.Client, o.ResourceManagerAuthorizer) - resourceProvidersClient := providers.NewProvidersClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&resourceProvidersClient.Client, o.ResourceManagerAuthorizer) @@ -65,7 +58,6 @@ func NewClient(o *common.ClientOptions) *Client { DeploymentScriptsClient: &deploymentScriptsClient, FeaturesClient: &featuresClient, LocksClient: &locksClient, - ProvidersClient: &providersClient, ResourceProvidersClient: &resourceProvidersClient, ResourcesClient: &resourcesClient, TagsClient: &tagsClient, diff --git a/internal/services/resource/custompollers/resource_provider_register_poller.go b/internal/services/resource/custompollers/resource_provider_register_poller.go new file mode 100644 index 000000000000..69125ef04e68 --- /dev/null +++ b/internal/services/resource/custompollers/resource_provider_register_poller.go @@ -0,0 +1,47 @@ +package custompollers + +import ( + "context" + "fmt" + "strings" + + "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" +) + +var _ pollers.PollerType = &resourceProviderRegistrationPoller{} + +func NewResourceProviderRegistrationPoller(client *providers.ProvidersClient, id providers.SubscriptionProviderId) *resourceProviderRegistrationPoller { + return &resourceProviderRegistrationPoller{ + client: client, + id: id, + } +} + +type resourceProviderRegistrationPoller struct { + client *providers.ProvidersClient + id providers.SubscriptionProviderId +} + +func (p *resourceProviderRegistrationPoller) Poll(ctx context.Context) (*pollers.PollResult, error) { + resp, err := p.client.Get(ctx, p.id, providers.DefaultGetOperationOptions()) + if err != nil { + return nil, fmt.Errorf("retrieving %s: %+v", err) + } + + registrationState := "" + if model := resp.Model; model != nil && model.RegistrationState != nil { + registrationState = *model.RegistrationState + } + + if strings.EqualFold(registrationState, "Registered") { + return &pollers.PollResult{ + Status: pollers.PollingStatusSucceeded, + }, nil + } + + // Processing + return &pollers.PollResult{ + Status: pollers.PollingStatusInProgress, + }, nil +} diff --git a/internal/services/resource/custompollers/resource_provider_unregister_poller.go b/internal/services/resource/custompollers/resource_provider_unregister_poller.go new file mode 100644 index 000000000000..8588bbfad02b --- /dev/null +++ b/internal/services/resource/custompollers/resource_provider_unregister_poller.go @@ -0,0 +1,47 @@ +package custompollers + +import ( + "context" + "fmt" + "strings" + + "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" +) + +var _ pollers.PollerType = &resourceProviderUnregistrationPoller{} + +func NewResourceProviderUnregistrationPoller(client *providers.ProvidersClient, id providers.SubscriptionProviderId) *resourceProviderUnregistrationPoller { + return &resourceProviderUnregistrationPoller{ + client: client, + id: id, + } +} + +type resourceProviderUnregistrationPoller struct { + client *providers.ProvidersClient + id providers.SubscriptionProviderId +} + +func (p *resourceProviderUnregistrationPoller) Poll(ctx context.Context) (*pollers.PollResult, error) { + resp, err := p.client.Get(ctx, p.id, providers.DefaultGetOperationOptions()) + if err != nil { + return nil, fmt.Errorf("retrieving %s: %+v", err) + } + + registrationState := "" + if model := resp.Model; model != nil && model.RegistrationState != nil { + registrationState = *model.RegistrationState + } + + if strings.EqualFold(registrationState, "Unregistered") { + return &pollers.PollResult{ + Status: pollers.PollingStatusSucceeded, + }, nil + } + + // Processing + return &pollers.PollResult{ + Status: pollers.PollingStatusInProgress, + }, nil +} diff --git a/internal/services/resource/resource_group_template_deployment_resource.go b/internal/services/resource/resource_group_template_deployment_resource.go index 8b9584eed38e..aa31d7206430 100644 --- a/internal/services/resource/resource_group_template_deployment_resource.go +++ b/internal/services/resource/resource_group_template_deployment_resource.go @@ -356,7 +356,7 @@ func resourceGroupTemplateDeploymentResourceDelete(d *pluginsdk.ResourceData, me if deleteItemsInTemplate { resourceClient := meta.(*clients.Client).Resource log.Printf("[DEBUG] Removing items provisioned by the Template Deployment %q (Resource Group %q)..", id.DeploymentName, id.ResourceGroup) - if err := deleteItemsProvisionedByTemplate(ctx, resourceClient, *template.Properties); err != nil { + if err := deleteItemsProvisionedByTemplate(ctx, resourceClient, *template.Properties, id.SubscriptionId); err != nil { return fmt.Errorf("removing items provisioned by this Template Deployment: %+v", err) } log.Printf("[DEBUG] Removed items provisioned by the Template Deployment %q (Resource Group %q)..", id.DeploymentName, id.ResourceGroup) diff --git a/internal/services/resource/resource_provider_registration_resource.go b/internal/services/resource/resource_provider_registration_resource.go index bcc056982fc6..7d9410223e55 100644 --- a/internal/services/resource/resource_provider_registration_resource.go +++ b/internal/services/resource/resource_provider_registration_resource.go @@ -7,16 +7,18 @@ import ( "strings" "time" - "github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources" "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2015-12-01/features" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/resourceproviders" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/resource/custompollers" "github.com/hashicorp/terraform-provider-azurerm/internal/services/resource/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/resource/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) var ( @@ -90,7 +92,7 @@ func (r ResourceProviderRegistrationResource) ResourceType() string { func (r ResourceProviderRegistrationResource) Create() sdk.ResourceFunc { return sdk.ResourceFunc{ Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { - client := metadata.Client.Resource.ProvidersClient + client := metadata.Client.Resource.ResourceProvidersClient account := metadata.Client.Account var obj ResourceProviderRegistrationModel @@ -98,24 +100,27 @@ func (r ResourceProviderRegistrationResource) Create() sdk.ResourceFunc { return err } - resourceId := parse.NewResourceProviderID(account.SubscriptionId, obj.Name) - if err := r.checkIfManagedByTerraform(resourceId.ResourceProvider, account); err != nil { + resourceId := providers.NewSubscriptionProviderID(account.SubscriptionId, obj.Name) + if err := r.checkIfManagedByTerraform(resourceId.ProviderName, account); err != nil { return err } - provider, err := client.Get(ctx, resourceId.ResourceProvider, "") + provider, err := client.Get(ctx, resourceId, providers.DefaultGetOperationOptions()) if err != nil { - if utils.ResponseWasNotFound(provider.Response) { - return fmt.Errorf("the Resource Provider %q was not found", resourceId.ResourceProvider) + if response.WasNotFound(provider.HttpResponse) { + return fmt.Errorf("%s was not found", resourceId) } - return fmt.Errorf("retrieving Resource Provider %q: %+v", resourceId.ResourceProvider, err) + return fmt.Errorf("retrieving %q: %+v", resourceId, err) } - if provider.RegistrationState == nil { - return fmt.Errorf("retrieving Resource Provider %q: `registrationState` was nil", resourceId.ResourceProvider) + registrationState := "" + if model := provider.Model; model != nil && model.RegistrationState != nil { + registrationState = *model.RegistrationState } - - if strings.EqualFold(*provider.RegistrationState, "Registered") { + if registrationState == "" { + return fmt.Errorf("retrieving %s: `registrationState` was nil", resourceId) + } + if strings.EqualFold(registrationState, "Registered") { return metadata.ResourceRequiresImport(r.ResourceType(), resourceId) } @@ -123,33 +128,23 @@ func (r ResourceProviderRegistrationResource) Create() sdk.ResourceFunc { oldFeaturesRaw, newFeaturesRaw := metadata.ResourceData.GetChange("feature") err := r.applyFeatures(ctx, metadata, resourceId, oldFeaturesRaw.(*pluginsdk.Set).List(), newFeaturesRaw.(*pluginsdk.Set).List()) if err != nil { - return fmt.Errorf("applying features for Resource Provider %q: %+v", resourceId.ResourceProvider, err) + return fmt.Errorf("applying features for %q: %+v", resourceId, err) } } - log.Printf("[DEBUG] Registering Resource Provider %q..", resourceId.ResourceProvider) - if _, err := client.Register(ctx, resourceId.ResourceProvider); err != nil { - return fmt.Errorf("registering Resource Provider %q: %+v", resourceId.ResourceProvider, err) + log.Printf("[DEBUG] Registering %s..", resourceId) + payload := providers.ProviderRegistrationRequest{} + if _, err := client.Register(ctx, resourceId, payload); err != nil { + return fmt.Errorf("registering %s: %+v", resourceId, err) } - deadline, ok := ctx.Deadline() - if !ok { - return fmt.Errorf("could not retrieve context deadline for %s", resourceId.ID()) - } - // TODO: @tombuildsstuff - expose a nicer means of doing this in the SDK - log.Printf("[DEBUG] Waiting for Resource Provider %q to finish registering..", resourceId.ResourceProvider) - stateConf := &pluginsdk.StateChangeConf{ - Pending: []string{"Processing"}, - Target: []string{"Registered"}, - Refresh: r.registerRefreshFunc(ctx, client, resourceId.ResourceProvider), - MinTimeout: 15 * time.Second, - PollInterval: 30 * time.Second, - Timeout: time.Until(deadline), + log.Printf("[DEBUG] Waiting for %s to finish registering..", resourceId) + pollerType := custompollers.NewResourceProviderRegistrationPoller(client, resourceId) + poller := pollers.NewPoller(pollerType, 10*time.Second, pollers.DefaultNumberOfDroppedConnectionsToAllow) + if err := poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("waiting for %s to be registered: %s", resourceId, err) } - if _, err := stateConf.WaitForStateContext(ctx); err != nil { - return fmt.Errorf("waiting for Resource Provider Namespace %q to be registered: %s", resourceId.ResourceProvider, err) - } - log.Printf("[DEBUG] Registered Resource Provider %q.", resourceId.ResourceProvider) + log.Printf("[DEBUG] Registered Resource Provider %q.", resourceId) metadata.SetID(resourceId) return nil @@ -162,7 +157,7 @@ func (r ResourceProviderRegistrationResource) Create() sdk.ResourceFunc { func (r ResourceProviderRegistrationResource) Update() sdk.ResourceFunc { return sdk.ResourceFunc{ Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { - client := metadata.Client.Resource.ProvidersClient + client := metadata.Client.Resource.ResourceProvidersClient account := metadata.Client.Account var obj ResourceProviderRegistrationModel @@ -170,58 +165,55 @@ func (r ResourceProviderRegistrationResource) Update() sdk.ResourceFunc { return err } - resourceId := parse.NewResourceProviderID(account.SubscriptionId, obj.Name) - if err := r.checkIfManagedByTerraform(resourceId.ResourceProvider, account); err != nil { + resourceId, err := providers.ParseSubscriptionProviderID(metadata.ResourceData.Id()) + if err != nil { + return err + } + if err := r.checkIfManagedByTerraform(resourceId.ProviderName, account); err != nil { return err } - provider, err := client.Get(ctx, resourceId.ResourceProvider, "") + provider, err := client.Get(ctx, *resourceId, providers.DefaultGetOperationOptions()) if err != nil { - if utils.ResponseWasNotFound(provider.Response) { - return fmt.Errorf("the Resource Provider %q was not found", resourceId.ResourceProvider) + if response.WasNotFound(provider.HttpResponse) { + return fmt.Errorf("the %s was not found", *resourceId) } - return fmt.Errorf("retrieving Resource Provider %q: %+v", resourceId.ResourceProvider, err) + return fmt.Errorf("retrieving %s: %+v", *resourceId, err) + } + registrationState := "" + if model := provider.Model; model != nil && model.RegistrationState != nil { + } - if provider.RegistrationState == nil { - return fmt.Errorf("retrieving Resource Provider %q: `registrationState` was nil", resourceId.ResourceProvider) + if registrationState == "" { + return fmt.Errorf("retrieving %s: `registrationState` was nil", *resourceId) } - if !strings.EqualFold(*provider.RegistrationState, "Registered") { - return fmt.Errorf("retrieving Resource Provider %q: `registrationState` was not `Registered`", resourceId.ResourceProvider) + if !strings.EqualFold(registrationState, "Registered") { + return fmt.Errorf("retrieving %s: `registrationState` was not `Registered` but %q", *resourceId, registrationState) } if metadata.ResourceData.HasChange("feature") { oldFeaturesRaw, newFeaturesRaw := metadata.ResourceData.GetChange("feature") - err := r.applyFeatures(ctx, metadata, resourceId, oldFeaturesRaw.(*pluginsdk.Set).List(), newFeaturesRaw.(*pluginsdk.Set).List()) + err := r.applyFeatures(ctx, metadata, *resourceId, oldFeaturesRaw.(*pluginsdk.Set).List(), newFeaturesRaw.(*pluginsdk.Set).List()) if err != nil { - return fmt.Errorf("applying features for Resource Provider %q: %+v", resourceId.ResourceProvider, err) + return fmt.Errorf("applying features for %s: %+v", *resourceId, err) } } - log.Printf("[DEBUG] Registering Resource Provider %q..", resourceId.ResourceProvider) - if _, err := client.Register(ctx, resourceId.ResourceProvider); err != nil { - return fmt.Errorf("registering Resource Provider %q: %+v", resourceId.ResourceProvider, err) + log.Printf("[DEBUG] Registering %s..", *resourceId) + payload := providers.ProviderRegistrationRequest{} + if _, err := client.Register(ctx, *resourceId, payload); err != nil { + return fmt.Errorf("registering %s: %+v", *resourceId, err) } - deadline, ok := ctx.Deadline() - if !ok { - return fmt.Errorf("could not retrieve context deadline for %s", resourceId.ID()) - } - // TODO: @tombuildsstuff - expose a nicer means of doing this in the SDK - log.Printf("[DEBUG] Waiting for Resource Provider %q to finish registering..", resourceId.ResourceProvider) - stateConf := &pluginsdk.StateChangeConf{ - Pending: []string{"Processing"}, - Target: []string{"Registered"}, - Refresh: r.registerRefreshFunc(ctx, client, resourceId.ResourceProvider), - MinTimeout: 15 * time.Second, - PollInterval: 30 * time.Second, - Timeout: time.Until(deadline), - } - if _, err := stateConf.WaitForStateContext(ctx); err != nil { - return fmt.Errorf("waiting for Resource Provider Namespace %q to be registered: %s", resourceId.ResourceProvider, err) + log.Printf("[DEBUG] Waiting for %s to finish registering..", resourceId) + pollerType := custompollers.NewResourceProviderRegistrationPoller(client, *resourceId) + poller := pollers.NewPoller(pollerType, 10*time.Second, pollers.DefaultNumberOfDroppedConnectionsToAllow) + if err := poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("waiting for %s to be registered: %s", resourceId, err) } - log.Printf("[DEBUG] Registered Resource Provider %q.", resourceId.ResourceProvider) + log.Printf("[DEBUG] Registered Resource Provider %q.", resourceId) metadata.SetID(resourceId) return nil @@ -233,42 +225,46 @@ func (r ResourceProviderRegistrationResource) Update() sdk.ResourceFunc { func (r ResourceProviderRegistrationResource) Read() sdk.ResourceFunc { return sdk.ResourceFunc{ Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { - client := metadata.Client.Resource.ProvidersClient + client := metadata.Client.Resource.ResourceProvidersClient featureClient := metadata.Client.Resource.FeaturesClient account := metadata.Client.Account - id, err := parse.ResourceProviderID(metadata.ResourceData.Id()) + id, err := providers.ParseSubscriptionProviderID(metadata.ResourceData.Id()) if err != nil { return err } - if err := r.checkIfManagedByTerraform(id.ResourceProvider, account); err != nil { + if err := r.checkIfManagedByTerraform(id.ProviderName, account); err != nil { return err } - resp, err := client.Get(ctx, id.ResourceProvider, "") + resp, err := client.Get(ctx, *id, providers.DefaultGetOperationOptions()) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { return metadata.MarkAsGone(id) } - return fmt.Errorf("retrieving Resource Provider %q: %+v", id.ResourceProvider, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } - if resp.RegistrationState != nil && !strings.EqualFold(*resp.RegistrationState, "Registered") { - log.Printf("[WARN] Resource Provider %q was not registered", id.ResourceProvider) + registrationState := "" + if model := resp.Model; model != nil && model.RegistrationState != nil { + registrationState = *model.RegistrationState + } + if !strings.EqualFold(registrationState, "Registered") { + log.Printf("[WARN] %s was not registered - removing from state", id) return metadata.MarkAsGone(id) } - result, err := featureClient.ListComplete(ctx, id.ResourceProvider) + result, err := featureClient.ListComplete(ctx, id.ProviderName) if err != nil { - return fmt.Errorf("retrieving features for Resource Provider %q: %+v", id.ResourceProvider, err) + return fmt.Errorf("retrieving features for %s: %+v", *id, err) } features := make([]ResourceProviderRegistrationFeatureModel, 0) for result.NotDone() { value := result.Value() if value.Properties != nil && value.Properties.State != nil && value.Name != nil { - featureName := (*value.Name)[len(id.ResourceProvider)+1:] + featureName := (*value.Name)[len(id.ProviderName)+1:] switch *value.Properties.State { case Registering, Registered: features = append(features, ResourceProviderRegistrationFeatureModel{Name: featureName, Registered: true}) @@ -282,7 +278,7 @@ func (r ResourceProviderRegistrationResource) Read() sdk.ResourceFunc { } return metadata.Encode(&ResourceProviderRegistrationModel{ - Name: id.ResourceProvider, + Name: id.ProviderName, Features: features, }) }, @@ -293,42 +289,34 @@ func (r ResourceProviderRegistrationResource) Read() sdk.ResourceFunc { func (r ResourceProviderRegistrationResource) Delete() sdk.ResourceFunc { return sdk.ResourceFunc{ Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { - client := metadata.Client.Resource.ProvidersClient + client := metadata.Client.Resource.ResourceProvidersClient account := metadata.Client.Account - id, err := parse.ResourceProviderID(metadata.ResourceData.Id()) + id, err := providers.ParseSubscriptionProviderID(metadata.ResourceData.Id()) if err != nil { return err } - if err := r.checkIfManagedByTerraform(id.ResourceProvider, account); err != nil { + if err := r.checkIfManagedByTerraform(id.ProviderName, account); err != nil { return err } err = r.applyFeatures(ctx, metadata, *id, metadata.ResourceData.Get("feature").(*pluginsdk.Set).List(), make([]interface{}, 0)) if err != nil { - return fmt.Errorf("applying features for Resource Provider %q: %+v", id.ResourceProvider, err) + return fmt.Errorf("applying features for %s: %+v", *id, err) } - if _, err := client.Unregister(ctx, id.ResourceProvider); err != nil { - return fmt.Errorf("unregistering Resource Provider %q: %+v", id.ResourceProvider, err) + if _, err := client.Unregister(ctx, *id); err != nil { + return fmt.Errorf("unregistering Resource Provider %q: %+v", *id, err) } - deadline, ok := ctx.Deadline() - if !ok { - return fmt.Errorf("could not retrieve context deadline for %s", id.ID()) - } - // TODO: @tombuildsstuff - we should likely expose something in the SDK to make this easier - stateConf := &pluginsdk.StateChangeConf{ - Pending: []string{"Processing"}, - Target: []string{"Unregistered"}, - Refresh: r.unregisterRefreshFunc(ctx, client, id.ResourceProvider), - MinTimeout: 15 * time.Second, - Timeout: time.Until(deadline), - } - if _, err := stateConf.WaitForStateContext(ctx); err != nil { - return fmt.Errorf("waiting for Resource Provider %q to become unregistered: %+v", id.ResourceProvider, err) + log.Printf("[DEBUG] Waiting for %s to finish unregistering..", *id) + pollerType := custompollers.NewResourceProviderUnregistrationPoller(client, *id) + poller := pollers.NewPoller(pollerType, 10*time.Second, pollers.DefaultNumberOfDroppedConnectionsToAllow) + if err := poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("waiting for %s to become unregistered: %+v", *id, err) } + log.Printf("[DEBUG] Unregistered Resource Provider %q.", *id) return nil }, @@ -342,33 +330,39 @@ func (r ResourceProviderRegistrationResource) IDValidationFunc() pluginsdk.Schem func (r ResourceProviderRegistrationResource) CustomImporter() sdk.ResourceRunFunc { return func(ctx context.Context, metadata sdk.ResourceMetaData) error { - client := metadata.Client.Resource.ProvidersClient + client := metadata.Client.Resource.ResourceProvidersClient account := metadata.Client.Account - id, err := parse.ResourceProviderID(metadata.ResourceData.Id()) + id, err := providers.ParseSubscriptionProviderID(metadata.ResourceData.Id()) if err != nil { return err } - provider, err := client.Get(ctx, id.ResourceProvider, "") + provider, err := client.Get(ctx, *id, providers.DefaultGetOperationOptions()) if err != nil { - return fmt.Errorf("retrieving Resource Provider %q: %+v", id.ResourceProvider, err) + return fmt.Errorf("retrieving %s: %+v", *id, err) } - if provider.Namespace == nil { - return fmt.Errorf("retrieving Resource Provider %q: `namespace` was nil", id.ResourceProvider) + namespace := "" + registrationState := "" + if model := provider.Model; model != nil { + if model.Namespace != nil { + namespace = *model.Namespace + } + if model.RegistrationState != nil { + registrationState = *model.RegistrationState + } } - - if *provider.Namespace != id.ResourceProvider { - return fmt.Errorf("importing Resource Provider %q: expected %q", id.ResourceProvider, *provider.Namespace) + if namespace != id.ProviderName { + return fmt.Errorf("importing %s: expected %q but got %q", *id, id.ProviderName, namespace) } - if provider.RegistrationState == nil || !strings.EqualFold(*provider.RegistrationState, "Registered") { - return fmt.Errorf("importing Resource Provider %q: Resource Provider must be registered to be imported", id.ResourceProvider) + if !strings.EqualFold(registrationState, "Registered") { + return fmt.Errorf("importing %s: Resource Provider must be registered to be imported", id.ProviderName) } - if err := r.checkIfManagedByTerraform(id.ResourceProvider, account); err != nil { - return fmt.Errorf("importing Resource Provider %q: %+v", id.ResourceProvider, err) + if err := r.checkIfManagedByTerraform(id.ProviderName, account); err != nil { + return fmt.Errorf("importing %s: %+v", *id, err) } return nil @@ -394,46 +388,16 @@ to 'true' in the Provider block) to avoid conflicting with Terraform.` return nil } -func (r ResourceProviderRegistrationResource) registerRefreshFunc(ctx context.Context, client *resources.ProvidersClient, resourceProviderNamespace string) pluginsdk.StateRefreshFunc { - return func() (interface{}, string, error) { - resp, err := client.Get(ctx, resourceProviderNamespace, "") - if err != nil { - return resp, "Failed", err - } - - if resp.RegistrationState != nil && strings.EqualFold(*resp.RegistrationState, "Registered") { - return resp, "Registered", nil - } - - return resp, "Processing", nil - } -} - -func (r ResourceProviderRegistrationResource) unregisterRefreshFunc(ctx context.Context, client *resources.ProvidersClient, resourceProvider string) pluginsdk.StateRefreshFunc { - return func() (interface{}, string, error) { - resp, err := client.Get(ctx, resourceProvider, "") - if err != nil { - return resp, "Failed", err - } - - if resp.RegistrationState != nil && strings.EqualFold(*resp.RegistrationState, "Unregistered") { - return resp, "Unregistered", nil - } - - return resp, "Processing", nil - } -} - -func (r ResourceProviderRegistrationResource) applyFeatures(ctx context.Context, metadata sdk.ResourceMetaData, id parse.ResourceProviderId, oldFeatures []interface{}, newFeatures []interface{}) error { +func (r ResourceProviderRegistrationResource) applyFeatures(ctx context.Context, metadata sdk.ResourceMetaData, id providers.SubscriptionProviderId, oldFeatures []interface{}, newFeatures []interface{}) error { for _, v := range newFeatures { value := v.(map[string]interface{}) name := value["name"].(string) if value["registered"].(bool) { - if err := r.registerFeature(ctx, metadata, parse.NewFeatureID(id.SubscriptionId, id.ResourceProvider, name)); err != nil { + if err := r.registerFeature(ctx, metadata, parse.NewFeatureID(id.SubscriptionId, id.ProviderName, name)); err != nil { return err } } else { - if err := r.unregisterFeature(ctx, metadata, parse.NewFeatureID(id.SubscriptionId, id.ResourceProvider, name)); err != nil { + if err := r.unregisterFeature(ctx, metadata, parse.NewFeatureID(id.SubscriptionId, id.ProviderName, name)); err != nil { return err } } @@ -454,7 +418,7 @@ func (r ResourceProviderRegistrationResource) applyFeatures(ctx context.Context, for featureName, registered := range unmanagedRegisteredFeatures { if registered { - if err := r.unregisterFeature(ctx, metadata, parse.NewFeatureID(id.SubscriptionId, id.ResourceProvider, featureName)); err != nil { + if err := r.unregisterFeature(ctx, metadata, parse.NewFeatureID(id.SubscriptionId, id.ProviderName, featureName)); err != nil { return err } } diff --git a/internal/services/resource/resource_provider_registration_resource_test.go b/internal/services/resource/resource_provider_registration_resource_test.go index fee6b6f6cbaa..3764e391548a 100644 --- a/internal/services/resource/resource_provider_registration_resource_test.go +++ b/internal/services/resource/resource_provider_registration_resource_test.go @@ -7,10 +7,15 @@ import ( "testing" "time" + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/testclient" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/resource/custompollers" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -91,17 +96,25 @@ func TestAccResourceProviderRegistration_feature(t *testing.T) { } func (ResourceProviderRegistrationResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - name := state.Attributes["name"] - resp, err := client.Resource.ProvidersClient.Get(ctx, name, "") + id, err := providers.ParseSubscriptionProviderID(state.ID) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + return nil, err + } + + resp, err := client.Resource.ResourceProvidersClient.Get(ctx, *id, providers.DefaultGetOperationOptions()) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { return utils.Bool(false), nil } - return nil, fmt.Errorf("Bad: Get on ProvidersClient: %+v", err) + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } - return utils.Bool(resp.RegistrationState != nil && strings.EqualFold(*resp.RegistrationState, "Registered")), nil + isRegistered := false + if model := resp.Model; model != nil && model.RegistrationState != nil { + isRegistered = strings.EqualFold(*model.RegistrationState, "Registered") + } + return pointer.To(isRegistered), nil } func (ResourceProviderRegistrationResource) basic(name string) string { @@ -150,50 +163,33 @@ func (r ResourceProviderRegistrationResource) unRegisterProvider(client *clients ctx, cancel := context.WithDeadline(client.StopContext, time.Now().Add(30*time.Minute)) defer cancel() - providersClient := client.Resource.ProvidersClient - provider, err := providersClient.Get(ctx, resourceProvider, "") + providersClient := client.Resource.ResourceProvidersClient + id := providers.NewSubscriptionProviderID(client.Account.SubscriptionId, resourceProvider) + provider, err := providersClient.Get(ctx, id, providers.DefaultGetOperationOptions()) if err != nil { - return fmt.Errorf("retrieving Resource Provider %q: %+v", resourceProvider, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } - if provider.RegistrationState == nil { + registrationState := "" + if model := provider.Model; model != nil && model.RegistrationState != nil { + registrationState = *model.RegistrationState + } + if registrationState == "" { return fmt.Errorf("retrieving Resource Provider %q: `registrationState` was nil", resourceProvider) } - if !strings.EqualFold(*provider.RegistrationState, "Registered") { + if !strings.EqualFold(registrationState, "Registered") { return nil } - if _, err := providersClient.Unregister(ctx, resourceProvider); err != nil { - return fmt.Errorf("unregistering Resource Provider %q: %+v", resourceProvider, err) - } - - deadline, ok := ctx.Deadline() - if !ok { - return fmt.Errorf("could not retrieve context deadline") - } - - stateConf := &pluginsdk.StateChangeConf{ - Pending: []string{"Processing"}, - Target: []string{"Unregistered"}, - Refresh: func() (interface{}, string, error) { - resp, err := providersClient.Get(ctx, resourceProvider, "") - if err != nil { - return resp, "Failed", err - } - - if resp.RegistrationState != nil && strings.EqualFold(*resp.RegistrationState, "Unregistered") { - return resp, "Unregistered", nil - } - - return resp, "Processing", nil - }, - MinTimeout: 15 * time.Second, - Timeout: time.Until(deadline), + if _, err := providersClient.Unregister(ctx, id); err != nil { + return fmt.Errorf("unregistering %s: %+v", id, err) } - if _, err := stateConf.WaitForStateContext(ctx); err != nil { - return fmt.Errorf("waiting for Resource Provider %q to become unregistered: %+v", resourceProvider, err) + pollerType := custompollers.NewResourceProviderUnregistrationPoller(providersClient, id) + poller := pollers.NewPoller(pollerType, 10*time.Minute, pollers.DefaultNumberOfDroppedConnectionsToAllow) + if err := poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("waiting for %s to become unregistered: %+v", id, err) } return nil diff --git a/internal/services/resource/template_deployment_common.go b/internal/services/resource/template_deployment_common.go index 2f4619e0ef2c..1cd5d5b77a0e 100644 --- a/internal/services/resource/template_deployment_common.go +++ b/internal/services/resource/template_deployment_common.go @@ -10,8 +10,8 @@ import ( "strings" "time" - providers "github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources" "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-06-01/resources" // nolint: staticcheck + "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/internal/services/resource/client" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" @@ -191,7 +191,7 @@ func deleteNestedResource(ctx context.Context, resourcesClient *resources.Client return nil } -func deleteItemsProvisionedByTemplate(ctx context.Context, client *client.Client, properties resources.DeploymentPropertiesExtended) error { +func deleteItemsProvisionedByTemplate(ctx context.Context, client *client.Client, properties resources.DeploymentPropertiesExtended, subscriptionId string) error { if properties.Providers == nil { return fmt.Errorf("`properties.Providers` was nil - insufficient data to clean up this Template Deployment") } @@ -199,11 +199,11 @@ func deleteItemsProvisionedByTemplate(ctx context.Context, client *client.Client return fmt.Errorf("`properties.OutputResources` was nil - insufficient data to clean up this Template Deployment") } - providersClient := client.ProvidersClient + providersClient := client.ResourceProvidersClient resourcesClient := client.ResourcesClient log.Printf("[DEBUG] Determining the API Versions used for Resources provisioned in this Template..") - resourceProviderApiVersions, err := determineResourceProviderAPIVersionsForResources(ctx, providersClient, *properties.Providers) + resourceProviderApiVersions, err := determineResourceProviderAPIVersionsForResources(ctx, providersClient, *properties.Providers, subscriptionId) if err != nil { return fmt.Errorf("determining API Versions for Resource Providers: %+v", err) } @@ -250,34 +250,38 @@ func deleteItemsProvisionedByTemplate(ctx context.Context, client *client.Client }) } -func determineResourceProviderAPIVersionsForResources(ctx context.Context, client *providers.ProvidersClient, providers []resources.Provider) (*map[string]string, error) { +func determineResourceProviderAPIVersionsForResources(ctx context.Context, client *providers.ProvidersClient, resourceProviders []resources.Provider, subscriptionId string) (*map[string]string, error) { resourceProviderApiVersions := make(map[string]string) - for _, provider := range providers { + for _, provider := range resourceProviders { if provider.Namespace == nil { continue } - resourceProviderName := *provider.Namespace - providerResp, err := client.Get(ctx, resourceProviderName, "") + providerId := providers.NewSubscriptionProviderID(subscriptionId, *provider.Namespace) + providerResp, err := client.Get(ctx, providerId, providers.DefaultGetOperationOptions()) if err != nil { - return nil, fmt.Errorf("retrieving Resource Provider MetaData for %q: %+v", resourceProviderName, err) + return nil, fmt.Errorf("retrieving MetaData for %s: %+v", providerId, err) } - if providerResp.ResourceTypes == nil { - return nil, fmt.Errorf("`resourceTypes` was nil for Resource Provider %q", resourceProviderName) + resourceTypes := make([]providers.ProviderResourceType, 0) + if model := providerResp.Model; model != nil && model.ResourceTypes != nil { + resourceTypes = *model.ResourceTypes + } + if len(resourceTypes) == 0 { + return nil, fmt.Errorf("`resourceTypes` was nil/empty for %s", providerId) } for _, resourceType := range *provider.ResourceTypes { resourceTypeName := *resourceType.ResourceType - availableResourceTypes := *providerResp.ResourceTypes + availableResourceTypes := resourceTypes apiVersion := findApiVersionForResourceType(resourceTypeName, availableResourceTypes) if apiVersion == nil { - return nil, fmt.Errorf("unable to determine API version for Resource Type %q (Resource Provider %q)", resourceTypeName, resourceProviderName) + return nil, fmt.Errorf("unable to determine API version for Resource Type %q (%s)", resourceTypeName, providerId) } // NOTE: there's an enhancement in that not all RP's necessarily offer everything in every version // but the majority do, so this is likely sufficient for now - resourceProviderApiVersions[strings.ToLower(resourceProviderName)] = *apiVersion + resourceProviderApiVersions[strings.ToLower(providerId.ProviderName)] = *apiVersion break } } @@ -287,14 +291,14 @@ func determineResourceProviderAPIVersionsForResources(ctx context.Context, clien func findApiVersionForResourceType(resourceType string, availableResourceTypes []providers.ProviderResourceType) *string { for _, item := range availableResourceTypes { - if item.ResourceType == nil || item.APIVersions == nil { + if item.ResourceType == nil || item.ApiVersions == nil { continue } isExactMatch := strings.EqualFold(resourceType, *item.ResourceType) isPrefixMatch := strings.HasPrefix(strings.ToLower(resourceType), strings.ToLower(*item.ResourceType)) if isExactMatch || isPrefixMatch { - apiVersions := *item.APIVersions + apiVersions := *item.ApiVersions apiVersion := apiVersions[0] return &apiVersion } From bba61967a9b21865ac5f7473dffa6400c9f59689 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 5 May 2023 15:21:40 +0200 Subject: [PATCH 5/9] go mod tidy / go mod vendor --- .../resources/mgmt/resources/models.go | 198 -- .../mgmt/2016-02-01/resources/CHANGELOG.md | 2 - .../mgmt/2016-02-01/resources/_meta.json | 11 - .../mgmt/2016-02-01/resources/client.go | 43 - .../resources/deploymentoperations.go | 249 --- .../mgmt/2016-02-01/resources/deployments.go | 846 -------- .../mgmt/2016-02-01/resources/enums.go | 35 - .../mgmt/2016-02-01/resources/groups.go | 799 ------- .../mgmt/2016-02-01/resources/models.go | 1841 ----------------- .../mgmt/2016-02-01/resources/providers.go | 381 ---- .../mgmt/2016-02-01/resources/resources.go | 700 ------- .../mgmt/2016-02-01/resources/tags.go | 442 ---- .../mgmt/2016-02-01/resources/version.go | 19 - vendor/modules.txt | 2 - 14 files changed, 5568 deletions(-) delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources/models.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/CHANGELOG.md delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/_meta.json delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/client.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/deploymentoperations.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/deployments.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/enums.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/groups.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/models.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/providers.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/resources.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/tags.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/version.go diff --git a/vendor/github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources/models.go b/vendor/github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources/models.go deleted file mode 100644 index f2309f9dde50..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources/models.go +++ /dev/null @@ -1,198 +0,0 @@ -//go:build go1.9 -// +build go1.9 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -// This code was auto-generated by: -// github.com/Azure/azure-sdk-for-go/eng/tools/profileBuilder - -package resources - -import ( - "context" - - original "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources" -) - -const ( - DefaultBaseURI = original.DefaultBaseURI -) - -type DeploymentMode = original.DeploymentMode - -const ( - Complete DeploymentMode = original.Complete - Incremental DeploymentMode = original.Incremental -) - -type ResourceIdentityType = original.ResourceIdentityType - -const ( - SystemAssigned ResourceIdentityType = original.SystemAssigned -) - -type AliasPathType = original.AliasPathType -type AliasType = original.AliasType -type BaseClient = original.BaseClient -type BasicDependency = original.BasicDependency -type Client = original.Client -type CloudError = original.CloudError -type DebugSetting = original.DebugSetting -type Dependency = original.Dependency -type Deployment = original.Deployment -type DeploymentExportResult = original.DeploymentExportResult -type DeploymentExtended = original.DeploymentExtended -type DeploymentExtendedFilter = original.DeploymentExtendedFilter -type DeploymentListResult = original.DeploymentListResult -type DeploymentListResultIterator = original.DeploymentListResultIterator -type DeploymentListResultPage = original.DeploymentListResultPage -type DeploymentOperation = original.DeploymentOperation -type DeploymentOperationProperties = original.DeploymentOperationProperties -type DeploymentOperationsClient = original.DeploymentOperationsClient -type DeploymentOperationsListResult = original.DeploymentOperationsListResult -type DeploymentOperationsListResultIterator = original.DeploymentOperationsListResultIterator -type DeploymentOperationsListResultPage = original.DeploymentOperationsListResultPage -type DeploymentProperties = original.DeploymentProperties -type DeploymentPropertiesExtended = original.DeploymentPropertiesExtended -type DeploymentValidateResult = original.DeploymentValidateResult -type DeploymentsClient = original.DeploymentsClient -type DeploymentsCreateOrUpdateFuture = original.DeploymentsCreateOrUpdateFuture -type DeploymentsDeleteFuture = original.DeploymentsDeleteFuture -type ErrorAdditionalInfo = original.ErrorAdditionalInfo -type ErrorResponse = original.ErrorResponse -type ExportTemplateRequest = original.ExportTemplateRequest -type GenericResource = original.GenericResource -type GenericResourceExpanded = original.GenericResourceExpanded -type GenericResourceFilter = original.GenericResourceFilter -type Group = original.Group -type GroupExportResult = original.GroupExportResult -type GroupFilter = original.GroupFilter -type GroupListResult = original.GroupListResult -type GroupListResultIterator = original.GroupListResultIterator -type GroupListResultPage = original.GroupListResultPage -type GroupProperties = original.GroupProperties -type GroupsClient = original.GroupsClient -type GroupsDeleteFuture = original.GroupsDeleteFuture -type HTTPMessage = original.HTTPMessage -type Identity = original.Identity -type ListResult = original.ListResult -type ListResultIterator = original.ListResultIterator -type ListResultPage = original.ListResultPage -type ManagementErrorWithDetails = original.ManagementErrorWithDetails -type MoveInfo = original.MoveInfo -type MoveResourcesFuture = original.MoveResourcesFuture -type ParametersLink = original.ParametersLink -type Plan = original.Plan -type Provider = original.Provider -type ProviderListResult = original.ProviderListResult -type ProviderListResultIterator = original.ProviderListResultIterator -type ProviderListResultPage = original.ProviderListResultPage -type ProviderOperationDisplayProperties = original.ProviderOperationDisplayProperties -type ProviderResourceType = original.ProviderResourceType -type ProvidersClient = original.ProvidersClient -type Resource = original.Resource -type Sku = original.Sku -type SubResource = original.SubResource -type TagCount = original.TagCount -type TagDetails = original.TagDetails -type TagValue = original.TagValue -type TagsClient = original.TagsClient -type TagsListResult = original.TagsListResult -type TagsListResultIterator = original.TagsListResultIterator -type TagsListResultPage = original.TagsListResultPage -type TargetResource = original.TargetResource -type TemplateHashResult = original.TemplateHashResult -type TemplateLink = original.TemplateLink -type UpdateFuture = original.UpdateFuture - -func New(subscriptionID string) BaseClient { - return original.New(subscriptionID) -} -func NewClient(subscriptionID string) Client { - return original.NewClient(subscriptionID) -} -func NewClientWithBaseURI(baseURI string, subscriptionID string) Client { - return original.NewClientWithBaseURI(baseURI, subscriptionID) -} -func NewDeploymentListResultIterator(page DeploymentListResultPage) DeploymentListResultIterator { - return original.NewDeploymentListResultIterator(page) -} -func NewDeploymentListResultPage(cur DeploymentListResult, getNextPage func(context.Context, DeploymentListResult) (DeploymentListResult, error)) DeploymentListResultPage { - return original.NewDeploymentListResultPage(cur, getNextPage) -} -func NewDeploymentOperationsClient(subscriptionID string) DeploymentOperationsClient { - return original.NewDeploymentOperationsClient(subscriptionID) -} -func NewDeploymentOperationsClientWithBaseURI(baseURI string, subscriptionID string) DeploymentOperationsClient { - return original.NewDeploymentOperationsClientWithBaseURI(baseURI, subscriptionID) -} -func NewDeploymentOperationsListResultIterator(page DeploymentOperationsListResultPage) DeploymentOperationsListResultIterator { - return original.NewDeploymentOperationsListResultIterator(page) -} -func NewDeploymentOperationsListResultPage(cur DeploymentOperationsListResult, getNextPage func(context.Context, DeploymentOperationsListResult) (DeploymentOperationsListResult, error)) DeploymentOperationsListResultPage { - return original.NewDeploymentOperationsListResultPage(cur, getNextPage) -} -func NewDeploymentsClient(subscriptionID string) DeploymentsClient { - return original.NewDeploymentsClient(subscriptionID) -} -func NewDeploymentsClientWithBaseURI(baseURI string, subscriptionID string) DeploymentsClient { - return original.NewDeploymentsClientWithBaseURI(baseURI, subscriptionID) -} -func NewGroupListResultIterator(page GroupListResultPage) GroupListResultIterator { - return original.NewGroupListResultIterator(page) -} -func NewGroupListResultPage(cur GroupListResult, getNextPage func(context.Context, GroupListResult) (GroupListResult, error)) GroupListResultPage { - return original.NewGroupListResultPage(cur, getNextPage) -} -func NewGroupsClient(subscriptionID string) GroupsClient { - return original.NewGroupsClient(subscriptionID) -} -func NewGroupsClientWithBaseURI(baseURI string, subscriptionID string) GroupsClient { - return original.NewGroupsClientWithBaseURI(baseURI, subscriptionID) -} -func NewListResultIterator(page ListResultPage) ListResultIterator { - return original.NewListResultIterator(page) -} -func NewListResultPage(cur ListResult, getNextPage func(context.Context, ListResult) (ListResult, error)) ListResultPage { - return original.NewListResultPage(cur, getNextPage) -} -func NewProviderListResultIterator(page ProviderListResultPage) ProviderListResultIterator { - return original.NewProviderListResultIterator(page) -} -func NewProviderListResultPage(cur ProviderListResult, getNextPage func(context.Context, ProviderListResult) (ProviderListResult, error)) ProviderListResultPage { - return original.NewProviderListResultPage(cur, getNextPage) -} -func NewProvidersClient(subscriptionID string) ProvidersClient { - return original.NewProvidersClient(subscriptionID) -} -func NewProvidersClientWithBaseURI(baseURI string, subscriptionID string) ProvidersClient { - return original.NewProvidersClientWithBaseURI(baseURI, subscriptionID) -} -func NewTagsClient(subscriptionID string) TagsClient { - return original.NewTagsClient(subscriptionID) -} -func NewTagsClientWithBaseURI(baseURI string, subscriptionID string) TagsClient { - return original.NewTagsClientWithBaseURI(baseURI, subscriptionID) -} -func NewTagsListResultIterator(page TagsListResultPage) TagsListResultIterator { - return original.NewTagsListResultIterator(page) -} -func NewTagsListResultPage(cur TagsListResult, getNextPage func(context.Context, TagsListResult) (TagsListResult, error)) TagsListResultPage { - return original.NewTagsListResultPage(cur, getNextPage) -} -func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { - return original.NewWithBaseURI(baseURI, subscriptionID) -} -func PossibleDeploymentModeValues() []DeploymentMode { - return original.PossibleDeploymentModeValues() -} -func PossibleResourceIdentityTypeValues() []ResourceIdentityType { - return original.PossibleResourceIdentityTypeValues() -} -func UserAgent() string { - return original.UserAgent() + " profiles/2017-03-09" -} -func Version() string { - return original.Version() -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/CHANGELOG.md deleted file mode 100644 index 52911e4cc5e4..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/CHANGELOG.md +++ /dev/null @@ -1,2 +0,0 @@ -# Change History - diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/_meta.json b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/_meta.json deleted file mode 100644 index 118e460b7c96..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/_meta.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", - "readme": "/_/azure-rest-api-specs/specification/resources/resource-manager/readme.md", - "tag": "package-resources-2016-02", - "use": "@microsoft.azure/autorest.go@2.1.187", - "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-resources-2016-02 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/resources/resource-manager/readme.md", - "additional_properties": { - "additional_options": "--go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION" - } -} \ No newline at end of file diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/client.go deleted file mode 100644 index 0a8520a0cce1..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/client.go +++ /dev/null @@ -1,43 +0,0 @@ -// Deprecated: Please note, this package has been deprecated. A replacement package is available [github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources). We strongly encourage you to upgrade to continue receiving updates. See [Migration Guide](https://aka.ms/azsdk/golang/t2/migration) for guidance on upgrading. Refer to our [deprecation policy](https://azure.github.io/azure-sdk/policies_support.html) for more details. -// -// Package resources implements the Azure ARM Resources service API version 2016-02-01. -// -// -package resources - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "github.com/Azure/go-autorest/autorest" -) - -const ( - // DefaultBaseURI is the default URI used for the service Resources - DefaultBaseURI = "https://management.azure.com" -) - -// BaseClient is the base client for Resources. -type BaseClient struct { - autorest.Client - BaseURI string - SubscriptionID string -} - -// New creates an instance of the BaseClient client. -func New(subscriptionID string) BaseClient { - return NewWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with -// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { - return BaseClient{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: baseURI, - SubscriptionID: subscriptionID, - } -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/deploymentoperations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/deploymentoperations.go deleted file mode 100644 index 1025ab1ea0fc..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/deploymentoperations.go +++ /dev/null @@ -1,249 +0,0 @@ -package resources - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// DeploymentOperationsClient is the client for the DeploymentOperations methods of the Resources service. -type DeploymentOperationsClient struct { - BaseClient -} - -// NewDeploymentOperationsClient creates an instance of the DeploymentOperationsClient client. -func NewDeploymentOperationsClient(subscriptionID string) DeploymentOperationsClient { - return NewDeploymentOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewDeploymentOperationsClientWithBaseURI creates an instance of the DeploymentOperationsClient client using a custom -// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure -// stack). -func NewDeploymentOperationsClientWithBaseURI(baseURI string, subscriptionID string) DeploymentOperationsClient { - return DeploymentOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// Get get a list of deployments operations. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// deploymentName - the name of the deployment. -// operationID - operation Id. -func (client DeploymentOperationsClient) Get(ctx context.Context, resourceGroupName string, deploymentName string, operationID string) (result DeploymentOperation, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DeploymentOperationsClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.DeploymentOperationsClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, deploymentName, operationID) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentOperationsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.DeploymentOperationsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentOperationsClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client DeploymentOperationsClient) GetPreparer(ctx context.Context, resourceGroupName string, deploymentName string, operationID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "deploymentName": autorest.Encode("path", deploymentName), - "operationId": autorest.Encode("path", operationID), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client DeploymentOperationsClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client DeploymentOperationsClient) GetResponder(resp *http.Response) (result DeploymentOperation, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List gets a list of deployments operations. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// deploymentName - the name of the deployment. -// top - query parameters. -func (client DeploymentOperationsClient) List(ctx context.Context, resourceGroupName string, deploymentName string, top *int32) (result DeploymentOperationsListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DeploymentOperationsClient.List") - defer func() { - sc := -1 - if result.dolr.Response.Response != nil { - sc = result.dolr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.DeploymentOperationsClient", "List", err.Error()) - } - - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, resourceGroupName, deploymentName, top) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentOperationsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.dolr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.DeploymentOperationsClient", "List", resp, "Failure sending request") - return - } - - result.dolr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentOperationsClient", "List", resp, "Failure responding to request") - return - } - if result.dolr.hasNextLink() && result.dolr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListPreparer prepares the List request. -func (client DeploymentOperationsClient) ListPreparer(ctx context.Context, resourceGroupName string, deploymentName string, top *int32) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "deploymentName": autorest.Encode("path", deploymentName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client DeploymentOperationsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client DeploymentOperationsClient) ListResponder(resp *http.Response) (result DeploymentOperationsListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client DeploymentOperationsClient) listNextResults(ctx context.Context, lastResults DeploymentOperationsListResult) (result DeploymentOperationsListResult, err error) { - req, err := lastResults.deploymentOperationsListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.DeploymentOperationsClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.DeploymentOperationsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentOperationsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client DeploymentOperationsClient) ListComplete(ctx context.Context, resourceGroupName string, deploymentName string, top *int32) (result DeploymentOperationsListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DeploymentOperationsClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx, resourceGroupName, deploymentName, top) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/deployments.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/deployments.go deleted file mode 100644 index 92a030e5403c..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/deployments.go +++ /dev/null @@ -1,846 +0,0 @@ -package resources - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// DeploymentsClient is the client for the Deployments methods of the Resources service. -type DeploymentsClient struct { - BaseClient -} - -// NewDeploymentsClient creates an instance of the DeploymentsClient client. -func NewDeploymentsClient(subscriptionID string) DeploymentsClient { - return NewDeploymentsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewDeploymentsClientWithBaseURI creates an instance of the DeploymentsClient client using a custom endpoint. Use -// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewDeploymentsClientWithBaseURI(baseURI string, subscriptionID string) DeploymentsClient { - return DeploymentsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CalculateTemplateHash calculate the hash of the given template. -// Parameters: -// templateParameter - the template provided to calculate hash. -func (client DeploymentsClient) CalculateTemplateHash(ctx context.Context, templateParameter interface{}) (result TemplateHashResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DeploymentsClient.CalculateTemplateHash") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.CalculateTemplateHashPreparer(ctx, templateParameter) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "CalculateTemplateHash", nil, "Failure preparing request") - return - } - - resp, err := client.CalculateTemplateHashSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "CalculateTemplateHash", resp, "Failure sending request") - return - } - - result, err = client.CalculateTemplateHashResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "CalculateTemplateHash", resp, "Failure responding to request") - return - } - - return -} - -// CalculateTemplateHashPreparer prepares the CalculateTemplateHash request. -func (client DeploymentsClient) CalculateTemplateHashPreparer(ctx context.Context, templateParameter interface{}) (*http.Request, error) { - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/providers/Microsoft.Resources/calculateTemplateHash"), - autorest.WithJSON(templateParameter), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CalculateTemplateHashSender sends the CalculateTemplateHash request. The method will close the -// http.Response Body if it receives an error. -func (client DeploymentsClient) CalculateTemplateHashSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// CalculateTemplateHashResponder handles the response to the CalculateTemplateHash request. The method always -// closes the http.Response Body. -func (client DeploymentsClient) CalculateTemplateHashResponder(resp *http.Response) (result TemplateHashResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Cancel cancel a currently running template deployment. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// deploymentName - the name of the deployment. -func (client DeploymentsClient) Cancel(ctx context.Context, resourceGroupName string, deploymentName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DeploymentsClient.Cancel") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.DeploymentsClient", "Cancel", err.Error()) - } - - req, err := client.CancelPreparer(ctx, resourceGroupName, deploymentName) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Cancel", nil, "Failure preparing request") - return - } - - resp, err := client.CancelSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Cancel", resp, "Failure sending request") - return - } - - result, err = client.CancelResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Cancel", resp, "Failure responding to request") - return - } - - return -} - -// CancelPreparer prepares the Cancel request. -func (client DeploymentsClient) CancelPreparer(ctx context.Context, resourceGroupName string, deploymentName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "deploymentName": autorest.Encode("path", deploymentName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CancelSender sends the Cancel request. The method will close the -// http.Response Body if it receives an error. -func (client DeploymentsClient) CancelSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CancelResponder handles the response to the Cancel request. The method always -// closes the http.Response Body. -func (client DeploymentsClient) CancelResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// CheckExistence checks whether deployment exists. -// Parameters: -// resourceGroupName - the name of the resource group to check. The name is case insensitive. -// deploymentName - the name of the deployment. -func (client DeploymentsClient) CheckExistence(ctx context.Context, resourceGroupName string, deploymentName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DeploymentsClient.CheckExistence") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.DeploymentsClient", "CheckExistence", err.Error()) - } - - req, err := client.CheckExistencePreparer(ctx, resourceGroupName, deploymentName) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "CheckExistence", nil, "Failure preparing request") - return - } - - resp, err := client.CheckExistenceSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "CheckExistence", resp, "Failure sending request") - return - } - - result, err = client.CheckExistenceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "CheckExistence", resp, "Failure responding to request") - return - } - - return -} - -// CheckExistencePreparer prepares the CheckExistence request. -func (client DeploymentsClient) CheckExistencePreparer(ctx context.Context, resourceGroupName string, deploymentName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "deploymentName": autorest.Encode("path", deploymentName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsHead(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CheckExistenceSender sends the CheckExistence request. The method will close the -// http.Response Body if it receives an error. -func (client DeploymentsClient) CheckExistenceSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CheckExistenceResponder handles the response to the CheckExistence request. The method always -// closes the http.Response Body. -func (client DeploymentsClient) CheckExistenceResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusNotFound), - autorest.ByClosing()) - result.Response = resp - return -} - -// CreateOrUpdate create a named template deployment using a template. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// deploymentName - the name of the deployment. -// parameters - additional parameters supplied to the operation. -func (client DeploymentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, parameters Deployment) (result DeploymentsCreateOrUpdateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DeploymentsClient.CreateOrUpdate") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}, - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.Properties", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.Properties.TemplateLink", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.Properties.TemplateLink.URI", Name: validation.Null, Rule: true, Chain: nil}}}, - {Target: "parameters.Properties.ParametersLink", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.Properties.ParametersLink.URI", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { - return result, validation.NewError("resources.DeploymentsClient", "CreateOrUpdate", err.Error()) - } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, deploymentName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = client.CreateOrUpdateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "CreateOrUpdate", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client DeploymentsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, deploymentName string, parameters Deployment) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "deploymentName": autorest.Encode("path", deploymentName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client DeploymentsClient) CreateOrUpdateSender(req *http.Request) (future DeploymentsCreateOrUpdateFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client DeploymentsClient) CreateOrUpdateResponder(resp *http.Response) (result DeploymentExtended, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete delete deployment. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// deploymentName - the name of the deployment to be deleted. -func (client DeploymentsClient) Delete(ctx context.Context, resourceGroupName string, deploymentName string) (result DeploymentsDeleteFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DeploymentsClient.Delete") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.DeploymentsClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, deploymentName) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Delete", result.Response(), "Failure sending request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client DeploymentsClient) DeletePreparer(ctx context.Context, resourceGroupName string, deploymentName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "deploymentName": autorest.Encode("path", deploymentName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client DeploymentsClient) DeleteSender(req *http.Request) (future DeploymentsDeleteFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client DeploymentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// ExportTemplate exports a deployment template. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// deploymentName - the name of the deployment. -func (client DeploymentsClient) ExportTemplate(ctx context.Context, resourceGroupName string, deploymentName string) (result DeploymentExportResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DeploymentsClient.ExportTemplate") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.DeploymentsClient", "ExportTemplate", err.Error()) - } - - req, err := client.ExportTemplatePreparer(ctx, resourceGroupName, deploymentName) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "ExportTemplate", nil, "Failure preparing request") - return - } - - resp, err := client.ExportTemplateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "ExportTemplate", resp, "Failure sending request") - return - } - - result, err = client.ExportTemplateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "ExportTemplate", resp, "Failure responding to request") - return - } - - return -} - -// ExportTemplatePreparer prepares the ExportTemplate request. -func (client DeploymentsClient) ExportTemplatePreparer(ctx context.Context, resourceGroupName string, deploymentName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "deploymentName": autorest.Encode("path", deploymentName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ExportTemplateSender sends the ExportTemplate request. The method will close the -// http.Response Body if it receives an error. -func (client DeploymentsClient) ExportTemplateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ExportTemplateResponder handles the response to the ExportTemplate request. The method always -// closes the http.Response Body. -func (client DeploymentsClient) ExportTemplateResponder(resp *http.Response) (result DeploymentExportResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Get get a deployment. -// Parameters: -// resourceGroupName - the name of the resource group to get. The name is case insensitive. -// deploymentName - the name of the deployment. -func (client DeploymentsClient) Get(ctx context.Context, resourceGroupName string, deploymentName string) (result DeploymentExtended, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DeploymentsClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.DeploymentsClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, deploymentName) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client DeploymentsClient) GetPreparer(ctx context.Context, resourceGroupName string, deploymentName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "deploymentName": autorest.Encode("path", deploymentName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client DeploymentsClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client DeploymentsClient) GetResponder(resp *http.Response) (result DeploymentExtended, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List get a list of deployments. -// Parameters: -// resourceGroupName - the name of the resource group to filter by. The name is case insensitive. -// filter - the filter to apply on the operation. -// top - query parameters. If null is passed returns all deployments. -func (client DeploymentsClient) List(ctx context.Context, resourceGroupName string, filter string, top *int32) (result DeploymentListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DeploymentsClient.List") - defer func() { - sc := -1 - if result.dlr.Response.Response != nil { - sc = result.dlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.DeploymentsClient", "List", err.Error()) - } - - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, resourceGroupName, filter, top) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.dlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "List", resp, "Failure sending request") - return - } - - result.dlr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "List", resp, "Failure responding to request") - return - } - if result.dlr.hasNextLink() && result.dlr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListPreparer prepares the List request. -func (client DeploymentsClient) ListPreparer(ctx context.Context, resourceGroupName string, filter string, top *int32) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client DeploymentsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client DeploymentsClient) ListResponder(resp *http.Response) (result DeploymentListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client DeploymentsClient) listNextResults(ctx context.Context, lastResults DeploymentListResult) (result DeploymentListResult, err error) { - req, err := lastResults.deploymentListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client DeploymentsClient) ListComplete(ctx context.Context, resourceGroupName string, filter string, top *int32) (result DeploymentListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DeploymentsClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx, resourceGroupName, filter, top) - return -} - -// Validate validate a deployment template. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// deploymentName - the name of the deployment. -// parameters - deployment to validate. -func (client DeploymentsClient) Validate(ctx context.Context, resourceGroupName string, deploymentName string, parameters Deployment) (result DeploymentValidateResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DeploymentsClient.Validate") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}, - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.Properties", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.Properties.TemplateLink", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.Properties.TemplateLink.URI", Name: validation.Null, Rule: true, Chain: nil}}}, - {Target: "parameters.Properties.ParametersLink", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.Properties.ParametersLink.URI", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { - return result, validation.NewError("resources.DeploymentsClient", "Validate", err.Error()) - } - - req, err := client.ValidatePreparer(ctx, resourceGroupName, deploymentName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Validate", nil, "Failure preparing request") - return - } - - resp, err := client.ValidateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Validate", resp, "Failure sending request") - return - } - - result, err = client.ValidateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Validate", resp, "Failure responding to request") - return - } - - return -} - -// ValidatePreparer prepares the Validate request. -func (client DeploymentsClient) ValidatePreparer(ctx context.Context, resourceGroupName string, deploymentName string, parameters Deployment) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "deploymentName": autorest.Encode("path", deploymentName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ValidateSender sends the Validate request. The method will close the -// http.Response Body if it receives an error. -func (client DeploymentsClient) ValidateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ValidateResponder handles the response to the Validate request. The method always -// closes the http.Response Body. -func (client DeploymentsClient) ValidateResponder(resp *http.Response) (result DeploymentValidateResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusBadRequest), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/enums.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/enums.go deleted file mode 100644 index 8ae735f07feb..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/enums.go +++ /dev/null @@ -1,35 +0,0 @@ -package resources - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -// DeploymentMode enumerates the values for deployment mode. -type DeploymentMode string - -const ( - // Complete ... - Complete DeploymentMode = "Complete" - // Incremental ... - Incremental DeploymentMode = "Incremental" -) - -// PossibleDeploymentModeValues returns an array of possible values for the DeploymentMode const type. -func PossibleDeploymentModeValues() []DeploymentMode { - return []DeploymentMode{Complete, Incremental} -} - -// ResourceIdentityType enumerates the values for resource identity type. -type ResourceIdentityType string - -const ( - // SystemAssigned ... - SystemAssigned ResourceIdentityType = "SystemAssigned" -) - -// PossibleResourceIdentityTypeValues returns an array of possible values for the ResourceIdentityType const type. -func PossibleResourceIdentityTypeValues() []ResourceIdentityType { - return []ResourceIdentityType{SystemAssigned} -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/groups.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/groups.go deleted file mode 100644 index 6e17cd452a86..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/groups.go +++ /dev/null @@ -1,799 +0,0 @@ -package resources - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// GroupsClient is the client for the Groups methods of the Resources service. -type GroupsClient struct { - BaseClient -} - -// NewGroupsClient creates an instance of the GroupsClient client. -func NewGroupsClient(subscriptionID string) GroupsClient { - return NewGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewGroupsClientWithBaseURI creates an instance of the GroupsClient client using a custom endpoint. Use this when -// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewGroupsClientWithBaseURI(baseURI string, subscriptionID string) GroupsClient { - return GroupsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CheckExistence checks whether resource group exists. -// Parameters: -// resourceGroupName - the name of the resource group to check. The name is case insensitive. -func (client GroupsClient) CheckExistence(ctx context.Context, resourceGroupName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GroupsClient.CheckExistence") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.GroupsClient", "CheckExistence", err.Error()) - } - - req, err := client.CheckExistencePreparer(ctx, resourceGroupName) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "CheckExistence", nil, "Failure preparing request") - return - } - - resp, err := client.CheckExistenceSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "CheckExistence", resp, "Failure sending request") - return - } - - result, err = client.CheckExistenceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "CheckExistence", resp, "Failure responding to request") - return - } - - return -} - -// CheckExistencePreparer prepares the CheckExistence request. -func (client GroupsClient) CheckExistencePreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsHead(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CheckExistenceSender sends the CheckExistence request. The method will close the -// http.Response Body if it receives an error. -func (client GroupsClient) CheckExistenceSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CheckExistenceResponder handles the response to the CheckExistence request. The method always -// closes the http.Response Body. -func (client GroupsClient) CheckExistenceResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusNotFound), - autorest.ByClosing()) - result.Response = resp - return -} - -// CreateOrUpdate create a resource group. -// Parameters: -// resourceGroupName - the name of the resource group to be created or updated. -// parameters - parameters supplied to the create or update resource group service operation. -func (client GroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, parameters Group) (result Group, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GroupsClient.CreateOrUpdate") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}, - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.GroupsClient", "CreateOrUpdate", err.Error()) - } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "CreateOrUpdate", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "CreateOrUpdate", resp, "Failure responding to request") - return - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client GroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, parameters Group) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - parameters.ID = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client GroupsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client GroupsClient) CreateOrUpdateResponder(resp *http.Response) (result Group, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete delete resource group. -// Parameters: -// resourceGroupName - the name of the resource group to be deleted. The name is case insensitive. -func (client GroupsClient) Delete(ctx context.Context, resourceGroupName string) (result GroupsDeleteFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GroupsClient.Delete") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.GroupsClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Delete", result.Response(), "Failure sending request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client GroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client GroupsClient) DeleteSender(req *http.Request) (future GroupsDeleteFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client GroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByClosing()) - result.Response = resp - return -} - -// ExportTemplate captures the specified resource group as a template. -// Parameters: -// resourceGroupName - the name of the resource group to be created or updated. -// parameters - parameters supplied to the export template resource group operation. -func (client GroupsClient) ExportTemplate(ctx context.Context, resourceGroupName string, parameters ExportTemplateRequest) (result GroupExportResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GroupsClient.ExportTemplate") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.GroupsClient", "ExportTemplate", err.Error()) - } - - req, err := client.ExportTemplatePreparer(ctx, resourceGroupName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "ExportTemplate", nil, "Failure preparing request") - return - } - - resp, err := client.ExportTemplateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "ExportTemplate", resp, "Failure sending request") - return - } - - result, err = client.ExportTemplateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "ExportTemplate", resp, "Failure responding to request") - return - } - - return -} - -// ExportTemplatePreparer prepares the ExportTemplate request. -func (client GroupsClient) ExportTemplatePreparer(ctx context.Context, resourceGroupName string, parameters ExportTemplateRequest) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ExportTemplateSender sends the ExportTemplate request. The method will close the -// http.Response Body if it receives an error. -func (client GroupsClient) ExportTemplateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ExportTemplateResponder handles the response to the ExportTemplate request. The method always -// closes the http.Response Body. -func (client GroupsClient) ExportTemplateResponder(resp *http.Response) (result GroupExportResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Get get a resource group. -// Parameters: -// resourceGroupName - the name of the resource group to get. The name is case insensitive. -func (client GroupsClient) Get(ctx context.Context, resourceGroupName string) (result Group, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GroupsClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.GroupsClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client GroupsClient) GetPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client GroupsClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client GroupsClient) GetResponder(resp *http.Response) (result Group, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List gets a collection of resource groups. -// Parameters: -// filter - the filter to apply on the operation. -// top - query parameters. If null is passed returns all resource groups. -func (client GroupsClient) List(ctx context.Context, filter string, top *int32) (result GroupListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GroupsClient.List") - defer func() { - sc := -1 - if result.glr.Response.Response != nil { - sc = result.glr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, filter, top) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.glr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "List", resp, "Failure sending request") - return - } - - result.glr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "List", resp, "Failure responding to request") - return - } - if result.glr.hasNextLink() && result.glr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListPreparer prepares the List request. -func (client GroupsClient) ListPreparer(ctx context.Context, filter string, top *int32) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client GroupsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client GroupsClient) ListResponder(resp *http.Response) (result GroupListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client GroupsClient) listNextResults(ctx context.Context, lastResults GroupListResult) (result GroupListResult, err error) { - req, err := lastResults.groupListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client GroupsClient) ListComplete(ctx context.Context, filter string, top *int32) (result GroupListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GroupsClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx, filter, top) - return -} - -// ListResources get all of the resources under a subscription. -// Parameters: -// resourceGroupName - query parameters. If null is passed returns all resource groups. -// filter - the filter to apply on the operation. -// expand - comma-separated list of additional properties to be included in the response. Valid values include -// `createdTime`, `changedTime` and `provisioningState`. For example, `$expand=createdTime,changedTime`. -// top - query parameters. If null is passed returns all resource groups. -func (client GroupsClient) ListResources(ctx context.Context, resourceGroupName string, filter string, expand string, top *int32) (result ListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GroupsClient.ListResources") - defer func() { - sc := -1 - if result.lr.Response.Response != nil { - sc = result.lr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.GroupsClient", "ListResources", err.Error()) - } - - result.fn = client.listResourcesNextResults - req, err := client.ListResourcesPreparer(ctx, resourceGroupName, filter, expand, top) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "ListResources", nil, "Failure preparing request") - return - } - - resp, err := client.ListResourcesSender(req) - if err != nil { - result.lr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "ListResources", resp, "Failure sending request") - return - } - - result.lr, err = client.ListResourcesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "ListResources", resp, "Failure responding to request") - return - } - if result.lr.hasNextLink() && result.lr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListResourcesPreparer prepares the ListResources request. -func (client GroupsClient) ListResourcesPreparer(ctx context.Context, resourceGroupName string, filter string, expand string, top *int32) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - if len(expand) > 0 { - queryParameters["$expand"] = autorest.Encode("query", expand) - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListResourcesSender sends the ListResources request. The method will close the -// http.Response Body if it receives an error. -func (client GroupsClient) ListResourcesSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResourcesResponder handles the response to the ListResources request. The method always -// closes the http.Response Body. -func (client GroupsClient) ListResourcesResponder(resp *http.Response) (result ListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listResourcesNextResults retrieves the next set of results, if any. -func (client GroupsClient) listResourcesNextResults(ctx context.Context, lastResults ListResult) (result ListResult, err error) { - req, err := lastResults.listResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "listResourcesNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListResourcesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "listResourcesNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResourcesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "listResourcesNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListResourcesComplete enumerates all values, automatically crossing page boundaries as required. -func (client GroupsClient) ListResourcesComplete(ctx context.Context, resourceGroupName string, filter string, expand string, top *int32) (result ListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GroupsClient.ListResources") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListResources(ctx, resourceGroupName, filter, expand, top) - return -} - -// Patch resource groups can be updated through a simple PATCH operation to a group address. The format of the request -// is the same as that for creating a resource groups, though if a field is unspecified current value will be carried -// over. -// Parameters: -// resourceGroupName - the name of the resource group to be created or updated. The name is case insensitive. -// parameters - parameters supplied to the update state resource group service operation. -func (client GroupsClient) Patch(ctx context.Context, resourceGroupName string, parameters Group) (result Group, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GroupsClient.Patch") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.GroupsClient", "Patch", err.Error()) - } - - req, err := client.PatchPreparer(ctx, resourceGroupName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Patch", nil, "Failure preparing request") - return - } - - resp, err := client.PatchSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Patch", resp, "Failure sending request") - return - } - - result, err = client.PatchResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Patch", resp, "Failure responding to request") - return - } - - return -} - -// PatchPreparer prepares the Patch request. -func (client GroupsClient) PatchPreparer(ctx context.Context, resourceGroupName string, parameters Group) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - parameters.ID = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// PatchSender sends the Patch request. The method will close the -// http.Response Body if it receives an error. -func (client GroupsClient) PatchSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// PatchResponder handles the response to the Patch request. The method always -// closes the http.Response Body. -func (client GroupsClient) PatchResponder(resp *http.Response) (result Group, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/models.go deleted file mode 100644 index c45dbf0557c1..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/models.go +++ /dev/null @@ -1,1841 +0,0 @@ -package resources - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "encoding/json" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/date" - "github.com/Azure/go-autorest/autorest/to" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// The package's fully qualified name. -const fqdn = "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources" - -// AliasPathType ... -type AliasPathType struct { - // Path - The path of an alias. - Path *string `json:"path,omitempty"` - // APIVersions - The api versions. - APIVersions *[]string `json:"apiVersions,omitempty"` -} - -// AliasType ... -type AliasType struct { - // Name - The alias name. - Name *string `json:"name,omitempty"` - // Paths - The paths for an alias. - Paths *[]AliasPathType `json:"paths,omitempty"` -} - -// BasicDependency deployment dependency information. -type BasicDependency struct { - // ID - The ID of the dependency. - ID *string `json:"id,omitempty"` - // ResourceType - The dependency resource type. - ResourceType *string `json:"resourceType,omitempty"` - // ResourceName - The dependency resource name. - ResourceName *string `json:"resourceName,omitempty"` -} - -// CloudError an error response for a resource management request. -type CloudError struct { - Error *ErrorResponse `json:"error,omitempty"` -} - -// DebugSetting ... -type DebugSetting struct { - // DetailLevel - The debug detail level. - DetailLevel *string `json:"detailLevel,omitempty"` -} - -// Dependency deployment dependency information. -type Dependency struct { - // DependsOn - The list of dependencies. - DependsOn *[]BasicDependency `json:"dependsOn,omitempty"` - // ID - The ID of the dependency. - ID *string `json:"id,omitempty"` - // ResourceType - The dependency resource type. - ResourceType *string `json:"resourceType,omitempty"` - // ResourceName - The dependency resource name. - ResourceName *string `json:"resourceName,omitempty"` -} - -// Deployment deployment operation parameters. -type Deployment struct { - // Properties - The deployment properties. - Properties *DeploymentProperties `json:"properties,omitempty"` -} - -// DeploymentExportResult ... -type DeploymentExportResult struct { - autorest.Response `json:"-"` - // Template - The template content. - Template interface{} `json:"template,omitempty"` -} - -// DeploymentExtended deployment information. -type DeploymentExtended struct { - autorest.Response `json:"-"` - // ID - READ-ONLY; The ID of the deployment. - ID *string `json:"id,omitempty"` - // Name - The name of the deployment. - Name *string `json:"name,omitempty"` - // Properties - Deployment properties. - Properties *DeploymentPropertiesExtended `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for DeploymentExtended. -func (de DeploymentExtended) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if de.Name != nil { - objectMap["name"] = de.Name - } - if de.Properties != nil { - objectMap["properties"] = de.Properties - } - return json.Marshal(objectMap) -} - -// DeploymentExtendedFilter deployment filter. -type DeploymentExtendedFilter struct { - // ProvisioningState - The provisioning state. - ProvisioningState *string `json:"provisioningState,omitempty"` -} - -// DeploymentListResult list of deployments. -type DeploymentListResult struct { - autorest.Response `json:"-"` - // Value - The list of deployments. - Value *[]DeploymentExtended `json:"value,omitempty"` - // NextLink - The URL to get the next set of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// DeploymentListResultIterator provides access to a complete listing of DeploymentExtended values. -type DeploymentListResultIterator struct { - i int - page DeploymentListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *DeploymentListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DeploymentListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *DeploymentListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter DeploymentListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter DeploymentListResultIterator) Response() DeploymentListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter DeploymentListResultIterator) Value() DeploymentExtended { - if !iter.page.NotDone() { - return DeploymentExtended{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the DeploymentListResultIterator type. -func NewDeploymentListResultIterator(page DeploymentListResultPage) DeploymentListResultIterator { - return DeploymentListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (dlr DeploymentListResult) IsEmpty() bool { - return dlr.Value == nil || len(*dlr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (dlr DeploymentListResult) hasNextLink() bool { - return dlr.NextLink != nil && len(*dlr.NextLink) != 0 -} - -// deploymentListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (dlr DeploymentListResult) deploymentListResultPreparer(ctx context.Context) (*http.Request, error) { - if !dlr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(dlr.NextLink))) -} - -// DeploymentListResultPage contains a page of DeploymentExtended values. -type DeploymentListResultPage struct { - fn func(context.Context, DeploymentListResult) (DeploymentListResult, error) - dlr DeploymentListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *DeploymentListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DeploymentListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.dlr) - if err != nil { - return err - } - page.dlr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *DeploymentListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page DeploymentListResultPage) NotDone() bool { - return !page.dlr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page DeploymentListResultPage) Response() DeploymentListResult { - return page.dlr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page DeploymentListResultPage) Values() []DeploymentExtended { - if page.dlr.IsEmpty() { - return nil - } - return *page.dlr.Value -} - -// Creates a new instance of the DeploymentListResultPage type. -func NewDeploymentListResultPage(cur DeploymentListResult, getNextPage func(context.Context, DeploymentListResult) (DeploymentListResult, error)) DeploymentListResultPage { - return DeploymentListResultPage{ - fn: getNextPage, - dlr: cur, - } -} - -// DeploymentOperation deployment operation information. -type DeploymentOperation struct { - autorest.Response `json:"-"` - // ID - Full deployment operation id. - ID *string `json:"id,omitempty"` - // OperationID - Deployment operation id. - OperationID *string `json:"operationId,omitempty"` - // Properties - Deployment properties. - Properties *DeploymentOperationProperties `json:"properties,omitempty"` -} - -// DeploymentOperationProperties deployment operation properties. -type DeploymentOperationProperties struct { - // ProvisioningState - The state of the provisioning. - ProvisioningState *string `json:"provisioningState,omitempty"` - // Timestamp - The date and time of the operation. - Timestamp *date.Time `json:"timestamp,omitempty"` - // ServiceRequestID - Deployment operation service request id. - ServiceRequestID *string `json:"serviceRequestId,omitempty"` - // StatusCode - Operation status code. - StatusCode *string `json:"statusCode,omitempty"` - // StatusMessage - Operation status message. - StatusMessage interface{} `json:"statusMessage,omitempty"` - // TargetResource - The target resource. - TargetResource *TargetResource `json:"targetResource,omitempty"` - // Request - The HTTP request message. - Request *HTTPMessage `json:"request,omitempty"` - // Response - The HTTP response message. - Response *HTTPMessage `json:"response,omitempty"` -} - -// DeploymentOperationsListResult list of deployment operations. -type DeploymentOperationsListResult struct { - autorest.Response `json:"-"` - // Value - The list of deployments. - Value *[]DeploymentOperation `json:"value,omitempty"` - // NextLink - The URL to get the next set of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// DeploymentOperationsListResultIterator provides access to a complete listing of DeploymentOperation -// values. -type DeploymentOperationsListResultIterator struct { - i int - page DeploymentOperationsListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *DeploymentOperationsListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DeploymentOperationsListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *DeploymentOperationsListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter DeploymentOperationsListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter DeploymentOperationsListResultIterator) Response() DeploymentOperationsListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter DeploymentOperationsListResultIterator) Value() DeploymentOperation { - if !iter.page.NotDone() { - return DeploymentOperation{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the DeploymentOperationsListResultIterator type. -func NewDeploymentOperationsListResultIterator(page DeploymentOperationsListResultPage) DeploymentOperationsListResultIterator { - return DeploymentOperationsListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (dolr DeploymentOperationsListResult) IsEmpty() bool { - return dolr.Value == nil || len(*dolr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (dolr DeploymentOperationsListResult) hasNextLink() bool { - return dolr.NextLink != nil && len(*dolr.NextLink) != 0 -} - -// deploymentOperationsListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (dolr DeploymentOperationsListResult) deploymentOperationsListResultPreparer(ctx context.Context) (*http.Request, error) { - if !dolr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(dolr.NextLink))) -} - -// DeploymentOperationsListResultPage contains a page of DeploymentOperation values. -type DeploymentOperationsListResultPage struct { - fn func(context.Context, DeploymentOperationsListResult) (DeploymentOperationsListResult, error) - dolr DeploymentOperationsListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *DeploymentOperationsListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DeploymentOperationsListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.dolr) - if err != nil { - return err - } - page.dolr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *DeploymentOperationsListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page DeploymentOperationsListResultPage) NotDone() bool { - return !page.dolr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page DeploymentOperationsListResultPage) Response() DeploymentOperationsListResult { - return page.dolr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page DeploymentOperationsListResultPage) Values() []DeploymentOperation { - if page.dolr.IsEmpty() { - return nil - } - return *page.dolr.Value -} - -// Creates a new instance of the DeploymentOperationsListResultPage type. -func NewDeploymentOperationsListResultPage(cur DeploymentOperationsListResult, getNextPage func(context.Context, DeploymentOperationsListResult) (DeploymentOperationsListResult, error)) DeploymentOperationsListResultPage { - return DeploymentOperationsListResultPage{ - fn: getNextPage, - dolr: cur, - } -} - -// DeploymentProperties deployment properties. -type DeploymentProperties struct { - // Template - The template content. It can be a JObject or a well formed JSON string. Use only one of Template or TemplateLink. - Template interface{} `json:"template,omitempty"` - // TemplateLink - The template URI. Use only one of Template or TemplateLink. - TemplateLink *TemplateLink `json:"templateLink,omitempty"` - // Parameters - Deployment parameters. It can be a JObject or a well formed JSON string. Use only one of Parameters or ParametersLink. - Parameters interface{} `json:"parameters,omitempty"` - // ParametersLink - The parameters URI. Use only one of Parameters or ParametersLink. - ParametersLink *ParametersLink `json:"parametersLink,omitempty"` - // Mode - The deployment mode. Possible values include: 'Incremental', 'Complete' - Mode DeploymentMode `json:"mode,omitempty"` - // DebugSetting - The debug setting of the deployment. - DebugSetting *DebugSetting `json:"debugSetting,omitempty"` -} - -// DeploymentPropertiesExtended deployment properties with additional details. -type DeploymentPropertiesExtended struct { - // ProvisioningState - The state of the provisioning. - ProvisioningState *string `json:"provisioningState,omitempty"` - // CorrelationID - The correlation ID of the deployment. - CorrelationID *string `json:"correlationId,omitempty"` - // Timestamp - The timestamp of the template deployment. - Timestamp *date.Time `json:"timestamp,omitempty"` - // Outputs - Key/value pairs that represent deployment output. - Outputs interface{} `json:"outputs,omitempty"` - // Providers - The list of resource providers needed for the deployment. - Providers *[]Provider `json:"providers,omitempty"` - // Dependencies - The list of deployment dependencies. - Dependencies *[]Dependency `json:"dependencies,omitempty"` - // Template - The template content. Use only one of Template or TemplateLink. - Template interface{} `json:"template,omitempty"` - // TemplateLink - The URI referencing the template. Use only one of Template or TemplateLink. - TemplateLink *TemplateLink `json:"templateLink,omitempty"` - // Parameters - Deployment parameters. Use only one of Parameters or ParametersLink. - Parameters interface{} `json:"parameters,omitempty"` - // ParametersLink - The URI referencing the parameters. Use only one of Parameters or ParametersLink. - ParametersLink *ParametersLink `json:"parametersLink,omitempty"` - // Mode - The deployment mode. Possible values include: 'Incremental', 'Complete' - Mode DeploymentMode `json:"mode,omitempty"` - // DebugSetting - The debug setting of the deployment. - DebugSetting *DebugSetting `json:"debugSetting,omitempty"` -} - -// DeploymentsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type DeploymentsCreateOrUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(DeploymentsClient) (DeploymentExtended, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *DeploymentsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for DeploymentsCreateOrUpdateFuture.Result. -func (future *DeploymentsCreateOrUpdateFuture) result(client DeploymentsClient) (de DeploymentExtended, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - de.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("resources.DeploymentsCreateOrUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if de.Response.Response, err = future.GetResult(sender); err == nil && de.Response.Response.StatusCode != http.StatusNoContent { - de, err = client.CreateOrUpdateResponder(de.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsCreateOrUpdateFuture", "Result", de.Response.Response, "Failure responding to request") - } - } - return -} - -// DeploymentsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type DeploymentsDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(DeploymentsClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *DeploymentsDeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for DeploymentsDeleteFuture.Result. -func (future *DeploymentsDeleteFuture) result(client DeploymentsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("resources.DeploymentsDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// DeploymentValidateResult information from validate template deployment response. -type DeploymentValidateResult struct { - autorest.Response `json:"-"` - // Error - Validation error. - Error *ManagementErrorWithDetails `json:"error,omitempty"` - // Properties - The template deployment properties. - Properties *DeploymentPropertiesExtended `json:"properties,omitempty"` -} - -// ErrorAdditionalInfo the resource management error additional info. -type ErrorAdditionalInfo struct { - // Type - READ-ONLY; The additional info type. - Type *string `json:"type,omitempty"` - // Info - READ-ONLY; The additional info. - Info interface{} `json:"info,omitempty"` -} - -// MarshalJSON is the custom marshaler for ErrorAdditionalInfo. -func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// ErrorResponse common error response for all Azure Resource Manager APIs to return error details for -// failed operations. (This also follows the OData error response format.) -type ErrorResponse struct { - // Code - READ-ONLY; The error code. - Code *string `json:"code,omitempty"` - // Message - READ-ONLY; The error message. - Message *string `json:"message,omitempty"` - // Target - READ-ONLY; The error target. - Target *string `json:"target,omitempty"` - // Details - READ-ONLY; The error details. - Details *[]ErrorResponse `json:"details,omitempty"` - // AdditionalInfo - READ-ONLY; The error additional info. - AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` -} - -// MarshalJSON is the custom marshaler for ErrorResponse. -func (er ErrorResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// ExportTemplateRequest export resource group template request parameters. -type ExportTemplateRequest struct { - // ResourcesProperty - The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - ResourcesProperty *[]string `json:"resources,omitempty"` - // Options - The export template options. A CSV-formatted list containing zero or more of the following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization' - Options *string `json:"options,omitempty"` -} - -// GenericResource resource information. -type GenericResource struct { - autorest.Response `json:"-"` - // Plan - The plan of the resource. - Plan *Plan `json:"plan,omitempty"` - // Properties - The resource properties. - Properties interface{} `json:"properties,omitempty"` - // Kind - The kind of the resource. - Kind *string `json:"kind,omitempty"` - // ManagedBy - Id of the resource that manages this resource. - ManagedBy *string `json:"managedBy,omitempty"` - // Sku - The sku of the resource. - Sku *Sku `json:"sku,omitempty"` - // Identity - The identity of the resource. - Identity *Identity `json:"identity,omitempty"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` - // Location - Resource location - Location *string `json:"location,omitempty"` - // Tags - Resource tags - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for GenericResource. -func (gr GenericResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if gr.Plan != nil { - objectMap["plan"] = gr.Plan - } - if gr.Properties != nil { - objectMap["properties"] = gr.Properties - } - if gr.Kind != nil { - objectMap["kind"] = gr.Kind - } - if gr.ManagedBy != nil { - objectMap["managedBy"] = gr.ManagedBy - } - if gr.Sku != nil { - objectMap["sku"] = gr.Sku - } - if gr.Identity != nil { - objectMap["identity"] = gr.Identity - } - if gr.Location != nil { - objectMap["location"] = gr.Location - } - if gr.Tags != nil { - objectMap["tags"] = gr.Tags - } - return json.Marshal(objectMap) -} - -// GenericResourceExpanded resource information. -type GenericResourceExpanded struct { - // CreatedTime - READ-ONLY; The created time of the resource. This is only present if requested via the $expand query parameter. - CreatedTime *date.Time `json:"createdTime,omitempty"` - // ChangedTime - READ-ONLY; The changed time of the resource. This is only present if requested via the $expand query parameter. - ChangedTime *date.Time `json:"changedTime,omitempty"` - // ProvisioningState - READ-ONLY; The provisioning state of the resource. This is only present if requested via the $expand query parameter. - ProvisioningState *string `json:"provisioningState,omitempty"` - // Plan - The plan of the resource. - Plan *Plan `json:"plan,omitempty"` - // Properties - The resource properties. - Properties interface{} `json:"properties,omitempty"` - // Kind - The kind of the resource. - Kind *string `json:"kind,omitempty"` - // ManagedBy - Id of the resource that manages this resource. - ManagedBy *string `json:"managedBy,omitempty"` - // Sku - The sku of the resource. - Sku *Sku `json:"sku,omitempty"` - // Identity - The identity of the resource. - Identity *Identity `json:"identity,omitempty"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` - // Location - Resource location - Location *string `json:"location,omitempty"` - // Tags - Resource tags - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for GenericResourceExpanded. -func (gre GenericResourceExpanded) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if gre.Plan != nil { - objectMap["plan"] = gre.Plan - } - if gre.Properties != nil { - objectMap["properties"] = gre.Properties - } - if gre.Kind != nil { - objectMap["kind"] = gre.Kind - } - if gre.ManagedBy != nil { - objectMap["managedBy"] = gre.ManagedBy - } - if gre.Sku != nil { - objectMap["sku"] = gre.Sku - } - if gre.Identity != nil { - objectMap["identity"] = gre.Identity - } - if gre.Location != nil { - objectMap["location"] = gre.Location - } - if gre.Tags != nil { - objectMap["tags"] = gre.Tags - } - return json.Marshal(objectMap) -} - -// GenericResourceFilter resource filter. -type GenericResourceFilter struct { - // ResourceType - The resource type. - ResourceType *string `json:"resourceType,omitempty"` - // Tagname - The tag name. - Tagname *string `json:"tagname,omitempty"` - // Tagvalue - The tag value. - Tagvalue *string `json:"tagvalue,omitempty"` -} - -// Group resource group information. -type Group struct { - autorest.Response `json:"-"` - // ID - READ-ONLY; The ID of the resource group. - ID *string `json:"id,omitempty"` - // Name - The Name of the resource group. - Name *string `json:"name,omitempty"` - Properties *GroupProperties `json:"properties,omitempty"` - // Location - The location of the resource group. It cannot be changed after the resource group has been created. Has to be one of the supported Azure Locations, such as West US, East US, West Europe, East Asia, etc. - Location *string `json:"location,omitempty"` - // Tags - The tags attached to the resource group. - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for Group. -func (g Group) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if g.Name != nil { - objectMap["name"] = g.Name - } - if g.Properties != nil { - objectMap["properties"] = g.Properties - } - if g.Location != nil { - objectMap["location"] = g.Location - } - if g.Tags != nil { - objectMap["tags"] = g.Tags - } - return json.Marshal(objectMap) -} - -// GroupExportResult ... -type GroupExportResult struct { - autorest.Response `json:"-"` - // Template - The template content. - Template interface{} `json:"template,omitempty"` - // Error - The error. - Error *ManagementErrorWithDetails `json:"error,omitempty"` -} - -// GroupFilter resource group filter. -type GroupFilter struct { - // TagName - The tag name. - TagName *string `json:"tagName,omitempty"` - // TagValue - The tag value. - TagValue *string `json:"tagValue,omitempty"` -} - -// GroupListResult list of resource groups. -type GroupListResult struct { - autorest.Response `json:"-"` - // Value - The list of resource groups. - Value *[]Group `json:"value,omitempty"` - // NextLink - The URL to get the next set of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// GroupListResultIterator provides access to a complete listing of Group values. -type GroupListResultIterator struct { - i int - page GroupListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *GroupListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GroupListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *GroupListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter GroupListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter GroupListResultIterator) Response() GroupListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter GroupListResultIterator) Value() Group { - if !iter.page.NotDone() { - return Group{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the GroupListResultIterator type. -func NewGroupListResultIterator(page GroupListResultPage) GroupListResultIterator { - return GroupListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (glr GroupListResult) IsEmpty() bool { - return glr.Value == nil || len(*glr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (glr GroupListResult) hasNextLink() bool { - return glr.NextLink != nil && len(*glr.NextLink) != 0 -} - -// groupListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (glr GroupListResult) groupListResultPreparer(ctx context.Context) (*http.Request, error) { - if !glr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(glr.NextLink))) -} - -// GroupListResultPage contains a page of Group values. -type GroupListResultPage struct { - fn func(context.Context, GroupListResult) (GroupListResult, error) - glr GroupListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *GroupListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GroupListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.glr) - if err != nil { - return err - } - page.glr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *GroupListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page GroupListResultPage) NotDone() bool { - return !page.glr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page GroupListResultPage) Response() GroupListResult { - return page.glr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page GroupListResultPage) Values() []Group { - if page.glr.IsEmpty() { - return nil - } - return *page.glr.Value -} - -// Creates a new instance of the GroupListResultPage type. -func NewGroupListResultPage(cur GroupListResult, getNextPage func(context.Context, GroupListResult) (GroupListResult, error)) GroupListResultPage { - return GroupListResultPage{ - fn: getNextPage, - glr: cur, - } -} - -// GroupProperties the resource group properties. -type GroupProperties struct { - // ProvisioningState - READ-ONLY; The provisioning state. - ProvisioningState *string `json:"provisioningState,omitempty"` -} - -// MarshalJSON is the custom marshaler for GroupProperties. -func (gp GroupProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// GroupsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. -type GroupsDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(GroupsClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *GroupsDeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for GroupsDeleteFuture.Result. -func (future *GroupsDeleteFuture) result(client GroupsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupsDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("resources.GroupsDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// HTTPMessage ... -type HTTPMessage struct { - // Content - HTTP message content. - Content interface{} `json:"content,omitempty"` -} - -// Identity identity for the resource. -type Identity struct { - // PrincipalID - READ-ONLY; The principal id of resource identity. - PrincipalID *string `json:"principalId,omitempty"` - // TenantID - READ-ONLY; The tenant id of resource. - TenantID *string `json:"tenantId,omitempty"` - // Type - The identity type. Possible values include: 'SystemAssigned' - Type ResourceIdentityType `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for Identity. -func (i Identity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if i.Type != "" { - objectMap["type"] = i.Type - } - return json.Marshal(objectMap) -} - -// ListResult list of resource groups. -type ListResult struct { - autorest.Response `json:"-"` - // Value - The list of resources. - Value *[]GenericResourceExpanded `json:"value,omitempty"` - // NextLink - The URL to get the next set of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// ListResultIterator provides access to a complete listing of GenericResourceExpanded values. -type ListResultIterator struct { - i int - page ListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *ListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *ListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter ListResultIterator) Response() ListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter ListResultIterator) Value() GenericResourceExpanded { - if !iter.page.NotDone() { - return GenericResourceExpanded{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the ListResultIterator type. -func NewListResultIterator(page ListResultPage) ListResultIterator { - return ListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (lr ListResult) IsEmpty() bool { - return lr.Value == nil || len(*lr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (lr ListResult) hasNextLink() bool { - return lr.NextLink != nil && len(*lr.NextLink) != 0 -} - -// listResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (lr ListResult) listResultPreparer(ctx context.Context) (*http.Request, error) { - if !lr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(lr.NextLink))) -} - -// ListResultPage contains a page of GenericResourceExpanded values. -type ListResultPage struct { - fn func(context.Context, ListResult) (ListResult, error) - lr ListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *ListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.lr) - if err != nil { - return err - } - page.lr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *ListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ListResultPage) NotDone() bool { - return !page.lr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page ListResultPage) Response() ListResult { - return page.lr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page ListResultPage) Values() []GenericResourceExpanded { - if page.lr.IsEmpty() { - return nil - } - return *page.lr.Value -} - -// Creates a new instance of the ListResultPage type. -func NewListResultPage(cur ListResult, getNextPage func(context.Context, ListResult) (ListResult, error)) ListResultPage { - return ListResultPage{ - fn: getNextPage, - lr: cur, - } -} - -// ManagementErrorWithDetails ... -type ManagementErrorWithDetails struct { - // Code - The error code returned from the server. - Code *string `json:"code,omitempty"` - // Message - The error message returned from the server. - Message *string `json:"message,omitempty"` - // Target - The target of the error. - Target *string `json:"target,omitempty"` - // Details - Validation error. - Details *[]ManagementErrorWithDetails `json:"details,omitempty"` -} - -// MoveInfo parameters of move resources. -type MoveInfo struct { - // ResourcesProperty - The ids of the resources. - ResourcesProperty *[]string `json:"resources,omitempty"` - // TargetResourceGroup - The target resource group. - TargetResourceGroup *string `json:"targetResourceGroup,omitempty"` -} - -// MoveResourcesFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type MoveResourcesFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(Client) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *MoveResourcesFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for MoveResourcesFuture.Result. -func (future *MoveResourcesFuture) result(client Client) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.MoveResourcesFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("resources.MoveResourcesFuture") - return - } - ar.Response = future.Response() - return -} - -// ParametersLink entity representing the reference to the deployment parameters. -type ParametersLink struct { - // URI - URI referencing the template. - URI *string `json:"uri,omitempty"` - // ContentVersion - If included it must match the ContentVersion in the template. - ContentVersion *string `json:"contentVersion,omitempty"` -} - -// Plan plan for the resource. -type Plan struct { - // Name - The plan ID. - Name *string `json:"name,omitempty"` - // Publisher - The publisher ID. - Publisher *string `json:"publisher,omitempty"` - // Product - The offer ID. - Product *string `json:"product,omitempty"` - // PromotionCode - The promotion code. - PromotionCode *string `json:"promotionCode,omitempty"` -} - -// Provider resource provider information. -type Provider struct { - autorest.Response `json:"-"` - // ID - The provider id. - ID *string `json:"id,omitempty"` - // Namespace - The namespace of the provider. - Namespace *string `json:"namespace,omitempty"` - // RegistrationState - The registration state of the provider. - RegistrationState *string `json:"registrationState,omitempty"` - // ResourceTypes - The collection of provider resource types. - ResourceTypes *[]ProviderResourceType `json:"resourceTypes,omitempty"` -} - -// ProviderListResult list of resource providers. -type ProviderListResult struct { - autorest.Response `json:"-"` - // Value - The list of resource providers. - Value *[]Provider `json:"value,omitempty"` - // NextLink - The URL to get the next set of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// ProviderListResultIterator provides access to a complete listing of Provider values. -type ProviderListResultIterator struct { - i int - page ProviderListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *ProviderListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ProviderListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *ProviderListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ProviderListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter ProviderListResultIterator) Response() ProviderListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter ProviderListResultIterator) Value() Provider { - if !iter.page.NotDone() { - return Provider{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the ProviderListResultIterator type. -func NewProviderListResultIterator(page ProviderListResultPage) ProviderListResultIterator { - return ProviderListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (plr ProviderListResult) IsEmpty() bool { - return plr.Value == nil || len(*plr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (plr ProviderListResult) hasNextLink() bool { - return plr.NextLink != nil && len(*plr.NextLink) != 0 -} - -// providerListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (plr ProviderListResult) providerListResultPreparer(ctx context.Context) (*http.Request, error) { - if !plr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(plr.NextLink))) -} - -// ProviderListResultPage contains a page of Provider values. -type ProviderListResultPage struct { - fn func(context.Context, ProviderListResult) (ProviderListResult, error) - plr ProviderListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *ProviderListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ProviderListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.plr) - if err != nil { - return err - } - page.plr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *ProviderListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ProviderListResultPage) NotDone() bool { - return !page.plr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page ProviderListResultPage) Response() ProviderListResult { - return page.plr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page ProviderListResultPage) Values() []Provider { - if page.plr.IsEmpty() { - return nil - } - return *page.plr.Value -} - -// Creates a new instance of the ProviderListResultPage type. -func NewProviderListResultPage(cur ProviderListResult, getNextPage func(context.Context, ProviderListResult) (ProviderListResult, error)) ProviderListResultPage { - return ProviderListResultPage{ - fn: getNextPage, - plr: cur, - } -} - -// ProviderOperationDisplayProperties resource provider operation's display properties. -type ProviderOperationDisplayProperties struct { - // Publisher - Operation description. - Publisher *string `json:"publisher,omitempty"` - // Provider - Operation provider. - Provider *string `json:"provider,omitempty"` - // Resource - Operation resource. - Resource *string `json:"resource,omitempty"` - // Operation - Operation. - Operation *string `json:"operation,omitempty"` - // Description - Operation description. - Description *string `json:"description,omitempty"` -} - -// ProviderResourceType resource type managed by the resource provider. -type ProviderResourceType struct { - // ResourceType - The resource type. - ResourceType *string `json:"resourceType,omitempty"` - // Locations - The collection of locations where this resource type can be created in. - Locations *[]string `json:"locations,omitempty"` - // Aliases - The aliases that are supported by this resource type. - Aliases *[]AliasType `json:"aliases,omitempty"` - // APIVersions - The api version. - APIVersions *[]string `json:"apiVersions,omitempty"` - // Properties - The properties. - Properties map[string]*string `json:"properties"` -} - -// MarshalJSON is the custom marshaler for ProviderResourceType. -func (prt ProviderResourceType) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if prt.ResourceType != nil { - objectMap["resourceType"] = prt.ResourceType - } - if prt.Locations != nil { - objectMap["locations"] = prt.Locations - } - if prt.Aliases != nil { - objectMap["aliases"] = prt.Aliases - } - if prt.APIVersions != nil { - objectMap["apiVersions"] = prt.APIVersions - } - if prt.Properties != nil { - objectMap["properties"] = prt.Properties - } - return json.Marshal(objectMap) -} - -// Resource ... -type Resource struct { - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` - // Location - Resource location - Location *string `json:"location,omitempty"` - // Tags - Resource tags - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for Resource. -func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if r.Location != nil { - objectMap["location"] = r.Location - } - if r.Tags != nil { - objectMap["tags"] = r.Tags - } - return json.Marshal(objectMap) -} - -// Sku sku for the resource. -type Sku struct { - // Name - The sku name. - Name *string `json:"name,omitempty"` - // Tier - The sku tier. - Tier *string `json:"tier,omitempty"` - // Size - The sku size. - Size *string `json:"size,omitempty"` - // Family - The sku family. - Family *string `json:"family,omitempty"` - // Model - The sku model. - Model *string `json:"model,omitempty"` - // Capacity - The sku capacity. - Capacity *int32 `json:"capacity,omitempty"` -} - -// SubResource ... -type SubResource struct { - // ID - Resource Id - ID *string `json:"id,omitempty"` -} - -// TagCount tag count. -type TagCount struct { - // Type - Type of count. - Type *string `json:"type,omitempty"` - // Value - Value of count. - Value *string `json:"value,omitempty"` -} - -// TagDetails tag details. -type TagDetails struct { - autorest.Response `json:"-"` - // ID - READ-ONLY; The tag ID. - ID *string `json:"id,omitempty"` - // TagName - The tag name. - TagName *string `json:"tagName,omitempty"` - // Count - The tag count. - Count *TagCount `json:"count,omitempty"` - // Values - The list of tag values. - Values *[]TagValue `json:"values,omitempty"` -} - -// MarshalJSON is the custom marshaler for TagDetails. -func (td TagDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if td.TagName != nil { - objectMap["tagName"] = td.TagName - } - if td.Count != nil { - objectMap["count"] = td.Count - } - if td.Values != nil { - objectMap["values"] = td.Values - } - return json.Marshal(objectMap) -} - -// TagsListResult list of subscription tags. -type TagsListResult struct { - autorest.Response `json:"-"` - // Value - The list of tags. - Value *[]TagDetails `json:"value,omitempty"` - // NextLink - The URL to get the next set of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// TagsListResultIterator provides access to a complete listing of TagDetails values. -type TagsListResultIterator struct { - i int - page TagsListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *TagsListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TagsListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *TagsListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter TagsListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter TagsListResultIterator) Response() TagsListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter TagsListResultIterator) Value() TagDetails { - if !iter.page.NotDone() { - return TagDetails{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the TagsListResultIterator type. -func NewTagsListResultIterator(page TagsListResultPage) TagsListResultIterator { - return TagsListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (tlr TagsListResult) IsEmpty() bool { - return tlr.Value == nil || len(*tlr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (tlr TagsListResult) hasNextLink() bool { - return tlr.NextLink != nil && len(*tlr.NextLink) != 0 -} - -// tagsListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (tlr TagsListResult) tagsListResultPreparer(ctx context.Context) (*http.Request, error) { - if !tlr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(tlr.NextLink))) -} - -// TagsListResultPage contains a page of TagDetails values. -type TagsListResultPage struct { - fn func(context.Context, TagsListResult) (TagsListResult, error) - tlr TagsListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *TagsListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TagsListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.tlr) - if err != nil { - return err - } - page.tlr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *TagsListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page TagsListResultPage) NotDone() bool { - return !page.tlr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page TagsListResultPage) Response() TagsListResult { - return page.tlr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page TagsListResultPage) Values() []TagDetails { - if page.tlr.IsEmpty() { - return nil - } - return *page.tlr.Value -} - -// Creates a new instance of the TagsListResultPage type. -func NewTagsListResultPage(cur TagsListResult, getNextPage func(context.Context, TagsListResult) (TagsListResult, error)) TagsListResultPage { - return TagsListResultPage{ - fn: getNextPage, - tlr: cur, - } -} - -// TagValue tag information. -type TagValue struct { - autorest.Response `json:"-"` - // ID - READ-ONLY; The tag ID. - ID *string `json:"id,omitempty"` - // TagValue - The tag value. - TagValue *string `json:"tagValue,omitempty"` - // Count - The tag value count. - Count *TagCount `json:"count,omitempty"` -} - -// MarshalJSON is the custom marshaler for TagValue. -func (tv TagValue) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if tv.TagValue != nil { - objectMap["tagValue"] = tv.TagValue - } - if tv.Count != nil { - objectMap["count"] = tv.Count - } - return json.Marshal(objectMap) -} - -// TargetResource target resource. -type TargetResource struct { - // ID - The ID of the resource. - ID *string `json:"id,omitempty"` - // ResourceName - The name of the resource. - ResourceName *string `json:"resourceName,omitempty"` - // ResourceType - The type of the resource. - ResourceType *string `json:"resourceType,omitempty"` -} - -// TemplateHashResult result of the request to calculate template hash. It contains a string of minified -// template and its hash. -type TemplateHashResult struct { - autorest.Response `json:"-"` - // MinifiedTemplate - The minified template string. - MinifiedTemplate *string `json:"minifiedTemplate,omitempty"` - // TemplateHash - The template hash. - TemplateHash *string `json:"templateHash,omitempty"` -} - -// TemplateLink entity representing the reference to the template. -type TemplateLink struct { - // URI - URI referencing the template. - URI *string `json:"uri,omitempty"` - // ContentVersion - If included it must match the ContentVersion in the template. - ContentVersion *string `json:"contentVersion,omitempty"` -} - -// UpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. -type UpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(Client) (GenericResource, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *UpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for UpdateFuture.Result. -func (future *UpdateFuture) result(client Client) (gr GenericResource, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.UpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - gr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("resources.UpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if gr.Response.Response, err = future.GetResult(sender); err == nil && gr.Response.Response.StatusCode != http.StatusNoContent { - gr, err = client.UpdateResponder(gr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.UpdateFuture", "Result", gr.Response.Response, "Failure responding to request") - } - } - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/providers.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/providers.go deleted file mode 100644 index e4dde4b269e6..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/providers.go +++ /dev/null @@ -1,381 +0,0 @@ -package resources - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// ProvidersClient is the client for the Providers methods of the Resources service. -type ProvidersClient struct { - BaseClient -} - -// NewProvidersClient creates an instance of the ProvidersClient client. -func NewProvidersClient(subscriptionID string) ProvidersClient { - return NewProvidersClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewProvidersClientWithBaseURI creates an instance of the ProvidersClient client using a custom endpoint. Use this -// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewProvidersClientWithBaseURI(baseURI string, subscriptionID string) ProvidersClient { - return ProvidersClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// Get gets a resource provider. -// Parameters: -// resourceProviderNamespace - namespace of the resource provider. -// expand - the $expand query parameter. e.g. To include property aliases in response, use -// $expand=resourceTypes/aliases. -func (client ProvidersClient) Get(ctx context.Context, resourceProviderNamespace string, expand string) (result Provider, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ProvidersClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetPreparer(ctx, resourceProviderNamespace, expand) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.ProvidersClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.ProvidersClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.ProvidersClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client ProvidersClient) GetPreparer(ctx context.Context, resourceProviderNamespace string, expand string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(expand) > 0 { - queryParameters["$expand"] = autorest.Encode("query", expand) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client ProvidersClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client ProvidersClient) GetResponder(resp *http.Response) (result Provider, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List gets a list of resource providers. -// Parameters: -// top - query parameters. If null is passed returns all deployments. -// expand - the $expand query parameter. e.g. To include property aliases in response, use -// $expand=resourceTypes/aliases. -func (client ProvidersClient) List(ctx context.Context, top *int32, expand string) (result ProviderListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ProvidersClient.List") - defer func() { - sc := -1 - if result.plr.Response.Response != nil { - sc = result.plr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, top, expand) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.ProvidersClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.plr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.ProvidersClient", "List", resp, "Failure sending request") - return - } - - result.plr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.ProvidersClient", "List", resp, "Failure responding to request") - return - } - if result.plr.hasNextLink() && result.plr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListPreparer prepares the List request. -func (client ProvidersClient) ListPreparer(ctx context.Context, top *int32, expand string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - if len(expand) > 0 { - queryParameters["$expand"] = autorest.Encode("query", expand) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client ProvidersClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client ProvidersClient) ListResponder(resp *http.Response) (result ProviderListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client ProvidersClient) listNextResults(ctx context.Context, lastResults ProviderListResult) (result ProviderListResult, err error) { - req, err := lastResults.providerListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.ProvidersClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.ProvidersClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.ProvidersClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client ProvidersClient) ListComplete(ctx context.Context, top *int32, expand string) (result ProviderListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ProvidersClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx, top, expand) - return -} - -// Register registers provider to be used with a subscription. -// Parameters: -// resourceProviderNamespace - namespace of the resource provider. -func (client ProvidersClient) Register(ctx context.Context, resourceProviderNamespace string) (result Provider, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ProvidersClient.Register") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.RegisterPreparer(ctx, resourceProviderNamespace) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.ProvidersClient", "Register", nil, "Failure preparing request") - return - } - - resp, err := client.RegisterSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.ProvidersClient", "Register", resp, "Failure sending request") - return - } - - result, err = client.RegisterResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.ProvidersClient", "Register", resp, "Failure responding to request") - return - } - - return -} - -// RegisterPreparer prepares the Register request. -func (client ProvidersClient) RegisterPreparer(ctx context.Context, resourceProviderNamespace string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// RegisterSender sends the Register request. The method will close the -// http.Response Body if it receives an error. -func (client ProvidersClient) RegisterSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// RegisterResponder handles the response to the Register request. The method always -// closes the http.Response Body. -func (client ProvidersClient) RegisterResponder(resp *http.Response) (result Provider, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Unregister unregisters provider from a subscription. -// Parameters: -// resourceProviderNamespace - namespace of the resource provider. -func (client ProvidersClient) Unregister(ctx context.Context, resourceProviderNamespace string) (result Provider, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ProvidersClient.Unregister") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.UnregisterPreparer(ctx, resourceProviderNamespace) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.ProvidersClient", "Unregister", nil, "Failure preparing request") - return - } - - resp, err := client.UnregisterSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.ProvidersClient", "Unregister", resp, "Failure sending request") - return - } - - result, err = client.UnregisterResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.ProvidersClient", "Unregister", resp, "Failure responding to request") - return - } - - return -} - -// UnregisterPreparer prepares the Unregister request. -func (client ProvidersClient) UnregisterPreparer(ctx context.Context, resourceProviderNamespace string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UnregisterSender sends the Unregister request. The method will close the -// http.Response Body if it receives an error. -func (client ProvidersClient) UnregisterSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// UnregisterResponder handles the response to the Unregister request. The method always -// closes the http.Response Body. -func (client ProvidersClient) UnregisterResponder(resp *http.Response) (result Provider, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/resources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/resources.go deleted file mode 100644 index a243d6bac8c2..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/resources.go +++ /dev/null @@ -1,700 +0,0 @@ -package resources - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// Client is the client for the Resources methods of the Resources service. -type Client struct { - BaseClient -} - -// NewClient creates an instance of the Client client. -func NewClient(subscriptionID string) Client { - return NewClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewClientWithBaseURI creates an instance of the Client client using a custom endpoint. Use this when interacting -// with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewClientWithBaseURI(baseURI string, subscriptionID string) Client { - return Client{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CheckExistence checks whether resource exists. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// resourceProviderNamespace - resource identity. -// parentResourcePath - resource identity. -// resourceType - resource identity. -// resourceName - resource identity. -func (client Client) CheckExistence(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/Client.CheckExistence") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.Client", "CheckExistence", err.Error()) - } - - req, err := client.CheckExistencePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, APIVersion) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "CheckExistence", nil, "Failure preparing request") - return - } - - resp, err := client.CheckExistenceSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "resources.Client", "CheckExistence", resp, "Failure sending request") - return - } - - result, err = client.CheckExistenceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "CheckExistence", resp, "Failure responding to request") - return - } - - return -} - -// CheckExistencePreparer prepares the CheckExistence request. -func (client Client) CheckExistencePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "parentResourcePath": parentResourcePath, - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), - "resourceType": resourceType, - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsHead(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CheckExistenceSender sends the CheckExistence request. The method will close the -// http.Response Body if it receives an error. -func (client Client) CheckExistenceSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CheckExistenceResponder handles the response to the CheckExistence request. The method always -// closes the http.Response Body. -func (client Client) CheckExistenceResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusNotFound), - autorest.ByClosing()) - result.Response = resp - return -} - -// CreateOrUpdate create a resource. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// resourceProviderNamespace - resource identity. -// parentResourcePath - resource identity. -// resourceType - resource identity. -// resourceName - resource identity. -// parameters - create or update resource parameters. -func (client Client) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string, parameters GenericResource) (result GenericResource, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/Client.CreateOrUpdate") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.Client", "CreateOrUpdate", err.Error()) - } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, APIVersion, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.Client", "CreateOrUpdate", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "CreateOrUpdate", resp, "Failure responding to request") - return - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client Client) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string, parameters GenericResource) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "parentResourcePath": parentResourcePath, - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), - "resourceType": resourceType, - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client Client) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client Client) CreateOrUpdateResponder(resp *http.Response) (result GenericResource, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete delete resource and all of its resources. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// resourceProviderNamespace - resource identity. -// parentResourcePath - resource identity. -// resourceType - resource identity. -// resourceName - resource identity. -func (client Client) Delete(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/Client.Delete") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.Client", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, APIVersion) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "resources.Client", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "Delete", resp, "Failure responding to request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client Client) DeletePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "parentResourcePath": parentResourcePath, - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), - "resourceType": resourceType, - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client Client) DeleteSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client Client) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get returns a resource belonging to a resource group. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// resourceProviderNamespace - resource identity. -// parentResourcePath - resource identity. -// resourceType - resource identity. -// resourceName - resource identity. -func (client Client) Get(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string) (result GenericResource, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/Client.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.Client", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, APIVersion) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.Client", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client Client) GetPreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "parentResourcePath": parentResourcePath, - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), - "resourceType": resourceType, - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client Client) GetResponder(resp *http.Response) (result GenericResource, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List get all of the resources under a subscription. -// Parameters: -// filter - the filter to apply on the operation. -// expand - comma-separated list of additional properties to be included in the response. Valid values include -// `createdTime`, `changedTime` and `provisioningState`. For example, `$expand=createdTime,changedTime`. -// top - query parameters. If null is passed returns all resource groups. -func (client Client) List(ctx context.Context, filter string, expand string, top *int32) (result ListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/Client.List") - defer func() { - sc := -1 - if result.lr.Response.Response != nil { - sc = result.lr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, filter, expand, top) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.lr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.Client", "List", resp, "Failure sending request") - return - } - - result.lr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "List", resp, "Failure responding to request") - return - } - if result.lr.hasNextLink() && result.lr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListPreparer prepares the List request. -func (client Client) ListPreparer(ctx context.Context, filter string, expand string, top *int32) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - if len(expand) > 0 { - queryParameters["$expand"] = autorest.Encode("query", expand) - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resources", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client Client) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client Client) ListResponder(resp *http.Response) (result ListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client Client) listNextResults(ctx context.Context, lastResults ListResult) (result ListResult, err error) { - req, err := lastResults.listResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.Client", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.Client", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client Client) ListComplete(ctx context.Context, filter string, expand string, top *int32) (result ListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/Client.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx, filter, expand, top) - return -} - -// MoveResources move resources from one resource group to another. The resources being moved should all be in the same -// resource group. -// Parameters: -// sourceResourceGroupName - source resource group name. -// parameters - move resources' parameters. -func (client Client) MoveResources(ctx context.Context, sourceResourceGroupName string, parameters MoveInfo) (result MoveResourcesFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/Client.MoveResources") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: sourceResourceGroupName, - Constraints: []validation.Constraint{{Target: "sourceResourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "sourceResourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "sourceResourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.Client", "MoveResources", err.Error()) - } - - req, err := client.MoveResourcesPreparer(ctx, sourceResourceGroupName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "MoveResources", nil, "Failure preparing request") - return - } - - result, err = client.MoveResourcesSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "MoveResources", result.Response(), "Failure sending request") - return - } - - return -} - -// MoveResourcesPreparer prepares the MoveResources request. -func (client Client) MoveResourcesPreparer(ctx context.Context, sourceResourceGroupName string, parameters MoveInfo) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "sourceResourceGroupName": autorest.Encode("path", sourceResourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// MoveResourcesSender sends the MoveResources request. The method will close the -// http.Response Body if it receives an error. -func (client Client) MoveResourcesSender(req *http.Request) (future MoveResourcesFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// MoveResourcesResponder handles the response to the MoveResources request. The method always -// closes the http.Response Body. -func (client Client) MoveResourcesResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Update updates a resource. -// Parameters: -// resourceGroupName - the name of the resource group for the resource. The name is case insensitive. -// resourceProviderNamespace - the namespace of the resource provider. -// parentResourcePath - the parent resource identity. -// resourceType - the resource type of the resource to update. -// resourceName - the name of the resource to update. -// APIVersion - the API version to use for the operation. -// parameters - parameters for updating the resource. -func (client Client) Update(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string, parameters GenericResource) (result UpdateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/Client.Update") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.Client", "Update", err.Error()) - } - - req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, APIVersion, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "Update", nil, "Failure preparing request") - return - } - - result, err = client.UpdateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "Update", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdatePreparer prepares the Update request. -func (client Client) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string, parameters GenericResource) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "parentResourcePath": parentResourcePath, - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), - "resourceType": resourceType, - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateSender sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (client Client) UpdateSender(req *http.Request) (future UpdateFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// UpdateResponder handles the response to the Update request. The method always -// closes the http.Response Body. -func (client Client) UpdateResponder(resp *http.Response) (result GenericResource, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/tags.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/tags.go deleted file mode 100644 index 3cd6668f18c0..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/tags.go +++ /dev/null @@ -1,442 +0,0 @@ -package resources - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// TagsClient is the client for the Tags methods of the Resources service. -type TagsClient struct { - BaseClient -} - -// NewTagsClient creates an instance of the TagsClient client. -func NewTagsClient(subscriptionID string) TagsClient { - return NewTagsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewTagsClientWithBaseURI creates an instance of the TagsClient client using a custom endpoint. Use this when -// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewTagsClientWithBaseURI(baseURI string, subscriptionID string) TagsClient { - return TagsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdate create a subscription resource tag. -// Parameters: -// tagName - the name of the tag. -func (client TagsClient) CreateOrUpdate(ctx context.Context, tagName string) (result TagDetails, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TagsClient.CreateOrUpdate") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.CreateOrUpdatePreparer(ctx, tagName) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.TagsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.TagsClient", "CreateOrUpdate", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.TagsClient", "CreateOrUpdate", resp, "Failure responding to request") - return - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client TagsClient) CreateOrUpdatePreparer(ctx context.Context, tagName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "tagName": autorest.Encode("path", tagName), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/tagNames/{tagName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client TagsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client TagsClient) CreateOrUpdateResponder(resp *http.Response) (result TagDetails, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateOrUpdateValue create a subscription resource tag value. -// Parameters: -// tagName - the name of the tag. -// tagValue - the value of the tag. -func (client TagsClient) CreateOrUpdateValue(ctx context.Context, tagName string, tagValue string) (result TagValue, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TagsClient.CreateOrUpdateValue") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.CreateOrUpdateValuePreparer(ctx, tagName, tagValue) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.TagsClient", "CreateOrUpdateValue", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateValueSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.TagsClient", "CreateOrUpdateValue", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateValueResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.TagsClient", "CreateOrUpdateValue", resp, "Failure responding to request") - return - } - - return -} - -// CreateOrUpdateValuePreparer prepares the CreateOrUpdateValue request. -func (client TagsClient) CreateOrUpdateValuePreparer(ctx context.Context, tagName string, tagValue string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "tagName": autorest.Encode("path", tagName), - "tagValue": autorest.Encode("path", tagValue), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateValueSender sends the CreateOrUpdateValue request. The method will close the -// http.Response Body if it receives an error. -func (client TagsClient) CreateOrUpdateValueSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateValueResponder handles the response to the CreateOrUpdateValue request. The method always -// closes the http.Response Body. -func (client TagsClient) CreateOrUpdateValueResponder(resp *http.Response) (result TagValue, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete delete a subscription resource tag. -// Parameters: -// tagName - the name of the tag. -func (client TagsClient) Delete(ctx context.Context, tagName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TagsClient.Delete") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.DeletePreparer(ctx, tagName) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.TagsClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "resources.TagsClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.TagsClient", "Delete", resp, "Failure responding to request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client TagsClient) DeletePreparer(ctx context.Context, tagName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "tagName": autorest.Encode("path", tagName), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/tagNames/{tagName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client TagsClient) DeleteSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client TagsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteValue delete a subscription resource tag value. -// Parameters: -// tagName - the name of the tag. -// tagValue - the value of the tag. -func (client TagsClient) DeleteValue(ctx context.Context, tagName string, tagValue string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TagsClient.DeleteValue") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.DeleteValuePreparer(ctx, tagName, tagValue) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.TagsClient", "DeleteValue", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteValueSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "resources.TagsClient", "DeleteValue", resp, "Failure sending request") - return - } - - result, err = client.DeleteValueResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.TagsClient", "DeleteValue", resp, "Failure responding to request") - return - } - - return -} - -// DeleteValuePreparer prepares the DeleteValue request. -func (client TagsClient) DeleteValuePreparer(ctx context.Context, tagName string, tagValue string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "tagName": autorest.Encode("path", tagName), - "tagValue": autorest.Encode("path", tagValue), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteValueSender sends the DeleteValue request. The method will close the -// http.Response Body if it receives an error. -func (client TagsClient) DeleteValueSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteValueResponder handles the response to the DeleteValue request. The method always -// closes the http.Response Body. -func (client TagsClient) DeleteValueResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// List get a list of subscription resource tags. -func (client TagsClient) List(ctx context.Context) (result TagsListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TagsClient.List") - defer func() { - sc := -1 - if result.tlr.Response.Response != nil { - sc = result.tlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.TagsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.tlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.TagsClient", "List", resp, "Failure sending request") - return - } - - result.tlr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.TagsClient", "List", resp, "Failure responding to request") - return - } - if result.tlr.hasNextLink() && result.tlr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListPreparer prepares the List request. -func (client TagsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-02-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/tagNames", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client TagsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client TagsClient) ListResponder(resp *http.Response) (result TagsListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client TagsClient) listNextResults(ctx context.Context, lastResults TagsListResult) (result TagsListResult, err error) { - req, err := lastResults.tagsListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.TagsClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.TagsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.TagsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client TagsClient) ListComplete(ctx context.Context) (result TagsListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TagsClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/version.go deleted file mode 100644 index a83a12b96ec2..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/version.go +++ /dev/null @@ -1,19 +0,0 @@ -package resources - -import "github.com/Azure/azure-sdk-for-go/version" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -// UserAgent returns the UserAgent string to use when sending http.Requests. -func UserAgent() string { - return "Azure-SDK-For-Go/" + Version() + " resources/2016-02-01" -} - -// Version returns the semantic version (see http://semver.org) of the client. -func Version() string { - return version.Number -} diff --git a/vendor/modules.txt b/vendor/modules.txt index cce4c227cb86..252dd73854a2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,6 +1,5 @@ # github.com/Azure/azure-sdk-for-go v66.0.0+incompatible ## explicit -github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources github.com/Azure/azure-sdk-for-go/services/aad/mgmt/2017-04-01/aad github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement github.com/Azure/azure-sdk-for-go/services/appinsights/mgmt/2020-02-02/insights @@ -33,7 +32,6 @@ github.com/Azure/azure-sdk-for-go/services/preview/synapse/mgmt/v2.0/synapse github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2018-07-10/siterecovery github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2021-12-01/backup github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2015-12-01/features -github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-06-01/resources From 8f329765ee5536721841bffbd42ce954f96a626e Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Mon, 8 May 2023 11:26:59 +0200 Subject: [PATCH 6/9] resourceproviders: polling at 10s intervals to ensure these are registered --- internal/provider/provider.go | 6 +++++- internal/resourceproviders/cache.go | 5 +++++ .../resource_provider_register_poller.go | 7 +++++-- .../resource_provider_unregister_poller.go | 7 +++++-- internal/resourceproviders/registration.go | 15 ++++++++++++++- .../resource_provider_registration_resource.go | 2 +- ...esource_provider_registration_resource_test.go | 2 +- 7 files changed, 36 insertions(+), 8 deletions(-) rename internal/{services/resource => resourceproviders}/custompollers/resource_provider_register_poller.go (87%) rename internal/{services/resource => resourceproviders}/custompollers/resource_provider_unregister_poller.go (87%) diff --git a/internal/provider/provider.go b/internal/provider/provider.go index b7ec6f40d657..e3a406d9f734 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -8,6 +8,7 @@ import ( "log" "os" "strings" + "time" "github.com/hashicorp/go-azure-sdk/sdk/auth" "github.com/hashicorp/go-azure-sdk/sdk/environments" @@ -458,7 +459,10 @@ func buildClient(ctx context.Context, p *schema.Provider, d *schema.ResourceData if !skipProviderRegistration { subscriptionId := commonids.NewSubscriptionID(client.Account.SubscriptionId) requiredResourceProviders := resourceproviders.Required() - if err := resourceproviders.EnsureRegistered(ctx, client.Resource.ResourceProvidersClient, subscriptionId, requiredResourceProviders); err != nil { + ctx2, cancel := context.WithTimeout(ctx, 30*time.Minute) + defer cancel() + + if err := resourceproviders.EnsureRegistered(ctx2, client.Resource.ResourceProvidersClient, subscriptionId, requiredResourceProviders); err != nil { return nil, diag.Errorf(resourceProviderRegistrationErrorFmt, err) } } diff --git a/internal/resourceproviders/cache.go b/internal/resourceproviders/cache.go index bf41711196a7..caa5bdaf6e83 100644 --- a/internal/resourceproviders/cache.go +++ b/internal/resourceproviders/cache.go @@ -20,6 +20,11 @@ var cacheLock = &sync.Mutex{} // CacheSupportedProviders attempts to retrieve the supported Resource Providers from the Resource Manager API // and caches them, for used in enhanced validation func CacheSupportedProviders(ctx context.Context, client *providers.ProvidersClient, subscriptionId commonids.SubscriptionId) error { + // already populated + if cachedResourceProviders != nil { + return nil + } + if err := populateCache(ctx, client, subscriptionId); err != nil { return fmt.Errorf("populating cache: %+v", err) } diff --git a/internal/services/resource/custompollers/resource_provider_register_poller.go b/internal/resourceproviders/custompollers/resource_provider_register_poller.go similarity index 87% rename from internal/services/resource/custompollers/resource_provider_register_poller.go rename to internal/resourceproviders/custompollers/resource_provider_register_poller.go index 69125ef04e68..fd59c28cbeca 100644 --- a/internal/services/resource/custompollers/resource_provider_register_poller.go +++ b/internal/resourceproviders/custompollers/resource_provider_register_poller.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "strings" + "time" "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers" "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" @@ -36,12 +37,14 @@ func (p *resourceProviderRegistrationPoller) Poll(ctx context.Context) (*pollers if strings.EqualFold(registrationState, "Registered") { return &pollers.PollResult{ - Status: pollers.PollingStatusSucceeded, + Status: pollers.PollingStatusSucceeded, + PollInterval: 10 * time.Second, }, nil } // Processing return &pollers.PollResult{ - Status: pollers.PollingStatusInProgress, + Status: pollers.PollingStatusInProgress, + PollInterval: 10 * time.Second, }, nil } diff --git a/internal/services/resource/custompollers/resource_provider_unregister_poller.go b/internal/resourceproviders/custompollers/resource_provider_unregister_poller.go similarity index 87% rename from internal/services/resource/custompollers/resource_provider_unregister_poller.go rename to internal/resourceproviders/custompollers/resource_provider_unregister_poller.go index 8588bbfad02b..37b2f7235a81 100644 --- a/internal/services/resource/custompollers/resource_provider_unregister_poller.go +++ b/internal/resourceproviders/custompollers/resource_provider_unregister_poller.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "strings" + "time" "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers" "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" @@ -36,12 +37,14 @@ func (p *resourceProviderUnregistrationPoller) Poll(ctx context.Context) (*polle if strings.EqualFold(registrationState, "Unregistered") { return &pollers.PollResult{ - Status: pollers.PollingStatusSucceeded, + Status: pollers.PollingStatusSucceeded, + PollInterval: 10 * time.Second, }, nil } // Processing return &pollers.PollResult{ - Status: pollers.PollingStatusInProgress, + Status: pollers.PollingStatusInProgress, + PollInterval: 10 * time.Second, }, nil } diff --git a/internal/resourceproviders/registration.go b/internal/resourceproviders/registration.go index 875045bf9273..c99a7828d994 100644 --- a/internal/resourceproviders/registration.go +++ b/internal/resourceproviders/registration.go @@ -3,16 +3,19 @@ package resourceproviders import ( "context" "fmt" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/terraform-provider-azurerm/internal/resourceproviders/custompollers" "log" "strings" "sync" + "time" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers" ) func EnsureRegistered(ctx context.Context, client *providers.ProvidersClient, subscriptionId commonids.SubscriptionId, requiredRPs map[string]struct{}) error { - if registeredResourceProviders == nil || unregisteredResourceProviders == nil { + if cachedResourceProviders == nil || registeredResourceProviders == nil || unregisteredResourceProviders == nil { if err := populateCache(ctx, client, subscriptionId); err != nil { return fmt.Errorf("populating Resource Provider cache: %+v", err) } @@ -68,9 +71,19 @@ func registerForSubscription(ctx context.Context, client *providers.ProvidersCli func registerWithSubscription(ctx context.Context, client *providers.ProvidersClient, subscriptionId commonids.SubscriptionId, providerName string) error { providerId := providers.NewSubscriptionProviderID(subscriptionId.SubscriptionId, providerName) + log.Printf("[DEBUG] Registering %s..", providerId) if _, err := client.Register(ctx, providerId, providers.ProviderRegistrationRequest{}); err != nil { return fmt.Errorf("Cannot register provider %s with Azure Resource Manager: %s.", providerName, err) } + log.Printf("[DEBUG] Waiting for %s to finish registering..", providerId) + pollerType := custompollers.NewResourceProviderRegistrationPoller(client, providerId) + poller := pollers.NewPoller(pollerType, 10*time.Second, pollers.DefaultNumberOfDroppedConnectionsToAllow) + if err := poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("waiting for %s to be registered: %s", providerId, err) + } + + log.Printf("[DEBUG] %s is registered.", providerId) + return nil } diff --git a/internal/services/resource/resource_provider_registration_resource.go b/internal/services/resource/resource_provider_registration_resource.go index 7d9410223e55..d6206345520c 100644 --- a/internal/services/resource/resource_provider_registration_resource.go +++ b/internal/services/resource/resource_provider_registration_resource.go @@ -13,8 +13,8 @@ import ( "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/resourceproviders" + "github.com/hashicorp/terraform-provider-azurerm/internal/resourceproviders/custompollers" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/resource/custompollers" "github.com/hashicorp/terraform-provider-azurerm/internal/services/resource/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/resource/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" diff --git a/internal/services/resource/resource_provider_registration_resource_test.go b/internal/services/resource/resource_provider_registration_resource_test.go index 3764e391548a..d4126eaa8a1f 100644 --- a/internal/services/resource/resource_provider_registration_resource_test.go +++ b/internal/services/resource/resource_provider_registration_resource_test.go @@ -15,7 +15,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/testclient" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/resource/custompollers" + "github.com/hashicorp/terraform-provider-azurerm/internal/resourceproviders/custompollers" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) From f1b416a242d72b79e938d4a06aeb27b0b0b6d9c7 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Mon, 8 May 2023 12:08:27 +0200 Subject: [PATCH 7/9] linting --- internal/clients/builder.go | 2 +- internal/provider/provider.go | 4 ++-- internal/resourceproviders/registration.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/clients/builder.go b/internal/clients/builder.go index 213da056df3c..de915bbba85a 100644 --- a/internal/clients/builder.go +++ b/internal/clients/builder.go @@ -3,11 +3,11 @@ package clients import ( "context" "fmt" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "log" "strings" "github.com/hashicorp/go-azure-helpers/authentication" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "github.com/hashicorp/go-azure-sdk/sdk/auth" authWrapper "github.com/hashicorp/go-azure-sdk/sdk/auth/autorest" diff --git a/internal/provider/provider.go b/internal/provider/provider.go index e3a406d9f734..aaca578e31cc 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -4,12 +4,12 @@ import ( "context" "encoding/base64" "fmt" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "log" "os" "strings" "time" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-sdk/sdk/auth" "github.com/hashicorp/go-azure-sdk/sdk/environments" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -461,7 +461,7 @@ func buildClient(ctx context.Context, p *schema.Provider, d *schema.ResourceData requiredResourceProviders := resourceproviders.Required() ctx2, cancel := context.WithTimeout(ctx, 30*time.Minute) defer cancel() - + if err := resourceproviders.EnsureRegistered(ctx2, client.Resource.ResourceProvidersClient, subscriptionId, requiredResourceProviders); err != nil { return nil, diag.Errorf(resourceProviderRegistrationErrorFmt, err) } diff --git a/internal/resourceproviders/registration.go b/internal/resourceproviders/registration.go index c99a7828d994..5b649739a3d2 100644 --- a/internal/resourceproviders/registration.go +++ b/internal/resourceproviders/registration.go @@ -3,8 +3,6 @@ package resourceproviders import ( "context" "fmt" - "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" - "github.com/hashicorp/terraform-provider-azurerm/internal/resourceproviders/custompollers" "log" "strings" "sync" @@ -12,6 +10,8 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/terraform-provider-azurerm/internal/resourceproviders/custompollers" ) func EnsureRegistered(ctx context.Context, client *providers.ProvidersClient, subscriptionId commonids.SubscriptionId, requiredRPs map[string]struct{}) error { From 98c0f5342149c26df42fc7920414cb5c15198b85 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Mon, 8 May 2023 12:35:06 +0200 Subject: [PATCH 8/9] adding a missing fmt value --- .../custompollers/resource_provider_register_poller.go | 2 +- .../custompollers/resource_provider_unregister_poller.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/resourceproviders/custompollers/resource_provider_register_poller.go b/internal/resourceproviders/custompollers/resource_provider_register_poller.go index fd59c28cbeca..5108d4b5750a 100644 --- a/internal/resourceproviders/custompollers/resource_provider_register_poller.go +++ b/internal/resourceproviders/custompollers/resource_provider_register_poller.go @@ -27,7 +27,7 @@ type resourceProviderRegistrationPoller struct { func (p *resourceProviderRegistrationPoller) Poll(ctx context.Context) (*pollers.PollResult, error) { resp, err := p.client.Get(ctx, p.id, providers.DefaultGetOperationOptions()) if err != nil { - return nil, fmt.Errorf("retrieving %s: %+v", err) + return nil, fmt.Errorf("retrieving %s: %+v", p.id, err) } registrationState := "" diff --git a/internal/resourceproviders/custompollers/resource_provider_unregister_poller.go b/internal/resourceproviders/custompollers/resource_provider_unregister_poller.go index 37b2f7235a81..fe8d35bba647 100644 --- a/internal/resourceproviders/custompollers/resource_provider_unregister_poller.go +++ b/internal/resourceproviders/custompollers/resource_provider_unregister_poller.go @@ -27,7 +27,7 @@ type resourceProviderUnregistrationPoller struct { func (p *resourceProviderUnregistrationPoller) Poll(ctx context.Context) (*pollers.PollResult, error) { resp, err := p.client.Get(ctx, p.id, providers.DefaultGetOperationOptions()) if err != nil { - return nil, fmt.Errorf("retrieving %s: %+v", err) + return nil, fmt.Errorf("retrieving %s: %+v", p.id, err) } registrationState := "" From b528f029fcae8e8857f94ebf1d9458d18fa58a90 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Mon, 8 May 2023 12:43:04 +0200 Subject: [PATCH 9/9] r/resource_provider_registration: validating the RP registration state during creation --- .../resource/resource_provider_registration_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/resource/resource_provider_registration_resource.go b/internal/services/resource/resource_provider_registration_resource.go index d6206345520c..d926b4a38dcf 100644 --- a/internal/services/resource/resource_provider_registration_resource.go +++ b/internal/services/resource/resource_provider_registration_resource.go @@ -183,7 +183,7 @@ func (r ResourceProviderRegistrationResource) Update() sdk.ResourceFunc { } registrationState := "" if model := provider.Model; model != nil && model.RegistrationState != nil { - + registrationState = *model.RegistrationState } if registrationState == "" { return fmt.Errorf("retrieving %s: `registrationState` was nil", *resourceId)