diff --git a/azurerm/azurerm_sweeper_test.go b/azurerm/azurerm_sweeper_test.go index 8d5dfa6a1f9f..0dbc318b7ffc 100644 --- a/azurerm/azurerm_sweeper_test.go +++ b/azurerm/azurerm_sweeper_test.go @@ -7,8 +7,8 @@ import ( "strings" "testing" + "github.com/hashicorp/go-azure-helpers/authentication" "github.com/hashicorp/terraform/helper/resource" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/authentication" ) func TestMain(m *testing.M) { diff --git a/azurerm/config.go b/azurerm/config.go index d1d633a800f2..026b088bf36b 100644 --- a/azurerm/config.go +++ b/azurerm/config.go @@ -9,6 +9,7 @@ import ( "sync" "time" + "github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources" appinsights "github.com/Azure/azure-sdk-for-go/services/appinsights/mgmt/2015-05-01/insights" "github.com/Azure/azure-sdk-for-go/services/automation/mgmt/2015-10-31/automation" "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn" @@ -53,7 +54,6 @@ import ( "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-06-01/subscriptions" "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks" "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-12-01/policy" - "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources" "github.com/Azure/azure-sdk-for-go/services/scheduler/mgmt/2016-03-01/scheduler" "github.com/Azure/azure-sdk-for-go/services/search/mgmt/2015-08-19/search" "github.com/Azure/azure-sdk-for-go/services/servicebus/mgmt/2017-04-01/servicebus" @@ -66,9 +66,9 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/adal" az "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/authentication" "github.com/hashicorp/go-uuid" "github.com/hashicorp/terraform/httpclient" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/authentication" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" "github.com/terraform-providers/terraform-provider-azurerm/version" diff --git a/azurerm/data_source_dns_zone.go b/azurerm/data_source_dns_zone.go index 3fa115a048ab..8a741758ce52 100644 --- a/azurerm/data_source_dns_zone.go +++ b/azurerm/data_source_dns_zone.go @@ -4,8 +4,8 @@ import ( "context" "fmt" + "github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources" "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" - "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources" "github.com/hashicorp/terraform/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) diff --git a/azurerm/helpers/authentication/auth_method_azure_cli_parsing_test.go b/azurerm/helpers/authentication/auth_method_azure_cli_parsing_test.go deleted file mode 100644 index c54fa0f7f8e2..000000000000 --- a/azurerm/helpers/authentication/auth_method_azure_cli_parsing_test.go +++ /dev/null @@ -1,157 +0,0 @@ -package authentication - -import ( - "testing" - - "github.com/Azure/go-autorest/autorest/adal" -) - -func TestAzureCLIParsingAuth_isApplicable(t *testing.T) { - cases := []struct { - Description string - Builder Builder - Valid bool - }{ - { - Description: "Empty Configuration", - Builder: Builder{}, - Valid: false, - }, - { - Description: "Feature Toggled off", - Builder: Builder{ - SupportsAzureCliCloudShellParsing: false, - }, - Valid: false, - }, - { - Description: "Feature Toggled on", - Builder: Builder{ - SupportsAzureCliCloudShellParsing: true, - }, - Valid: true, - }, - } - - for _, v := range cases { - applicable := azureCliParsingAuth{}.isApplicable(v.Builder) - if v.Valid != applicable { - t.Fatalf("Expected %q to be %t but got %t", v.Description, v.Valid, applicable) - } - } -} - -func TestAzureCLIParsingAuth_populateConfig(t *testing.T) { - config := &Config{} - auth := azureCliParsingAuth{ - profile: &azureCLIProfile{ - clientId: "some-subscription-id", - environment: "dimension-c137", - subscriptionId: "some-subscription-id", - tenantId: "some-tenant-id", - }, - } - - err := auth.populateConfig(config) - if err != nil { - t.Fatalf("Error populating config: %s", err) - } - - if auth.profile.clientId != config.ClientID { - t.Fatalf("Expected Client ID to be %q but got %q", auth.profile.tenantId, config.TenantID) - } - - if auth.profile.environment != config.Environment { - t.Fatalf("Expected Environment to be %q but got %q", auth.profile.tenantId, config.TenantID) - } - - if auth.profile.subscriptionId != config.SubscriptionID { - t.Fatalf("Expected Subscription ID to be %q but got %q", auth.profile.tenantId, config.TenantID) - } - - if auth.profile.tenantId != config.TenantID { - t.Fatalf("Expected Tenant ID to be %q but got %q", auth.profile.tenantId, config.TenantID) - } -} - -func TestAzureCLIParsingAuth_validate(t *testing.T) { - cases := []struct { - Description string - Config azureCliParsingAuth - ExpectError bool - }{ - { - Description: "Empty Configuration", - Config: azureCliParsingAuth{}, - ExpectError: true, - }, - { - Description: "Missing Access Token", - Config: azureCliParsingAuth{ - profile: &azureCLIProfile{ - clientId: "62e73395-5017-43b6-8ebf-d6c30a514cf1", - subscriptionId: "8e8b5e02-5c13-4822-b7dc-4232afb7e8c2", - tenantId: "9834f8d0-24b3-41b7-8b8d-c611c461a129", - }, - }, - ExpectError: true, - }, - { - Description: "Missing Client ID", - Config: azureCliParsingAuth{ - profile: &azureCLIProfile{ - accessToken: &adal.Token{}, - subscriptionId: "8e8b5e02-5c13-4822-b7dc-4232afb7e8c2", - tenantId: "9834f8d0-24b3-41b7-8b8d-c611c461a129", - }, - }, - ExpectError: true, - }, - { - Description: "Missing Subscription ID", - Config: azureCliParsingAuth{ - profile: &azureCLIProfile{ - accessToken: &adal.Token{}, - clientId: "62e73395-5017-43b6-8ebf-d6c30a514cf1", - tenantId: "9834f8d0-24b3-41b7-8b8d-c611c461a129", - }, - }, - ExpectError: true, - }, - { - Description: "Missing Tenant ID", - Config: azureCliParsingAuth{ - profile: &azureCLIProfile{ - accessToken: &adal.Token{}, - clientId: "62e73395-5017-43b6-8ebf-d6c30a514cf1", - subscriptionId: "8e8b5e02-5c13-4822-b7dc-4232afb7e8c2", - }, - }, - ExpectError: true, - }, - { - Description: "Valid Configuration", - Config: azureCliParsingAuth{ - profile: &azureCLIProfile{ - accessToken: &adal.Token{}, - clientId: "62e73395-5017-43b6-8ebf-d6c30a514cf1", - subscriptionId: "8e8b5e02-5c13-4822-b7dc-4232afb7e8c2", - tenantId: "9834f8d0-24b3-41b7-8b8d-c611c461a129", - }, - }, - ExpectError: false, - }, - } - - for _, v := range cases { - err := v.Config.validate() - - if v.ExpectError && err == nil { - t.Fatalf("Expected an error for %q: didn't get one", v.Description) - } - - if !v.ExpectError && err != nil { - t.Fatalf("Expected there to be no error for %q - but got: %v", v.Description, err) - } - } -} diff --git a/azurerm/helpers/authentication/auth_method_client_cert_test.go b/azurerm/helpers/authentication/auth_method_client_cert_test.go deleted file mode 100644 index e67a94fb4340..000000000000 --- a/azurerm/helpers/authentication/auth_method_client_cert_test.go +++ /dev/null @@ -1,217 +0,0 @@ -package authentication - -import ( - "io/ioutil" - "os" - "testing" -) - -func TestServicePrincipalClientCertAuth_builder(t *testing.T) { - builder := Builder{ - ClientID: "some-client-id", - ClientCertPath: "some-client-cert-path", - ClientCertPassword: "some-password", - Environment: "some-environment", - SubscriptionID: "some-subscription-id", - TenantID: "some-tenant-id", - } - config, err := servicePrincipalClientCertificateAuth{}.build(builder) - if err != nil { - t.Fatalf("Error building client cert auth: %s", err) - } - - servicePrincipal := config.(servicePrincipalClientCertificateAuth) - - if builder.ClientID != servicePrincipal.clientId { - t.Fatalf("Expected Client ID to be %q but got %q", builder.ClientID, servicePrincipal.clientId) - } - - if builder.ClientCertPath != servicePrincipal.clientCertPath { - t.Fatalf("Expected Client Certificate Path to be %q but got %q", builder.ClientCertPath, servicePrincipal.clientCertPath) - } - - if builder.ClientCertPassword != servicePrincipal.clientCertPassword { - t.Fatalf("Expected Client Certificate Password to be %q but got %q", builder.ClientCertPassword, servicePrincipal.clientCertPassword) - } - - if builder.SubscriptionID != servicePrincipal.subscriptionId { - t.Fatalf("Expected Subscription ID to be %q but got %q", builder.SubscriptionID, servicePrincipal.subscriptionId) - } - - if builder.TenantID != servicePrincipal.tenantId { - t.Fatalf("Expected Tenant ID to be %q but got %q", builder.TenantID, servicePrincipal.tenantId) - } -} - -func TestServicePrincipalClientCertAuth_isApplicable(t *testing.T) { - cases := []struct { - Description string - Builder Builder - Valid bool - }{ - { - Description: "Empty Configuration", - Builder: Builder{}, - Valid: false, - }, - { - Description: "Feature Toggled off", - Builder: Builder{ - SupportsClientCertAuth: false, - }, - Valid: false, - }, - { - Description: "Feature Toggled on but no cert specified", - Builder: Builder{ - SupportsClientCertAuth: true, - }, - Valid: false, - }, - { - Description: "Cert specified but feature toggled off", - Builder: Builder{ - ClientCertPath: "./path/to/file", - }, - Valid: false, - }, - { - Description: "Valid configuration", - Builder: Builder{ - SupportsClientCertAuth: true, - ClientCertPath: "./path/to/file", - }, - Valid: true, - }, - } - - for _, v := range cases { - applicable := servicePrincipalClientCertificateAuth{}.isApplicable(v.Builder) - if v.Valid != applicable { - t.Fatalf("Expected %q to be %t but got %t", v.Description, v.Valid, applicable) - } - } -} - -func TestServicePrincipalClientCertAuth_populateConfig(t *testing.T) { - config := &Config{} - err := servicePrincipalClientCertificateAuth{}.populateConfig(config) - if err != nil { - t.Fatalf("Error populating config: %s", err) - } - - if !config.AuthenticatedAsAServicePrincipal { - t.Fatalf("Expected `AuthenticatedAsAServicePrincipal` to be true but it wasn't") - } -} - -func TestServicePrincipalClientCertAuth_validate(t *testing.T) { - data := []byte("client-cert-auth") - filePath := "./example.pfx" - err := ioutil.WriteFile(filePath, data, 0600) - if err != nil { - t.Fatal(err) - } - defer os.Remove(filePath) - - cases := []struct { - Description string - Config servicePrincipalClientCertificateAuth - ExpectError bool - }{ - { - Description: "Empty Configuration", - Config: servicePrincipalClientCertificateAuth{}, - ExpectError: true, - }, - { - Description: "Missing Client ID", - Config: servicePrincipalClientCertificateAuth{ - subscriptionId: "8e8b5e02-5c13-4822-b7dc-4232afb7e8c2", - clientCertPath: filePath, - tenantId: "9834f8d0-24b3-41b7-8b8d-c611c461a129", - }, - ExpectError: true, - }, - { - Description: "Missing Subscription ID", - Config: servicePrincipalClientCertificateAuth{ - clientId: "62e73395-5017-43b6-8ebf-d6c30a514cf1", - clientCertPath: filePath, - tenantId: "9834f8d0-24b3-41b7-8b8d-c611c461a129", - }, - ExpectError: true, - }, - { - Description: "Missing Client Certificate Path", - Config: servicePrincipalClientCertificateAuth{ - clientId: "62e73395-5017-43b6-8ebf-d6c30a514cf1", - subscriptionId: "8e8b5e02-5c13-4822-b7dc-4232afb7e8c2", - tenantId: "9834f8d0-24b3-41b7-8b8d-c611c461a129", - }, - ExpectError: true, - }, - { - Description: "Missing Tenant ID", - Config: servicePrincipalClientCertificateAuth{ - clientId: "62e73395-5017-43b6-8ebf-d6c30a514cf1", - subscriptionId: "8e8b5e02-5c13-4822-b7dc-4232afb7e8c2", - clientCertPath: filePath, - }, - ExpectError: true, - }, - { - Description: "File isn't a pfx", - Config: servicePrincipalClientCertificateAuth{ - clientId: "62e73395-5017-43b6-8ebf-d6c30a514cf1", - subscriptionId: "8e8b5e02-5c13-4822-b7dc-4232afb7e8c2", - clientCertPath: "not-valid.txt", - tenantId: "9834f8d0-24b3-41b7-8b8d-c611c461a129", - }, - ExpectError: true, - }, - { - Description: "File does not exist", - Config: servicePrincipalClientCertificateAuth{ - clientId: "62e73395-5017-43b6-8ebf-d6c30a514cf1", - subscriptionId: "8e8b5e02-5c13-4822-b7dc-4232afb7e8c2", - clientCertPath: "does-not-exist.pfx", - tenantId: "9834f8d0-24b3-41b7-8b8d-c611c461a129", - }, - ExpectError: true, - }, - { - Description: "Valid Configuration (Basic)", - Config: servicePrincipalClientCertificateAuth{ - clientId: "62e73395-5017-43b6-8ebf-d6c30a514cf1", - subscriptionId: "8e8b5e02-5c13-4822-b7dc-4232afb7e8c2", - clientCertPath: filePath, - tenantId: "9834f8d0-24b3-41b7-8b8d-c611c461a129", - }, - ExpectError: false, - }, - { - Description: "Valid Configuration (Complete)", - Config: servicePrincipalClientCertificateAuth{ - clientId: "62e73395-5017-43b6-8ebf-d6c30a514cf1", - subscriptionId: "8e8b5e02-5c13-4822-b7dc-4232afb7e8c2", - clientCertPath: filePath, - clientCertPassword: "Password1234!", - tenantId: "9834f8d0-24b3-41b7-8b8d-c611c461a129", - }, - ExpectError: false, - }, - } - - for _, v := range cases { - err := v.Config.validate() - - if v.ExpectError && err == nil { - t.Fatalf("Expected an error for %q: didn't get one", v.Description) - } - - if !v.ExpectError && err != nil { - t.Fatalf("Expected there to be no error for %q - but got: %v", v.Description, err) - } - } -} diff --git a/azurerm/helpers/authentication/auth_method_client_secret_test.go b/azurerm/helpers/authentication/auth_method_client_secret_test.go deleted file mode 100644 index 1fcf3005a3a1..000000000000 --- a/azurerm/helpers/authentication/auth_method_client_secret_test.go +++ /dev/null @@ -1,167 +0,0 @@ -package authentication - -import "testing" - -func TestServicePrincipalClientSecretAuth_builder(t *testing.T) { - builder := Builder{ - ClientID: "some-client-id", - ClientSecret: "some-client-secret", - SubscriptionID: "some-subscription-id", - TenantID: "some-tenant-id", - } - config, err := servicePrincipalClientSecretAuth{}.build(builder) - if err != nil { - t.Fatalf("Error building client secret auth: %s", err) - } - servicePrincipal := config.(servicePrincipalClientSecretAuth) - - if builder.ClientID != servicePrincipal.clientId { - t.Fatalf("Expected Client ID to be %q but got %q", builder.ClientID, servicePrincipal.clientId) - } - - if builder.ClientSecret != servicePrincipal.clientSecret { - t.Fatalf("Expected Client Secret to be %q but got %q", builder.ClientSecret, servicePrincipal.clientSecret) - } - - if builder.SubscriptionID != servicePrincipal.subscriptionId { - t.Fatalf("Expected Subscription ID to be %q but got %q", builder.SubscriptionID, servicePrincipal.subscriptionId) - } - - if builder.TenantID != servicePrincipal.tenantId { - t.Fatalf("Expected Tenant ID to be %q but got %q", builder.TenantID, servicePrincipal.tenantId) - } -} - -func TestServicePrincipalClientSecretAuth_isApplicable(t *testing.T) { - cases := []struct { - Description string - Builder Builder - Valid bool - }{ - { - Description: "Empty Configuration", - Builder: Builder{}, - Valid: false, - }, - { - Description: "Feature Toggled off", - Builder: Builder{ - SupportsClientSecretAuth: false, - }, - Valid: false, - }, - { - Description: "Feature Toggled on but no secret specified", - Builder: Builder{ - SupportsClientSecretAuth: true, - }, - Valid: false, - }, - { - Description: "Secret specified but feature toggled off", - Builder: Builder{ - ClientSecret: "I turned myself into a pickle morty!", - }, - Valid: false, - }, - { - Description: "Valid configuration", - Builder: Builder{ - SupportsClientSecretAuth: true, - ClientSecret: "I turned myself into a pickle morty!", - }, - Valid: true, - }, - } - - for _, v := range cases { - applicable := servicePrincipalClientSecretAuth{}.isApplicable(v.Builder) - if v.Valid != applicable { - t.Fatalf("Expected %q to be %t but got %t", v.Description, v.Valid, applicable) - } - } -} - -func TestServicePrincipalClientSecretAuth_populateConfig(t *testing.T) { - config := &Config{} - err := servicePrincipalClientSecretAuth{}.populateConfig(config) - if err != nil { - t.Fatalf("Error populating config: %s", err) - } - - if !config.AuthenticatedAsAServicePrincipal { - t.Fatalf("Expected `AuthenticatedAsAServicePrincipal` to be true but it wasn't") - } -} - -func TestServicePrincipalClientSecretAuth_validate(t *testing.T) { - cases := []struct { - Description string - Config servicePrincipalClientSecretAuth - ExpectError bool - }{ - { - Description: "Empty Configuration", - Config: servicePrincipalClientSecretAuth{}, - ExpectError: true, - }, - { - Description: "Missing Client ID", - Config: servicePrincipalClientSecretAuth{ - subscriptionId: "8e8b5e02-5c13-4822-b7dc-4232afb7e8c2", - clientSecret: "Does Hammer Time have Daylight Savings Time?", - tenantId: "9834f8d0-24b3-41b7-8b8d-c611c461a129", - }, - ExpectError: true, - }, - { - Description: "Missing Subscription ID", - Config: servicePrincipalClientSecretAuth{ - clientId: "62e73395-5017-43b6-8ebf-d6c30a514cf1", - clientSecret: "Does Hammer Time have Daylight Savings Time?", - tenantId: "9834f8d0-24b3-41b7-8b8d-c611c461a129", - }, - ExpectError: true, - }, - { - Description: "Missing Client Secret", - Config: servicePrincipalClientSecretAuth{ - clientId: "62e73395-5017-43b6-8ebf-d6c30a514cf1", - subscriptionId: "8e8b5e02-5c13-4822-b7dc-4232afb7e8c2", - tenantId: "9834f8d0-24b3-41b7-8b8d-c611c461a129", - }, - ExpectError: true, - }, - { - Description: "Missing Tenant ID", - Config: servicePrincipalClientSecretAuth{ - clientId: "62e73395-5017-43b6-8ebf-d6c30a514cf1", - subscriptionId: "8e8b5e02-5c13-4822-b7dc-4232afb7e8c2", - clientSecret: "Does Hammer Time have Daylight Savings Time?", - }, - ExpectError: true, - }, - { - Description: "Valid Configuration", - Config: servicePrincipalClientSecretAuth{ - clientId: "62e73395-5017-43b6-8ebf-d6c30a514cf1", - subscriptionId: "8e8b5e02-5c13-4822-b7dc-4232afb7e8c2", - clientSecret: "Does Hammer Time have Daylight Savings Time?", - tenantId: "9834f8d0-24b3-41b7-8b8d-c611c461a129", - }, - ExpectError: false, - }, - } - - for _, v := range cases { - err := v.Config.validate() - - if v.ExpectError && err == nil { - t.Fatalf("Expected an error for %q: didn't get one", v.Description) - } - - if !v.ExpectError && err != nil { - t.Fatalf("Expected there to be no error for %q - but got: %v", v.Description, err) - } - } -} diff --git a/azurerm/helpers/authentication/auth_method_msi_test.go b/azurerm/helpers/authentication/auth_method_msi_test.go deleted file mode 100644 index f026d89c5c22..000000000000 --- a/azurerm/helpers/authentication/auth_method_msi_test.go +++ /dev/null @@ -1,97 +0,0 @@ -package authentication - -import "testing" - -func TestManagedServiceIdentity_builder(t *testing.T) { - builder := Builder{ - MsiEndpoint: "https://hello-world", - } - - method, err := managedServiceIdentityAuth{}.build(builder) - if err != nil { - t.Fatalf("Error building MSI Identity Auth: %+v", err) - } - - authMethod := method.(managedServiceIdentityAuth) - if builder.MsiEndpoint != authMethod.endpoint { - t.Fatalf("Expected MSI Endpoint to be %q but got %q", builder.MsiEndpoint, authMethod.endpoint) - } -} - -func TestManagedServiceIdentity_isApplicable(t *testing.T) { - cases := []struct { - Description string - Builder Builder - Valid bool - }{ - { - Description: "Empty Configuration", - Builder: Builder{}, - Valid: false, - }, - { - Description: "Feature Toggled off", - Builder: Builder{ - SupportsManagedServiceIdentity: false, - }, - Valid: false, - }, - { - Description: "Feature Toggled on", - Builder: Builder{ - SupportsManagedServiceIdentity: true, - }, - Valid: false, - }, - } - - for _, v := range cases { - applicable := servicePrincipalClientSecretAuth{}.isApplicable(v.Builder) - if v.Valid != applicable { - t.Fatalf("Expected %q to be %t but got %t", v.Description, v.Valid, applicable) - } - } -} - -func TestManagedServiceIdentity_populateConfig(t *testing.T) { - config := &Config{} - err := servicePrincipalClientSecretAuth{}.populateConfig(config) - if err != nil { - t.Fatalf("Error populating config: %s", err) - } - - // nothing to check since it's not doing anything -} - -func TestManagedServiceIdentity_validate(t *testing.T) { - cases := []struct { - Description string - Config managedServiceIdentityAuth - ExpectError bool - }{ - { - Description: "Empty Configuration", - Config: managedServiceIdentityAuth{}, - ExpectError: true, - }, - { - Description: "Valid Configuration", - Config: managedServiceIdentityAuth{ - endpoint: "https://some-location", - }, - ExpectError: false, - }, - } - - for _, v := range cases { - err := v.Config.validate() - - if v.ExpectError && err == nil { - t.Fatalf("Expected an error for %q: didn't get one", v.Description) - } - - if !v.ExpectError && err != nil { - t.Fatalf("Expected there to be no error for %q - but got: %v", v.Description, err) - } - } -} diff --git a/azurerm/helpers/authentication/azure_cli_access_token_test.go b/azurerm/helpers/authentication/azure_cli_access_token_test.go deleted file mode 100644 index 97937a672e1b..000000000000 --- a/azurerm/helpers/authentication/azure_cli_access_token_test.go +++ /dev/null @@ -1,217 +0,0 @@ -package authentication - -import ( - "testing" - "time" - - "github.com/Azure/go-autorest/autorest/azure/cli" -) - -func TestAzureFindValidAccessTokenForTenant_InvalidDate(t *testing.T) { - tenantId := "c056adac-c6a6-4ddf-ab20-0f26d47f7eea" - expectedToken := cli.Token{ - ExpiresOn: "invalid date", - AccessToken: "7cabcf30-8dca-43f9-91e6-fd56dfb8632f", - TokenType: "9b10b986-7a61-4542-8d5a-9fcd96112585", - RefreshToken: "4ec3874d-ee2e-4980-ba47-b5bac11ddb94", - Resource: "https://management.core.windows.net/", - Authority: tenantId, - } - tokens := []cli.Token{expectedToken} - token, err := findValidAccessTokenForTenant(tokens, tenantId) - - if err == nil { - t.Fatalf("Expected an error to be returned but got nil") - } - - if token != nil { - t.Fatalf("Expected Token to be nil but got: %+v", token) - } -} - -func TestAzureFindValidAccessTokenForTenant_Expired(t *testing.T) { - expirationDate := time.Now().Add(time.Minute * -1) - tenantId := "c056adac-c6a6-4ddf-ab20-0f26d47f7eea" - expectedToken := cli.Token{ - ExpiresOn: expirationDate.Format("2006-01-02 15:04:05.999999"), - AccessToken: "7cabcf30-8dca-43f9-91e6-fd56dfb8632f", - TokenType: "9b10b986-7a61-4542-8d5a-9fcd96112585", - RefreshToken: "4ec3874d-ee2e-4980-ba47-b5bac11ddb94", - Resource: "https://management.core.windows.net/", - Authority: tenantId, - } - tokens := []cli.Token{expectedToken} - token, err := findValidAccessTokenForTenant(tokens, tenantId) - - if err == nil { - t.Fatalf("Expected an error to be returned but got nil") - } - - if token != nil { - t.Fatalf("Expected Token to be nil but got: %+v", token) - } -} - -func TestAzureFindValidAccessTokenForTenant_ExpiringIn(t *testing.T) { - minutesToVerify := []int{1, 30, 60} - - for _, minute := range minutesToVerify { - expirationDate := time.Now().Add(time.Minute * time.Duration(minute)) - tenantId := "c056adac-c6a6-4ddf-ab20-0f26d47f7eea" - expectedToken := cli.Token{ - ExpiresOn: expirationDate.Format("2006-01-02 15:04:05.999999"), - AccessToken: "7cabcf30-8dca-43f9-91e6-fd56dfb8632f", - TokenType: "9b10b986-7a61-4542-8d5a-9fcd96112585", - RefreshToken: "4ec3874d-ee2e-4980-ba47-b5bac11ddb94", - Resource: "https://management.core.windows.net/", - Authority: tenantId, - } - tokens := []cli.Token{expectedToken} - token, err := findValidAccessTokenForTenant(tokens, tenantId) - - if err != nil { - t.Fatalf("Expected no error to be returned for minute %d but got %+v", minute, err) - } - - if token == nil { - t.Fatalf("Expected Token to have a value for minute %d but it was nil", minute) - } - - if token.AccessToken.AccessToken != expectedToken.AccessToken { - t.Fatalf("Expected the Access Token to be %q for minute %d but got %q", expectedToken.AccessToken, minute, token.AccessToken.AccessToken) - } - - if token.ClientID != expectedToken.ClientID { - t.Fatalf("Expected the Client ID to be %q for minute %d but got %q", expectedToken.ClientID, minute, token.ClientID) - } - - if token.IsCloudShell { - t.Fatalf("Expected `IsCloudShell` to be false for minute %d but got true", minute) - } - } -} - -func TestAzureFindValidAccessTokenForTenant_InvalidManagementDomain(t *testing.T) { - expirationDate := time.Now().Add(1 * time.Hour) - tenantId := "c056adac-c6a6-4ddf-ab20-0f26d47f7eea" - expectedToken := cli.Token{ - ExpiresOn: expirationDate.Format("2006-01-02 15:04:05.999999"), - AccessToken: "7cabcf30-8dca-43f9-91e6-fd56dfb8632f", - TokenType: "9b10b986-7a61-4542-8d5a-9fcd96112585", - Resource: "https://portal.azure.com/", - Authority: tenantId, - } - tokens := []cli.Token{expectedToken} - token, err := findValidAccessTokenForTenant(tokens, tenantId) - - if err == nil { - t.Fatalf("Expected an error but didn't get one") - } - - if token != nil { - t.Fatalf("Expected Token to be nil but got: %+v", token) - } -} - -func TestAzureFindValidAccessTokenForTenant_DifferentTenant(t *testing.T) { - expirationDate := time.Now().Add(1 * time.Hour) - expectedToken := cli.Token{ - ExpiresOn: expirationDate.Format("2006-01-02 15:04:05.999999"), - AccessToken: "7cabcf30-8dca-43f9-91e6-fd56dfb8632f", - TokenType: "9b10b986-7a61-4542-8d5a-9fcd96112585", - Resource: "https://management.core.windows.net/", - Authority: "9b5095de-5496-4b5e-9bc6-ef2c017b9d35", - } - tokens := []cli.Token{expectedToken} - token, err := findValidAccessTokenForTenant(tokens, "c056adac-c6a6-4ddf-ab20-0f26d47f7eea") - - if err == nil { - t.Fatalf("Expected an error but didn't get one") - } - - if token != nil { - t.Fatalf("Expected Token to be nil but got: %+v", token) - } -} - -func TestAzureFindValidAccessTokenForTenant_ValidFromCloudShell(t *testing.T) { - expirationDate := time.Now().Add(1 * time.Hour) - tenantId := "c056adac-c6a6-4ddf-ab20-0f26d47f7eea" - expectedToken := cli.Token{ - ExpiresOn: expirationDate.Format(time.RFC3339), - AccessToken: "7cabcf30-8dca-43f9-91e6-fd56dfb8632f", - TokenType: "9b10b986-7a61-4542-8d5a-9fcd96112585", - Resource: "https://management.core.windows.net/", - Authority: tenantId, - } - tokens := []cli.Token{expectedToken} - token, err := findValidAccessTokenForTenant(tokens, tenantId) - - if err != nil { - t.Fatalf("Expected no error to be returned but got %+v", err) - } - - if token == nil { - t.Fatalf("Expected Token to have a value but it was nil") - } - - if token.AccessToken.AccessToken != expectedToken.AccessToken { - t.Fatalf("Expected the Access Token to be %q but got %q", expectedToken.AccessToken, token.AccessToken.AccessToken) - } - - if token.ClientID != expectedToken.ClientID { - t.Fatalf("Expected the Client ID to be %q but got %q", expectedToken.ClientID, token.ClientID) - } - - if !token.IsCloudShell { - t.Fatalf("Expected `IsCloudShell` to be true but got false") - } -} - -func TestAzureFindValidAccessTokenForTenant_ValidFromAzureCLI(t *testing.T) { - expirationDate := time.Now().Add(1 * time.Hour) - tenantId := "c056adac-c6a6-4ddf-ab20-0f26d47f7eea" - expectedToken := cli.Token{ - ExpiresOn: expirationDate.Format("2006-01-02 15:04:05.999999"), - AccessToken: "7cabcf30-8dca-43f9-91e6-fd56dfb8632f", - TokenType: "9b10b986-7a61-4542-8d5a-9fcd96112585", - RefreshToken: "4ec3874d-ee2e-4980-ba47-b5bac11ddb94", - Resource: "https://management.core.windows.net/", - Authority: tenantId, - } - tokens := []cli.Token{expectedToken} - token, err := findValidAccessTokenForTenant(tokens, tenantId) - - if err != nil { - t.Fatalf("Expected no error to be returned but got %+v", err) - } - - if token == nil { - t.Fatalf("Expected Token to have a value but it was nil") - } - - if token.AccessToken.AccessToken != expectedToken.AccessToken { - t.Fatalf("Expected the Access Token to be %q but got %q", expectedToken.AccessToken, token.AccessToken.AccessToken) - } - - if token.ClientID != expectedToken.ClientID { - t.Fatalf("Expected the Client ID to be %q but got %q", expectedToken.ClientID, token.ClientID) - } - - if token.IsCloudShell { - t.Fatalf("Expected `IsCloudShell` to be false but got true") - } -} - -func TestAzureFindValidAccessTokenForTenant_NoTokens(t *testing.T) { - tokens := make([]cli.Token, 0) - token, err := findValidAccessTokenForTenant(tokens, "abc123") - - if err == nil { - t.Fatalf("Expected an error but didn't get one") - } - - if token != nil { - t.Fatalf("Expected a null token to be returned but got: %+v", token) - } -} diff --git a/azurerm/helpers/authentication/azure_cli_profile_population_test.go b/azurerm/helpers/authentication/azure_cli_profile_population_test.go deleted file mode 100644 index 8745f5541e72..000000000000 --- a/azurerm/helpers/authentication/azure_cli_profile_population_test.go +++ /dev/null @@ -1,121 +0,0 @@ -package authentication - -import ( - "testing" - - "github.com/Azure/go-autorest/autorest/azure/cli" -) - -func TestAzureCliProfile_populateSubscriptionIdMissing(t *testing.T) { - cliProfile := azureCLIProfile{ - profile: cli.Profile{ - Subscriptions: []cli.Subscription{}, - }, - } - - err := cliProfile.populateSubscriptionID() - if err == nil { - t.Fatalf("Expected an error to be returned - but didn't get one") - } -} - -func TestAzureCliProfile_populateSubscriptionIdNoDefault(t *testing.T) { - cliProfile := azureCLIProfile{ - profile: cli.Profile{ - Subscriptions: []cli.Subscription{ - { - IsDefault: false, - ID: "abc123", - }, - }, - }, - } - - err := cliProfile.populateSubscriptionID() - if err == nil { - t.Fatalf("Expected an error to be returned - but didn't get one") - } -} - -func TestAzureCliProfile_populateSubscriptionIdValid(t *testing.T) { - subscriptionId := "abc123" - cliProfile := azureCLIProfile{ - profile: cli.Profile{ - Subscriptions: []cli.Subscription{ - { - IsDefault: true, - ID: subscriptionId, - }, - }, - }, - } - - err := cliProfile.populateSubscriptionID() - if err != nil { - t.Fatalf("Expected no error to be returned - but got: %+v", err) - } - - if cliProfile.subscriptionId != subscriptionId { - t.Fatalf("Expected the Subscription ID to be %q but got %q", subscriptionId, cliProfile.subscriptionId) - } -} - -func TestAzureCliProfile_populateTenantIdEmpty(t *testing.T) { - cliProfile := azureCLIProfile{ - profile: cli.Profile{ - Subscriptions: []cli.Subscription{}, - }, - } - - err := cliProfile.populateEnvironment() - if err == nil { - t.Fatalf("Expected an error to be returned - but didn't get one") - } -} - -func TestAzureCliProfile_populateTenantIdMissingSubscription(t *testing.T) { - cliProfile := azureCLIProfile{ - subscriptionId: "bcd234", - profile: cli.Profile{ - Subscriptions: []cli.Subscription{ - { - IsDefault: false, - ID: "abc123", - }, - }, - }, - } - - err := cliProfile.populateTenantID() - if err == nil { - t.Fatalf("Expected an error to be returned - but didn't get one") - } -} - -func TestAzureCliProfile_populateTenantIdValid(t *testing.T) { - cliProfile := azureCLIProfile{ - subscriptionId: "abc123", - profile: cli.Profile{ - Subscriptions: []cli.Subscription{ - { - IsDefault: false, - ID: "abc123", - TenantID: "bcd234", - }, - }, - }, - } - - err := cliProfile.populateTenantID() - if err != nil { - t.Fatalf("Expected no error to be returned - but got: %+v", err) - } - - if cliProfile.subscriptionId != "abc123" { - t.Fatalf("Expected Subscription ID to be 'abc123' - got %q", cliProfile.subscriptionId) - } - - if cliProfile.tenantId != "bcd234" { - t.Fatalf("Expected Tenant ID to be 'bcd234' - got %q", cliProfile.tenantId) - } -} diff --git a/azurerm/helpers/authentication/azure_cli_profile_test.go b/azurerm/helpers/authentication/azure_cli_profile_test.go deleted file mode 100644 index 70bcc7a7118d..000000000000 --- a/azurerm/helpers/authentication/azure_cli_profile_test.go +++ /dev/null @@ -1,192 +0,0 @@ -package authentication - -import ( - "testing" - - "github.com/Azure/go-autorest/autorest/azure/cli" -) - -func TestAzureCLIProfileFindDefaultSubscription(t *testing.T) { - cases := []struct { - Description string - Subscriptions []cli.Subscription - ExpectedSubscriptionId string - ExpectError bool - }{ - { - Description: "Empty Subscriptions", - Subscriptions: []cli.Subscription{}, - ExpectError: true, - }, - { - Description: "Single Subscription", - Subscriptions: []cli.Subscription{ - { - ID: "7f68fe06-9404-4db8-a5c7-29639dc4b299", - IsDefault: true, - }, - }, - ExpectError: false, - ExpectedSubscriptionId: "7f68fe06-9404-4db8-a5c7-29639dc4b299", - }, - { - Description: "Multiple Subscriptions with First as the Default", - Subscriptions: []cli.Subscription{ - { - ID: "7f68fe06-9404-4db8-a5c7-29639dc4b299", - IsDefault: true, - }, - { - ID: "f36508bb-53b9-4aad-a2ac-2df86acf0c31", - IsDefault: false, - }, - }, - ExpectError: false, - ExpectedSubscriptionId: "7f68fe06-9404-4db8-a5c7-29639dc4b299", - }, - { - Description: "Multiple Subscriptions with Second as the Default", - Subscriptions: []cli.Subscription{ - { - ID: "7f68fe06-9404-4db8-a5c7-29639dc4b299", - IsDefault: false, - }, - { - ID: "f36508bb-53b9-4aad-a2ac-2df86acf0c31", - IsDefault: true, - }, - }, - ExpectError: false, - ExpectedSubscriptionId: "f36508bb-53b9-4aad-a2ac-2df86acf0c31", - }, - { - Description: "Multiple Subscriptions with None as the Default", - Subscriptions: []cli.Subscription{ - { - ID: "7f68fe06-9404-4db8-a5c7-29639dc4b299", - IsDefault: false, - }, - { - ID: "f36508bb-53b9-4aad-a2ac-2df86acf0c31", - IsDefault: false, - }, - }, - ExpectError: true, - }, - } - - for _, v := range cases { - profile := azureCLIProfile{ - profile: cli.Profile{ - Subscriptions: v.Subscriptions, - }, - } - actualSubscriptionId, err := profile.findDefaultSubscriptionId() - - if v.ExpectError && err == nil { - t.Fatalf("Expected an error for %q: didn't get one", v.Description) - } - - if !v.ExpectError && err != nil { - t.Fatalf("Expected there to be no error for %q - but got: %v", v.Description, err) - } - - if actualSubscriptionId != v.ExpectedSubscriptionId { - t.Fatalf("Expected Subscription ID to be %q - got %q", v.ExpectedSubscriptionId, actualSubscriptionId) - } - } -} - -func TestAzureCLIProfileFindSubscription(t *testing.T) { - cases := []struct { - Description string - Subscriptions []cli.Subscription - SubscriptionIdToSearchFor string - ExpectError bool - }{ - { - Description: "Empty Subscriptions", - Subscriptions: []cli.Subscription{}, - SubscriptionIdToSearchFor: "7f68fe06-9404-4db8-a5c7-29639dc4b299", - ExpectError: true, - }, - { - Description: "Single Subscription", - SubscriptionIdToSearchFor: "7f68fe06-9404-4db8-a5c7-29639dc4b299", - Subscriptions: []cli.Subscription{ - { - ID: "7f68fe06-9404-4db8-a5c7-29639dc4b299", - IsDefault: true, - }, - }, - ExpectError: false, - }, - { - Description: "Finding the default subscription", - SubscriptionIdToSearchFor: "7f68fe06-9404-4db8-a5c7-29639dc4b299", - Subscriptions: []cli.Subscription{ - { - ID: "7f68fe06-9404-4db8-a5c7-29639dc4b299", - IsDefault: true, - }, - { - ID: "f36508bb-53b9-4aad-a2ac-2df86acf0c31", - IsDefault: false, - }, - }, - ExpectError: false, - }, - { - Description: "Finding a non default Subscription", - SubscriptionIdToSearchFor: "7f68fe06-9404-4db8-a5c7-29639dc4b299", - Subscriptions: []cli.Subscription{ - { - ID: "7f68fe06-9404-4db8-a5c7-29639dc4b299", - IsDefault: false, - }, - { - ID: "f36508bb-53b9-4aad-a2ac-2df86acf0c31", - IsDefault: true, - }, - }, - ExpectError: false, - }, - { - Description: "Multiple Subscriptions with None as the Default", - SubscriptionIdToSearchFor: "224f4ca6-117f-4928-bc0f-3df018feba3e", - Subscriptions: []cli.Subscription{ - { - ID: "7f68fe06-9404-4db8-a5c7-29639dc4b299", - IsDefault: false, - }, - { - ID: "f36508bb-53b9-4aad-a2ac-2df86acf0c31", - IsDefault: false, - }, - }, - ExpectError: true, - }, - } - - for _, v := range cases { - profile := azureCLIProfile{ - profile: cli.Profile{ - Subscriptions: v.Subscriptions, - }, - } - - subscription, err := profile.findSubscription(v.SubscriptionIdToSearchFor) - - if v.ExpectError && err == nil { - t.Fatalf("Expected an error for %q: didn't get one", v.Description) - } - - if !v.ExpectError && err != nil { - t.Fatalf("Expected there to be no error for %q - but got: %v", v.Description, err) - } - - if subscription != nil && subscription.ID != v.SubscriptionIdToSearchFor { - t.Fatalf("Expected to find Subscription ID %q - got %q", subscription.ID, v.SubscriptionIdToSearchFor) - } - } -} diff --git a/azurerm/helpers/authentication/environment_test.go b/azurerm/helpers/authentication/environment_test.go deleted file mode 100644 index efe57b7110ca..000000000000 --- a/azurerm/helpers/authentication/environment_test.go +++ /dev/null @@ -1,23 +0,0 @@ -package authentication - -import ( - "testing" -) - -func TestAzureEnvironmentNames(t *testing.T) { - testData := map[string]string{ - "": "public", - "AzureChinaCloud": "china", - "AzureCloud": "public", - "AzureGermanCloud": "german", - "AZUREUSGOVERNMENTCLOUD": "usgovernment", - "AzurePublicCloud": "public", - } - - for input, expected := range testData { - actual := normalizeEnvironmentName(input) - if actual != expected { - t.Fatalf("Expected %q for input %q: got %q!", expected, input, actual) - } - } -} diff --git a/azurerm/helpers/response/response.go b/azurerm/helpers/response/response.go index 210e5dd78489..39114c183a6b 100644 --- a/azurerm/helpers/response/response.go +++ b/azurerm/helpers/response/response.go @@ -2,22 +2,16 @@ package response import ( "net/http" + + "github.com/hashicorp/go-azure-helpers/response" ) +// TODO: deprecate and remove these func WasConflict(resp *http.Response) bool { - return responseWasStatusCode(resp, http.StatusConflict) + return response.WasConflict(resp) } +// TODO: deprecate and remove these func WasNotFound(resp *http.Response) bool { - return responseWasStatusCode(resp, http.StatusNotFound) -} - -func responseWasStatusCode(resp *http.Response, statusCode int) bool { - if r := resp; r != nil { - if r.StatusCode == statusCode { - return true - } - } - - return false + return response.WasNotFound(resp) } diff --git a/azurerm/helpers/response/response_test.go b/azurerm/helpers/response/response_test.go deleted file mode 100644 index 6f0e2be81ff6..000000000000 --- a/azurerm/helpers/response/response_test.go +++ /dev/null @@ -1,65 +0,0 @@ -package response - -import ( - "net/http" - "testing" -) - -func TestConflict_DroppedConnection(t *testing.T) { - resp := http.Response{} - if WasConflict(&resp) { - t.Fatalf("wasConflict should return `false` for a dropped connection") - } -} - -func TestConflcit_StatusCodes(t *testing.T) { - testCases := []struct { - statusCode int - expectedResult bool - }{ - {http.StatusOK, false}, - {http.StatusInternalServerError, false}, - {http.StatusNotFound, false}, - {http.StatusConflict, true}, - } - - for _, test := range testCases { - resp := http.Response{ - StatusCode: test.statusCode, - } - result := WasConflict(&resp) - if test.expectedResult != result { - t.Fatalf("Expected '%+v' for status code '%d' - got '%+v'", - test.expectedResult, test.statusCode, result) - } - } -} - -func TestNotFound_DroppedConnection(t *testing.T) { - resp := http.Response{} - if WasNotFound(&resp) { - t.Fatalf("wasNotFound should return `false` for a dropped connection") - } -} - -func TestNotFound_StatusCodes(t *testing.T) { - testCases := []struct { - statusCode int - expectedResult bool - }{ - {http.StatusOK, false}, - {http.StatusInternalServerError, false}, - {http.StatusNotFound, true}, - } - - for _, test := range testCases { - resp := http.Response{ - StatusCode: test.statusCode, - } - result := WasNotFound(&resp) - if test.expectedResult != result { - t.Fatalf("Expected '%+v' for status code '%d' - got '%+v'", - test.expectedResult, test.statusCode, result) - } - } -} diff --git a/azurerm/provider.go b/azurerm/provider.go index 648a0f84742a..ad332a9b87d1 100644 --- a/azurerm/provider.go +++ b/azurerm/provider.go @@ -7,10 +7,10 @@ import ( "fmt" "strings" + "github.com/hashicorp/go-azure-helpers/authentication" "github.com/hashicorp/terraform/helper/mutexkv" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/terraform" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/authentication" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/suppress" ) diff --git a/azurerm/provider_test.go b/azurerm/provider_test.go index aa738720e0c8..822f70b4c505 100644 --- a/azurerm/provider_test.go +++ b/azurerm/provider_test.go @@ -6,10 +6,10 @@ import ( "testing" "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/authentication" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/terraform" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/authentication" ) var testAccProviders map[string]terraform.ResourceProvider diff --git a/azurerm/required_resource_providers.go b/azurerm/required_resource_providers.go index 1853ab76021b..5c23dc71b7f4 100644 --- a/azurerm/required_resource_providers.go +++ b/azurerm/required_resource_providers.go @@ -4,8 +4,8 @@ import ( "context" "log" - "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/resourceproviders" + "github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources" + "github.com/hashicorp/go-azure-helpers/resourceproviders" ) // requiredResourceProviders returns all of the Resource Providers used by the AzureRM Provider diff --git a/azurerm/required_resource_providers_test.go b/azurerm/required_resource_providers_test.go index f66fe4393795..aac7fed6047e 100644 --- a/azurerm/required_resource_providers_test.go +++ b/azurerm/required_resource_providers_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/davecgh/go-spew/spew" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/resourceproviders" + "github.com/hashicorp/go-azure-helpers/resourceproviders" ) func TestAccAzureRMEnsureRequiredResourceProvidersAreRegistered(t *testing.T) { diff --git a/azurerm/resource_arm_container_registry_migrate_test.go b/azurerm/resource_arm_container_registry_migrate_test.go index 5fb5b81c8594..01896bd41b11 100644 --- a/azurerm/resource_arm_container_registry_migrate_test.go +++ b/azurerm/resource_arm_container_registry_migrate_test.go @@ -6,7 +6,7 @@ import ( "reflect" "testing" - "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources" + "github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources" "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage" "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/terraform" diff --git a/azurerm/resource_arm_resource_group.go b/azurerm/resource_arm_resource_group.go index 92a0f1ed9672..e9e7ae0456ef 100644 --- a/azurerm/resource_arm_resource_group.go +++ b/azurerm/resource_arm_resource_group.go @@ -4,7 +4,7 @@ import ( "fmt" "log" - "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources" + "github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources" "github.com/hashicorp/terraform/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/response" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" diff --git a/azurerm/resource_arm_template_deployment.go b/azurerm/resource_arm_template_deployment.go index b67b0d435420..52e25b3e388e 100644 --- a/azurerm/resource_arm_template_deployment.go +++ b/azurerm/resource_arm_template_deployment.go @@ -9,7 +9,7 @@ import ( "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources" + "github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" 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 new file mode 100644 index 000000000000..c1e080fbdbb8 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources/models.go @@ -0,0 +1,163 @@ +// +build go1.9 + +// Copyright 2018 Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package resources + +import original "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources" + +const ( + DefaultBaseURI = original.DefaultBaseURI +) + +type BaseClient = original.BaseClient +type DeploymentOperationsClient = original.DeploymentOperationsClient +type DeploymentsClient = original.DeploymentsClient +type GroupsClient = original.GroupsClient +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 BasicDependency = original.BasicDependency +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 DeploymentOperationsListResult = original.DeploymentOperationsListResult +type DeploymentOperationsListResultIterator = original.DeploymentOperationsListResultIterator +type DeploymentOperationsListResultPage = original.DeploymentOperationsListResultPage +type DeploymentProperties = original.DeploymentProperties +type DeploymentPropertiesExtended = original.DeploymentPropertiesExtended +type DeploymentsCreateOrUpdateFuture = original.DeploymentsCreateOrUpdateFuture +type DeploymentsDeleteFuture = original.DeploymentsDeleteFuture +type DeploymentValidateResult = original.DeploymentValidateResult +type ExportTemplateRequest = original.ExportTemplateRequest +type GenericResource = original.GenericResource +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 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 Resource = original.Resource +type Sku = original.Sku +type SubResource = original.SubResource +type TagCount = original.TagCount +type TagDetails = original.TagDetails +type TagsListResult = original.TagsListResult +type TagsListResultIterator = original.TagsListResultIterator +type TagsListResultPage = original.TagsListResultPage +type TagValue = original.TagValue +type TargetResource = original.TargetResource +type TemplateLink = original.TemplateLink +type UpdateFuture = original.UpdateFuture +type ProvidersClient = original.ProvidersClient +type Client = original.Client +type TagsClient = original.TagsClient + +func New(subscriptionID string) BaseClient { + return original.New(subscriptionID) +} +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return original.NewWithBaseURI(baseURI, subscriptionID) +} +func NewDeploymentOperationsClient(subscriptionID string) DeploymentOperationsClient { + return original.NewDeploymentOperationsClient(subscriptionID) +} +func NewDeploymentOperationsClientWithBaseURI(baseURI string, subscriptionID string) DeploymentOperationsClient { + return original.NewDeploymentOperationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewDeploymentsClient(subscriptionID string) DeploymentsClient { + return original.NewDeploymentsClient(subscriptionID) +} +func NewDeploymentsClientWithBaseURI(baseURI string, subscriptionID string) DeploymentsClient { + return original.NewDeploymentsClientWithBaseURI(baseURI, subscriptionID) +} +func NewGroupsClient(subscriptionID string) GroupsClient { + return original.NewGroupsClient(subscriptionID) +} +func NewGroupsClientWithBaseURI(baseURI string, subscriptionID string) GroupsClient { + return original.NewGroupsClientWithBaseURI(baseURI, subscriptionID) +} +func PossibleDeploymentModeValues() []DeploymentMode { + return original.PossibleDeploymentModeValues() +} +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return original.PossibleResourceIdentityTypeValues() +} +func NewProvidersClient(subscriptionID string) ProvidersClient { + return original.NewProvidersClient(subscriptionID) +} +func NewProvidersClientWithBaseURI(baseURI string, subscriptionID string) ProvidersClient { + return original.NewProvidersClientWithBaseURI(baseURI, subscriptionID) +} +func NewClient(subscriptionID string) Client { + return original.NewClient(subscriptionID) +} +func NewClientWithBaseURI(baseURI string, subscriptionID string) Client { + return original.NewClientWithBaseURI(baseURI, subscriptionID) +} +func NewTagsClient(subscriptionID string) TagsClient { + return original.NewTagsClient(subscriptionID) +} +func NewTagsClientWithBaseURI(baseURI string, subscriptionID string) TagsClient { + return original.NewTagsClientWithBaseURI(baseURI, subscriptionID) +} +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/2017-05-10/resources/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/client.go similarity index 94% rename from vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/client.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/client.go index 0f1914aa28e0..a25b93f1110e 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/client.go @@ -1,6 +1,6 @@ -// Package resources implements the Azure ARM Resources service API version 2017-05-10. +// Package resources implements the Azure ARM Resources service API version 2016-02-01. +// // -// Provides operations for working with resources and resource groups. package resources // Copyright (c) Microsoft and contributors. All rights reserved. diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/deploymentoperations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/deploymentoperations.go similarity index 88% rename from vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/deploymentoperations.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/deploymentoperations.go index 7ca7a807d32a..215e1ffbadfd 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/deploymentoperations.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/deploymentoperations.go @@ -25,7 +25,7 @@ import ( "net/http" ) -// DeploymentOperationsClient is the provides operations for working with resources and resource groups. +// DeploymentOperationsClient is the client for the DeploymentOperations methods of the Resources service. type DeploymentOperationsClient struct { BaseClient } @@ -40,21 +40,17 @@ func NewDeploymentOperationsClientWithBaseURI(baseURI string, subscriptionID str return DeploymentOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} } -// Get gets a deployments operation. +// 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 - the ID of the operation to get. +// operationID - operation Id. func (client DeploymentOperationsClient) Get(ctx context.Context, resourceGroupName string, deploymentName string, operationID string) (result DeploymentOperation, err error) { 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: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: deploymentName, - Constraints: []validation.Constraint{{Target: "deploymentName", Name: validation.MaxLength, Rule: 64, Chain: nil}, - {Target: "deploymentName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "deploymentName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { return result, validation.NewError("resources.DeploymentOperationsClient", "Get", err.Error()) } @@ -88,7 +84,7 @@ func (client DeploymentOperationsClient) GetPreparer(ctx context.Context, resour "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -121,21 +117,17 @@ func (client DeploymentOperationsClient) GetResponder(resp *http.Response) (resu return } -// List gets all deployments operations for a deployment. +// 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 with the operation to get. -// top - the number of results to return. +// 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 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: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: deploymentName, - Constraints: []validation.Constraint{{Target: "deploymentName", Name: validation.MaxLength, Rule: 64, Chain: nil}, - {Target: "deploymentName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "deploymentName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { return result, validation.NewError("resources.DeploymentOperationsClient", "List", err.Error()) } @@ -169,7 +161,7 @@ func (client DeploymentOperationsClient) ListPreparer(ctx context.Context, resou "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/deployments.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/deployments.go similarity index 76% rename from vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/deployments.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/deployments.go index 1c767e9d1018..db4c7ca6a44c 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/deployments.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/deployments.go @@ -25,7 +25,7 @@ import ( "net/http" ) -// DeploymentsClient is the provides operations for working with resources and resource groups. +// DeploymentsClient is the client for the Deployments methods of the Resources service. type DeploymentsClient struct { BaseClient } @@ -40,22 +40,16 @@ func NewDeploymentsClientWithBaseURI(baseURI string, subscriptionID string) Depl return DeploymentsClient{NewWithBaseURI(baseURI, subscriptionID)} } -// Cancel you can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is -// canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running -// template deployment and leaves the resource group partially deployed. +// 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 to cancel. +// deploymentName - the name of the deployment. func (client DeploymentsClient) Cancel(ctx context.Context, resourceGroupName string, deploymentName string) (result autorest.Response, err error) { 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: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: deploymentName, - Constraints: []validation.Constraint{{Target: "deploymentName", Name: validation.MaxLength, Rule: 64, Chain: nil}, - {Target: "deploymentName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "deploymentName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { return result, validation.NewError("resources.DeploymentsClient", "Cancel", err.Error()) } @@ -88,7 +82,7 @@ func (client DeploymentsClient) CancelPreparer(ctx context.Context, resourceGrou "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -120,21 +114,16 @@ func (client DeploymentsClient) CancelResponder(resp *http.Response) (result aut return } -// CheckExistence checks whether the deployment exists. +// CheckExistence checks whether deployment exists. // Parameters: -// resourceGroupName - the name of the resource group with the deployment to check. The name is case -// insensitive. -// deploymentName - the name of the deployment to check. +// 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 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: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: deploymentName, - Constraints: []validation.Constraint{{Target: "deploymentName", Name: validation.MaxLength, Rule: 64, Chain: nil}, - {Target: "deploymentName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "deploymentName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { return result, validation.NewError("resources.DeploymentsClient", "CheckExistence", err.Error()) } @@ -167,7 +156,7 @@ func (client DeploymentsClient) CheckExistencePreparer(ctx context.Context, reso "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -199,10 +188,9 @@ func (client DeploymentsClient) CheckExistenceResponder(resp *http.Response) (re return } -// CreateOrUpdate you can provide the template and parameters directly in the request or link to JSON files. +// CreateOrUpdate create a named template deployment using a template. // Parameters: -// resourceGroupName - the name of the resource group to deploy the resources to. The name is case insensitive. -// The resource group must already exist. +// 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) { @@ -211,12 +199,8 @@ func (client DeploymentsClient) CreateOrUpdate(ctx context.Context, resourceGrou 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: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: deploymentName, - Constraints: []validation.Constraint{{Target: "deploymentName", Name: validation.MaxLength, Rule: 64, Chain: nil}, - {Target: "deploymentName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "deploymentName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.Properties", Name: validation.Null, Rule: true, + 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, @@ -248,7 +232,7 @@ func (client DeploymentsClient) CreateOrUpdatePreparer(ctx context.Context, reso "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -289,27 +273,16 @@ func (client DeploymentsClient) CreateOrUpdateResponder(resp *http.Response) (re return } -// Delete a template deployment that is currently running cannot be deleted. Deleting a template deployment removes the -// associated deployment operations. Deleting a template deployment does not affect the state of the resource group. -// This is an asynchronous operation that returns a status of 202 until the template deployment is successfully -// deleted. The Location response header contains the URI that is used to obtain the status of the process. While the -// process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the -// URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the -// Location header returns an error-level status code. +// Delete delete deployment. // Parameters: -// resourceGroupName - the name of the resource group with the deployment to delete. The name is case -// insensitive. -// deploymentName - the name of the deployment to delete. +// 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 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: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: deploymentName, - Constraints: []validation.Constraint{{Target: "deploymentName", Name: validation.MaxLength, Rule: 64, Chain: nil}, - {Target: "deploymentName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "deploymentName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { return result, validation.NewError("resources.DeploymentsClient", "Delete", err.Error()) } @@ -336,7 +309,7 @@ func (client DeploymentsClient) DeletePreparer(ctx context.Context, resourceGrou "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -374,20 +347,16 @@ func (client DeploymentsClient) DeleteResponder(resp *http.Response) (result aut return } -// ExportTemplate exports the template used for specified deployment. +// ExportTemplate exports a deployment template. // Parameters: // resourceGroupName - the name of the resource group. The name is case insensitive. -// deploymentName - the name of the deployment from which to get the template. +// deploymentName - the name of the deployment. func (client DeploymentsClient) ExportTemplate(ctx context.Context, resourceGroupName string, deploymentName string) (result DeploymentExportResult, err error) { 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: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: deploymentName, - Constraints: []validation.Constraint{{Target: "deploymentName", Name: validation.MaxLength, Rule: 64, Chain: nil}, - {Target: "deploymentName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "deploymentName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { return result, validation.NewError("resources.DeploymentsClient", "ExportTemplate", err.Error()) } @@ -420,7 +389,7 @@ func (client DeploymentsClient) ExportTemplatePreparer(ctx context.Context, reso "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -453,20 +422,16 @@ func (client DeploymentsClient) ExportTemplateResponder(resp *http.Response) (re return } -// Get gets a deployment. +// Get get a deployment. // Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// deploymentName - the name of the deployment to get. +// 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 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: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: deploymentName, - Constraints: []validation.Constraint{{Target: "deploymentName", Name: validation.MaxLength, Rule: 64, Chain: nil}, - {Target: "deploymentName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "deploymentName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { return result, validation.NewError("resources.DeploymentsClient", "Get", err.Error()) } @@ -499,7 +464,7 @@ func (client DeploymentsClient) GetPreparer(ctx context.Context, resourceGroupNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -532,52 +497,50 @@ func (client DeploymentsClient) GetResponder(resp *http.Response) (result Deploy return } -// ListByResourceGroup get all the deployments for a resource group. +// List get a list of deployments. // Parameters: -// resourceGroupName - the name of the resource group with the deployments to get. The name is case -// insensitive. -// filter - the filter to apply on the operation. For example, you can use $filter=provisioningState eq -// '{state}'. -// top - the number of results to get. If null is passed, returns all deployments. -func (client DeploymentsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string, top *int32) (result DeploymentListResultPage, err error) { +// 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 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: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.DeploymentsClient", "ListByResourceGroup", err.Error()) + return result, validation.NewError("resources.DeploymentsClient", "List", err.Error()) } - result.fn = client.listByResourceGroupNextResults - req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, filter, top) + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, filter, top) if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "List", nil, "Failure preparing request") return } - resp, err := client.ListByResourceGroupSender(req) + resp, err := client.ListSender(req) if err != nil { result.dlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "List", resp, "Failure sending request") return } - result.dlr, err = client.ListByResourceGroupResponder(resp) + result.dlr, err = client.ListResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "ListByResourceGroup", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "List", resp, "Failure responding to request") } return } -// ListByResourceGroupPreparer prepares the ListByResourceGroup request. -func (client DeploymentsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string, top *int32) (*http.Request, error) { +// 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 = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -596,16 +559,16 @@ func (client DeploymentsClient) ListByResourceGroupPreparer(ctx context.Context, return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// ListSender sends the List request. The method will close the // http.Response Body if it receives an error. -func (client DeploymentsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { +func (client DeploymentsClient) ListSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req, azure.DoRetryWithRegistration(client.Client)) } -// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// ListResponder handles the response to the List request. The method always // closes the http.Response Body. -func (client DeploymentsClient) ListByResourceGroupResponder(resp *http.Response) (result DeploymentListResult, err error) { +func (client DeploymentsClient) ListResponder(resp *http.Response) (result DeploymentListResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -616,52 +579,46 @@ func (client DeploymentsClient) ListByResourceGroupResponder(resp *http.Response return } -// listByResourceGroupNextResults retrieves the next set of results, if any. -func (client DeploymentsClient) listByResourceGroupNextResults(lastResults DeploymentListResult) (result DeploymentListResult, err error) { +// listNextResults retrieves the next set of results, if any. +func (client DeploymentsClient) listNextResults(lastResults DeploymentListResult) (result DeploymentListResult, err error) { req, err := lastResults.deploymentListResultPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "listNextResults", nil, "Failure preparing next results request") } if req == nil { return } - resp, err := client.ListByResourceGroupSender(req) + resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "listNextResults", resp, "Failure sending next results request") } - result, err = client.ListByResourceGroupResponder(resp) + result, err = client.ListResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "listNextResults", resp, "Failure responding to next results request") } return } -// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. -func (client DeploymentsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string, top *int32) (result DeploymentListResultIterator, err error) { - result.page, err = client.ListByResourceGroup(ctx, resourceGroupName, filter, top) +// 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) { + result.page, err = client.List(ctx, resourceGroupName, filter, top) return } -// Validate validates whether the specified template is syntactically correct and will be accepted by Azure Resource -// Manager.. +// Validate validate a deployment template. // Parameters: -// resourceGroupName - the name of the resource group the template will be deployed to. The name is case -// insensitive. +// resourceGroupName - the name of the resource group. The name is case insensitive. // deploymentName - the name of the deployment. -// parameters - parameters to validate. +// parameters - deployment to validate. func (client DeploymentsClient) Validate(ctx context.Context, resourceGroupName string, deploymentName string, parameters Deployment) (result DeploymentValidateResult, err error) { 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: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: deploymentName, - Constraints: []validation.Constraint{{Target: "deploymentName", Name: validation.MaxLength, Rule: 64, Chain: nil}, - {Target: "deploymentName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "deploymentName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.Properties", Name: validation.Null, Rule: true, + 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, @@ -699,7 +656,7 @@ func (client DeploymentsClient) ValidatePreparer(ctx context.Context, resourceGr "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/groups.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/groups.go similarity index 74% rename from vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/groups.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/groups.go index 15650baac745..f4d05a1b48c3 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/groups.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/groups.go @@ -25,7 +25,7 @@ import ( "net/http" ) -// GroupsClient is the provides operations for working with resources and resource groups. +// GroupsClient is the client for the Groups methods of the Resources service. type GroupsClient struct { BaseClient } @@ -40,7 +40,7 @@ func NewGroupsClientWithBaseURI(baseURI string, subscriptionID string) GroupsCli return GroupsClient{NewWithBaseURI(baseURI, subscriptionID)} } -// CheckExistence checks whether a resource group exists. +// 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) { @@ -80,7 +80,7 @@ func (client GroupsClient) CheckExistencePreparer(ctx context.Context, resourceG "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -112,10 +112,10 @@ func (client GroupsClient) CheckExistenceResponder(resp *http.Response) (result return } -// CreateOrUpdate creates or updates a resource group. +// CreateOrUpdate create a resource group. // Parameters: -// resourceGroupName - the name of the resource group to create or update. -// parameters - parameters supplied to the create or update a resource group. +// 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 err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, @@ -155,7 +155,7 @@ func (client GroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceG "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -190,10 +190,9 @@ func (client GroupsClient) CreateOrUpdateResponder(resp *http.Response) (result return } -// Delete when you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes -// all of its template deployments and currently stored operations. +// Delete delete resource group. // Parameters: -// resourceGroupName - the name of the resource group to delete. The name is case insensitive. +// 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 err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, @@ -225,7 +224,7 @@ func (client GroupsClient) DeletePreparer(ctx context.Context, resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -265,8 +264,8 @@ func (client GroupsClient) DeleteResponder(resp *http.Response) (result autorest // ExportTemplate captures the specified resource group as a template. // Parameters: -// resourceGroupName - the name of the resource group to export as a template. -// parameters - parameters for exporting the template. +// 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 err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, @@ -304,7 +303,7 @@ func (client GroupsClient) ExportTemplatePreparer(ctx context.Context, resourceG "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -339,7 +338,7 @@ func (client GroupsClient) ExportTemplateResponder(resp *http.Response) (result return } -// Get gets a resource group. +// 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) { @@ -379,7 +378,7 @@ func (client GroupsClient) GetPreparer(ctx context.Context, resourceGroupName st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -412,10 +411,10 @@ func (client GroupsClient) GetResponder(resp *http.Response) (result Group, err return } -// List gets all the resource groups for a subscription. +// List gets a collection of resource groups. // Parameters: // filter - the filter to apply on the operation. -// top - the number of results to return. If null is passed, returns all resource groups. +// 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) { result.fn = client.listNextResults req, err := client.ListPreparer(ctx, filter, top) @@ -445,7 +444,7 @@ func (client GroupsClient) ListPreparer(ctx context.Context, filter string, top "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -511,49 +510,163 @@ func (client GroupsClient) ListComplete(ctx context.Context, filter string, top return } -// Update 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 group. If a field is unspecified, the current value is retained. +// ListResources get all of the resources under a subscription. // Parameters: -// resourceGroupName - the name of the resource group to update. The name is case insensitive. -// parameters - parameters supplied to update a resource group. -func (client GroupsClient) Update(ctx context.Context, resourceGroupName string, parameters GroupPatchable) (result Group, err error) { +// resourceGroupName - query parameters. If null is passed returns all resource groups. +// filter - the filter to apply on the operation. +// expand - the $expand query parameter +// 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 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: `^[-\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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults ListResult) (result ListResult, err error) { + req, err := lastResults.listResultPreparer() + 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) { + 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 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: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.GroupsClient", "Update", err.Error()) + return result, validation.NewError("resources.GroupsClient", "Patch", err.Error()) } - req, err := client.UpdatePreparer(ctx, resourceGroupName, parameters) + req, err := client.PatchPreparer(ctx, resourceGroupName, parameters) if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Patch", nil, "Failure preparing request") return } - resp, err := client.UpdateSender(req) + resp, err := client.PatchSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Patch", resp, "Failure sending request") return } - result, err = client.UpdateResponder(resp) + result, err = client.PatchResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Update", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Patch", resp, "Failure responding to request") } return } -// UpdatePreparer prepares the Update request. -func (client GroupsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, parameters GroupPatchable) (*http.Request, error) { +// 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 = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -568,16 +681,16 @@ func (client GroupsClient) UpdatePreparer(ctx context.Context, resourceGroupName return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// UpdateSender sends the Update request. The method will close the +// PatchSender sends the Patch request. The method will close the // http.Response Body if it receives an error. -func (client GroupsClient) UpdateSender(req *http.Request) (*http.Response, error) { +func (client GroupsClient) PatchSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req, azure.DoRetryWithRegistration(client.Client)) } -// UpdateResponder handles the response to the Update request. The method always +// PatchResponder handles the response to the Patch request. The method always // closes the http.Response Body. -func (client GroupsClient) UpdateResponder(resp *http.Response) (result Group, err error) { +func (client GroupsClient) PatchResponder(resp *http.Response) (result Group, err error) { err = autorest.Respond( resp, client.ByInspecting(), diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/models.go similarity index 77% rename from vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/models.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/models.go index 691edfa3597e..bf84a5d4c614 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/models.go @@ -54,15 +54,15 @@ func PossibleResourceIdentityTypeValues() []ResourceIdentityType { return []ResourceIdentityType{SystemAssigned} } -// AliasPathType the type of the paths for alias. +// AliasPathType ... type AliasPathType struct { // Path - The path of an alias. Path *string `json:"path,omitempty"` - // APIVersions - The API versions. + // APIVersions - The api versions. APIVersions *[]string `json:"apiVersions,omitempty"` } -// AliasType the alias type. +// AliasType ... type AliasType struct { // Name - The alias name. Name *string `json:"name,omitempty"` @@ -80,112 +80,12 @@ type BasicDependency struct { ResourceName *string `json:"resourceName,omitempty"` } -// CreateOrUpdateByIDFuture an abstraction for monitoring and retrieving the results of a long-running operation. -type CreateOrUpdateByIDFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *CreateOrUpdateByIDFuture) Result(client Client) (gr GenericResource, err error) { - var done bool - done, err = future.Done(client) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.CreateOrUpdateByIDFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("resources.CreateOrUpdateByIDFuture") - 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.CreateOrUpdateByIDResponder(gr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.CreateOrUpdateByIDFuture", "Result", gr.Response.Response, "Failure responding to request") - } - } - return -} - -// CreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. -type CreateOrUpdateFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *CreateOrUpdateFuture) Result(client Client) (gr GenericResource, err error) { - var done bool - done, err = future.Done(client) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.CreateOrUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("resources.CreateOrUpdateFuture") - 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.CreateOrUpdateResponder(gr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.CreateOrUpdateFuture", "Result", gr.Response.Response, "Failure responding to request") - } - } - return -} - // DebugSetting ... type DebugSetting struct { - // DetailLevel - Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. + // DetailLevel - The debug detail level. DetailLevel *string `json:"detailLevel,omitempty"` } -// DeleteByIDFuture an abstraction for monitoring and retrieving the results of a long-running operation. -type DeleteByIDFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DeleteByIDFuture) Result(client Client) (ar autorest.Response, err error) { - var done bool - done, err = future.Done(client) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeleteByIDFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("resources.DeleteByIDFuture") - return - } - ar.Response = future.Response() - return -} - -// DeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. -type DeleteFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DeleteFuture) Result(client Client) (ar autorest.Response, err error) { - var done bool - done, err = future.Done(client) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("resources.DeleteFuture") - return - } - ar.Response = future.Response() - return -} - // Dependency deployment dependency information. type Dependency struct { // DependsOn - The list of dependencies. @@ -204,7 +104,7 @@ type Deployment struct { Properties *DeploymentProperties `json:"properties,omitempty"` } -// DeploymentExportResult the deployment export result. +// DeploymentExportResult ... type DeploymentExportResult struct { autorest.Response `json:"-"` // Template - The template content. @@ -231,9 +131,9 @@ type DeploymentExtendedFilter struct { // DeploymentListResult list of deployments. type DeploymentListResult struct { autorest.Response `json:"-"` - // Value - An array of deployments. + // Value - The list of deployments. Value *[]DeploymentExtended `json:"value,omitempty"` - // NextLink - The URL to use for getting the next set of results. + // NextLink - The URL to get the next set of results. NextLink *string `json:"nextLink,omitempty"` } @@ -333,9 +233,9 @@ func (page DeploymentListResultPage) Values() []DeploymentExtended { // DeploymentOperation deployment operation information. type DeploymentOperation struct { autorest.Response `json:"-"` - // ID - Full deployment operation ID. + // ID - Full deployment operation id. ID *string `json:"id,omitempty"` - // OperationID - Deployment operation ID. + // OperationID - Deployment operation id. OperationID *string `json:"operationId,omitempty"` // Properties - Deployment properties. Properties *DeploymentOperationProperties `json:"properties,omitempty"` @@ -364,9 +264,9 @@ type DeploymentOperationProperties struct { // DeploymentOperationsListResult list of deployment operations. type DeploymentOperationsListResult struct { autorest.Response `json:"-"` - // Value - An array of deployment operations. + // Value - The list of deployments. Value *[]DeploymentOperation `json:"value,omitempty"` - // NextLink - The URL to use for getting the next set of results. + // NextLink - The URL to get the next set of results. NextLink *string `json:"nextLink,omitempty"` } @@ -465,15 +365,15 @@ func (page DeploymentOperationsListResultPage) Values() []DeploymentOperation { // DeploymentProperties deployment properties. type DeploymentProperties struct { - // Template - The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. + // 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 URI of the template. Use either the templateLink property or the template property, but not both. + // TemplateLink - The template URI. Use only one of Template or TemplateLink. TemplateLink *TemplateLink `json:"templateLink,omitempty"` - // Parameters - Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. + // 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 URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. + // ParametersLink - The parameters URI. Use only one of Parameters or ParametersLink. ParametersLink *ParametersLink `json:"parametersLink,omitempty"` - // Mode - The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: 'Incremental', 'Complete' + // 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"` @@ -501,7 +401,7 @@ type DeploymentPropertiesExtended struct { 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 are Incremental and Complete. Possible values include: 'Incremental', 'Complete' + // 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"` @@ -569,7 +469,7 @@ type DeploymentValidateResult struct { // ExportTemplateRequest export resource group template request parameters. type ExportTemplateRequest struct { - // ResourcesProperty - The IDs of the resources. The only supported string currently is '*' (all resources). Future updates will support exporting specific resources. + // ResourcesProperty - The ids of the resources. The only supported string currently is '*' (all resources). Future api updates will support exporting specific resources. ResourcesProperty *[]string `json:"resources,omitempty"` // Options - The export template options. Supported values include 'IncludeParameterDefaultValue', 'IncludeComments' or 'IncludeParameterDefaultValue, IncludeComments Options *string `json:"options,omitempty"` @@ -584,13 +484,13 @@ type GenericResource struct { 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 - Id of the resource that manages this resource. ManagedBy *string `json:"managedBy,omitempty"` - // Sku - The SKU of the resource. + // Sku - The sku of the resource. Sku *Sku `json:"sku,omitempty"` // Identity - The identity of the resource. Identity *Identity `json:"identity,omitempty"` - // ID - Resource ID + // ID - Resource Id ID *string `json:"id,omitempty"` // Name - Resource name Name *string `json:"name,omitempty"` @@ -654,13 +554,11 @@ type Group struct { autorest.Response `json:"-"` // ID - The ID of the resource group. ID *string `json:"id,omitempty"` - // Name - The name of the resource group. + // 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. It must be one of the supported Azure locations. + // 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"` - // ManagedBy - The ID of the resource that manages this resource group. - ManagedBy *string `json:"managedBy,omitempty"` // Tags - The tags attached to the resource group. Tags map[string]*string `json:"tags"` } @@ -680,16 +578,13 @@ func (g Group) MarshalJSON() ([]byte, error) { if g.Location != nil { objectMap["location"] = g.Location } - if g.ManagedBy != nil { - objectMap["managedBy"] = g.ManagedBy - } if g.Tags != nil { objectMap["tags"] = g.Tags } return json.Marshal(objectMap) } -// GroupExportResult resource group export result. +// GroupExportResult ... type GroupExportResult struct { autorest.Response `json:"-"` // Template - The template content. @@ -709,9 +604,9 @@ type GroupFilter struct { // GroupListResult list of resource groups. type GroupListResult struct { autorest.Response `json:"-"` - // Value - An array of resource groups. + // Value - The list of resource groups. Value *[]Group `json:"value,omitempty"` - // NextLink - The URL to use for getting the next set of results. + // NextLink - The URL to get the next set of results. NextLink *string `json:"nextLink,omitempty"` } @@ -808,35 +703,6 @@ func (page GroupListResultPage) Values() []Group { return *page.glr.Value } -// GroupPatchable resource group information. -type GroupPatchable struct { - // Name - The name of the resource group. - Name *string `json:"name,omitempty"` - Properties *GroupProperties `json:"properties,omitempty"` - // ManagedBy - The ID of the resource that manages this resource group. - ManagedBy *string `json:"managedBy,omitempty"` - // Tags - The tags attached to the resource group. - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for GroupPatchable. -func (gp GroupPatchable) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if gp.Name != nil { - objectMap["name"] = gp.Name - } - if gp.Properties != nil { - objectMap["properties"] = gp.Properties - } - if gp.ManagedBy != nil { - objectMap["managedBy"] = gp.ManagedBy - } - if gp.Tags != nil { - objectMap["tags"] = gp.Tags - } - return json.Marshal(objectMap) -} - // GroupProperties the resource group properties. type GroupProperties struct { // ProvisioningState - The provisioning state. @@ -865,7 +731,7 @@ func (future *GroupsDeleteFuture) Result(client GroupsClient) (ar autorest.Respo return } -// HTTPMessage HTTP message. +// HTTPMessage ... type HTTPMessage struct { // Content - HTTP message content. Content interface{} `json:"content,omitempty"` @@ -873,9 +739,9 @@ type HTTPMessage struct { // Identity identity for the resource. type Identity struct { - // PrincipalID - The principal ID of resource identity. + // PrincipalID - The principal id of resource identity. PrincipalID *string `json:"principalId,omitempty"` - // TenantID - The tenant ID of resource. + // TenantID - The tenant id of resource. TenantID *string `json:"tenantId,omitempty"` // Type - The identity type. Possible values include: 'SystemAssigned' Type ResourceIdentityType `json:"type,omitempty"` @@ -884,9 +750,9 @@ type Identity struct { // ListResult list of resource groups. type ListResult struct { autorest.Response `json:"-"` - // Value - An array of resources. + // Value - The list of resources. Value *[]GenericResource `json:"value,omitempty"` - // NextLink - The URL to use for getting the next set of results. + // NextLink - The URL to get the next set of results. NextLink *string `json:"nextLink,omitempty"` } @@ -983,11 +849,11 @@ func (page ListResultPage) Values() []GenericResource { return *page.lr.Value } -// ManagementErrorWithDetails the detailed error message of resource management. +// ManagementErrorWithDetails ... type ManagementErrorWithDetails struct { - // Code - The error code returned when exporting the template. + // Code - The error code returned from the server. Code *string `json:"code,omitempty"` - // Message - The error message describing the export error. + // Message - The error message returned from the server. Message *string `json:"message,omitempty"` // Target - The target of the error. Target *string `json:"target,omitempty"` @@ -997,7 +863,7 @@ type ManagementErrorWithDetails struct { // MoveInfo parameters of move resources. type MoveInfo struct { - // ResourcesProperty - The IDs of the resources. + // ResourcesProperty - The ids of the resources. ResourcesProperty *[]string `json:"resources,omitempty"` // TargetResourceGroup - The target resource group. TargetResourceGroup *string `json:"targetResourceGroup,omitempty"` @@ -1027,9 +893,9 @@ func (future *MoveResourcesFuture) Result(client Client) (ar autorest.Response, // ParametersLink entity representing the reference to the deployment paramaters. type ParametersLink struct { - // URI - The URI of the parameters file. + // URI - URI referencing the template. URI *string `json:"uri,omitempty"` - // ContentVersion - If included, must match the ContentVersion in the template. + // ContentVersion - If included it must match the ContentVersion in the template. ContentVersion *string `json:"contentVersion,omitempty"` } @@ -1043,16 +909,14 @@ type Plan struct { Product *string `json:"product,omitempty"` // PromotionCode - The promotion code. PromotionCode *string `json:"promotionCode,omitempty"` - // Version - The plan's version. - Version *string `json:"version,omitempty"` } // Provider resource provider information. type Provider struct { autorest.Response `json:"-"` - // ID - The provider ID. + // ID - The provider id. ID *string `json:"id,omitempty"` - // Namespace - The namespace of the resource provider. + // Namespace - The namespace of the provider. Namespace *string `json:"namespace,omitempty"` // RegistrationState - The registration state of the provider. RegistrationState *string `json:"registrationState,omitempty"` @@ -1063,9 +927,9 @@ type Provider struct { // ProviderListResult list of resource providers. type ProviderListResult struct { autorest.Response `json:"-"` - // Value - An array of resource providers. + // Value - The list of resource providers. Value *[]Provider `json:"value,omitempty"` - // NextLink - The URL to use for getting the next set of results. + // NextLink - The URL to get the next set of results. NextLink *string `json:"nextLink,omitempty"` } @@ -1170,7 +1034,7 @@ type ProviderOperationDisplayProperties struct { Provider *string `json:"provider,omitempty"` // Resource - Operation resource. Resource *string `json:"resource,omitempty"` - // Operation - The operation name. + // Operation - Operation. Operation *string `json:"operation,omitempty"` // Description - Operation description. Description *string `json:"description,omitempty"` @@ -1180,11 +1044,11 @@ type ProviderOperationDisplayProperties struct { type ProviderResourceType struct { // ResourceType - The resource type. ResourceType *string `json:"resourceType,omitempty"` - // Locations - The collection of locations where this resource type can be created. + // 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 - The api version. APIVersions *[]string `json:"apiVersions,omitempty"` // Properties - The properties. Properties map[string]*string `json:"properties"` @@ -1211,9 +1075,9 @@ func (prt ProviderResourceType) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// Resource basic set of the resource properties. +// Resource ... type Resource struct { - // ID - Resource ID + // ID - Resource Id ID *string `json:"id,omitempty"` // Name - Resource name Name *string `json:"name,omitempty"` @@ -1246,25 +1110,25 @@ func (r Resource) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// Sku SKU for the resource. +// Sku sku for the resource. type Sku struct { - // Name - The SKU name. + // Name - The sku name. Name *string `json:"name,omitempty"` - // Tier - The SKU tier. + // Tier - The sku tier. Tier *string `json:"tier,omitempty"` - // Size - The SKU size. + // Size - The sku size. Size *string `json:"size,omitempty"` - // Family - The SKU family. + // Family - The sku family. Family *string `json:"family,omitempty"` - // Model - The SKU model. + // Model - The sku model. Model *string `json:"model,omitempty"` - // Capacity - The SKU capacity. + // Capacity - The sku capacity. Capacity *int32 `json:"capacity,omitempty"` } -// SubResource sub-resource. +// SubResource ... type SubResource struct { - // ID - Resource ID + // ID - Resource Id ID *string `json:"id,omitempty"` } @@ -1273,7 +1137,7 @@ type TagCount struct { // Type - Type of count. Type *string `json:"type,omitempty"` // Value - Value of count. - Value *int32 `json:"value,omitempty"` + Value *string `json:"value,omitempty"` } // TagDetails tag details. @@ -1283,7 +1147,7 @@ type TagDetails struct { ID *string `json:"id,omitempty"` // TagName - The tag name. TagName *string `json:"tagName,omitempty"` - // Count - The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. + // Count - The tag count. Count *TagCount `json:"count,omitempty"` // Values - The list of tag values. Values *[]TagValue `json:"values,omitempty"` @@ -1292,9 +1156,9 @@ type TagDetails struct { // TagsListResult list of subscription tags. type TagsListResult struct { autorest.Response `json:"-"` - // Value - An array of tags. + // Value - The list of tags. Value *[]TagDetails `json:"value,omitempty"` - // NextLink - The URL to use for getting the next set of results. + // NextLink - The URL to get the next set of results. NextLink *string `json:"nextLink,omitempty"` } @@ -1414,40 +1278,12 @@ type TargetResource struct { // TemplateLink entity representing the reference to the template. type TemplateLink struct { - // URI - The URI of the template to deploy. + // URI - URI referencing the template. URI *string `json:"uri,omitempty"` - // ContentVersion - If included, must match the ContentVersion in the template. + // ContentVersion - If included it must match the ContentVersion in the template. ContentVersion *string `json:"contentVersion,omitempty"` } -// UpdateByIDFuture an abstraction for monitoring and retrieving the results of a long-running operation. -type UpdateByIDFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *UpdateByIDFuture) Result(client Client) (gr GenericResource, err error) { - var done bool - done, err = future.Done(client) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.UpdateByIDFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("resources.UpdateByIDFuture") - 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.UpdateByIDResponder(gr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.UpdateByIDFuture", "Result", gr.Response.Response, "Failure responding to request") - } - } - return -} - // UpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. type UpdateFuture struct { azure.Future @@ -1475,26 +1311,3 @@ func (future *UpdateFuture) Result(client Client) (gr GenericResource, err error } return } - -// ValidateMoveResourcesFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type ValidateMoveResourcesFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *ValidateMoveResourcesFuture) Result(client Client) (ar autorest.Response, err error) { - var done bool - done, err = future.Done(client) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.ValidateMoveResourcesFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("resources.ValidateMoveResourcesFuture") - return - } - ar.Response = future.Response() - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/providers.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/providers.go similarity index 91% rename from vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/providers.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/providers.go index d1b998cf59e3..4993b1f432dc 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/providers.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/providers.go @@ -24,7 +24,7 @@ import ( "net/http" ) -// ProvidersClient is the provides operations for working with resources and resource groups. +// ProvidersClient is the client for the Providers methods of the Resources service. type ProvidersClient struct { BaseClient } @@ -39,10 +39,10 @@ func NewProvidersClientWithBaseURI(baseURI string, subscriptionID string) Provid return ProvidersClient{NewWithBaseURI(baseURI, subscriptionID)} } -// Get gets the specified resource provider. +// Get gets a resource provider. // Parameters: -// resourceProviderNamespace - the namespace of the resource provider. -// expand - the $expand query parameter. For example, to include property aliases in response, use +// 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) { req, err := client.GetPreparer(ctx, resourceProviderNamespace, expand) @@ -73,7 +73,7 @@ func (client ProvidersClient) GetPreparer(ctx context.Context, resourceProviderN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -109,11 +109,10 @@ func (client ProvidersClient) GetResponder(resp *http.Response) (result Provider return } -// List gets all resource providers for a subscription. +// List gets a list of resource providers. // Parameters: -// top - the number of results to return. If null is passed returns all deployments. -// expand - the properties to include in the results. For example, use &$expand=metadata in the query string to -// retrieve resource provider metadata. To include property aliases in response, use +// 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) { result.fn = client.listNextResults @@ -144,7 +143,7 @@ func (client ProvidersClient) ListPreparer(ctx context.Context, top *int32, expa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -210,9 +209,9 @@ func (client ProvidersClient) ListComplete(ctx context.Context, top *int32, expa return } -// Register registers a subscription with a resource provider. +// Register registers provider to be used with a subscription. // Parameters: -// resourceProviderNamespace - the namespace of the resource provider to register. +// resourceProviderNamespace - namespace of the resource provider. func (client ProvidersClient) Register(ctx context.Context, resourceProviderNamespace string) (result Provider, err error) { req, err := client.RegisterPreparer(ctx, resourceProviderNamespace) if err != nil { @@ -242,7 +241,7 @@ func (client ProvidersClient) RegisterPreparer(ctx context.Context, resourceProv "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -275,9 +274,9 @@ func (client ProvidersClient) RegisterResponder(resp *http.Response) (result Pro return } -// Unregister unregisters a subscription from a resource provider. +// Unregister unregisters provider from a subscription. // Parameters: -// resourceProviderNamespace - the namespace of the resource provider to unregister. +// resourceProviderNamespace - namespace of the resource provider. func (client ProvidersClient) Unregister(ctx context.Context, resourceProviderNamespace string) (result Provider, err error) { req, err := client.UnregisterPreparer(ctx, resourceProviderNamespace) if err != nil { @@ -307,7 +306,7 @@ func (client ProvidersClient) UnregisterPreparer(ctx context.Context, resourcePr "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } 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 new file mode 100644 index 000000000000..301b9934e903 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/resources.go @@ -0,0 +1,629 @@ +package resources + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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" + "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. +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) (result autorest.Response, err error) { + 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: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("resources.Client", "CheckExistence", err.Error()) + } + + req, err := client.CheckExistencePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) + 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 +} + +// CheckExistencePreparer prepares the CheckExistence request. +func (client Client) CheckExistencePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName 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), + } + + 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/{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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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, parameters GenericResource) (result GenericResource, err error) { + 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: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("resources.Client", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, 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 +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client Client) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName 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), + } + + 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/{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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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) (result autorest.Response, err error) { + 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: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("resources.Client", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) + 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 +} + +// DeletePreparer prepares the Delete request. +func (client Client) DeletePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName 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), + } + + 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/{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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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) (result GenericResource, err error) { + 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: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("resources.Client", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) + 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 +} + +// GetPreparer prepares the Get request. +func (client Client) GetPreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName 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), + } + + 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/{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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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 - the $expand query parameter. +// 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults ListResult) (result ListResult, err error) { + req, err := lastResults.listResultPreparer() + 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) { + 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 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: `^[-\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 + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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, + client.ByInspecting(), + 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. +// parameters - parameters for updating the resource. +func (client Client) Update(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, parameters GenericResource) (result UpdateFuture, err error) { + 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: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("resources.Client", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, 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, 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), + } + + const APIVersion = "2016-02-01" + 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 + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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, + client.ByInspecting(), + 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/2017-05-10/resources/tags.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/tags.go similarity index 93% rename from vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/tags.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/tags.go index f692f8027fcb..c38a38188365 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/tags.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/tags.go @@ -24,7 +24,7 @@ import ( "net/http" ) -// TagsClient is the provides operations for working with resources and resource groups. +// TagsClient is the client for the Tags methods of the Resources service. type TagsClient struct { BaseClient } @@ -39,10 +39,9 @@ func NewTagsClientWithBaseURI(baseURI string, subscriptionID string) TagsClient return TagsClient{NewWithBaseURI(baseURI, subscriptionID)} } -// CreateOrUpdate the tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure -// have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. +// CreateOrUpdate create a subscription resource tag. // Parameters: -// tagName - the name of the tag to create. +// tagName - the name of the tag. func (client TagsClient) CreateOrUpdate(ctx context.Context, tagName string) (result TagDetails, err error) { req, err := client.CreateOrUpdatePreparer(ctx, tagName) if err != nil { @@ -72,7 +71,7 @@ func (client TagsClient) CreateOrUpdatePreparer(ctx context.Context, tagName str "tagName": autorest.Encode("path", tagName), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -105,10 +104,10 @@ func (client TagsClient) CreateOrUpdateResponder(resp *http.Response) (result Ta return } -// CreateOrUpdateValue creates a tag value. The name of the tag must already exist. +// CreateOrUpdateValue create a subscription resource tag value. // Parameters: // tagName - the name of the tag. -// tagValue - the value of the tag to create. +// tagValue - the value of the tag. func (client TagsClient) CreateOrUpdateValue(ctx context.Context, tagName string, tagValue string) (result TagValue, err error) { req, err := client.CreateOrUpdateValuePreparer(ctx, tagName, tagValue) if err != nil { @@ -139,7 +138,7 @@ func (client TagsClient) CreateOrUpdateValuePreparer(ctx context.Context, tagNam "tagValue": autorest.Encode("path", tagValue), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -172,7 +171,7 @@ func (client TagsClient) CreateOrUpdateValueResponder(resp *http.Response) (resu return } -// Delete you must remove all values from a resource tag before you can delete it. +// 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) { @@ -204,7 +203,7 @@ func (client TagsClient) DeletePreparer(ctx context.Context, tagName string) (*h "tagName": autorest.Encode("path", tagName), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -236,10 +235,10 @@ func (client TagsClient) DeleteResponder(resp *http.Response) (result autorest.R return } -// DeleteValue deletes a tag value. +// DeleteValue delete a subscription resource tag value. // Parameters: // tagName - the name of the tag. -// tagValue - the value of the tag to delete. +// tagValue - the value of the tag. func (client TagsClient) DeleteValue(ctx context.Context, tagName string, tagValue string) (result autorest.Response, err error) { req, err := client.DeleteValuePreparer(ctx, tagName, tagValue) if err != nil { @@ -270,7 +269,7 @@ func (client TagsClient) DeleteValuePreparer(ctx context.Context, tagName string "tagValue": autorest.Encode("path", tagValue), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -302,7 +301,7 @@ func (client TagsClient) DeleteValueResponder(resp *http.Response) (result autor return } -// List gets the names and values of all resource tags that are defined in a subscription. +// List get a list of subscription resource tags. func (client TagsClient) List(ctx context.Context) (result TagsListResultPage, err error) { result.fn = client.listNextResults req, err := client.ListPreparer(ctx) @@ -332,7 +331,7 @@ func (client TagsClient) ListPreparer(ctx context.Context) (*http.Request, error "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-05-10" + const APIVersion = "2016-02-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/version.go similarity index 93% rename from vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/version.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/version.go index f8c6aaf16d71..b7b502887982 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources/version.go @@ -21,7 +21,7 @@ import "github.com/Azure/azure-sdk-for-go/version" // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/" + version.Number + " resources/2017-05-10" + return "Azure-SDK-For-Go/" + version.Number + " resources/2016-02-01" } // Version returns the semantic version (see http://semver.org) of the client. diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/resources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/resources.go deleted file mode 100644 index 455d5a882360..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources/resources.go +++ /dev/null @@ -1,1169 +0,0 @@ -package resources - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// 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" - "net/http" -) - -// Client is the provides operations for working with resources and resource groups. -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. -func NewClientWithBaseURI(baseURI string, subscriptionID string) Client { - return Client{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CheckExistence checks whether a resource exists. -// Parameters: -// resourceGroupName - the name of the resource group containing the resource to check. The name is case -// insensitive. -// resourceProviderNamespace - the resource provider of the resource to check. -// parentResourcePath - the parent resource identity. -// resourceType - the resource type. -// resourceName - the name of the resource to check whether it exists. -func (client Client) CheckExistence(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result autorest.Response, err error) { - 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: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.Client", "CheckExistence", err.Error()) - } - - req, err := client.CheckExistencePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) - 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 -} - -// CheckExistencePreparer prepares the CheckExistence request. -func (client Client) CheckExistencePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName 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), - } - - const APIVersion = "2017-05-10" - 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 autorest.SendWithSender(client, 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, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusNotFound), - autorest.ByClosing()) - result.Response = resp - return -} - -// CheckExistenceByID checks by ID whether a resource exists. -// Parameters: -// resourceID - the fully qualified ID of the resource, including the resource name and resource type. Use the -// format, -// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} -func (client Client) CheckExistenceByID(ctx context.Context, resourceID string) (result autorest.Response, err error) { - req, err := client.CheckExistenceByIDPreparer(ctx, resourceID) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "CheckExistenceByID", nil, "Failure preparing request") - return - } - - resp, err := client.CheckExistenceByIDSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "resources.Client", "CheckExistenceByID", resp, "Failure sending request") - return - } - - result, err = client.CheckExistenceByIDResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "CheckExistenceByID", resp, "Failure responding to request") - } - - return -} - -// CheckExistenceByIDPreparer prepares the CheckExistenceByID request. -func (client Client) CheckExistenceByIDPreparer(ctx context.Context, resourceID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceId": resourceID, - } - - const APIVersion = "2017-05-10" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsHead(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{resourceId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CheckExistenceByIDSender sends the CheckExistenceByID request. The method will close the -// http.Response Body if it receives an error. -func (client Client) CheckExistenceByIDSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// CheckExistenceByIDResponder handles the response to the CheckExistenceByID request. The method always -// closes the http.Response Body. -func (client Client) CheckExistenceByIDResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusNotFound), - autorest.ByClosing()) - result.Response = resp - return -} - -// CreateOrUpdate creates 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 create. -// resourceName - the name of the resource to create. -// parameters - parameters for creating or updating the resource. -func (client Client) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, parameters GenericResource) (result CreateOrUpdateFuture, err error) { - 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: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Pattern, Rule: `^[-\w\._,\(\)]+$`, Chain: nil}}}}}}); err != nil { - return result, validation.NewError("resources.Client", "CreateOrUpdate", err.Error()) - } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = client.CreateOrUpdateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "CreateOrUpdate", result.Response(), "Failure sending 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, 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), - } - - const APIVersion = "2017-05-10" - 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) (future CreateOrUpdateFuture, err error) { - var resp *http.Response - resp, err = autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// 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, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateOrUpdateByID create a resource by ID. -// Parameters: -// resourceID - the fully qualified ID of the resource, including the resource name and resource type. Use the -// format, -// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} -// parameters - create or update resource parameters. -func (client Client) CreateOrUpdateByID(ctx context.Context, resourceID string, parameters GenericResource) (result CreateOrUpdateByIDFuture, err error) { - if err := validation.Validate([]validation.Validation{ - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Pattern, Rule: `^[-\w\._,\(\)]+$`, Chain: nil}}}}}}); err != nil { - return result, validation.NewError("resources.Client", "CreateOrUpdateByID", err.Error()) - } - - req, err := client.CreateOrUpdateByIDPreparer(ctx, resourceID, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "CreateOrUpdateByID", nil, "Failure preparing request") - return - } - - result, err = client.CreateOrUpdateByIDSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "CreateOrUpdateByID", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateOrUpdateByIDPreparer prepares the CreateOrUpdateByID request. -func (client Client) CreateOrUpdateByIDPreparer(ctx context.Context, resourceID string, parameters GenericResource) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceId": resourceID, - } - - const APIVersion = "2017-05-10" - 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("/{resourceId}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateByIDSender sends the CreateOrUpdateByID request. The method will close the -// http.Response Body if it receives an error. -func (client Client) CreateOrUpdateByIDSender(req *http.Request) (future CreateOrUpdateByIDFuture, err error) { - var resp *http.Response - resp, err = autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// CreateOrUpdateByIDResponder handles the response to the CreateOrUpdateByID request. The method always -// closes the http.Response Body. -func (client Client) CreateOrUpdateByIDResponder(resp *http.Response) (result GenericResource, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete deletes a resource. -// Parameters: -// resourceGroupName - the name of the resource group that contains the resource to delete. The name is case -// insensitive. -// resourceProviderNamespace - the namespace of the resource provider. -// parentResourcePath - the parent resource identity. -// resourceType - the resource type. -// resourceName - the name of the resource to delete. -func (client Client) Delete(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result DeleteFuture, err error) { - 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: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.Client", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "Delete", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "Delete", result.Response(), "Failure sending 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) (*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), - } - - const APIVersion = "2017-05-10" - 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) (future DeleteFuture, err error) { - var resp *http.Response - resp, err = autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// 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, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteByID deletes a resource by ID. -// Parameters: -// resourceID - the fully qualified ID of the resource, including the resource name and resource type. Use the -// format, -// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} -func (client Client) DeleteByID(ctx context.Context, resourceID string) (result DeleteByIDFuture, err error) { - req, err := client.DeleteByIDPreparer(ctx, resourceID) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "DeleteByID", nil, "Failure preparing request") - return - } - - result, err = client.DeleteByIDSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "DeleteByID", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteByIDPreparer prepares the DeleteByID request. -func (client Client) DeleteByIDPreparer(ctx context.Context, resourceID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceId": resourceID, - } - - const APIVersion = "2017-05-10" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{resourceId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteByIDSender sends the DeleteByID request. The method will close the -// http.Response Body if it receives an error. -func (client Client) DeleteByIDSender(req *http.Request) (future DeleteByIDFuture, err error) { - var resp *http.Response - resp, err = autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// DeleteByIDResponder handles the response to the DeleteByID request. The method always -// closes the http.Response Body. -func (client Client) DeleteByIDResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get gets a resource. -// Parameters: -// resourceGroupName - the name of the resource group containing the resource to get. The name is case -// insensitive. -// resourceProviderNamespace - the namespace of the resource provider. -// parentResourcePath - the parent resource identity. -// resourceType - the resource type of the resource. -// resourceName - the name of the resource to get. -func (client Client) Get(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result GenericResource, err error) { - 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: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.Client", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) - 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 -} - -// GetPreparer prepares the Get request. -func (client Client) GetPreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName 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), - } - - const APIVersion = "2017-05-10" - 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 autorest.SendWithSender(client, 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, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetByID gets a resource by ID. -// Parameters: -// resourceID - the fully qualified ID of the resource, including the resource name and resource type. Use the -// format, -// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} -func (client Client) GetByID(ctx context.Context, resourceID string) (result GenericResource, err error) { - req, err := client.GetByIDPreparer(ctx, resourceID) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "GetByID", nil, "Failure preparing request") - return - } - - resp, err := client.GetByIDSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.Client", "GetByID", resp, "Failure sending request") - return - } - - result, err = client.GetByIDResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "GetByID", resp, "Failure responding to request") - } - - return -} - -// GetByIDPreparer prepares the GetByID request. -func (client Client) GetByIDPreparer(ctx context.Context, resourceID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceId": resourceID, - } - - const APIVersion = "2017-05-10" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{resourceId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetByIDSender sends the GetByID request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetByIDSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// GetByIDResponder handles the response to the GetByID request. The method always -// closes the http.Response Body. -func (client Client) GetByIDResponder(resp *http.Response) (result GenericResource, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List get all the resources in a subscription. -// Parameters: -// filter - the filter to apply on the operation. -// expand - the $expand query parameter. -// top - the number of results to return. 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) { - 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 -} - -// 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 = "2017-05-10" - 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 autorest.SendWithSender(client, 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, - client.ByInspecting(), - 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(lastResults ListResult) (result ListResult, err error) { - req, err := lastResults.listResultPreparer() - 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) { - result.page, err = client.List(ctx, filter, expand, top) - return -} - -// ListByResourceGroup get all the resources for a resource group. -// Parameters: -// resourceGroupName - the resource group with the resources to get. -// filter - the filter to apply on the operation. -// expand - the $expand query parameter -// top - the number of results to return. If null is passed, returns all resources. -func (client Client) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string, expand string, top *int32) (result ListResultPage, err error) { - 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: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.Client", "ListByResourceGroup", err.Error()) - } - - result.fn = client.listByResourceGroupNextResults - req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, filter, expand, top) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp, err := client.ListByResourceGroupSender(req) - if err != nil { - result.lr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "resources.Client", "ListByResourceGroup", resp, "Failure sending request") - return - } - - result.lr, err = client.ListByResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "ListByResourceGroup", resp, "Failure responding to request") - } - - return -} - -// ListByResourceGroupPreparer prepares the ListByResourceGroup request. -func (client Client) ListByResourceGroupPreparer(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 = "2017-05-10" - 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)) -} - -// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the -// http.Response Body if it receives an error. -func (client Client) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (client Client) ListByResourceGroupResponder(resp *http.Response) (result ListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listByResourceGroupNextResults retrieves the next set of results, if any. -func (client Client) listByResourceGroupNextResults(lastResults ListResult) (result ListResult, err error) { - req, err := lastResults.listResultPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.Client", "listByResourceGroupNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListByResourceGroupSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.Client", "listByResourceGroupNextResults", resp, "Failure sending next results request") - } - result, err = client.ListByResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "listByResourceGroupNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. -func (client Client) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string, expand string, top *int32) (result ListResultIterator, err error) { - result.page, err = client.ListByResourceGroup(ctx, resourceGroupName, filter, expand, top) - return -} - -// MoveResources the resources to move must be in the same source resource group. The target resource group may be in a -// different subscription. When moving resources, both the source group and the target group are locked for the -// duration of the operation. Write and delete operations are blocked on the groups until the move completes. -// Parameters: -// sourceResourceGroupName - the name of the resource group containing the resources to move. -// parameters - parameters for moving resources. -func (client Client) MoveResources(ctx context.Context, sourceResourceGroupName string, parameters MoveInfo) (result MoveResourcesFuture, err error) { - 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: `^[-\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 = "2017-05-10" - 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 - resp, err = autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - 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, - client.ByInspecting(), - 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. -// parameters - parameters for updating the resource. -func (client Client) Update(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, parameters GenericResource) (result UpdateFuture, err error) { - 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: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.Client", "Update", err.Error()) - } - - req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, 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, 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), - } - - const APIVersion = "2017-05-10" - 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 - resp, err = autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - 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, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// UpdateByID updates a resource by ID. -// Parameters: -// resourceID - the fully qualified ID of the resource, including the resource name and resource type. Use the -// format, -// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} -// parameters - update resource parameters. -func (client Client) UpdateByID(ctx context.Context, resourceID string, parameters GenericResource) (result UpdateByIDFuture, err error) { - req, err := client.UpdateByIDPreparer(ctx, resourceID, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "UpdateByID", nil, "Failure preparing request") - return - } - - result, err = client.UpdateByIDSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "UpdateByID", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdateByIDPreparer prepares the UpdateByID request. -func (client Client) UpdateByIDPreparer(ctx context.Context, resourceID string, parameters GenericResource) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceId": resourceID, - } - - const APIVersion = "2017-05-10" - 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("/{resourceId}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateByIDSender sends the UpdateByID request. The method will close the -// http.Response Body if it receives an error. -func (client Client) UpdateByIDSender(req *http.Request) (future UpdateByIDFuture, err error) { - var resp *http.Response - resp, err = autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// UpdateByIDResponder handles the response to the UpdateByID request. The method always -// closes the http.Response Body. -func (client Client) UpdateByIDResponder(resp *http.Response) (result GenericResource, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ValidateMoveResources this operation checks whether the specified resources can be moved to the target. The -// resources to move must be in the same source resource group. The target resource group may be in a different -// subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it -// returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to -// check the result of the long-running operation. -// Parameters: -// sourceResourceGroupName - the name of the resource group containing the resources to validate for move. -// parameters - parameters for moving resources. -func (client Client) ValidateMoveResources(ctx context.Context, sourceResourceGroupName string, parameters MoveInfo) (result ValidateMoveResourcesFuture, err error) { - 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: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("resources.Client", "ValidateMoveResources", err.Error()) - } - - req, err := client.ValidateMoveResourcesPreparer(ctx, sourceResourceGroupName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "ValidateMoveResources", nil, "Failure preparing request") - return - } - - result, err = client.ValidateMoveResourcesSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.Client", "ValidateMoveResources", result.Response(), "Failure sending request") - return - } - - return -} - -// ValidateMoveResourcesPreparer prepares the ValidateMoveResources request. -func (client Client) ValidateMoveResourcesPreparer(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 = "2017-05-10" - 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}/validateMoveResources", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ValidateMoveResourcesSender sends the ValidateMoveResources request. The method will close the -// http.Response Body if it receives an error. -func (client Client) ValidateMoveResourcesSender(req *http.Request) (future ValidateMoveResourcesFuture, err error) { - var resp *http.Response - resp, err = autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// ValidateMoveResourcesResponder handles the response to the ValidateMoveResources request. The method always -// closes the http.Response Body. -func (client Client) ValidateMoveResourcesResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent, http.StatusConflict), - autorest.ByClosing()) - result.Response = resp - return -} diff --git a/vendor/github.com/hashicorp/go-azure-helpers/LICENSE b/vendor/github.com/hashicorp/go-azure-helpers/LICENSE new file mode 100644 index 000000000000..be2cc4dfb609 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-helpers/LICENSE @@ -0,0 +1,362 @@ +Mozilla Public License, version 2.0 + +1. Definitions + +1.1. "Contributor" + + means each individual or legal entity that creates, contributes to the + creation of, or owns Covered Software. + +1.2. "Contributor Version" + + means the combination of the Contributions of others (if any) used by a + Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + + means Source Code Form to which the initial Contributor has attached the + notice in Exhibit A, the Executable Form of such Source Code Form, and + Modifications of such Source Code Form, in each case including portions + thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + a. that the initial Contributor has attached the notice described in + Exhibit B to the Covered Software; or + + b. that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the terms of + a Secondary License. + +1.6. "Executable Form" + + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + + means a work that combines Covered Software with other material, in a + separate file or files, that is not Covered Software. + +1.8. "License" + + means this document. + +1.9. "Licensable" + + means having the right to grant, to the maximum extent possible, whether + at the time of the initial grant or subsequently, any and all of the + rights conveyed by this License. + +1.10. "Modifications" + + means any of the following: + + a. any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered Software; or + + b. any new file in Source Code Form that contains any Covered Software. + +1.11. "Patent Claims" of a Contributor + + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the License, + by the making, using, selling, offering for sale, having made, import, + or transfer of either its Contributions or its Contributor Version. + +1.12. "Secondary License" + + means either the GNU General Public License, Version 2.0, the GNU Lesser + General Public License, Version 2.1, the GNU Affero General Public + License, Version 3.0, or any later versions of those licenses. + +1.13. "Source Code Form" + + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that controls, is + controlled by, or is under common control with You. For purposes of this + definition, "control" means (a) the power, direct or indirect, to cause + the direction or management of such entity, whether by contract or + otherwise, or (b) ownership of more than fifty percent (50%) of the + outstanding shares or beneficial ownership of such entity. + + +2. License Grants and Conditions + +2.1. Grants + + Each Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + + a. under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + + b. under Patent Claims of such Contributor to make, use, sell, offer for + sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + + The licenses granted in Section 2.1 with respect to any Contribution + become effective for each Contribution on the date the Contributor first + distributes such Contribution. + +2.3. Limitations on Grant Scope + + The licenses granted in this Section 2 are the only rights granted under + this License. No additional rights or licenses will be implied from the + distribution or licensing of Covered Software under this License. + Notwithstanding Section 2.1(b) above, no patent license is granted by a + Contributor: + + a. for any code that a Contributor has removed from Covered Software; or + + b. for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + + c. under Patent Claims infringed by Covered Software in the absence of + its Contributions. + + This License does not grant any rights in the trademarks, service marks, + or logos of any Contributor (except as may be necessary to comply with + the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + + No Contributor makes additional grants as a result of Your choice to + distribute the Covered Software under a subsequent version of this + License (see Section 10.2) or under the terms of a Secondary License (if + permitted under the terms of Section 3.3). + +2.5. Representation + + Each Contributor represents that the Contributor believes its + Contributions are its original creation(s) or it has sufficient rights to + grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + + This License is not intended to limit any rights You have under + applicable copyright doctrines of fair use, fair dealing, or other + equivalents. + +2.7. Conditions + + Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in + Section 2.1. + + +3. Responsibilities + +3.1. Distribution of Source Form + + All distribution of Covered Software in Source Code Form, including any + Modifications that You create or to which You contribute, must be under + the terms of this License. You must inform recipients that the Source + Code Form of the Covered Software is governed by the terms of this + License, and how they can obtain a copy of this License. You may not + attempt to alter or restrict the recipients' rights in the Source Code + Form. + +3.2. Distribution of Executable Form + + If You distribute Covered Software in Executable Form then: + + a. such Covered Software must also be made available in Source Code Form, + as described in Section 3.1, and You must inform recipients of the + Executable Form how they can obtain a copy of such Source Code Form by + reasonable means in a timely manner, at a charge no more than the cost + of distribution to the recipient; and + + b. You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter the + recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + + You may create and distribute a Larger Work under terms of Your choice, + provided that You also comply with the requirements of this License for + the Covered Software. If the Larger Work is a combination of Covered + Software with a work governed by one or more Secondary Licenses, and the + Covered Software is not Incompatible With Secondary Licenses, this + License permits You to additionally distribute such Covered Software + under the terms of such Secondary License(s), so that the recipient of + the Larger Work may, at their option, further distribute the Covered + Software under the terms of either this License or such Secondary + License(s). + +3.4. Notices + + You may not remove or alter the substance of any license notices + (including copyright notices, patent notices, disclaimers of warranty, or + limitations of liability) contained within the Source Code Form of the + Covered Software, except that You may alter any license notices to the + extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + + You may choose to offer, and to charge a fee for, warranty, support, + indemnity or liability obligations to one or more recipients of Covered + Software. However, You may do so only on Your own behalf, and not on + behalf of any Contributor. You must make it absolutely clear that any + such warranty, support, indemnity, or liability obligation is offered by + You alone, and You hereby agree to indemnify every Contributor for any + liability incurred by such Contributor as a result of warranty, support, + indemnity or liability terms You offer. You may include additional + disclaimers of warranty and limitations of liability specific to any + jurisdiction. + +4. Inability to Comply Due to Statute or Regulation + + If it is impossible for You to comply with any of the terms of this License + with respect to some or all of the Covered Software due to statute, + judicial order, or regulation then You must: (a) comply with the terms of + this License to the maximum extent possible; and (b) describe the + limitations and the code they affect. Such description must be placed in a + text file included with all distributions of the Covered Software under + this License. Except to the extent prohibited by statute or regulation, + such description must be sufficiently detailed for a recipient of ordinary + skill to be able to understand it. + +5. Termination + +5.1. The rights granted under this License will terminate automatically if You + fail to comply with any of its terms. However, if You become compliant, + then the rights granted under this License from a particular Contributor + are reinstated (a) provisionally, unless and until such Contributor + explicitly and finally terminates Your grants, and (b) on an ongoing + basis, if such Contributor fails to notify You of the non-compliance by + some reasonable means prior to 60 days after You have come back into + compliance. Moreover, Your grants from a particular Contributor are + reinstated on an ongoing basis if such Contributor notifies You of the + non-compliance by some reasonable means, this is the first time You have + received notice of non-compliance with this License from such + Contributor, and You become compliant prior to 30 days after Your receipt + of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent + infringement claim (excluding declaratory judgment actions, + counter-claims, and cross-claims) alleging that a Contributor Version + directly or indirectly infringes any patent, then the rights granted to + You by any and all Contributors for the Covered Software under Section + 2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user + license agreements (excluding distributors and resellers) which have been + validly granted by You or Your distributors under this License prior to + termination shall survive termination. + +6. Disclaimer of Warranty + + Covered Software is provided under this License on an "as is" basis, + without warranty of any kind, either expressed, implied, or statutory, + including, without limitation, warranties that the Covered Software is free + of defects, merchantable, fit for a particular purpose or non-infringing. + The entire risk as to the quality and performance of the Covered Software + is with You. Should any Covered Software prove defective in any respect, + You (not any Contributor) assume the cost of any necessary servicing, + repair, or correction. This disclaimer of warranty constitutes an essential + part of this License. No use of any Covered Software is authorized under + this License except under this disclaimer. + +7. Limitation of Liability + + Under no circumstances and under no legal theory, whether tort (including + negligence), contract, or otherwise, shall any Contributor, or anyone who + distributes Covered Software as permitted above, be liable to You for any + direct, indirect, special, incidental, or consequential damages of any + character including, without limitation, damages for lost profits, loss of + goodwill, work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses, even if such party shall have been + informed of the possibility of such damages. This limitation of liability + shall not apply to liability for death or personal injury resulting from + such party's negligence to the extent applicable law prohibits such + limitation. Some jurisdictions do not allow the exclusion or limitation of + incidental or consequential damages, so this exclusion and limitation may + not apply to You. + +8. Litigation + + Any litigation relating to this License may be brought only in the courts + of a jurisdiction where the defendant maintains its principal place of + business and such litigation shall be governed by laws of that + jurisdiction, without reference to its conflict-of-law provisions. Nothing + in this Section shall prevent a party's ability to bring cross-claims or + counter-claims. + +9. Miscellaneous + + This License represents the complete agreement concerning the subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. Any law or regulation which provides that + the language of a contract shall be construed against the drafter shall not + be used to construe this License against a Contributor. + + +10. Versions of the License + +10.1. New Versions + + Mozilla Foundation is the license steward. Except as provided in Section + 10.3, no one other than the license steward has the right to modify or + publish new versions of this License. Each version will be given a + distinguishing version number. + +10.2. Effect of New Versions + + You may distribute the Covered Software under the terms of the version + of the License under which You originally received the Covered Software, + or under the terms of any subsequent version published by the license + steward. + +10.3. Modified Versions + + If you create software not governed by this License, and you want to + create a new license for such software, you may create and use a + modified version of this License if you rename the license and remove + any references to the name of the license steward (except to note that + such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary + Licenses If You choose to distribute Source Code Form that is + Incompatible With Secondary Licenses under the terms of this version of + the License, the notice described in Exhibit B of this License must be + attached. + +Exhibit A - Source Code Form License Notice + + This Source Code Form is subject to the + terms of the Mozilla Public License, v. + 2.0. If a copy of the MPL was not + distributed with this file, You can + obtain one at + http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular file, +then You may include the notice in a location (such as a LICENSE file in a +relevant directory) where a recipient would be likely to look for such a +notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice + + This Source Code Form is "Incompatible + With Secondary Licenses", as defined by + the Mozilla Public License, v. 2.0. diff --git a/azurerm/helpers/authentication/auth_method.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method.go similarity index 100% rename from azurerm/helpers/authentication/auth_method.go rename to vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method.go diff --git a/azurerm/helpers/authentication/auth_method_azure_cli_parsing.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_azure_cli_parsing.go similarity index 100% rename from azurerm/helpers/authentication/auth_method_azure_cli_parsing.go rename to vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_azure_cli_parsing.go diff --git a/azurerm/helpers/authentication/auth_method_client_cert.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_client_cert.go similarity index 100% rename from azurerm/helpers/authentication/auth_method_client_cert.go rename to vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_client_cert.go diff --git a/azurerm/helpers/authentication/auth_method_client_secret.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_client_secret.go similarity index 100% rename from azurerm/helpers/authentication/auth_method_client_secret.go rename to vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_client_secret.go diff --git a/azurerm/helpers/authentication/auth_method_msi.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_msi.go similarity index 100% rename from azurerm/helpers/authentication/auth_method_msi.go rename to vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_msi.go diff --git a/azurerm/helpers/authentication/azure_cli_access_token.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/azure_cli_access_token.go similarity index 100% rename from azurerm/helpers/authentication/azure_cli_access_token.go rename to vendor/github.com/hashicorp/go-azure-helpers/authentication/azure_cli_access_token.go diff --git a/azurerm/helpers/authentication/azure_cli_profile.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/azure_cli_profile.go similarity index 100% rename from azurerm/helpers/authentication/azure_cli_profile.go rename to vendor/github.com/hashicorp/go-azure-helpers/authentication/azure_cli_profile.go diff --git a/azurerm/helpers/authentication/azure_cli_profile_population.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/azure_cli_profile_population.go similarity index 100% rename from azurerm/helpers/authentication/azure_cli_profile_population.go rename to vendor/github.com/hashicorp/go-azure-helpers/authentication/azure_cli_profile_population.go diff --git a/azurerm/helpers/authentication/builder.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/builder.go similarity index 82% rename from azurerm/helpers/authentication/builder.go rename to vendor/github.com/hashicorp/go-azure-helpers/authentication/builder.go index 8abcb38bc042..b72ac805c72c 100644 --- a/azurerm/helpers/authentication/builder.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/authentication/builder.go @@ -14,6 +14,10 @@ type Builder struct { TenantID string Environment string + // The custom Resource Manager Endpoint which should be used + // only applicable for Azure Stack at this time. + CustomResourceManagerEndpoint string + // Azure CLI Parsing / CloudShell Auth SupportsAzureCliCloudShellParsing bool @@ -35,10 +39,11 @@ type Builder struct { // for authenticating with Azure func (b Builder) Build() (*Config, error) { config := Config{ - ClientID: b.ClientID, - SubscriptionID: b.SubscriptionID, - TenantID: b.TenantID, - Environment: b.Environment, + ClientID: b.ClientID, + SubscriptionID: b.SubscriptionID, + TenantID: b.TenantID, + Environment: b.Environment, + CustomResourceManagerEndpoint: b.CustomResourceManagerEndpoint, } // NOTE: the ordering here is important diff --git a/azurerm/helpers/authentication/config.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/config.go similarity index 86% rename from azurerm/helpers/authentication/config.go rename to vendor/github.com/hashicorp/go-azure-helpers/authentication/config.go index d9b606baac02..c3068152f8d8 100644 --- a/azurerm/helpers/authentication/config.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/authentication/config.go @@ -14,6 +14,10 @@ type Config struct { Environment string AuthenticatedAsAServicePrincipal bool + // A Custom Resource Manager Endpoint + // at this time this should only be applicable for Azure Stack. + CustomResourceManagerEndpoint string + authMethod authMethod } diff --git a/azurerm/helpers/authentication/environment.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/environment.go similarity index 68% rename from azurerm/helpers/authentication/environment.go rename to vendor/github.com/hashicorp/go-azure-helpers/authentication/environment.go index 73065638f212..7fc4e15b45bd 100644 --- a/azurerm/helpers/authentication/environment.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/authentication/environment.go @@ -25,6 +25,22 @@ func DetermineEnvironment(name string) (*azure.Environment, error) { return &env, nil } +// LoadEnvironmentFromUrl attempts to load the specified environment from the endpoint. +// if the endpoint is an empty string, or an environment can't be +// found at the endpoint url then an error is returned +func LoadEnvironmentFromUrl(endpoint string) (*azure.Environment, error) { + if endpoint == "" { + return nil, fmt.Errorf("Endpoint was not set!") + } + + env, err := azure.EnvironmentFromURL(endpoint) + if err != nil { + return nil, fmt.Errorf("Error retrieving Environment from Endpoint %q: %+v", endpoint, err) + } + + return &env, nil +} + func normalizeEnvironmentName(input string) string { // Environment is stored as `Azure{Environment}Cloud` output := strings.ToLower(input) diff --git a/azurerm/helpers/resourceproviders/registration.go b/vendor/github.com/hashicorp/go-azure-helpers/resourceproviders/registration.go similarity index 95% rename from azurerm/helpers/resourceproviders/registration.go rename to vendor/github.com/hashicorp/go-azure-helpers/resourceproviders/registration.go index ff9802b5cb64..accf0d923840 100644 --- a/azurerm/helpers/resourceproviders/registration.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourceproviders/registration.go @@ -7,7 +7,7 @@ import ( "strings" "sync" - "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources" + "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 diff --git a/vendor/github.com/hashicorp/go-azure-helpers/response/response.go b/vendor/github.com/hashicorp/go-azure-helpers/response/response.go new file mode 100644 index 000000000000..210e5dd78489 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-helpers/response/response.go @@ -0,0 +1,23 @@ +package response + +import ( + "net/http" +) + +func WasConflict(resp *http.Response) bool { + return responseWasStatusCode(resp, http.StatusConflict) +} + +func WasNotFound(resp *http.Response) bool { + return responseWasStatusCode(resp, http.StatusNotFound) +} + +func responseWasStatusCode(resp *http.Response, statusCode int) bool { + if r := resp; r != nil { + if r.StatusCode == statusCode { + return true + } + } + + return false +} diff --git a/vendor/vendor.json b/vendor/vendor.json index 37c7519f9800..d7f6ef73a7e6 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -2,6 +2,14 @@ "comment": "", "ignore": "test", "package": [ + { + "checksumSHA1": "Ohzmn3hdzuDAONRJ4pfj9gIcK9Y=", + "path": "github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources", + "revision": "da91af54816b4cf72949c225a2d0980f51fab01b", + "revisionTime": "2018-10-19T17:11:53Z", + "version": "v21.3.0", + "versionExact": "v21.3.0" + }, { "checksumSHA1": "Ynbz9cbfu714dUSimcL4QRIg96E=", "path": "github.com/Azure/azure-sdk-for-go/services/appinsights/mgmt/2015-05-01/insights", @@ -331,32 +339,32 @@ "versionExact": "v21.3.0" }, { - "checksumSHA1": "BNcbTSVY4BRQ3Qt6Cajo4fM9Esk=", - "path": "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-06-01/subscriptions", + "checksumSHA1": "dVI8mXjcACkxDIMil3qe9FXxfo8=", + "path": "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources", "revision": "da91af54816b4cf72949c225a2d0980f51fab01b", "revisionTime": "2018-10-19T17:11:53Z", "version": "v21.3.0", "versionExact": "v21.3.0" }, { - "checksumSHA1": "ARZrveVxX1XLLg2D070/YMD/TvM=", - "path": "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks", + "checksumSHA1": "BNcbTSVY4BRQ3Qt6Cajo4fM9Esk=", + "path": "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-06-01/subscriptions", "revision": "da91af54816b4cf72949c225a2d0980f51fab01b", "revisionTime": "2018-10-19T17:11:53Z", "version": "v21.3.0", "versionExact": "v21.3.0" }, { - "checksumSHA1": "pn550P6giSwxXck8lRRaNOPwxaQ=", - "path": "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-12-01/policy", + "checksumSHA1": "ARZrveVxX1XLLg2D070/YMD/TvM=", + "path": "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks", "revision": "da91af54816b4cf72949c225a2d0980f51fab01b", "revisionTime": "2018-10-19T17:11:53Z", "version": "v21.3.0", "versionExact": "v21.3.0" }, { - "checksumSHA1": "a6pcr3i1EBmvSKpAb7BB1rnh2I8=", - "path": "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources", + "checksumSHA1": "pn550P6giSwxXck8lRRaNOPwxaQ=", + "path": "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-12-01/policy", "revision": "da91af54816b4cf72949c225a2d0980f51fab01b", "revisionTime": "2018-10-19T17:11:53Z", "version": "v21.3.0", @@ -835,6 +843,30 @@ "revision": "d6c0cd88035724dd42e0f335ae30161c20575ecc", "revisionTime": "2018-07-15T04:49:06Z" }, + { + "checksumSHA1": "YOs3XOIFl4xo5etkrYYdZgH7Kr0=", + "path": "github.com/hashicorp/go-azure-helpers/authentication", + "revision": "dd1e326c888870e63e89b057ab34711e0fe63dd8", + "revisionTime": "2018-11-20T09:40:08Z", + "version": "0.1.1", + "versionExact": "0.1.1" + }, + { + "checksumSHA1": "QwsnT5sLpT2jJ/1qJQRvqU8xl14=", + "path": "github.com/hashicorp/go-azure-helpers/resourceproviders", + "revision": "dd1e326c888870e63e89b057ab34711e0fe63dd8", + "revisionTime": "2018-11-20T09:40:08Z", + "version": "0.1.1", + "versionExact": "0.1.1" + }, + { + "checksumSHA1": "ip//Px6kdSuCH6OKEJUSMIgI3ng=", + "path": "github.com/hashicorp/go-azure-helpers/response", + "revision": "dd1e326c888870e63e89b057ab34711e0fe63dd8", + "revisionTime": "2018-11-20T09:40:08Z", + "version": "0.1.1", + "versionExact": "0.1.1" + }, { "checksumSHA1": "b8F628srIitj5p7Y130xc9k0QWs=", "path": "github.com/hashicorp/go-cleanhttp",