diff --git a/builtin/providers/azure/resource_azure_instance.go b/builtin/providers/azure/resource_azure_instance.go index 659c7a955..d270514e2 100644 --- a/builtin/providers/azure/resource_azure_instance.go +++ b/builtin/providers/azure/resource_azure_instance.go @@ -664,9 +664,10 @@ func resourceAzureInstanceDelete(d *schema.ResourceData, meta interface{}) error } err = resource.Retry(15*time.Minute, func() *resource.RetryError { - exists, err := blobClient.BlobExists( - storageContainterName, fmt.Sprintf(osDiskBlobNameFormat, name), - ) + container := blobClient.GetContainerReference(storageContainterName) + blobName := fmt.Sprintf(osDiskBlobNameFormat, name) + blob := container.GetBlobReference(blobName) + exists, err := blob.Exists() if err != nil { return resource.NonRetryableError(err) } diff --git a/builtin/providers/azure/resource_azure_instance_test.go b/builtin/providers/azure/resource_azure_instance_test.go index 95061d30f..fbe58ad66 100644 --- a/builtin/providers/azure/resource_azure_instance_test.go +++ b/builtin/providers/azure/resource_azure_instance_test.go @@ -513,7 +513,7 @@ resource "azure_security_group_rule" "foo" { resource "azure_instance" "foo" { name = "terraform-test1" - image = "Windows Server 2012 R2 Datacenter, January 2016" + image = "Windows Server 2012 R2 Datacenter, April 2017" size = "Basic_A1" storage_service_name = "%s" location = "West US" @@ -588,7 +588,7 @@ resource "azure_security_group_rule" "bar" { resource "azure_instance" "foo" { name = "terraform-test1" - image = "Windows Server 2012 R2 Datacenter, January 2016" + image = "Windows Server 2012 R2 Datacenter, April 2017" size = "Basic_A2" storage_service_name = "%s" location = "West US" diff --git a/builtin/providers/azure/resource_azure_sql_database_server_firewall_rule_test.go b/builtin/providers/azure/resource_azure_sql_database_server_firewall_rule_test.go index e85e02412..c2bcbebbf 100644 --- a/builtin/providers/azure/resource_azure_sql_database_server_firewall_rule_test.go +++ b/builtin/providers/azure/resource_azure_sql_database_server_firewall_rule_test.go @@ -187,7 +187,7 @@ resource "azure_sql_database_server" "foo" { location = "West US" username = "SuperUser" password = "SuperSEKR3T" - version = "2.0" + version = "12.0" } resource "azure_sql_database_server_firewall_rule" "foo" { @@ -204,14 +204,14 @@ resource "azure_sql_database_server" "foo" { location = "West US" username = "SuperUser" password = "SuperSEKR3T" - version = "2.0" + version = "12.0" } resource "azure_sql_database_server" "bar" { location = "West US" username = "SuperUser" password = "SuperSEKR3T" - version = "2.0" + version = "12.0" } resource "azure_sql_database_server_firewall_rule" "foo" { @@ -234,14 +234,14 @@ resource "azure_sql_database_server" "foo" { location = "West US" username = "SuperUser" password = "SuperSEKR3T" - version = "2.0" + version = "12.0" } resource "azure_sql_database_server" "bar" { location = "West US" username = "SuperUser" password = "SuperSEKR3T" - version = "2.0" + version = "12.0" } resource "azure_sql_database_server_firewall_rule" "foo" { diff --git a/builtin/providers/azure/resource_azure_sql_database_server_test.go b/builtin/providers/azure/resource_azure_sql_database_server_test.go index 46f6ae1cb..d2789712b 100644 --- a/builtin/providers/azure/resource_azure_sql_database_server_test.go +++ b/builtin/providers/azure/resource_azure_sql_database_server_test.go @@ -29,7 +29,7 @@ func TestAccAzureSqlDatabaseServer(t *testing.T) { resource.TestCheckResourceAttrPtr(name, "name", testAccAzureSqlServerName), resource.TestCheckResourceAttr(name, "username", "SuperUser"), resource.TestCheckResourceAttr(name, "password", "SuperSEKR3T"), - resource.TestCheckResourceAttr(name, "version", "2.0"), + resource.TestCheckResourceAttr(name, "version", "12.0"), ), }, }, @@ -153,6 +153,6 @@ resource "azure_sql_database_server" "foo" { location = "West US" username = "SuperUser" password = "SuperSEKR3T" - version = "2.0" + version = "12.0" } ` diff --git a/builtin/providers/azure/resource_azure_storage_blob.go b/builtin/providers/azure/resource_azure_storage_blob.go index 272874bf9..1aeee7216 100644 --- a/builtin/providers/azure/resource_azure_storage_blob.go +++ b/builtin/providers/azure/resource_azure_storage_blob.go @@ -4,6 +4,7 @@ import ( "fmt" "log" + "github.com/Azure/azure-sdk-for-go/storage" "github.com/hashicorp/terraform/helper/schema" ) @@ -73,12 +74,19 @@ func resourceAzureStorageBlobCreate(d *schema.ResourceData, meta interface{}) er name := d.Get("name").(string) blobType := d.Get("type").(string) cont := d.Get("storage_container_name").(string) + + container := blobClient.GetContainerReference(cont) + blob := container.GetBlobReference(name) + switch blobType { case "BlockBlob": - err = blobClient.CreateBlockBlob(cont, name) + options := &storage.PutBlobOptions{} + err = blob.CreateBlockBlob(options) case "PageBlob": size := int64(d.Get("size").(int)) - err = blobClient.PutPageBlob(cont, name, size, map[string]string{}) + options := &storage.PutBlobOptions{} + blob.Properties.ContentLength = size + err = blob.PutPageBlob(options) default: err = fmt.Errorf("Invalid blob type specified; see parameter desciptions for more info.") } @@ -112,7 +120,9 @@ func resourceAzureStorageBlobRead(d *schema.ResourceData, meta interface{}) erro name := d.Get("name").(string) cont := d.Get("storage_container_name").(string) - url := blobClient.GetBlobURL(cont, name) + container := blobClient.GetContainerReference(cont) + blob := container.GetBlobReference(name) + url := blob.GetURL() d.Set("url", url) } @@ -135,7 +145,9 @@ func resourceAzureStorageBlobExists(d *schema.ResourceData, meta interface{}) (b log.Println("[INFO] Querying Azure for storage blob's existence.") name := d.Get("name").(string) cont := d.Get("storage_container_name").(string) - exists, err := blobClient.BlobExists(cont, name) + container := blobClient.GetContainerReference(cont) + blob := container.GetBlobReference(name) + exists, err := blob.Exists() if err != nil { return false, fmt.Errorf("Error whilst checking for Azure storage blob's existence: %s", err) } @@ -163,7 +175,13 @@ func resourceAzureStorageBlobDelete(d *schema.ResourceData, meta interface{}) er log.Println("[INFO] Issuing storage blob delete command off Azure.") name := d.Get("name").(string) cont := d.Get("storage_container_name").(string) - if _, err = blobClient.DeleteBlobIfExists(cont, name, make(map[string]string)); err != nil { + + container := blobClient.GetContainerReference(cont) + blob := container.GetBlobReference(name) + + options := &storage.DeleteBlobOptions{} + _, err = blob.DeleteIfExists(options) + if err != nil { return fmt.Errorf("Error whilst deleting storage blob: %s", err) } diff --git a/builtin/providers/azure/resource_azure_storage_blob_test.go b/builtin/providers/azure/resource_azure_storage_blob_test.go index d559a6bcd..dad87ea16 100644 --- a/builtin/providers/azure/resource_azure_storage_blob_test.go +++ b/builtin/providers/azure/resource_azure_storage_blob_test.go @@ -72,8 +72,10 @@ func testAccCheckAzureStorageBlobExists(name, typ string) resource.TestCheckFunc return err } - exists, err := blobClient.BlobExists(fmt.Sprintf("%s-%s", testAccStorageContainerName, typ), - resource.Primary.ID) + containerName := fmt.Sprintf("%s-%s", testAccStorageContainerName, typ) + container := blobClient.GetContainerReference(containerName) + blob := container.GetBlobReference(resource.Primary.ID) + exists, err := blob.Exists() if err != nil { return err } @@ -98,8 +100,10 @@ func testAccCheckAzureStorageBlobDeleted(typ string) resource.TestCheckFunc { return err } - exists, err := blobClient.BlobExists(fmt.Sprintf("%s-%s", testAccStorageContainerName, - typ), resource.Primary.ID) + containerName := fmt.Sprintf("%s-%s", testAccStorageContainerName, typ) + container := blobClient.GetContainerReference(containerName) + blob := container.GetBlobReference(resource.Primary.ID) + exists, err := blob.Exists() if err != nil { return err } diff --git a/builtin/providers/azure/resource_azure_storage_container.go b/builtin/providers/azure/resource_azure_storage_container.go index 8b8e375da..e4f3d2886 100644 --- a/builtin/providers/azure/resource_azure_storage_container.go +++ b/builtin/providers/azure/resource_azure_storage_container.go @@ -60,7 +60,11 @@ func resourceAzureStorageContainerCreate(d *schema.ResourceData, meta interface{ log.Println("[INFO] Creating storage container on Azure.") name := d.Get("name").(string) accessType := storage.ContainerAccessType(d.Get("container_access_type").(string)) - err = blobClient.CreateContainer(name, accessType) + container := blobClient.GetContainerReference(name) + options := &storage.CreateContainerOptions{ + Access: accessType, + } + err = container.Create(options) if err != nil { return fmt.Errorf("Failed to create storage container on Azure: %s", err) } @@ -129,7 +133,8 @@ func resourceAzureStorageContainerExists(d *schema.ResourceData, meta interface{ log.Println("[INFO] Checking existence of storage container on Azure.") name := d.Get("name").(string) - exists, err := blobClient.ContainerExists(name) + container := blobClient.GetContainerReference(name) + exists, err := container.Exists() if err != nil { return false, fmt.Errorf("Failed to query for Azure storage container existence: %s", err) } @@ -154,7 +159,10 @@ func resourceAzureStorageContainerDelete(d *schema.ResourceData, meta interface{ log.Println("[INFO] Issuing Azure storage container deletion call.") name := d.Get("name").(string) - if _, err := blobClient.DeleteContainerIfExists(name); err != nil { + container := blobClient.GetContainerReference(name) + options := &storage.DeleteContainerOptions{} + _, err = container.DeleteIfExists(options) + if err != nil { return fmt.Errorf("Failed deleting storage container off Azure: %s", err) } diff --git a/builtin/providers/azure/resource_azure_storage_container_test.go b/builtin/providers/azure/resource_azure_storage_container_test.go index 6c110c5e4..7fce5463f 100644 --- a/builtin/providers/azure/resource_azure_storage_container_test.go +++ b/builtin/providers/azure/resource_azure_storage_container_test.go @@ -50,7 +50,8 @@ func testAccCheckAzureStorageContainerExists(name string) resource.TestCheckFunc return err } - exists, err := blobClient.ContainerExists(resource.Primary.ID) + container := blobClient.GetContainerReference(resource.Primary.ID) + exists, err := container.Exists() if err != nil { return err } @@ -74,7 +75,8 @@ func testAccCheckAzureStorageContainerDestroyed(s *terraform.State) error { return err } - exists, err := blobClient.ContainerExists(resource.Primary.ID) + container := blobClient.GetContainerReference(resource.Primary.ID) + exists, err := container.Exists() if err != nil { return err } diff --git a/builtin/providers/azure/resource_azure_storage_queue.go b/builtin/providers/azure/resource_azure_storage_queue.go index 4799e236e..ecbb71559 100644 --- a/builtin/providers/azure/resource_azure_storage_queue.go +++ b/builtin/providers/azure/resource_azure_storage_queue.go @@ -4,6 +4,7 @@ import ( "fmt" "log" + "github.com/Azure/azure-sdk-for-go/storage" "github.com/hashicorp/terraform/helper/schema" ) @@ -45,7 +46,9 @@ func resourceAzureStorageQueueCreate(d *schema.ResourceData, meta interface{}) e // create the queue: log.Println("Sending Storage Queue creation request to Azure.") name := d.Get("name").(string) - err = queueClient.CreateQueue(name) + queue := queueClient.GetQueueReference(name) + options := &storage.QueueServiceOptions{} + err = queue.Create(options) if err != nil { return fmt.Errorf("Error creation Storage Queue on Azure: %s", err) } @@ -67,7 +70,8 @@ func resourceAzureStorageQueueRead(d *schema.ResourceData, meta interface{}) err // check for queue's existence: log.Println("[INFO] Sending Storage Queue existence query to Azure.") name := d.Get("name").(string) - exists, err := queueClient.QueueExists(name) + queue := queueClient.GetQueueReference(name) + exists, err := queue.Exists() if err != nil { return fmt.Errorf("Error checking for Storage Queue existence: %s", err) } @@ -94,7 +98,9 @@ func resourceAzureStorageQueueDelete(d *schema.ResourceData, meta interface{}) e // issue the deletion of the storage queue: log.Println("[INFO] Sending Storage Queue deletion request to Azure.") name := d.Get("name").(string) - err = queueClient.DeleteQueue(name) + queue := queueClient.GetQueueReference(name) + options := &storage.QueueServiceOptions{} + err = queue.Delete(options) if err != nil { return fmt.Errorf("Error deleting Storage queue off Azure: %s", err) } diff --git a/builtin/providers/azure/resource_azure_storage_queue_test.go b/builtin/providers/azure/resource_azure_storage_queue_test.go index c7c691f4e..7c3cb1fd8 100644 --- a/builtin/providers/azure/resource_azure_storage_queue_test.go +++ b/builtin/providers/azure/resource_azure_storage_queue_test.go @@ -45,7 +45,8 @@ func testAccCheckAzureStorageQueueExists(name string) resource.TestCheckFunc { return err } - exists, err := queueClient.QueueExists(resource.Primary.ID) + queue := queueClient.GetQueueReference(resource.Primary.ID) + exists, err := queue.Exists() if err != nil { return fmt.Errorf("Error querying Azure for Storage Queue existence: %s", err) } @@ -73,7 +74,8 @@ func testAccCheckAzureStorageQueueDeleted(s *terraform.State) error { return err } - exists, err := queueClient.QueueExists(resource.Primary.ID) + queue := queueClient.GetQueueReference(resource.Primary.ID) + exists, err := queue.Exists() if err != nil { return fmt.Errorf("Error querying Azure for Storage Queue existence: %s", err) } diff --git a/builtin/providers/azurerm/config.go b/builtin/providers/azurerm/config.go index 80e2d5bb8..347fd8ea3 100644 --- a/builtin/providers/azurerm/config.go +++ b/builtin/providers/azurerm/config.go @@ -87,7 +87,7 @@ type ArmClient struct { jobsCollectionsClient scheduler.JobCollectionsClient storageServiceClient storage.AccountsClient - storageUsageClient storage.UsageOperationsClient + storageUsageClient storage.UsageClient deploymentsClient resources.DeploymentsClient @@ -402,7 +402,7 @@ func (c *Config) getArmClient() (*ArmClient, error) { ssc.Sender = autorest.CreateSender(withRequestLogging()) client.storageServiceClient = ssc - suc := storage.NewUsageOperationsClientWithBaseURI(endpoint, c.SubscriptionID) + suc := storage.NewUsageClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&suc.Client) suc.Authorizer = spt suc.Sender = autorest.CreateSender(withRequestLogging()) diff --git a/builtin/providers/azurerm/import_arm_container_registry_test.go b/builtin/providers/azurerm/import_arm_container_registry_test.go index 34af9a2f2..00cb54695 100644 --- a/builtin/providers/azurerm/import_arm_container_registry_test.go +++ b/builtin/providers/azurerm/import_arm_container_registry_test.go @@ -1,7 +1,6 @@ package azurerm import ( - "fmt" "testing" "github.com/hashicorp/terraform/helper/acctest" @@ -13,7 +12,7 @@ func TestAccAzureRMContainerRegistry_importBasic(t *testing.T) { ri := acctest.RandInt() rs := acctest.RandString(4) - config := fmt.Sprintf(testAccAzureRMContainerRegistry_basic, ri, rs, ri) + config := testAccAzureRMContainerRegistry_basic(ri, rs) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -39,7 +38,7 @@ func TestAccAzureRMContainerRegistry_importComplete(t *testing.T) { ri := acctest.RandInt() rs := acctest.RandString(4) - config := fmt.Sprintf(testAccAzureRMContainerRegistry_complete, ri, rs, ri) + config := testAccAzureRMContainerRegistry_complete(ri, rs) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/builtin/providers/azurerm/location.go b/builtin/providers/azurerm/location.go index 3eb51e787..21f40515b 100644 --- a/builtin/providers/azurerm/location.go +++ b/builtin/providers/azurerm/location.go @@ -16,6 +16,17 @@ func locationSchema() *schema.Schema { } } +func deprecatedLocationSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeString, + ForceNew: true, + Optional: true, + StateFunc: azureRMNormalizeLocation, + DiffSuppressFunc: azureRMSuppressLocationDiff, + Deprecated: "location is no longer used", + } +} + // azureRMNormalizeLocation is a function which normalises human-readable region/location // names (e.g. "West US") to the values used and returned by the Azure API (e.g. "westus"). // In state we track the API internal version as it is easier to go from the human form diff --git a/builtin/providers/azurerm/resource_arm_cdn_endpoint.go b/builtin/providers/azurerm/resource_arm_cdn_endpoint.go index 77d8cf29f..a06a24e60 100644 --- a/builtin/providers/azurerm/resource_arm_cdn_endpoint.go +++ b/builtin/providers/azurerm/resource_arm_cdn_endpoint.go @@ -190,7 +190,8 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro Tags: expandTags(tags), } - _, err := cdnEndpointsClient.Create(resGroup, profileName, name, cdnEndpoint, make(chan struct{})) + _, error := cdnEndpointsClient.Create(resGroup, profileName, name, cdnEndpoint, make(<-chan struct{})) + err := <-error if err != nil { return err } @@ -305,7 +306,8 @@ func resourceArmCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) erro EndpointPropertiesUpdateParameters: &properties, } - _, err := cdnEndpointsClient.Update(resGroup, profileName, name, updateProps, make(chan struct{})) + _, error := cdnEndpointsClient.Update(resGroup, profileName, name, updateProps, make(<-chan struct{})) + err := <-error if err != nil { return fmt.Errorf("Error issuing Azure ARM update request to update CDN Endpoint %q: %s", name, err) } @@ -327,15 +329,17 @@ func resourceArmCdnEndpointDelete(d *schema.ResourceData, meta interface{}) erro } name := id.Path["endpoints"] - accResp, err := client.Delete(resGroup, profileName, name, make(chan struct{})) + accResp, error := client.Delete(resGroup, profileName, name, make(<-chan struct{})) + resp := <-accResp + err = <-error if err != nil { - if accResp.StatusCode == http.StatusNotFound { + if resp.StatusCode == http.StatusNotFound { return nil } return fmt.Errorf("Error issuing AzureRM delete request for CDN Endpoint %q: %s", name, err) } - return err + return nil } func validateCdnEndpointQuerystringCachingBehaviour(v interface{}, k string) (ws []string, errors []error) { diff --git a/builtin/providers/azurerm/resource_arm_cdn_endpoint_test.go b/builtin/providers/azurerm/resource_arm_cdn_endpoint_test.go index bebd4d615..1c4928079 100644 --- a/builtin/providers/azurerm/resource_arm_cdn_endpoint_test.go +++ b/builtin/providers/azurerm/resource_arm_cdn_endpoint_test.go @@ -134,7 +134,8 @@ func testCheckAzureRMCdnEndpointDisappears(name string) resource.TestCheckFunc { conn := testAccProvider.Meta().(*ArmClient).cdnEndpointsClient - _, err := conn.Delete(resourceGroup, profileName, name, make(chan struct{})) + _, error := conn.Delete(resourceGroup, profileName, name, make(chan struct{})) + err := <-error if err != nil { return fmt.Errorf("Bad: Delete on cdnEndpointsClient: %s", err) } @@ -156,7 +157,6 @@ func testCheckAzureRMCdnEndpointDestroy(s *terraform.State) error { profileName := rs.Primary.Attributes["profile_name"] resp, err := conn.Get(resourceGroup, profileName, name) - if err != nil { return nil } diff --git a/builtin/providers/azurerm/resource_arm_cdn_profile.go b/builtin/providers/azurerm/resource_arm_cdn_profile.go index 965cb5916..b0f58746d 100644 --- a/builtin/providers/azurerm/resource_arm_cdn_profile.go +++ b/builtin/providers/azurerm/resource_arm_cdn_profile.go @@ -68,7 +68,8 @@ func resourceArmCdnProfileCreate(d *schema.ResourceData, meta interface{}) error }, } - _, err := cdnProfilesClient.Create(resGroup, name, cdnProfile, make(chan struct{})) + _, error := cdnProfilesClient.Create(resGroup, name, cdnProfile, make(chan struct{})) + err := <-error if err != nil { return err } @@ -133,7 +134,8 @@ func resourceArmCdnProfileUpdate(d *schema.ResourceData, meta interface{}) error Tags: expandTags(newTags), } - _, err := cdnProfilesClient.Update(resGroup, name, props, make(chan struct{})) + _, error := cdnProfilesClient.Update(resGroup, name, props, make(chan struct{})) + err := <-error if err != nil { return fmt.Errorf("Error issuing Azure ARM update request to update CDN Profile %q: %s", name, err) } @@ -151,7 +153,8 @@ func resourceArmCdnProfileDelete(d *schema.ResourceData, meta interface{}) error resGroup := id.ResourceGroup name := id.Path["profiles"] - _, err = cdnProfilesClient.Delete(resGroup, name, make(chan struct{})) + _, error := cdnProfilesClient.Delete(resGroup, name, make(chan struct{})) + err = <-error // TODO: check the status code return err diff --git a/builtin/providers/azurerm/resource_arm_container_registry.go b/builtin/providers/azurerm/resource_arm_container_registry.go index ff5239c76..190d5352a 100644 --- a/builtin/providers/azurerm/resource_arm_container_registry.go +++ b/builtin/providers/azurerm/resource_arm_container_registry.go @@ -11,6 +11,7 @@ import ( "github.com/Azure/azure-sdk-for-go/arm/containerregistry" "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/helper/validation" "github.com/jen20/riviera/azure" ) @@ -18,11 +19,13 @@ func resourceArmContainerRegistry() *schema.Resource { return &schema.Resource{ Create: resourceArmContainerRegistryCreate, Read: resourceArmContainerRegistryRead, - Update: resourceArmContainerRegistryCreate, + Update: resourceArmContainerRegistryUpdate, Delete: resourceArmContainerRegistryDelete, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, + MigrateState: resourceAzureRMContainerRegistryMigrateState, + SchemaVersion: 1, Schema: map[string]*schema.Schema{ "name": { @@ -40,6 +43,16 @@ func resourceArmContainerRegistry() *schema.Resource { "location": locationSchema(), + "sku": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: ignoreCaseDiffSuppressFunc, + ValidateFunc: validation.StringInSlice([]string{ + string(containerregistry.Basic), + }, true), + }, + "admin_enabled": { Type: schema.TypeBool, Optional: true, @@ -93,13 +106,18 @@ func resourceArmContainerRegistryCreate(d *schema.ResourceData, meta interface{} resourceGroup := d.Get("resource_group_name").(string) name := d.Get("name").(string) location := d.Get("location").(string) + sku := d.Get("sku").(string) adminUserEnabled := d.Get("admin_enabled").(bool) tags := d.Get("tags").(map[string]interface{}) - parameters := containerregistry.Registry{ + parameters := containerregistry.RegistryCreateParameters{ Location: &location, - RegistryProperties: &containerregistry.RegistryProperties{ + Sku: &containerregistry.Sku{ + Name: &sku, + Tier: containerregistry.SkuTier(sku), + }, + RegistryPropertiesCreateParameters: &containerregistry.RegistryPropertiesCreateParameters{ AdminUserEnabled: &adminUserEnabled, }, Tags: expandTags(tags), @@ -109,17 +127,63 @@ func resourceArmContainerRegistryCreate(d *schema.ResourceData, meta interface{} account := accounts[0].(map[string]interface{}) storageAccountName := account["name"].(string) storageAccountAccessKey := account["access_key"].(string) - parameters.RegistryProperties.StorageAccount = &containerregistry.StorageAccountProperties{ + parameters.RegistryPropertiesCreateParameters.StorageAccount = &containerregistry.StorageAccountParameters{ Name: azure.String(storageAccountName), AccessKey: azure.String(storageAccountAccessKey), } - _, err := client.CreateOrUpdate(resourceGroup, name, parameters) + _, error := client.Create(resourceGroup, name, parameters, make(<-chan struct{})) + err := <-error if err != nil { return err } - read, err := client.GetProperties(resourceGroup, name) + read, err := client.Get(resourceGroup, name) + if err != nil { + return err + } + + if read.ID == nil { + return fmt.Errorf("Cannot read Container Registry %s (resource group %s) ID", name, resourceGroup) + } + + d.SetId(*read.ID) + + return resourceArmContainerRegistryRead(d, meta) +} + +func resourceArmContainerRegistryUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).containerRegistryClient + log.Printf("[INFO] preparing arguments for AzureRM Container Registry update.") + + resourceGroup := d.Get("resource_group_name").(string) + name := d.Get("name").(string) + + accounts := d.Get("storage_account").(*schema.Set).List() + account := accounts[0].(map[string]interface{}) + storageAccountName := account["name"].(string) + storageAccountAccessKey := account["access_key"].(string) + + adminUserEnabled := d.Get("admin_enabled").(bool) + tags := d.Get("tags").(map[string]interface{}) + + parameters := containerregistry.RegistryUpdateParameters{ + RegistryPropertiesUpdateParameters: &containerregistry.RegistryPropertiesUpdateParameters{ + AdminUserEnabled: &adminUserEnabled, + StorageAccount: &containerregistry.StorageAccountParameters{ + Name: azure.String(storageAccountName), + AccessKey: azure.String(storageAccountAccessKey), + }, + }, + Tags: expandTags(tags), + } + + _, err := client.Update(resourceGroup, name, parameters) + if err != nil { + return err + } + + read, err := client.Get(resourceGroup, name) if err != nil { return err } @@ -143,7 +207,7 @@ func resourceArmContainerRegistryRead(d *schema.ResourceData, meta interface{}) resourceGroup := id.ResourceGroup name := id.Path["registries"] - resp, err := client.GetProperties(resourceGroup, name) + resp, err := client.Get(resourceGroup, name) if err != nil { return fmt.Errorf("Error making Read request on Azure Container Registry %s: %s", name, err) } @@ -158,18 +222,25 @@ func resourceArmContainerRegistryRead(d *schema.ResourceData, meta interface{}) d.Set("admin_enabled", resp.AdminUserEnabled) d.Set("login_server", resp.LoginServer) + if resp.Sku != nil { + d.Set("sku", string(resp.Sku.Tier)) + } + if resp.StorageAccount != nil { flattenArmContainerRegistryStorageAccount(d, resp.StorageAccount) } if *resp.AdminUserEnabled { - credsResp, err := client.GetCredentials(resourceGroup, name) + credsResp, err := client.ListCredentials(resourceGroup, name) if err != nil { return fmt.Errorf("Error making Read request on Azure Container Registry %s for Credentials: %s", name, err) } d.Set("admin_username", credsResp.Username) - d.Set("admin_password", credsResp.Password) + for _, v := range *credsResp.Passwords { + d.Set("admin_password", v.Value) + break + } } else { d.Set("admin_username", "") d.Set("admin_password", "") diff --git a/builtin/providers/azurerm/resource_arm_container_registry_migrate.go b/builtin/providers/azurerm/resource_arm_container_registry_migrate.go new file mode 100644 index 000000000..6c6ff58f3 --- /dev/null +++ b/builtin/providers/azurerm/resource_arm_container_registry_migrate.go @@ -0,0 +1,34 @@ +package azurerm + +import ( + "fmt" + "log" + + "github.com/hashicorp/terraform/terraform" +) + +func resourceAzureRMContainerRegistryMigrateState( + v int, is *terraform.InstanceState, meta interface{}) (*terraform.InstanceState, error) { + switch v { + case 0: + log.Println("[INFO] Found AzureRM Container Registry State v0; migrating to v1") + return migrateAzureRMContainerRegistryStateV0toV1(is) + default: + return is, fmt.Errorf("Unexpected schema version: %d", v) + } +} + +func migrateAzureRMContainerRegistryStateV0toV1(is *terraform.InstanceState) (*terraform.InstanceState, error) { + if is.Empty() { + log.Println("[DEBUG] Empty InstanceState; nothing to migrate.") + return is, nil + } + + log.Printf("[DEBUG] ARM Container Registry Attributes before Migration: %#v", is.Attributes) + + is.Attributes["sku"] = "Basic" + + log.Printf("[DEBUG] ARM Container Registry Attributes after State Migration: %#v", is.Attributes) + + return is, nil +} diff --git a/builtin/providers/azurerm/resource_arm_container_registry_migrate_test.go b/builtin/providers/azurerm/resource_arm_container_registry_migrate_test.go new file mode 100644 index 000000000..43d65a242 --- /dev/null +++ b/builtin/providers/azurerm/resource_arm_container_registry_migrate_test.go @@ -0,0 +1,40 @@ +package azurerm + +import ( + "testing" + + "github.com/hashicorp/terraform/terraform" +) + +func TestAzureRMContainerRegistryMigrateState(t *testing.T) { + cases := map[string]struct { + StateVersion int + ID string + Attributes map[string]string + Expected string + Meta interface{} + }{ + "v0_1_without_value": { + StateVersion: 0, + ID: "some_id", + Attributes: map[string]string{}, + Expected: "Basic", + }, + } + + for tn, tc := range cases { + is := &terraform.InstanceState{ + ID: tc.ID, + Attributes: tc.Attributes, + } + is, err := resourceAzureRMContainerRegistryMigrateState(tc.StateVersion, is, tc.Meta) + + if err != nil { + t.Fatalf("bad: %s, err: %#v", tn, err) + } + + if is.Attributes["sku"] != tc.Expected { + t.Fatalf("bad Container Registry Migrate: %s\n\n expected: %s", is.Attributes["sku"], tc.Expected) + } + } +} diff --git a/builtin/providers/azurerm/resource_arm_container_registry_test.go b/builtin/providers/azurerm/resource_arm_container_registry_test.go index 77288b8b6..7efc92472 100644 --- a/builtin/providers/azurerm/resource_arm_container_registry_test.go +++ b/builtin/providers/azurerm/resource_arm_container_registry_test.go @@ -69,7 +69,7 @@ func TestAccAzureRMContainerRegistryName_validation(t *testing.T) { func TestAccAzureRMContainerRegistry_basic(t *testing.T) { ri := acctest.RandInt() rs := acctest.RandString(4) - config := fmt.Sprintf(testAccAzureRMContainerRegistry_basic, ri, rs, ri) + config := testAccAzureRMContainerRegistry_basic(ri, rs) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -89,7 +89,7 @@ func TestAccAzureRMContainerRegistry_basic(t *testing.T) { func TestAccAzureRMContainerRegistry_complete(t *testing.T) { ri := acctest.RandInt() rs := acctest.RandString(4) - config := fmt.Sprintf(testAccAzureRMContainerRegistry_complete, ri, rs, ri) + config := testAccAzureRMContainerRegistry_complete(ri, rs) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -106,6 +106,33 @@ func TestAccAzureRMContainerRegistry_complete(t *testing.T) { }) } +func TestAccAzureRMContainerRegistry_update(t *testing.T) { + ri := acctest.RandInt() + rs := acctest.RandString(4) + config := testAccAzureRMContainerRegistry_complete(ri, rs) + updatedConfig := testAccAzureRMContainerRegistry_completeUpdated(ri, rs) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMContainerRegistryDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMContainerRegistryExists("azurerm_container_registry.test"), + ), + }, + { + Config: updatedConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMContainerRegistryExists("azurerm_container_registry.test"), + ), + }, + }, + }) +} + func testCheckAzureRMContainerRegistryDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*ArmClient).containerRegistryClient @@ -117,7 +144,7 @@ func testCheckAzureRMContainerRegistryDestroy(s *terraform.State) error { name := rs.Primary.Attributes["name"] resourceGroup := rs.Primary.Attributes["resource_group_name"] - resp, err := conn.GetProperties(resourceGroup, name) + resp, err := conn.Get(resourceGroup, name) if err != nil { return nil @@ -147,7 +174,7 @@ func testCheckAzureRMContainerRegistryExists(name string) resource.TestCheckFunc conn := testAccProvider.Meta().(*ArmClient).containerRegistryClient - resp, err := conn.GetProperties(resourceGroup, name) + resp, err := conn.Get(resourceGroup, name) if err != nil { return fmt.Errorf("Bad: Get on containerRegistryClient: %s", err) } @@ -160,7 +187,8 @@ func testCheckAzureRMContainerRegistryExists(name string) resource.TestCheckFunc } } -var testAccAzureRMContainerRegistry_basic = ` +func testAccAzureRMContainerRegistry_basic(rInt int, rStr string) string { + return fmt.Sprintf(` resource "azurerm_resource_group" "test" { name = "testAccRg-%d" location = "West US" @@ -177,15 +205,18 @@ resource "azurerm_container_registry" "test" { name = "testacccr%d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" + sku = "Basic" storage_account { name = "${azurerm_storage_account.test.name}" access_key = "${azurerm_storage_account.test.primary_access_key}" } } -` +`, rInt, rStr, rInt) +} -var testAccAzureRMContainerRegistry_complete = ` +func testAccAzureRMContainerRegistry_complete(rInt int, rStr string) string { + return fmt.Sprintf(` resource "azurerm_resource_group" "test" { name = "testAccRg-%d" location = "West US" @@ -203,6 +234,7 @@ resource "azurerm_container_registry" "test" { resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" admin_enabled = false + sku = "Basic" storage_account { name = "${azurerm_storage_account.test.name}" @@ -213,4 +245,38 @@ resource "azurerm_container_registry" "test" { environment = "production" } } -` +`, rInt, rStr, rInt) +} + +func testAccAzureRMContainerRegistry_completeUpdated(rInt int, rStr string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "testAccRg-%d" + location = "West US" +} + +resource "azurerm_storage_account" "test" { + name = "testaccsa%s" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + account_type = "Standard_LRS" +} + +resource "azurerm_container_registry" "test" { + name = "testacccr%d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + admin_enabled = true + sku = "Basic" + + storage_account { + name = "${azurerm_storage_account.test.name}" + access_key = "${azurerm_storage_account.test.primary_access_key}" + } + + tags { + environment = "production" + } +} +`, rInt, rStr, rInt) +} diff --git a/builtin/providers/azurerm/resource_arm_container_service.go b/builtin/providers/azurerm/resource_arm_container_service.go index a49ec6591..da9db3580 100644 --- a/builtin/providers/azurerm/resource_arm_container_service.go +++ b/builtin/providers/azurerm/resource_arm_container_service.go @@ -224,7 +224,8 @@ func resourceArmContainerServiceCreate(d *schema.ResourceData, meta interface{}) parameters.ServicePrincipalProfile = servicePrincipalProfile } - _, err := containerServiceClient.CreateOrUpdate(resGroup, name, parameters, make(chan struct{})) + _, error := containerServiceClient.CreateOrUpdate(resGroup, name, parameters, make(chan struct{})) + err := <-error if err != nil { return err } @@ -315,7 +316,9 @@ func resourceArmContainerServiceDelete(d *schema.ResourceData, meta interface{}) resGroup := id.ResourceGroup name := id.Path["containerServices"] - resp, err := containerServiceClient.Delete(resGroup, name, make(chan struct{})) + delResp, error := containerServiceClient.Delete(resGroup, name, make(chan struct{})) + resp := <-delResp + err = <-error if err != nil { return err } diff --git a/builtin/providers/azurerm/resource_arm_eventhub.go b/builtin/providers/azurerm/resource_arm_eventhub.go index 169cf690f..672f8a927 100644 --- a/builtin/providers/azurerm/resource_arm_eventhub.go +++ b/builtin/providers/azurerm/resource_arm_eventhub.go @@ -69,8 +69,8 @@ func resourceArmEventHubCreate(d *schema.ResourceData, meta interface{}) error { log.Printf("[INFO] preparing arguments for Azure ARM EventHub creation.") name := d.Get("name").(string) - namespaceName := d.Get("namespace_name").(string) location := d.Get("location").(string) + namespaceName := d.Get("namespace_name").(string) resGroup := d.Get("resource_group_name").(string) partitionCount := int64(d.Get("partition_count").(int)) messageRetention := int64(d.Get("message_retention").(int)) @@ -123,9 +123,9 @@ func resourceArmEventHubRead(d *schema.ResourceData, meta interface{}) error { } d.Set("name", resp.Name) + d.Set("location", azureRMNormalizeLocation(*resp.Location)) d.Set("namespace_name", namespaceName) d.Set("resource_group_name", resGroup) - d.Set("location", azureRMNormalizeLocation(*resp.Location)) d.Set("partition_count", resp.Properties.PartitionCount) d.Set("message_retention", resp.Properties.MessageRetentionInDays) diff --git a/builtin/providers/azurerm/resource_arm_eventhub_authorization_rule.go b/builtin/providers/azurerm/resource_arm_eventhub_authorization_rule.go index f6f081677..2c3e53622 100644 --- a/builtin/providers/azurerm/resource_arm_eventhub_authorization_rule.go +++ b/builtin/providers/azurerm/resource_arm_eventhub_authorization_rule.go @@ -90,12 +90,12 @@ func resourceArmEventHubAuthorizationRule() *schema.Resource { func resourceArmEventHubAuthorizationRuleCreateUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*ArmClient).eventHubClient - log.Printf("[INFO] preparing arguments for Azure ARM EventHub Authorization Rule creation.") + log.Printf("[INFO] preparing arguments for AzureRM EventHub Authorization Rule creation.") name := d.Get("name").(string) + location := d.Get("location").(string) namespaceName := d.Get("namespace_name").(string) eventHubName := d.Get("eventhub_name").(string) - location := d.Get("location").(string) resGroup := d.Get("resource_group_name").(string) rights, err := expandEventHubAuthorizationRuleAccessRights(d) @@ -157,10 +157,10 @@ func resourceArmEventHubAuthorizationRuleRead(d *schema.ResourceData, meta inter } d.Set("name", name) + d.Set("location", azureRMNormalizeLocation(*resp.Location)) d.Set("eventhub_name", eventHubName) d.Set("namespace_name", namespaceName) d.Set("resource_group_name", resGroup) - d.Set("location", azureRMNormalizeLocation(*resp.Location)) flattenEventHubAuthorizationRuleAccessRights(d, resp) diff --git a/builtin/providers/azurerm/resource_arm_eventhub_authorization_rule_test.go b/builtin/providers/azurerm/resource_arm_eventhub_authorization_rule_test.go index cca1e8587..aee455b27 100644 --- a/builtin/providers/azurerm/resource_arm_eventhub_authorization_rule_test.go +++ b/builtin/providers/azurerm/resource_arm_eventhub_authorization_rule_test.go @@ -144,20 +144,20 @@ func testCheckAzureRMEventHubAuthorizationRuleExists(name string) resource.TestC var testAccAzureRMEventHubAuthorizationRule_listen = ` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "West US" + name = "acctestRG-%d" + location = "West US" } resource "azurerm_eventhub_namespace" "test" { - name = "acctesteventhubnamespace-%d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" - sku = "Standard" + name = "acctesteventhubnamespace-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + sku = "Standard" } resource "azurerm_eventhub" "test" { name = "acctesteventhub-%d" namespace_name = "${azurerm_eventhub_namespace.test.name}" - location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" partition_count = 2 message_retention = 7 } @@ -174,20 +174,20 @@ resource "azurerm_eventhub_authorization_rule" "test" { var testAccAzureRMEventHubAuthorizationRule_send = ` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "West US" + name = "acctestRG-%d" + location = "West US" } resource "azurerm_eventhub_namespace" "test" { - name = "acctesteventhubnamespace-%d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" - sku = "Standard" + name = "acctesteventhubnamespace-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + sku = "Standard" } resource "azurerm_eventhub" "test" { name = "acctesteventhub-%d" namespace_name = "${azurerm_eventhub_namespace.test.name}" - location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" partition_count = 2 message_retention = 7 } @@ -204,20 +204,20 @@ resource "azurerm_eventhub_authorization_rule" "test" { var testAccAzureRMEventHubAuthorizationRule_readwrite = ` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "West US" + name = "acctestRG-%d" + location = "West US" } resource "azurerm_eventhub_namespace" "test" { - name = "acctesteventhubnamespace-%d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" - sku = "Standard" + name = "acctesteventhubnamespace-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + sku = "Standard" } resource "azurerm_eventhub" "test" { name = "acctesteventhub-%d" namespace_name = "${azurerm_eventhub_namespace.test.name}" - location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" partition_count = 2 message_retention = 7 } @@ -234,20 +234,20 @@ resource "azurerm_eventhub_authorization_rule" "test" { var testAccAzureRMEventHubAuthorizationRule_manage = ` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "West US" + name = "acctestRG-%d" + location = "West US" } resource "azurerm_eventhub_namespace" "test" { - name = "acctesteventhubnamespace-%d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" - sku = "Standard" + name = "acctesteventhubnamespace-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + sku = "Standard" } resource "azurerm_eventhub" "test" { name = "acctesteventhub-%d" namespace_name = "${azurerm_eventhub_namespace.test.name}" - location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" partition_count = 2 message_retention = 7 } diff --git a/builtin/providers/azurerm/resource_arm_eventhub_consumer_group.go b/builtin/providers/azurerm/resource_arm_eventhub_consumer_group.go index f098ff808..618ec0db1 100644 --- a/builtin/providers/azurerm/resource_arm_eventhub_consumer_group.go +++ b/builtin/providers/azurerm/resource_arm_eventhub_consumer_group.go @@ -58,12 +58,12 @@ func resourceArmEventHubConsumerGroup() *schema.Resource { func resourceArmEventHubConsumerGroupCreateUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*ArmClient) eventhubClient := client.eventHubConsumerGroupClient - log.Printf("[INFO] preparing arguments for Azure ARM EventHub Consumer Group creation.") + log.Printf("[INFO] preparing arguments for AzureRM EventHub Consumer Group creation.") name := d.Get("name").(string) + location := d.Get("location").(string) namespaceName := d.Get("namespace_name").(string) eventHubName := d.Get("eventhub_name").(string) - location := d.Get("location").(string) resGroup := d.Get("resource_group_name").(string) userMetaData := d.Get("user_metadata").(string) @@ -117,10 +117,10 @@ func resourceArmEventHubConsumerGroupRead(d *schema.ResourceData, meta interface } d.Set("name", name) + d.Set("location", azureRMNormalizeLocation(*resp.Location)) d.Set("eventhub_name", eventHubName) d.Set("namespace_name", namespaceName) d.Set("resource_group_name", resGroup) - d.Set("location", azureRMNormalizeLocation(*resp.Location)) d.Set("user_metadata", resp.ConsumerGroupProperties.UserMetadata) return nil diff --git a/builtin/providers/azurerm/resource_arm_eventhub_consumer_group_test.go b/builtin/providers/azurerm/resource_arm_eventhub_consumer_group_test.go index 206f00c0f..04f3a9503 100644 --- a/builtin/providers/azurerm/resource_arm_eventhub_consumer_group_test.go +++ b/builtin/providers/azurerm/resource_arm_eventhub_consumer_group_test.go @@ -122,20 +122,20 @@ resource "azurerm_eventhub_namespace" "test" { } resource "azurerm_eventhub" "test" { - name = "acctesteventhub-%d" - namespace_name = "${azurerm_eventhub_namespace.test.name}" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" - partition_count = 2 - message_retention = 7 + name = "acctesteventhub-%d" + namespace_name = "${azurerm_eventhub_namespace.test.name}" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + partition_count = 2 + message_retention = 7 } resource "azurerm_eventhub_consumer_group" "test" { name = "acctesteventhubcg-%d" - namespace_name = "${azurerm_eventhub_namespace.test.name}" - eventhub_name = "${azurerm_eventhub.test.name}" + namespace_name = "${azurerm_eventhub_namespace.test.name}" + eventhub_name = "${azurerm_eventhub.test.name}" + location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" - location = "${azurerm_resource_group.test.location}" } ` @@ -152,20 +152,20 @@ resource "azurerm_eventhub_namespace" "test" { } resource "azurerm_eventhub" "test" { - name = "acctesteventhub-%d" - namespace_name = "${azurerm_eventhub_namespace.test.name}" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" - partition_count = 2 - message_retention = 7 + name = "acctesteventhub-%d" + namespace_name = "${azurerm_eventhub_namespace.test.name}" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + partition_count = 2 + message_retention = 7 } resource "azurerm_eventhub_consumer_group" "test" { - name = "acctesteventhubcg-%d" - namespace_name = "${azurerm_eventhub_namespace.test.name}" - eventhub_name = "${azurerm_eventhub.test.name}" + name = "acctesteventhubcg-%d" + namespace_name = "${azurerm_eventhub_namespace.test.name}" + eventhub_name = "${azurerm_eventhub.test.name}" + location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" - location = "${azurerm_resource_group.test.location}" - user_metadata = "some-meta-data" + user_metadata = "some-meta-data" } ` diff --git a/builtin/providers/azurerm/resource_arm_eventhub_namespace.go b/builtin/providers/azurerm/resource_arm_eventhub_namespace.go index d39016799..01a0bd8da 100644 --- a/builtin/providers/azurerm/resource_arm_eventhub_namespace.go +++ b/builtin/providers/azurerm/resource_arm_eventhub_namespace.go @@ -100,7 +100,8 @@ func resourceArmEventHubNamespaceCreate(d *schema.ResourceData, meta interface{} Tags: expandTags(tags), } - _, err := namespaceClient.CreateOrUpdate(resGroup, name, parameters, make(chan struct{})) + _, error := namespaceClient.CreateOrUpdate(resGroup, name, parameters, make(chan struct{})) + err := <-error if err != nil { return err } @@ -169,9 +170,10 @@ func resourceArmEventHubNamespaceDelete(d *schema.ResourceData, meta interface{} resGroup := id.ResourceGroup name := id.Path["namespaces"] - resp, err := namespaceClient.Delete(resGroup, name, make(chan struct{})) + _, error := namespaceClient.Delete(resGroup, name, make(chan struct{})) + err = <-error - if resp.StatusCode != http.StatusNotFound { + if err != nil { return fmt.Errorf("Error issuing Azure ARM delete request of EventHub Namespace '%s': %+v", name, err) } diff --git a/builtin/providers/azurerm/resource_arm_express_route_circuit.go b/builtin/providers/azurerm/resource_arm_express_route_circuit.go index 3f17fff79..2c03cbf03 100644 --- a/builtin/providers/azurerm/resource_arm_express_route_circuit.go +++ b/builtin/providers/azurerm/resource_arm_express_route_circuit.go @@ -142,7 +142,8 @@ func resourceArmExpressRouteCircuitCreateOrUpdate(d *schema.ResourceData, meta i Tags: expandedTags, } - _, err := ercClient.CreateOrUpdate(resGroup, name, erc, make(chan struct{})) + _, error := ercClient.CreateOrUpdate(resGroup, name, erc, make(chan struct{})) + err := <-error if err != nil { return errwrap.Wrapf("Error Creating/Updating ExpressRouteCircuit {{err}}", err) } @@ -203,7 +204,8 @@ func resourceArmExpressRouteCircuitDelete(d *schema.ResourceData, meta interface return errwrap.Wrapf("Error Parsing Azure Resource ID {{err}}", err) } - _, err = ercClient.Delete(resGroup, name, make(chan struct{})) + _, error := ercClient.Delete(resGroup, name, make(chan struct{})) + err = <-error return err } diff --git a/builtin/providers/azurerm/resource_arm_loadbalancer.go b/builtin/providers/azurerm/resource_arm_loadbalancer.go index 940b3fb98..6b9e4aacc 100644 --- a/builtin/providers/azurerm/resource_arm_loadbalancer.go +++ b/builtin/providers/azurerm/resource_arm_loadbalancer.go @@ -127,7 +127,8 @@ func resourceArmLoadBalancerCreate(d *schema.ResourceData, meta interface{}) err LoadBalancerPropertiesFormat: &properties, } - _, err := loadBalancerClient.CreateOrUpdate(resGroup, name, loadbalancer, make(chan struct{})) + _, error := loadBalancerClient.CreateOrUpdate(resGroup, name, loadbalancer, make(chan struct{})) + err := <-error if err != nil { return errwrap.Wrapf("Error Creating/Updating LoadBalancer {{err}}", err) } @@ -205,7 +206,8 @@ func resourceArmLoadBalancerDelete(d *schema.ResourceData, meta interface{}) err resGroup := id.ResourceGroup name := id.Path["loadBalancers"] - _, err = loadBalancerClient.Delete(resGroup, name, make(chan struct{})) + _, error := loadBalancerClient.Delete(resGroup, name, make(chan struct{})) + err = <-error if err != nil { return errwrap.Wrapf("Error Deleting LoadBalancer {{err}}", err) } diff --git a/builtin/providers/azurerm/resource_arm_loadbalancer_backend_address_pool.go b/builtin/providers/azurerm/resource_arm_loadbalancer_backend_address_pool.go index 0a7e4ae29..465860f84 100644 --- a/builtin/providers/azurerm/resource_arm_loadbalancer_backend_address_pool.go +++ b/builtin/providers/azurerm/resource_arm_loadbalancer_backend_address_pool.go @@ -28,14 +28,7 @@ func resourceArmLoadBalancerBackendAddressPool() *schema.Resource { ForceNew: true, }, - "location": { - Type: schema.TypeString, - ForceNew: true, - Optional: true, - StateFunc: azureRMNormalizeLocation, - DiffSuppressFunc: azureRMSuppressLocationDiff, - Deprecated: "location is no longer used", - }, + "location": deprecatedLocationSchema(), "resource_group_name": { Type: schema.TypeString, @@ -99,7 +92,8 @@ func resourceArmLoadBalancerBackendAddressPoolCreate(d *schema.ResourceData, met return errwrap.Wrapf("Error Getting LoadBalancer Name and Group: {{err}}", err) } - _, err = lbClient.CreateOrUpdate(resGroup, loadBalancerName, *loadBalancer, make(chan struct{})) + _, error := lbClient.CreateOrUpdate(resGroup, loadBalancerName, *loadBalancer, make(chan struct{})) + err = <-error if err != nil { return errwrap.Wrapf("Error Creating/Updating LoadBalancer {{err}}", err) } @@ -217,7 +211,8 @@ func resourceArmLoadBalancerBackendAddressPoolDelete(d *schema.ResourceData, met return errwrap.Wrapf("Error Getting LoadBalancer Name and Group: {{err}}", err) } - _, err = lbClient.CreateOrUpdate(resGroup, loadBalancerName, *loadBalancer, make(chan struct{})) + _, error := lbClient.CreateOrUpdate(resGroup, loadBalancerName, *loadBalancer, make(chan struct{})) + err = <-error if err != nil { return errwrap.Wrapf("Error Creating/Updating LoadBalancer {{err}}", err) } diff --git a/builtin/providers/azurerm/resource_arm_loadbalancer_backend_address_pool_test.go b/builtin/providers/azurerm/resource_arm_loadbalancer_backend_address_pool_test.go index 316fe2e9e..14a52135f 100644 --- a/builtin/providers/azurerm/resource_arm_loadbalancer_backend_address_pool_test.go +++ b/builtin/providers/azurerm/resource_arm_loadbalancer_backend_address_pool_test.go @@ -157,7 +157,8 @@ func testCheckAzureRMLoadBalancerBackEndAddressPoolDisappears(addressPoolName st return err } - _, err = conn.CreateOrUpdate(id.ResourceGroup, *lb.Name, *lb, make(chan struct{})) + _, error := conn.CreateOrUpdate(id.ResourceGroup, *lb.Name, *lb, make(chan struct{})) + err = <-error if err != nil { return fmt.Errorf("Error Creating/Updating LoadBalancer %s", err) } diff --git a/builtin/providers/azurerm/resource_arm_loadbalancer_nat_pool.go b/builtin/providers/azurerm/resource_arm_loadbalancer_nat_pool.go index 683be636d..59356ac91 100644 --- a/builtin/providers/azurerm/resource_arm_loadbalancer_nat_pool.go +++ b/builtin/providers/azurerm/resource_arm_loadbalancer_nat_pool.go @@ -29,14 +29,7 @@ func resourceArmLoadBalancerNatPool() *schema.Resource { ForceNew: true, }, - "location": { - Type: schema.TypeString, - ForceNew: true, - Optional: true, - StateFunc: azureRMNormalizeLocation, - DiffSuppressFunc: azureRMSuppressLocationDiff, - Deprecated: "location is no longer used", - }, + "location": deprecatedLocationSchema(), "resource_group_name": { Type: schema.TypeString, @@ -124,7 +117,8 @@ func resourceArmLoadBalancerNatPoolCreate(d *schema.ResourceData, meta interface return errwrap.Wrapf("Error Getting LoadBalancer Name and Group: {{err}}", err) } - _, err = lbClient.CreateOrUpdate(resGroup, loadBalancerName, *loadBalancer, make(chan struct{})) + _, error := lbClient.CreateOrUpdate(resGroup, loadBalancerName, *loadBalancer, make(chan struct{})) + err = <-error if err != nil { return errwrap.Wrapf("Error Creating/Updating LoadBalancer {{err}}", err) } @@ -239,7 +233,8 @@ func resourceArmLoadBalancerNatPoolDelete(d *schema.ResourceData, meta interface return errwrap.Wrapf("Error Getting LoadBalancer Name and Group: {{err}}", err) } - _, err = lbClient.CreateOrUpdate(resGroup, loadBalancerName, *loadBalancer, make(chan struct{})) + _, error := lbClient.CreateOrUpdate(resGroup, loadBalancerName, *loadBalancer, make(chan struct{})) + err = <-error if err != nil { return errwrap.Wrapf("Error Creating/Updating LoadBalancer {{err}}", err) } diff --git a/builtin/providers/azurerm/resource_arm_loadbalancer_nat_pool_test.go b/builtin/providers/azurerm/resource_arm_loadbalancer_nat_pool_test.go index b64dd786b..f6e77b1fd 100644 --- a/builtin/providers/azurerm/resource_arm_loadbalancer_nat_pool_test.go +++ b/builtin/providers/azurerm/resource_arm_loadbalancer_nat_pool_test.go @@ -197,7 +197,8 @@ func testCheckAzureRMLoadBalancerNatPoolDisappears(natPoolName string, lb *netwo return err } - _, err = conn.CreateOrUpdate(id.ResourceGroup, *lb.Name, *lb, make(chan struct{})) + _, error := conn.CreateOrUpdate(id.ResourceGroup, *lb.Name, *lb, make(chan struct{})) + err = <-error if err != nil { return fmt.Errorf("Error Creating/Updating LoadBalancer %s", err) } diff --git a/builtin/providers/azurerm/resource_arm_loadbalancer_nat_rule.go b/builtin/providers/azurerm/resource_arm_loadbalancer_nat_rule.go index e33684312..6c1b15dac 100644 --- a/builtin/providers/azurerm/resource_arm_loadbalancer_nat_rule.go +++ b/builtin/providers/azurerm/resource_arm_loadbalancer_nat_rule.go @@ -29,14 +29,7 @@ func resourceArmLoadBalancerNatRule() *schema.Resource { ForceNew: true, }, - "location": { - Type: schema.TypeString, - ForceNew: true, - Optional: true, - StateFunc: azureRMNormalizeLocation, - DiffSuppressFunc: azureRMSuppressLocationDiff, - Deprecated: "location is no longer used", - }, + "location": deprecatedLocationSchema(), "resource_group_name": { Type: schema.TypeString, @@ -124,7 +117,8 @@ func resourceArmLoadBalancerNatRuleCreate(d *schema.ResourceData, meta interface return errwrap.Wrapf("Error Getting LoadBalancer Name and Group: {{err}}", err) } - _, err = lbClient.CreateOrUpdate(resGroup, loadBalancerName, *loadBalancer, make(chan struct{})) + _, error := lbClient.CreateOrUpdate(resGroup, loadBalancerName, *loadBalancer, make(chan struct{})) + err = <-error if err != nil { return errwrap.Wrapf("Error Creating / Updating LoadBalancer {{err}}", err) } @@ -242,7 +236,8 @@ func resourceArmLoadBalancerNatRuleDelete(d *schema.ResourceData, meta interface return errwrap.Wrapf("Error Getting LoadBalancer Name and Group: {{err}}", err) } - _, err = lbClient.CreateOrUpdate(resGroup, loadBalancerName, *loadBalancer, make(chan struct{})) + _, error := lbClient.CreateOrUpdate(resGroup, loadBalancerName, *loadBalancer, make(chan struct{})) + err = <-error if err != nil { return errwrap.Wrapf("Error Creating/Updating LoadBalancer {{err}}", err) } diff --git a/builtin/providers/azurerm/resource_arm_loadbalancer_nat_rule_test.go b/builtin/providers/azurerm/resource_arm_loadbalancer_nat_rule_test.go index cfa4a65dd..aef65b154 100644 --- a/builtin/providers/azurerm/resource_arm_loadbalancer_nat_rule_test.go +++ b/builtin/providers/azurerm/resource_arm_loadbalancer_nat_rule_test.go @@ -199,7 +199,8 @@ func testCheckAzureRMLoadBalancerNatRuleDisappears(natRuleName string, lb *netwo return err } - _, err = conn.CreateOrUpdate(id.ResourceGroup, *lb.Name, *lb, make(chan struct{})) + _, error := conn.CreateOrUpdate(id.ResourceGroup, *lb.Name, *lb, make(chan struct{})) + err = <-error if err != nil { return fmt.Errorf("Error Creating/Updating LoadBalancer %s", err) } diff --git a/builtin/providers/azurerm/resource_arm_loadbalancer_probe.go b/builtin/providers/azurerm/resource_arm_loadbalancer_probe.go index df67c6ac6..640865696 100644 --- a/builtin/providers/azurerm/resource_arm_loadbalancer_probe.go +++ b/builtin/providers/azurerm/resource_arm_loadbalancer_probe.go @@ -29,14 +29,7 @@ func resourceArmLoadBalancerProbe() *schema.Resource { ForceNew: true, }, - "location": { - Type: schema.TypeString, - ForceNew: true, - Optional: true, - StateFunc: azureRMNormalizeLocation, - DiffSuppressFunc: azureRMSuppressLocationDiff, - Deprecated: "location is no longer used", - }, + "location": deprecatedLocationSchema(), "resource_group_name": { Type: schema.TypeString, @@ -129,7 +122,8 @@ func resourceArmLoadBalancerProbeCreate(d *schema.ResourceData, meta interface{} return errwrap.Wrapf("Error Getting LoadBalancer Name and Group: {{err}}", err) } - _, err = lbClient.CreateOrUpdate(resGroup, loadBalancerName, *loadBalancer, make(chan struct{})) + _, error := lbClient.CreateOrUpdate(resGroup, loadBalancerName, *loadBalancer, make(chan struct{})) + err = <-error if err != nil { return errwrap.Wrapf("Error Creating/Updating LoadBalancer {{err}}", err) } @@ -243,7 +237,8 @@ func resourceArmLoadBalancerProbeDelete(d *schema.ResourceData, meta interface{} return errwrap.Wrapf("Error Getting LoadBalancer Name and Group: {{err}}", err) } - _, err = lbClient.CreateOrUpdate(resGroup, loadBalancerName, *loadBalancer, make(chan struct{})) + _, error := lbClient.CreateOrUpdate(resGroup, loadBalancerName, *loadBalancer, make(chan struct{})) + err = <-error if err != nil { return errwrap.Wrapf("Error Creating/Updating LoadBalancer {{err}}", err) } diff --git a/builtin/providers/azurerm/resource_arm_loadbalancer_probe_test.go b/builtin/providers/azurerm/resource_arm_loadbalancer_probe_test.go index 5f5f816db..560aae7b2 100644 --- a/builtin/providers/azurerm/resource_arm_loadbalancer_probe_test.go +++ b/builtin/providers/azurerm/resource_arm_loadbalancer_probe_test.go @@ -227,7 +227,8 @@ func testCheckAzureRMLoadBalancerProbeDisappears(addressPoolName string, lb *net return err } - _, err = conn.CreateOrUpdate(id.ResourceGroup, *lb.Name, *lb, make(chan struct{})) + _, error := conn.CreateOrUpdate(id.ResourceGroup, *lb.Name, *lb, make(chan struct{})) + err = <-error if err != nil { return fmt.Errorf("Error Creating/Updating LoadBalancer %s", err) } diff --git a/builtin/providers/azurerm/resource_arm_loadbalancer_rule.go b/builtin/providers/azurerm/resource_arm_loadbalancer_rule.go index 7bcbe0744..89d39c602 100644 --- a/builtin/providers/azurerm/resource_arm_loadbalancer_rule.go +++ b/builtin/providers/azurerm/resource_arm_loadbalancer_rule.go @@ -31,14 +31,7 @@ func resourceArmLoadBalancerRule() *schema.Resource { ValidateFunc: validateArmLoadBalancerRuleName, }, - "location": { - Type: schema.TypeString, - ForceNew: true, - Optional: true, - StateFunc: azureRMNormalizeLocation, - DiffSuppressFunc: azureRMSuppressLocationDiff, - Deprecated: "location is no longer used", - }, + "location": deprecatedLocationSchema(), "resource_group_name": { Type: schema.TypeString, @@ -151,7 +144,8 @@ func resourceArmLoadBalancerRuleCreate(d *schema.ResourceData, meta interface{}) return errwrap.Wrapf("Error Getting LoadBalancer Name and Group: {{err}}", err) } - _, err = lbClient.CreateOrUpdate(resGroup, loadBalancerName, *loadBalancer, make(chan struct{})) + _, error := lbClient.CreateOrUpdate(resGroup, loadBalancerName, *loadBalancer, make(chan struct{})) + err = <-error if err != nil { return errwrap.Wrapf("Error Creating/Updating LoadBalancer {{err}}", err) } @@ -286,7 +280,8 @@ func resourceArmLoadBalancerRuleDelete(d *schema.ResourceData, meta interface{}) return errwrap.Wrapf("Error Getting LoadBalancer Name and Group: {{err}}", err) } - _, err = lbClient.CreateOrUpdate(resGroup, loadBalancerName, *loadBalancer, make(chan struct{})) + _, error := lbClient.CreateOrUpdate(resGroup, loadBalancerName, *loadBalancer, make(chan struct{})) + err = <-error if err != nil { return errwrap.Wrapf("Error Creating/Updating LoadBalancer {{err}}", err) } diff --git a/builtin/providers/azurerm/resource_arm_loadbalancer_rule_test.go b/builtin/providers/azurerm/resource_arm_loadbalancer_rule_test.go index 3a3a7dd4d..cb20b63c7 100644 --- a/builtin/providers/azurerm/resource_arm_loadbalancer_rule_test.go +++ b/builtin/providers/azurerm/resource_arm_loadbalancer_rule_test.go @@ -294,7 +294,8 @@ func testCheckAzureRMLoadBalancerRuleDisappears(ruleName string, lb *network.Loa return err } - _, err = conn.CreateOrUpdate(id.ResourceGroup, *lb.Name, *lb, make(chan struct{})) + _, error := conn.CreateOrUpdate(id.ResourceGroup, *lb.Name, *lb, make(chan struct{})) + err = <-error if err != nil { return fmt.Errorf("Error Creating/Updating LoadBalancer %s", err) } diff --git a/builtin/providers/azurerm/resource_arm_local_network_gateway.go b/builtin/providers/azurerm/resource_arm_local_network_gateway.go index 64c2243fb..e3af643b2 100644 --- a/builtin/providers/azurerm/resource_arm_local_network_gateway.go +++ b/builtin/providers/azurerm/resource_arm_local_network_gateway.go @@ -74,7 +74,8 @@ func resourceArmLocalNetworkGatewayCreate(d *schema.ResourceData, meta interface }, } - _, err := lnetClient.CreateOrUpdate(resGroup, name, gateway, make(chan struct{})) + _, error := lnetClient.CreateOrUpdate(resGroup, name, gateway, make(chan struct{})) + err := <-error if err != nil { return fmt.Errorf("Error creating Azure ARM Local Network Gateway '%s': %s", name, err) } @@ -140,7 +141,8 @@ func resourceArmLocalNetworkGatewayDelete(d *schema.ResourceData, meta interface name := id.Path["localNetworkGateways"] resGroup := id.ResourceGroup - _, err = lnetClient.Delete(resGroup, name, make(chan struct{})) + _, error := lnetClient.Delete(resGroup, name, make(chan struct{})) + err = <-error if err != nil { return fmt.Errorf("Error issuing Azure ARM delete request of local network gateway '%s': %s", name, err) } diff --git a/builtin/providers/azurerm/resource_arm_local_network_gateway_test.go b/builtin/providers/azurerm/resource_arm_local_network_gateway_test.go index cfd888b5d..a134614c5 100644 --- a/builtin/providers/azurerm/resource_arm_local_network_gateway_test.go +++ b/builtin/providers/azurerm/resource_arm_local_network_gateway_test.go @@ -104,7 +104,9 @@ func testCheckAzureRMLocalNetworkGatewayDisappears(name string) resource.TestChe // and finally, check that it exists on Azure: lnetClient := testAccProvider.Meta().(*ArmClient).localNetConnClient - resp, err := lnetClient.Delete(resGrp, localNetName, make(chan struct{})) + deleteResp, error := lnetClient.Delete(resGrp, localNetName, make(chan struct{})) + resp := <-deleteResp + err = <-error if err != nil { if resp.StatusCode == http.StatusNotFound { return fmt.Errorf("Local network gateway '%s' (resource group '%s') does not exist on Azure.", localNetName, resGrp) diff --git a/builtin/providers/azurerm/resource_arm_managed_disk.go b/builtin/providers/azurerm/resource_arm_managed_disk.go index a167a826a..f8581ca2e 100644 --- a/builtin/providers/azurerm/resource_arm_managed_disk.go +++ b/builtin/providers/azurerm/resource_arm_managed_disk.go @@ -151,8 +151,9 @@ func resourceArmManagedDiskCreate(d *schema.ResourceData, meta interface{}) erro createDisk.CreationData = creationData _, diskErr := diskClient.CreateOrUpdate(resGroup, name, createDisk, make(chan struct{})) - if diskErr != nil { - return diskErr + err := <-diskErr + if err != nil { + return err } read, err := diskClient.Get(resGroup, name) @@ -214,7 +215,9 @@ func resourceArmManagedDiskDelete(d *schema.ResourceData, meta interface{}) erro resGroup := id.ResourceGroup name := id.Path["disks"] - if _, err = diskClient.Delete(resGroup, name, make(chan struct{})); err != nil { + _, error := diskClient.Delete(resGroup, name, make(chan struct{})) + err = <-error + if err != nil { return err } diff --git a/builtin/providers/azurerm/resource_arm_managed_disk_test.go b/builtin/providers/azurerm/resource_arm_managed_disk_test.go index b7512e2a7..180c8aa84 100644 --- a/builtin/providers/azurerm/resource_arm_managed_disk_test.go +++ b/builtin/providers/azurerm/resource_arm_managed_disk_test.go @@ -199,7 +199,8 @@ func testDeleteAzureRMVirtualMachine(name string) resource.TestCheckFunc { conn := testAccProvider.Meta().(*ArmClient).vmClient - _, err := conn.Delete(resourceGroup, vmName, make(chan struct{})) + _, error := conn.Delete(resourceGroup, vmName, make(chan struct{})) + err := <-error if err != nil { return fmt.Errorf("Bad: Delete on vmClient: %s", err) } diff --git a/builtin/providers/azurerm/resource_arm_network_interface_card.go b/builtin/providers/azurerm/resource_arm_network_interface_card.go index 7baf33e9d..9ad2825da 100644 --- a/builtin/providers/azurerm/resource_arm_network_interface_card.go +++ b/builtin/providers/azurerm/resource_arm_network_interface_card.go @@ -224,7 +224,8 @@ func resourceArmNetworkInterfaceCreate(d *schema.ResourceData, meta interface{}) Tags: expandTags(tags), } - _, err := ifaceClient.CreateOrUpdate(resGroup, name, iface, make(chan struct{})) + _, error := ifaceClient.CreateOrUpdate(resGroup, name, iface, make(chan struct{})) + err := <-error if err != nil { return err } @@ -350,7 +351,8 @@ func resourceArmNetworkInterfaceDelete(d *schema.ResourceData, meta interface{}) azureRMLockMultiple(&namesToLock) defer azureRMUnlockMultiple(&namesToLock) - _, err = ifaceClient.Delete(resGroup, name, make(chan struct{})) + _, error := ifaceClient.Delete(resGroup, name, make(chan struct{})) + err = <-error return err } diff --git a/builtin/providers/azurerm/resource_arm_network_interface_card_test.go b/builtin/providers/azurerm/resource_arm_network_interface_card_test.go index f96775980..c885cc0b0 100644 --- a/builtin/providers/azurerm/resource_arm_network_interface_card_test.go +++ b/builtin/providers/azurerm/resource_arm_network_interface_card_test.go @@ -161,7 +161,8 @@ func testCheckAzureRMNetworkInterfaceDisappears(name string) resource.TestCheckF conn := testAccProvider.Meta().(*ArmClient).ifaceClient - _, err := conn.Delete(resourceGroup, name, make(chan struct{})) + _, error := conn.Delete(resourceGroup, name, make(chan struct{})) + err := <-error if err != nil { return fmt.Errorf("Bad: Delete on ifaceClient: %s", err) } diff --git a/builtin/providers/azurerm/resource_arm_network_security_group.go b/builtin/providers/azurerm/resource_arm_network_security_group.go index c538e6103..e8bc156f0 100644 --- a/builtin/providers/azurerm/resource_arm_network_security_group.go +++ b/builtin/providers/azurerm/resource_arm_network_security_group.go @@ -146,7 +146,8 @@ func resourceArmNetworkSecurityGroupCreate(d *schema.ResourceData, meta interfac Tags: expandTags(tags), } - _, err := secClient.CreateOrUpdate(resGroup, name, sg, make(chan struct{})) + _, error := secClient.CreateOrUpdate(resGroup, name, sg, make(chan struct{})) + err := <-error if err != nil { return err } @@ -217,7 +218,8 @@ func resourceArmNetworkSecurityGroupDelete(d *schema.ResourceData, meta interfac resGroup := id.ResourceGroup name := id.Path["networkSecurityGroups"] - _, err = secGroupClient.Delete(resGroup, name, make(chan struct{})) + _, error := secGroupClient.Delete(resGroup, name, make(chan struct{})) + err = <-error return err } diff --git a/builtin/providers/azurerm/resource_arm_network_security_group_test.go b/builtin/providers/azurerm/resource_arm_network_security_group_test.go index 3e7685ae3..629fa3f7d 100644 --- a/builtin/providers/azurerm/resource_arm_network_security_group_test.go +++ b/builtin/providers/azurerm/resource_arm_network_security_group_test.go @@ -153,7 +153,8 @@ func testCheckAzureRMNetworkSecurityGroupDisappears(name string) resource.TestCh conn := testAccProvider.Meta().(*ArmClient).secGroupClient - _, err := conn.Delete(resourceGroup, sgName, make(chan struct{})) + _, error := conn.Delete(resourceGroup, sgName, make(chan struct{})) + err := <-error if err != nil { return fmt.Errorf("Bad: Delete on secGroupClient: %s", err) } diff --git a/builtin/providers/azurerm/resource_arm_network_security_rule.go b/builtin/providers/azurerm/resource_arm_network_security_rule.go index ed7760511..470fb8c3e 100644 --- a/builtin/providers/azurerm/resource_arm_network_security_rule.go +++ b/builtin/providers/azurerm/resource_arm_network_security_rule.go @@ -144,7 +144,8 @@ func resourceArmNetworkSecurityRuleCreate(d *schema.ResourceData, meta interface SecurityRulePropertiesFormat: &properties, } - _, err := secClient.CreateOrUpdate(resGroup, nsgName, name, sgr, make(chan struct{})) + _, error := secClient.CreateOrUpdate(resGroup, nsgName, name, sgr, make(chan struct{})) + err := <-error if err != nil { return err } @@ -213,7 +214,8 @@ func resourceArmNetworkSecurityRuleDelete(d *schema.ResourceData, meta interface armMutexKV.Lock(nsgName) defer armMutexKV.Unlock(nsgName) - _, err = secRuleClient.Delete(resGroup, nsgName, sgRuleName, make(chan struct{})) + _, error := secRuleClient.Delete(resGroup, nsgName, sgRuleName, make(chan struct{})) + err = <-error return err } diff --git a/builtin/providers/azurerm/resource_arm_network_security_rule_test.go b/builtin/providers/azurerm/resource_arm_network_security_rule_test.go index e0b4d79be..d1392be66 100644 --- a/builtin/providers/azurerm/resource_arm_network_security_rule_test.go +++ b/builtin/providers/azurerm/resource_arm_network_security_rule_test.go @@ -119,7 +119,8 @@ func testCheckAzureRMNetworkSecurityRuleDisappears(name string) resource.TestChe conn := testAccProvider.Meta().(*ArmClient).secRuleClient - _, err := conn.Delete(resourceGroup, sgName, sgrName, make(chan struct{})) + _, error := conn.Delete(resourceGroup, sgName, sgrName, make(chan struct{})) + err := <-error if err != nil { return fmt.Errorf("Bad: Delete on secRuleClient: %s", err) } diff --git a/builtin/providers/azurerm/resource_arm_public_ip.go b/builtin/providers/azurerm/resource_arm_public_ip.go index 91f5f562e..934839d8c 100644 --- a/builtin/providers/azurerm/resource_arm_public_ip.go +++ b/builtin/providers/azurerm/resource_arm_public_ip.go @@ -130,7 +130,8 @@ func resourceArmPublicIpCreate(d *schema.ResourceData, meta interface{}) error { Tags: expandTags(tags), } - _, err := publicIPClient.CreateOrUpdate(resGroup, name, publicIp, make(chan struct{})) + _, error := publicIPClient.CreateOrUpdate(resGroup, name, publicIp, make(chan struct{})) + err := <-error if err != nil { return err } @@ -195,7 +196,8 @@ func resourceArmPublicIpDelete(d *schema.ResourceData, meta interface{}) error { resGroup := id.ResourceGroup name := id.Path["publicIPAddresses"] - _, err = publicIPClient.Delete(resGroup, name, make(chan struct{})) + _, error := publicIPClient.Delete(resGroup, name, make(chan struct{})) + err = <-error return err } diff --git a/builtin/providers/azurerm/resource_arm_public_ip_test.go b/builtin/providers/azurerm/resource_arm_public_ip_test.go index 65ec91c77..77041a332 100644 --- a/builtin/providers/azurerm/resource_arm_public_ip_test.go +++ b/builtin/providers/azurerm/resource_arm_public_ip_test.go @@ -278,7 +278,8 @@ func testCheckAzureRMPublicIpDisappears(name string) resource.TestCheckFunc { conn := testAccProvider.Meta().(*ArmClient).publicIPClient - _, err := conn.Delete(resourceGroup, publicIpName, make(chan struct{})) + _, error := conn.Delete(resourceGroup, publicIpName, make(chan struct{})) + err := <-error if err != nil { return fmt.Errorf("Bad: Delete on publicIPClient: %s", err) } diff --git a/builtin/providers/azurerm/resource_arm_redis_cache.go b/builtin/providers/azurerm/resource_arm_redis_cache.go index 9ff08a872..7c3921ef7 100644 --- a/builtin/providers/azurerm/resource_arm_redis_cache.go +++ b/builtin/providers/azurerm/resource_arm_redis_cache.go @@ -170,7 +170,8 @@ func resourceArmRedisCacheCreate(d *schema.ResourceData, meta interface{}) error parameters.ShardCount = &shardCount } - _, err := client.Create(resGroup, name, parameters, make(chan struct{})) + _, error := client.Create(resGroup, name, parameters, make(chan struct{})) + err := <-error if err != nil { return err } @@ -333,7 +334,9 @@ func resourceArmRedisCacheDelete(d *schema.ResourceData, meta interface{}) error resGroup := id.ResourceGroup name := id.Path["Redis"] - resp, err := redisClient.Delete(resGroup, name, make(chan struct{})) + deleteResp, error := redisClient.Delete(resGroup, name, make(chan struct{})) + resp := <-deleteResp + err = <-error if resp.StatusCode != http.StatusOK { return fmt.Errorf("Error issuing Azure ARM delete request of Redis Cache Instance '%s': %s", name, err) diff --git a/builtin/providers/azurerm/resource_arm_resource_group_test.go b/builtin/providers/azurerm/resource_arm_resource_group_test.go index ce1bf1450..bf091a938 100644 --- a/builtin/providers/azurerm/resource_arm_resource_group_test.go +++ b/builtin/providers/azurerm/resource_arm_resource_group_test.go @@ -126,7 +126,8 @@ func testCheckAzureRMResourceGroupDisappears(name string) resource.TestCheckFunc // Ensure resource group exists in API conn := testAccProvider.Meta().(*ArmClient).resourceGroupClient - _, err := conn.Delete(resourceGroup, make(chan struct{})) + _, error := conn.Delete(resourceGroup, make(chan struct{})) + err := <-error if err != nil { return fmt.Errorf("Bad: Delete on resourceGroupClient: %s", err) } diff --git a/builtin/providers/azurerm/resource_arm_route.go b/builtin/providers/azurerm/resource_arm_route.go index 62d8971c0..0f0899ac1 100644 --- a/builtin/providers/azurerm/resource_arm_route.go +++ b/builtin/providers/azurerm/resource_arm_route.go @@ -90,7 +90,8 @@ func resourceArmRouteCreate(d *schema.ResourceData, meta interface{}) error { RoutePropertiesFormat: &properties, } - _, err := routesClient.CreateOrUpdate(resGroup, rtName, name, route, make(chan struct{})) + _, error := routesClient.CreateOrUpdate(resGroup, rtName, name, route, make(chan struct{})) + err := <-error if err != nil { return err } @@ -155,7 +156,8 @@ func resourceArmRouteDelete(d *schema.ResourceData, meta interface{}) error { armMutexKV.Lock(rtName) defer armMutexKV.Unlock(rtName) - _, err = routesClient.Delete(resGroup, rtName, routeName, make(chan struct{})) + _, error := routesClient.Delete(resGroup, rtName, routeName, make(chan struct{})) + err = <-error return err } diff --git a/builtin/providers/azurerm/resource_arm_route_table.go b/builtin/providers/azurerm/resource_arm_route_table.go index 6cdfbdf52..bca0c29dd 100644 --- a/builtin/providers/azurerm/resource_arm_route_table.go +++ b/builtin/providers/azurerm/resource_arm_route_table.go @@ -111,7 +111,8 @@ func resourceArmRouteTableCreate(d *schema.ResourceData, meta interface{}) error } } - _, err := routeTablesClient.CreateOrUpdate(resGroup, name, routeSet, make(chan struct{})) + _, error := routeTablesClient.CreateOrUpdate(resGroup, name, routeSet, make(chan struct{})) + err := <-error if err != nil { return err } @@ -180,7 +181,8 @@ func resourceArmRouteTableDelete(d *schema.ResourceData, meta interface{}) error resGroup := id.ResourceGroup name := id.Path["routeTables"] - _, err = routeTablesClient.Delete(resGroup, name, make(chan struct{})) + _, error := routeTablesClient.Delete(resGroup, name, make(chan struct{})) + err = <-error return err } diff --git a/builtin/providers/azurerm/resource_arm_route_table_test.go b/builtin/providers/azurerm/resource_arm_route_table_test.go index b8164ebdd..940d259ed 100644 --- a/builtin/providers/azurerm/resource_arm_route_table_test.go +++ b/builtin/providers/azurerm/resource_arm_route_table_test.go @@ -215,7 +215,8 @@ func testCheckAzureRMRouteTableDisappears(name string) resource.TestCheckFunc { conn := testAccProvider.Meta().(*ArmClient).routeTablesClient - _, err := conn.Delete(resourceGroup, name, make(chan struct{})) + _, error := conn.Delete(resourceGroup, name, make(chan struct{})) + err := <-error if err != nil { return fmt.Errorf("Bad: Delete on routeTablesClient: %s", err) } diff --git a/builtin/providers/azurerm/resource_arm_route_test.go b/builtin/providers/azurerm/resource_arm_route_test.go index 24d7feb43..68decbe1d 100644 --- a/builtin/providers/azurerm/resource_arm_route_test.go +++ b/builtin/providers/azurerm/resource_arm_route_test.go @@ -127,7 +127,8 @@ func testCheckAzureRMRouteDisappears(name string) resource.TestCheckFunc { conn := testAccProvider.Meta().(*ArmClient).routesClient - _, err := conn.Delete(resourceGroup, rtName, name, make(chan struct{})) + _, error := conn.Delete(resourceGroup, rtName, name, make(chan struct{})) + err := <-error if err != nil { return fmt.Errorf("Bad: Delete on routesClient: %s", err) } diff --git a/builtin/providers/azurerm/resource_arm_servicebus_namespace.go b/builtin/providers/azurerm/resource_arm_servicebus_namespace.go index 1226560f8..56ba7f557 100644 --- a/builtin/providers/azurerm/resource_arm_servicebus_namespace.go +++ b/builtin/providers/azurerm/resource_arm_servicebus_namespace.go @@ -101,7 +101,8 @@ func resourceArmServiceBusNamespaceCreate(d *schema.ResourceData, meta interface Tags: expandTags(tags), } - _, err := namespaceClient.CreateOrUpdate(resGroup, name, parameters, make(chan struct{})) + _, error := namespaceClient.CreateOrUpdate(resGroup, name, parameters, make(chan struct{})) + err := <-error if err != nil { return err } @@ -170,7 +171,9 @@ func resourceArmServiceBusNamespaceDelete(d *schema.ResourceData, meta interface resGroup := id.ResourceGroup name := id.Path["namespaces"] - resp, err := namespaceClient.Delete(resGroup, name, make(chan struct{})) + deleteResp, error := namespaceClient.Delete(resGroup, name, make(chan struct{})) + resp := <-deleteResp + err = <-error if resp.StatusCode != http.StatusNotFound { return fmt.Errorf("Error issuing Azure ARM delete request of ServiceBus Namespace'%s': %+v", name, err) diff --git a/builtin/providers/azurerm/resource_arm_sql_elasticpool.go b/builtin/providers/azurerm/resource_arm_sql_elasticpool.go index 6231950fb..67f9f32c3 100644 --- a/builtin/providers/azurerm/resource_arm_sql_elasticpool.go +++ b/builtin/providers/azurerm/resource_arm_sql_elasticpool.go @@ -101,7 +101,8 @@ func resourceArmSqlElasticPoolCreate(d *schema.ResourceData, meta interface{}) e Tags: expandTags(tags), } - _, err := elasticPoolsClient.CreateOrUpdate(resGroup, serverName, name, elasticPool, make(chan struct{})) + _, error := elasticPoolsClient.CreateOrUpdate(resGroup, serverName, name, elasticPool, make(chan struct{})) + err := <-error if err != nil { return err } @@ -176,7 +177,7 @@ func resourceArmSqlElasticPoolDelete(d *schema.ResourceData, meta interface{}) e } func getArmSqlElasticPoolProperties(d *schema.ResourceData) *sql.ElasticPoolProperties { - edition := sql.ElasticPoolEditions(d.Get("edition").(string)) + edition := sql.ElasticPoolEdition(d.Get("edition").(string)) dtu := int32(d.Get("dtu").(int)) props := &sql.ElasticPoolProperties{ @@ -213,8 +214,8 @@ func parseArmSqlElasticPoolId(sqlElasticPoolId string) (string, string, string, func validateSqlElasticPoolEdition() schema.SchemaValidateFunc { return validation.StringInSlice([]string{ - string(sql.ElasticPoolEditionsBasic), - string(sql.ElasticPoolEditionsStandard), - string(sql.ElasticPoolEditionsPremium), + string(sql.ElasticPoolEditionBasic), + string(sql.ElasticPoolEditionStandard), + string(sql.ElasticPoolEditionPremium), }, false) } diff --git a/builtin/providers/azurerm/resource_arm_storage_account.go b/builtin/providers/azurerm/resource_arm_storage_account.go index 721ab8097..551c42a44 100644 --- a/builtin/providers/azurerm/resource_arm_storage_account.go +++ b/builtin/providers/azurerm/resource_arm_storage_account.go @@ -187,8 +187,8 @@ func resourceArmStorageAccountCreate(d *schema.ResourceData, meta interface{}) e } // Create - _, createErr := storageClient.Create( - resourceGroupName, storageAccountName, opts, make(chan struct{})) + _, createError := storageClient.Create(resourceGroupName, storageAccountName, opts, make(chan struct{})) + createErr := <-createError // The only way to get the ID back apparently is to read the resource again read, err := storageClient.GetProperties(resourceGroupName, storageAccountName) diff --git a/builtin/providers/azurerm/resource_arm_storage_blob.go b/builtin/providers/azurerm/resource_arm_storage_blob.go index 5fcf0f1c9..8ee2ea6c2 100644 --- a/builtin/providers/azurerm/resource_arm_storage_blob.go +++ b/builtin/providers/azurerm/resource_arm_storage_blob.go @@ -155,13 +155,21 @@ func resourceArmStorageBlobCreate(d *schema.ResourceData, meta interface{}) erro log.Printf("[INFO] Creating blob %q in storage account %q", name, storageAccountName) if sourceUri != "" { - if err := blobClient.CopyBlob(cont, name, sourceUri); err != nil { + options := &storage.CopyOptions{} + container := blobClient.GetContainerReference(cont) + blob := container.GetBlobReference(name) + err := blob.Copy(sourceUri, options) + if err != nil { return fmt.Errorf("Error creating storage blob on Azure: %s", err) } } else { switch strings.ToLower(blobType) { case "block": - if err := blobClient.CreateBlockBlob(cont, name); err != nil { + options := &storage.PutBlobOptions{} + container := blobClient.GetContainerReference(cont) + blob := container.GetBlobReference(name) + err := blob.CreateBlockBlob(options) + if err != nil { return fmt.Errorf("Error creating storage blob on Azure: %s", err) } @@ -183,7 +191,13 @@ func resourceArmStorageBlobCreate(d *schema.ResourceData, meta interface{}) erro } } else { size := int64(d.Get("size").(int)) - if err := blobClient.PutPageBlob(cont, name, size, map[string]string{}); err != nil { + options := &storage.PutBlobOptions{} + + container := blobClient.GetContainerReference(cont) + blob := container.GetBlobReference(name) + blob.Properties.ContentLength = size + err := blob.PutPageBlob(options) + if err != nil { return fmt.Errorf("Error creating storage blob on Azure: %s", err) } } @@ -213,7 +227,12 @@ func resourceArmStorageBlobPageUploadFromSource(container, name, source string, return fmt.Errorf("Error splitting source file %q into pages: %s", source, err) } - if err := client.PutPageBlob(container, name, blobSize, map[string]string{}); err != nil { + options := &storage.PutBlobOptions{} + containerRef := client.GetContainerReference(container) + blob := containerRef.GetBlobReference(name) + blob.Properties.ContentLength = blobSize + err = blob.PutPageBlob(options) + if err != nil { return fmt.Errorf("Error creating storage blob on Azure: %s", err) } @@ -343,7 +362,15 @@ func resourceArmStorageBlobPageUploadWorker(ctx resourceArmStorageBlobPageUpload } for x := 0; x < ctx.attempts; x++ { - err = ctx.client.PutPage(ctx.container, ctx.name, start, end, storage.PageWriteTypeUpdate, chunk, map[string]string{}) + container := ctx.client.GetContainerReference(ctx.container) + blob := container.GetBlobReference(ctx.name) + blobRange := storage.BlobRange{ + Start: uint64(start), + End: uint64(end), + } + options := &storage.PutPageOptions{} + reader := bytes.NewReader(chunk) + err = blob.WriteRange(blobRange, reader, options) if err == nil { break } @@ -406,7 +433,10 @@ func resourceArmStorageBlobBlockUploadFromSource(container, name, source string, return fmt.Errorf("Error while uploading source file %q: %s", source, <-errors) } - err = client.PutBlockList(container, name, blockList) + containerReference := client.GetContainerReference(container) + blobReference := containerReference.GetBlobReference(name) + options := &storage.PutBlockListOptions{} + err = blobReference.PutBlockList(blockList, options) if err != nil { return fmt.Errorf("Error updating block list for source file %q: %s", source, err) } @@ -479,7 +509,10 @@ func resourceArmStorageBlobBlockUploadWorker(ctx resourceArmStorageBlobBlockUplo } for i := 0; i < ctx.attempts; i++ { - err = ctx.client.PutBlock(ctx.container, ctx.name, block.id, buffer) + container := ctx.client.GetContainerReference(ctx.container) + blob := container.GetBlobReference(ctx.name) + options := &storage.PutBlockOptions{} + err = blob.PutBlock(block.id, buffer, options) if err == nil { break } @@ -523,7 +556,9 @@ func resourceArmStorageBlobRead(d *schema.ResourceData, meta interface{}) error name := d.Get("name").(string) storageContainerName := d.Get("storage_container_name").(string) - url := blobClient.GetBlobURL(storageContainerName, name) + container := blobClient.GetContainerReference(storageContainerName) + blob := container.GetBlobReference(name) + url := blob.GetURL() if url == "" { log.Printf("[INFO] URL for %q is empty", name) } @@ -552,7 +587,9 @@ func resourceArmStorageBlobExists(d *schema.ResourceData, meta interface{}) (boo storageContainerName := d.Get("storage_container_name").(string) log.Printf("[INFO] Checking for existence of storage blob %q.", name) - exists, err := blobClient.BlobExists(storageContainerName, name) + container := blobClient.GetContainerReference(storageContainerName) + blob := container.GetBlobReference(name) + exists, err := blob.Exists() if err != nil { return false, fmt.Errorf("error testing existence of storage blob %q: %s", name, err) } @@ -584,7 +621,11 @@ func resourceArmStorageBlobDelete(d *schema.ResourceData, meta interface{}) erro storageContainerName := d.Get("storage_container_name").(string) log.Printf("[INFO] Deleting storage blob %q", name) - if _, err = blobClient.DeleteBlobIfExists(storageContainerName, name, map[string]string{}); err != nil { + options := &storage.DeleteBlobOptions{} + container := blobClient.GetContainerReference(storageContainerName) + blob := container.GetBlobReference(name) + _, err = blob.DeleteIfExists(options) + if err != nil { return fmt.Errorf("Error deleting storage blob %q: %s", name, err) } diff --git a/builtin/providers/azurerm/resource_arm_storage_blob_test.go b/builtin/providers/azurerm/resource_arm_storage_blob_test.go index 4714b2b9f..74fb1f5bf 100644 --- a/builtin/providers/azurerm/resource_arm_storage_blob_test.go +++ b/builtin/providers/azurerm/resource_arm_storage_blob_test.go @@ -339,7 +339,9 @@ func testCheckAzureRMStorageBlobExists(name string) resource.TestCheckFunc { return fmt.Errorf("Bad: Storage Account %q does not exist", storageAccountName) } - exists, err := blobClient.BlobExists(storageContainerName, name) + container := blobClient.GetContainerReference(storageContainerName) + blob := container.GetBlobReference(name) + exists, err := blob.Exists() if err != nil { return err } @@ -377,7 +379,10 @@ func testCheckAzureRMStorageBlobDisappears(name string) resource.TestCheckFunc { return fmt.Errorf("Bad: Storage Account %q does not exist", storageAccountName) } - _, err = blobClient.DeleteBlobIfExists(storageContainerName, name, map[string]string{}) + container := blobClient.GetContainerReference(storageContainerName) + blob := container.GetBlobReference(name) + options := &storage.DeleteBlobOptions{} + _, err = blob.DeleteIfExists(options) if err != nil { return err } @@ -411,16 +416,22 @@ func testCheckAzureRMStorageBlobMatchesFile(name string, kind storage.BlobType, return fmt.Errorf("Bad: Storage Account %q does not exist", storageAccountName) } - properties, err := blobClient.GetBlobProperties(storageContainerName, name) + containerReference := blobClient.GetContainerReference(storageContainerName) + blobReference := containerReference.GetBlobReference(name) + propertyOptions := &storage.GetBlobPropertiesOptions{} + err = blobReference.GetProperties(propertyOptions) if err != nil { return err } + properties := blobReference.Properties + if properties.BlobType != kind { return fmt.Errorf("Bad: blob type %q does not match expected type %q", properties.BlobType, kind) } - blob, err := blobClient.GetBlob(storageContainerName, name) + getOptions := &storage.GetBlobOptions{} + blob, err := blobReference.Get(getOptions) if err != nil { return err } @@ -467,7 +478,9 @@ func testCheckAzureRMStorageBlobDestroy(s *terraform.State) error { return nil } - exists, err := blobClient.BlobExists(storageContainerName, name) + container := blobClient.GetContainerReference(storageContainerName) + blob := container.GetBlobReference(name) + exists, err := blob.Exists() if err != nil { return nil } diff --git a/builtin/providers/azurerm/resource_arm_storage_container.go b/builtin/providers/azurerm/resource_arm_storage_container.go index b58cc0c06..b6f50ef8c 100644 --- a/builtin/providers/azurerm/resource_arm_storage_container.go +++ b/builtin/providers/azurerm/resource_arm_storage_container.go @@ -107,11 +107,23 @@ func resourceArmStorageContainerCreate(d *schema.ResourceData, meta interface{}) } log.Printf("[INFO] Creating container %q in storage account %q.", name, storageAccountName) - _, err = blobClient.CreateContainerIfNotExists(name, accessType) + reference := blobClient.GetContainerReference(name) + + createOptions := &storage.CreateContainerOptions{} + _, err = reference.CreateIfNotExists(createOptions) if err != nil { return fmt.Errorf("Error creating container %q in storage account %q: %s", name, storageAccountName, err) } + permissions := storage.ContainerPermissions{ + AccessType: accessType, + } + permissionOptions := &storage.SetContainerPermissionOptions{} + err = reference.SetPermissions(permissions, permissionOptions) + if err != nil { + return fmt.Errorf("Error setting permissions for container %s in storage account %s: %+v", name, storageAccountName, err) + } + d.SetId(name) return resourceArmStorageContainerRead(d, meta) } @@ -185,7 +197,8 @@ func resourceArmStorageContainerExists(d *schema.ResourceData, meta interface{}) name := d.Get("name").(string) log.Printf("[INFO] Checking existence of storage container %q in storage account %q", name, storageAccountName) - exists, err := blobClient.ContainerExists(name) + reference := blobClient.GetContainerReference(name) + exists, err := reference.Exists() if err != nil { return false, fmt.Errorf("Error querying existence of storage container %q in storage account %q: %s", name, storageAccountName, err) } @@ -218,7 +231,9 @@ func resourceArmStorageContainerDelete(d *schema.ResourceData, meta interface{}) name := d.Get("name").(string) log.Printf("[INFO] Deleting storage container %q in account %q", name, storageAccountName) - if _, err := blobClient.DeleteContainerIfExists(name); err != nil { + reference := blobClient.GetContainerReference(name) + deleteOptions := &storage.DeleteContainerOptions{} + if _, err := reference.DeleteIfExists(deleteOptions); err != nil { return fmt.Errorf("Error deleting storage container %q from storage account %q: %s", name, storageAccountName, err) } diff --git a/builtin/providers/azurerm/resource_arm_storage_container_test.go b/builtin/providers/azurerm/resource_arm_storage_container_test.go index 6a89a0b0a..77fb17a55 100644 --- a/builtin/providers/azurerm/resource_arm_storage_container_test.go +++ b/builtin/providers/azurerm/resource_arm_storage_container_test.go @@ -154,7 +154,9 @@ func testAccARMStorageContainerDisappears(name string, c *storage.Container) res return nil } - _, err = blobClient.DeleteContainerIfExists(c.Name) + reference := blobClient.GetContainerReference(c.Name) + options := &storage.DeleteContainerOptions{} + _, err = reference.DeleteIfExists(options) if err != nil { return err } diff --git a/builtin/providers/azurerm/resource_arm_storage_queue.go b/builtin/providers/azurerm/resource_arm_storage_queue.go index c4515186e..7ef603a91 100644 --- a/builtin/providers/azurerm/resource_arm_storage_queue.go +++ b/builtin/providers/azurerm/resource_arm_storage_queue.go @@ -5,6 +5,7 @@ import ( "log" "regexp" + "github.com/Azure/azure-sdk-for-go/storage" "github.com/hashicorp/terraform/helper/schema" ) @@ -82,7 +83,9 @@ func resourceArmStorageQueueCreate(d *schema.ResourceData, meta interface{}) err name := d.Get("name").(string) log.Printf("[INFO] Creating queue %q in storage account %q", name, storageAccountName) - err = queueClient.CreateQueue(name) + queueReference := queueClient.GetQueueReference(name) + options := &storage.QueueServiceOptions{} + err = queueReference.Create(options) if err != nil { return fmt.Errorf("Error creating storage queue on Azure: %s", err) } @@ -125,7 +128,8 @@ func resourceArmStorageQueueExists(d *schema.ResourceData, meta interface{}) (bo name := d.Get("name").(string) log.Printf("[INFO] Checking for existence of storage queue %q.", name) - exists, err := queueClient.QueueExists(name) + queueReference := queueClient.GetQueueReference(name) + exists, err := queueReference.Exists() if err != nil { return false, fmt.Errorf("error testing existence of storage queue %q: %s", name, err) } @@ -156,7 +160,9 @@ func resourceArmStorageQueueDelete(d *schema.ResourceData, meta interface{}) err name := d.Get("name").(string) log.Printf("[INFO] Deleting storage queue %q", name) - if err = queueClient.DeleteQueue(name); err != nil { + queueReference := queueClient.GetQueueReference(name) + options := &storage.QueueServiceOptions{} + if err = queueReference.Delete(options); err != nil { return fmt.Errorf("Error deleting storage queue %q: %s", name, err) } diff --git a/builtin/providers/azurerm/resource_arm_storage_queue_test.go b/builtin/providers/azurerm/resource_arm_storage_queue_test.go index f561eadf7..ebc802727 100644 --- a/builtin/providers/azurerm/resource_arm_storage_queue_test.go +++ b/builtin/providers/azurerm/resource_arm_storage_queue_test.go @@ -95,7 +95,8 @@ func testCheckAzureRMStorageQueueExists(name string) resource.TestCheckFunc { return fmt.Errorf("Bad: Storage Account %q does not exist", storageAccountName) } - exists, err := queueClient.QueueExists(name) + queueReference := queueClient.GetQueueReference(name) + exists, err := queueReference.Exists() if err != nil { return err } @@ -130,7 +131,8 @@ func testCheckAzureRMStorageQueueDestroy(s *terraform.State) error { return nil } - exists, err := queueClient.QueueExists(name) + queueReference := queueClient.GetQueueReference(name) + exists, err := queueReference.Exists() if err != nil { return nil } diff --git a/builtin/providers/azurerm/resource_arm_storage_share.go b/builtin/providers/azurerm/resource_arm_storage_share.go index b48b7cf6f..f7543ef03 100644 --- a/builtin/providers/azurerm/resource_arm_storage_share.go +++ b/builtin/providers/azurerm/resource_arm_storage_share.go @@ -62,20 +62,21 @@ func resourceArmStorageShareCreate(d *schema.ResourceData, meta interface{}) err name := d.Get("name").(string) metaData := make(map[string]string) // TODO: support MetaData + options := &storage.FileRequestOptions{} log.Printf("[INFO] Creating share %q in storage account %q", name, storageAccountName) reference := fileClient.GetShareReference(name) - err = reference.Create() + err = reference.Create(options) log.Printf("[INFO] Setting share %q metadata in storage account %q", name, storageAccountName) reference.Metadata = metaData - reference.SetMetadata() + reference.SetMetadata(options) log.Printf("[INFO] Setting share %q properties in storage account %q", name, storageAccountName) reference.Properties = storage.ShareProperties{ Quota: d.Get("quota").(int), } - reference.SetProperties() + reference.SetProperties(options) d.SetId(name) return resourceArmStorageShareRead(d, meta) @@ -170,9 +171,9 @@ func resourceArmStorageShareDelete(d *schema.ResourceData, meta interface{}) err name := d.Get("name").(string) reference := fileClient.GetShareReference(name) - err = reference.Create() + options := &storage.FileRequestOptions{} - if _, err = reference.DeleteIfExists(); err != nil { + if _, err = reference.DeleteIfExists(options); err != nil { return fmt.Errorf("Error deleting storage file %q: %s", name, err) } diff --git a/builtin/providers/azurerm/resource_arm_storage_share_test.go b/builtin/providers/azurerm/resource_arm_storage_share_test.go index 87dce068d..fd1592c01 100644 --- a/builtin/providers/azurerm/resource_arm_storage_share_test.go +++ b/builtin/providers/azurerm/resource_arm_storage_share_test.go @@ -132,9 +132,10 @@ func testAccARMStorageShareDisappears(name string, sS *storage.Share) resource.T } reference := fileClient.GetShareReference(sS.Name) - err = reference.Create() + options := &storage.FileRequestOptions{} + err = reference.Create(options) - if _, err = reference.DeleteIfExists(); err != nil { + if _, err = reference.DeleteIfExists(options); err != nil { return fmt.Errorf("Error deleting storage file %q: %s", name, err) } diff --git a/builtin/providers/azurerm/resource_arm_storage_table.go b/builtin/providers/azurerm/resource_arm_storage_table.go index 9c440fa92..3db39165a 100644 --- a/builtin/providers/azurerm/resource_arm_storage_table.go +++ b/builtin/providers/azurerm/resource_arm_storage_table.go @@ -67,10 +67,13 @@ func resourceArmStorageTableCreate(d *schema.ResourceData, meta interface{}) err } name := d.Get("name").(string) - table := storage.AzureTable(name) + table := tableClient.GetTableReference(name) log.Printf("[INFO] Creating table %q in storage account %q.", name, storageAccountName) - err = tableClient.CreateTable(table) + + timeout := uint(60) + options := &storage.TableOptions{} + err = table.Create(timeout, storage.NoMetadata, options) if err != nil { return fmt.Errorf("Error creating table %q in storage account %q: %s", name, storageAccountName, err) } @@ -97,16 +100,19 @@ func resourceArmStorageTableRead(d *schema.ResourceData, meta interface{}) error } name := d.Get("name").(string) - tables, err := tableClient.QueryTables() + metaDataLevel := storage.MinimalMetadata + options := &storage.QueryTablesOptions{} + tables, err := tableClient.QueryTables(metaDataLevel, options) if err != nil { return fmt.Errorf("Failed to retrieve storage tables in account %q: %s", name, err) } var found bool - for _, table := range tables { - if string(table) == name { + for _, table := range tables.Tables { + tableName := string(table.Name) + if tableName == name { found = true - d.Set("name", string(table)) + d.Set("name", tableName) } } @@ -129,15 +135,17 @@ func resourceArmStorageTableDelete(d *schema.ResourceData, meta interface{}) err return err } if !accountExists { - log.Printf("[INFO]Storage Account %q doesn't exist so the table won't exist", storageAccountName) + log.Printf("[INFO] Storage Account %q doesn't exist so the table won't exist", storageAccountName) return nil } name := d.Get("name").(string) - table := storage.AzureTable(name) + table := tableClient.GetTableReference(name) + timeout := uint(60) + options := &storage.TableOptions{} log.Printf("[INFO] Deleting storage table %q in account %q", name, storageAccountName) - if err := tableClient.DeleteTable(table); err != nil { + if err := table.Delete(timeout, options); err != nil { return fmt.Errorf("Error deleting storage table %q from storage account %q: %s", name, storageAccountName, err) } diff --git a/builtin/providers/azurerm/resource_arm_storage_table_test.go b/builtin/providers/azurerm/resource_arm_storage_table_test.go index 3da97168f..33cc095aa 100644 --- a/builtin/providers/azurerm/resource_arm_storage_table_test.go +++ b/builtin/providers/azurerm/resource_arm_storage_table_test.go @@ -13,7 +13,7 @@ import ( ) func TestAccAzureRMStorageTable_basic(t *testing.T) { - var table storage.AzureTable + var table storage.Table ri := acctest.RandInt() rs := strings.ToLower(acctest.RandString(11)) @@ -35,7 +35,7 @@ func TestAccAzureRMStorageTable_basic(t *testing.T) { } func TestAccAzureRMStorageTable_disappears(t *testing.T) { - var table storage.AzureTable + var table storage.Table ri := acctest.RandInt() rs := strings.ToLower(acctest.RandString(11)) @@ -58,7 +58,7 @@ func TestAccAzureRMStorageTable_disappears(t *testing.T) { }) } -func testCheckAzureRMStorageTableExists(name string, t *storage.AzureTable) resource.TestCheckFunc { +func testCheckAzureRMStorageTableExists(name string, t *storage.Table) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[name] @@ -82,15 +82,16 @@ func testCheckAzureRMStorageTableExists(name string, t *storage.AzureTable) reso return fmt.Errorf("Bad: Storage Account %q does not exist", storageAccountName) } - tables, err := tableClient.QueryTables() + options := &storage.QueryTablesOptions{} + tables, err := tableClient.QueryTables(storage.MinimalMetadata, options) - if len(tables) == 0 { + if len(tables.Tables) == 0 { return fmt.Errorf("Bad: Storage Table %q (storage account: %q) does not exist", name, storageAccountName) } var found bool - for _, table := range tables { - if string(table) == name { + for _, table := range tables.Tables { + if table.Name == name { found = true *t = table } @@ -104,7 +105,7 @@ func testCheckAzureRMStorageTableExists(name string, t *storage.AzureTable) reso } } -func testAccARMStorageTableDisappears(name string, t *storage.AzureTable) resource.TestCheckFunc { +func testAccARMStorageTableDisappears(name string, t *storage.Table) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[name] if !ok { @@ -116,7 +117,7 @@ func testAccARMStorageTableDisappears(name string, t *storage.AzureTable) resour storageAccountName := rs.Primary.Attributes["storage_account_name"] resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] if !hasResourceGroup { - return fmt.Errorf("Bad: no resource group found in state for storage table: %s", string(*t)) + return fmt.Errorf("Bad: no resource group found in state for storage table: %s", t.Name) } tableClient, accountExists, err := armClient.getTableServiceClientForStorageAccount(resourceGroup, storageAccountName) @@ -128,8 +129,10 @@ func testAccARMStorageTableDisappears(name string, t *storage.AzureTable) resour return nil } - table := storage.AzureTable(string(*t)) - err = tableClient.DeleteTable(table) + table := tableClient.GetTableReference(t.Name) + timeout := uint(60) + options := &storage.TableOptions{} + err = table.Delete(timeout, options) if err != nil { return err } @@ -161,15 +164,16 @@ func testCheckAzureRMStorageTableDestroy(s *terraform.State) error { return nil } - tables, err := tableClient.QueryTables() + options := &storage.QueryTablesOptions{} + tables, err := tableClient.QueryTables(storage.NoMetadata, options) if err != nil { return nil } var found bool - for _, table := range tables { - if string(table) == name { + for _, table := range tables.Tables { + if table.Name == name { found = true } } diff --git a/builtin/providers/azurerm/resource_arm_subnet.go b/builtin/providers/azurerm/resource_arm_subnet.go index 8094e6a3a..044c6d4f1 100644 --- a/builtin/providers/azurerm/resource_arm_subnet.go +++ b/builtin/providers/azurerm/resource_arm_subnet.go @@ -122,7 +122,8 @@ func resourceArmSubnetCreate(d *schema.ResourceData, meta interface{}) error { SubnetPropertiesFormat: &properties, } - _, err := subnetClient.CreateOrUpdate(resGroup, vnetName, name, subnet, make(chan struct{})) + _, error := subnetClient.CreateOrUpdate(resGroup, vnetName, name, subnet, make(chan struct{})) + err := <-error if err != nil { return err } @@ -229,7 +230,8 @@ func resourceArmSubnetDelete(d *schema.ResourceData, meta interface{}) error { armMutexKV.Lock(name) defer armMutexKV.Unlock(name) - _, err = subnetClient.Delete(resGroup, vnetName, name, make(chan struct{})) + _, error := subnetClient.Delete(resGroup, vnetName, name, make(chan struct{})) + err = <-error return err } diff --git a/builtin/providers/azurerm/resource_arm_subnet_test.go b/builtin/providers/azurerm/resource_arm_subnet_test.go index 264b0a540..2c8016ba6 100644 --- a/builtin/providers/azurerm/resource_arm_subnet_test.go +++ b/builtin/providers/azurerm/resource_arm_subnet_test.go @@ -99,7 +99,8 @@ func testCheckAzureRMSubnetDisappears(name string) resource.TestCheckFunc { conn := testAccProvider.Meta().(*ArmClient).subnetClient - _, err := conn.Delete(resourceGroup, vnetName, name, make(chan struct{})) + _, error := conn.Delete(resourceGroup, vnetName, name, make(chan struct{})) + err := <-error if err != nil { return fmt.Errorf("Bad: Delete on subnetClient: %s", err) } diff --git a/builtin/providers/azurerm/resource_arm_template_deployment.go b/builtin/providers/azurerm/resource_arm_template_deployment.go index 9538f61ee..4431f537e 100644 --- a/builtin/providers/azurerm/resource_arm_template_deployment.go +++ b/builtin/providers/azurerm/resource_arm_template_deployment.go @@ -100,7 +100,8 @@ func resourceArmTemplateDeploymentCreate(d *schema.ResourceData, meta interface{ Properties: &properties, } - _, err := deployClient.CreateOrUpdate(resGroup, name, deployment, make(chan struct{})) + _, error := deployClient.CreateOrUpdate(resGroup, name, deployment, make(chan struct{})) + err := <-error if err != nil { return fmt.Errorf("Error creating deployment: %s", err) } @@ -206,8 +207,10 @@ func resourceArmTemplateDeploymentDelete(d *schema.ResourceData, meta interface{ name = id.Path["Deployments"] } - _, err = deployClient.Delete(resGroup, name, make(chan struct{})) - return nil + _, error := deployClient.Delete(resGroup, name, make(chan struct{})) + err = <-error + + return err } func expandTemplateBody(template string) (map[string]interface{}, error) { diff --git a/builtin/providers/azurerm/resource_arm_template_deployment_test.go b/builtin/providers/azurerm/resource_arm_template_deployment_test.go index b3ade2e0a..7344c8f7e 100644 --- a/builtin/providers/azurerm/resource_arm_template_deployment_test.go +++ b/builtin/providers/azurerm/resource_arm_template_deployment_test.go @@ -152,7 +152,8 @@ func testCheckAzureRMTemplateDeploymentDisappears(name string) resource.TestChec conn := testAccProvider.Meta().(*ArmClient).deploymentsClient - _, err := conn.Delete(resourceGroup, name, make(chan struct{})) + _, error := conn.Delete(resourceGroup, name, make(chan struct{})) + err := <-error if err != nil { return fmt.Errorf("Bad: Delete on deploymentsClient: %s", err) } diff --git a/builtin/providers/azurerm/resource_arm_virtual_machine.go b/builtin/providers/azurerm/resource_arm_virtual_machine.go index 4a01ca374..fc2d14a48 100644 --- a/builtin/providers/azurerm/resource_arm_virtual_machine.go +++ b/builtin/providers/azurerm/resource_arm_virtual_machine.go @@ -9,6 +9,7 @@ import ( "strings" "github.com/Azure/azure-sdk-for-go/arm/compute" + "github.com/Azure/azure-sdk-for-go/storage" "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" @@ -584,7 +585,8 @@ func resourceArmVirtualMachineCreate(d *schema.ResourceData, meta interface{}) e vm.Plan = plan } - _, vmErr := vmClient.CreateOrUpdate(resGroup, name, vm, make(chan struct{})) + _, vmError := vmClient.CreateOrUpdate(resGroup, name, vm, make(chan struct{})) + vmErr := <-vmError if vmErr != nil { return vmErr } @@ -712,7 +714,10 @@ func resourceArmVirtualMachineDelete(d *schema.ResourceData, meta interface{}) e resGroup := id.ResourceGroup name := id.Path["virtualMachines"] - if _, err = vmClient.Delete(resGroup, name, make(chan struct{})); err != nil { + _, error := vmClient.Delete(resGroup, name, make(chan struct{})) + err = <-error + + if err != nil { return err } @@ -793,7 +798,10 @@ func resourceArmVirtualMachineDeleteVhd(uri string, meta interface{}) error { } log.Printf("[INFO] Deleting VHD blob %s", blobName) - _, err = blobClient.DeleteBlobIfExists(containerName, blobName, nil) + container := blobClient.GetContainerReference(containerName) + blob := container.GetBlobReference(blobName) + options := &storage.DeleteBlobOptions{} + err = blob.Delete(options) if err != nil { return fmt.Errorf("Error deleting VHD blob: %s", err) } @@ -811,7 +819,8 @@ func resourceArmVirtualMachineDeleteManagedDisk(managedDiskID string, meta inter resGroup := id.ResourceGroup name := id.Path["disks"] - _, err = diskClient.Delete(resGroup, name, make(chan struct{})) + _, error := diskClient.Delete(resGroup, name, make(chan struct{})) + err = <-error if err != nil { return fmt.Errorf("Error deleting Managed Disk (%s %s) %s", name, resGroup, err) } diff --git a/builtin/providers/azurerm/resource_arm_virtual_machine_extension.go b/builtin/providers/azurerm/resource_arm_virtual_machine_extension.go index be772ce55..49155cd39 100644 --- a/builtin/providers/azurerm/resource_arm_virtual_machine_extension.go +++ b/builtin/providers/azurerm/resource_arm_virtual_machine_extension.go @@ -122,7 +122,8 @@ func resourceArmVirtualMachineExtensionsCreate(d *schema.ResourceData, meta inte extension.VirtualMachineExtensionProperties.ProtectedSettings = &protectedSettings } - _, err := client.CreateOrUpdate(resGroup, vmName, name, extension, make(chan struct{})) + _, error := client.CreateOrUpdate(resGroup, vmName, name, extension, make(chan struct{})) + err := <-error if err != nil { return err } @@ -195,7 +196,8 @@ func resourceArmVirtualMachineExtensionsDelete(d *schema.ResourceData, meta inte name := id.Path["extensions"] vmName := id.Path["virtualMachines"] - _, err = client.Delete(resGroup, vmName, name, make(chan struct{})) + _, error := client.Delete(resGroup, vmName, name, make(chan struct{})) + err = <-error - return nil + return err } diff --git a/builtin/providers/azurerm/resource_arm_virtual_machine_scale_set.go b/builtin/providers/azurerm/resource_arm_virtual_machine_scale_set.go index 12665b2c2..14cd15447 100644 --- a/builtin/providers/azurerm/resource_arm_virtual_machine_scale_set.go +++ b/builtin/providers/azurerm/resource_arm_virtual_machine_scale_set.go @@ -543,7 +543,8 @@ func resourceArmVirtualMachineScaleSetCreate(d *schema.ResourceData, meta interf Sku: sku, VirtualMachineScaleSetProperties: &scaleSetProps, } - _, vmErr := vmScaleSetClient.CreateOrUpdate(resGroup, name, scaleSetParams, make(chan struct{})) + _, vmError := vmScaleSetClient.CreateOrUpdate(resGroup, name, scaleSetParams, make(chan struct{})) + vmErr := <-vmError if vmErr != nil { return vmErr } @@ -665,7 +666,8 @@ func resourceArmVirtualMachineScaleSetDelete(d *schema.ResourceData, meta interf resGroup := id.ResourceGroup name := id.Path["virtualMachineScaleSets"] - _, err = vmScaleSetClient.Delete(resGroup, name, make(chan struct{})) + _, error := vmScaleSetClient.Delete(resGroup, name, make(chan struct{})) + err = <-error return err } diff --git a/builtin/providers/azurerm/resource_arm_virtual_machine_scale_set_test.go b/builtin/providers/azurerm/resource_arm_virtual_machine_scale_set_test.go index 737f7969c..ba8b881d7 100644 --- a/builtin/providers/azurerm/resource_arm_virtual_machine_scale_set_test.go +++ b/builtin/providers/azurerm/resource_arm_virtual_machine_scale_set_test.go @@ -282,7 +282,8 @@ func testCheckAzureRMVirtualMachineScaleSetDisappears(name string) resource.Test conn := testAccProvider.Meta().(*ArmClient).vmScaleSetClient - _, err := conn.Delete(resourceGroup, name, make(chan struct{})) + _, error := conn.Delete(resourceGroup, name, make(chan struct{})) + err := <-error if err != nil { return fmt.Errorf("Bad: Delete on vmScaleSetClient: %s", err) } diff --git a/builtin/providers/azurerm/resource_arm_virtual_machine_test.go b/builtin/providers/azurerm/resource_arm_virtual_machine_test.go index 5a81d8e24..c44c22f48 100644 --- a/builtin/providers/azurerm/resource_arm_virtual_machine_test.go +++ b/builtin/providers/azurerm/resource_arm_virtual_machine_test.go @@ -737,7 +737,9 @@ func testCheckAzureRMVirtualMachineVHDExistence(name string, shouldExist bool) r return fmt.Errorf("Error creating Blob storage client: %s", err) } - exists, err := storageClient.BlobExists(containerName, name) + container := storageClient.GetContainerReference(containerName) + blob := container.GetBlobReference(name) + exists, err := blob.Exists() if err != nil { return fmt.Errorf("Error checking if Disk VHD Blob exists: %s", err) } @@ -769,7 +771,8 @@ func testCheckAzureRMVirtualMachineDisappears(name string) resource.TestCheckFun conn := testAccProvider.Meta().(*ArmClient).vmClient - _, err := conn.Delete(resourceGroup, vmName, make(chan struct{})) + _, error := conn.Delete(resourceGroup, vmName, make(chan struct{})) + err := <-error if err != nil { return fmt.Errorf("Bad: Delete on vmClient: %s", err) } diff --git a/builtin/providers/azurerm/resource_arm_virtual_network.go b/builtin/providers/azurerm/resource_arm_virtual_network.go index c9bdb063c..2d396f8b5 100644 --- a/builtin/providers/azurerm/resource_arm_virtual_network.go +++ b/builtin/providers/azurerm/resource_arm_virtual_network.go @@ -112,7 +112,8 @@ func resourceArmVirtualNetworkCreate(d *schema.ResourceData, meta interface{}) e azureRMLockMultiple(&networkSecurityGroupNames) defer azureRMUnlockMultiple(&networkSecurityGroupNames) - _, err := vnetClient.CreateOrUpdate(resGroup, name, vnet, make(chan struct{})) + _, error := vnetClient.CreateOrUpdate(resGroup, name, vnet, make(chan struct{})) + err := <-error if err != nil { return err } @@ -205,7 +206,8 @@ func resourceArmVirtualNetworkDelete(d *schema.ResourceData, meta interface{}) e azureRMLockMultiple(&nsgNames) defer azureRMUnlockMultiple(&nsgNames) - _, err = vnetClient.Delete(resGroup, name, make(chan struct{})) + _, error := vnetClient.Delete(resGroup, name, make(chan struct{})) + err = <-error return err } diff --git a/builtin/providers/azurerm/resource_arm_virtual_network_peering.go b/builtin/providers/azurerm/resource_arm_virtual_network_peering.go index f4d6653fb..e783d6cd8 100644 --- a/builtin/providers/azurerm/resource_arm_virtual_network_peering.go +++ b/builtin/providers/azurerm/resource_arm_virtual_network_peering.go @@ -93,7 +93,8 @@ func resourceArmVirtualNetworkPeeringCreate(d *schema.ResourceData, meta interfa peerMutex.Lock() defer peerMutex.Unlock() - _, err := client.CreateOrUpdate(resGroup, vnetName, name, peer, make(chan struct{})) + _, error := client.CreateOrUpdate(resGroup, vnetName, name, peer, make(chan struct{})) + err := <-error if err != nil { return err } @@ -160,7 +161,8 @@ func resourceArmVirtualNetworkPeeringDelete(d *schema.ResourceData, meta interfa peerMutex.Lock() defer peerMutex.Unlock() - _, err = client.Delete(resGroup, vnetName, name, make(chan struct{})) + _, error := client.Delete(resGroup, vnetName, name, make(chan struct{})) + err = <-error return err } diff --git a/builtin/providers/azurerm/resource_arm_virtual_network_peering_test.go b/builtin/providers/azurerm/resource_arm_virtual_network_peering_test.go index eb6bcc102..3f6832183 100644 --- a/builtin/providers/azurerm/resource_arm_virtual_network_peering_test.go +++ b/builtin/providers/azurerm/resource_arm_virtual_network_peering_test.go @@ -154,7 +154,8 @@ func testCheckAzureRMVirtualNetworkPeeringDisappears(name string) resource.TestC // Ensure resource group/virtual network peering combination exists in API conn := testAccProvider.Meta().(*ArmClient).vnetPeeringsClient - _, err := conn.Delete(resourceGroup, vnetName, name, make(chan struct{})) + _, error := conn.Delete(resourceGroup, vnetName, name, make(chan struct{})) + err := <-error if err != nil { return fmt.Errorf("Bad: Delete on vnetPeeringsClient: %s", err) } diff --git a/builtin/providers/azurerm/resource_arm_virtual_network_test.go b/builtin/providers/azurerm/resource_arm_virtual_network_test.go index ecf138148..5cd347868 100644 --- a/builtin/providers/azurerm/resource_arm_virtual_network_test.go +++ b/builtin/providers/azurerm/resource_arm_virtual_network_test.go @@ -20,7 +20,7 @@ func TestAccAzureRMVirtualNetwork_basic(t *testing.T) { Providers: testAccProviders, CheckDestroy: testCheckAzureRMVirtualNetworkDestroy, Steps: []resource.TestStep{ - resource.TestStep{ + { Config: config, Check: resource.ComposeTestCheckFunc( testCheckAzureRMVirtualNetworkExists("azurerm_virtual_network.test"), @@ -40,7 +40,7 @@ func TestAccAzureRMVirtualNetwork_disappears(t *testing.T) { Providers: testAccProviders, CheckDestroy: testCheckAzureRMVirtualNetworkDestroy, Steps: []resource.TestStep{ - resource.TestStep{ + { Config: config, Check: resource.ComposeTestCheckFunc( testCheckAzureRMVirtualNetworkExists("azurerm_virtual_network.test"), @@ -137,7 +137,8 @@ func testCheckAzureRMVirtualNetworkDisappears(name string) resource.TestCheckFun // Ensure resource group/virtual network combination exists in API conn := testAccProvider.Meta().(*ArmClient).vnetClient - _, err := conn.Delete(resourceGroup, virtualNetworkName, make(chan struct{})) + _, error := conn.Delete(resourceGroup, virtualNetworkName, make(chan struct{})) + err := <-error if err != nil { return fmt.Errorf("Bad: Delete on vnetClient: %s", err) } diff --git a/state/remote/azure.go b/state/remote/azure.go index 649111426..9b3e460be 100644 --- a/state/remote/azure.go +++ b/state/remote/azure.go @@ -163,7 +163,10 @@ type AzureClient struct { } func (c *AzureClient) Get() (*Payload, error) { - blob, err := c.blobClient.GetBlob(c.containerName, c.keyName) + containerReference := c.blobClient.GetContainerReference(c.containerName) + blobReference := containerReference.GetBlobReference(c.keyName) + options := &mainStorage.GetBlobOptions{} + blob, err := blobReference.Get(options) if err != nil { if storErr, ok := err.(mainStorage.AzureStorageServiceError); ok { if storErr.Code == "BlobNotFound" { @@ -193,28 +196,38 @@ func (c *AzureClient) Get() (*Payload, error) { } func (c *AzureClient) Put(data []byte) error { - headers := map[string]string{ - "Content-Type": "application/json", - } + setOptions := &mainStorage.SetBlobPropertiesOptions{} + putOptions := &mainStorage.PutBlobOptions{} + + containerReference := c.blobClient.GetContainerReference(c.containerName) + blobReference := containerReference.GetBlobReference(c.keyName) + + blobReference.Properties.ContentType = "application/json" + blobReference.Properties.ContentLength = int64(len(data)) if c.leaseID != "" { - headers["x-ms-lease-id"] = c.leaseID + setOptions.LeaseID = c.leaseID + putOptions.LeaseID = c.leaseID } - return c.blobClient.CreateBlockBlobFromReader( - c.containerName, - c.keyName, - uint64(len(data)), - bytes.NewReader(data), - headers, - ) + reader := bytes.NewReader(data) + + err := blobReference.CreateBlockBlobFromReader(reader, putOptions) + if err != nil { + return err + } + + return blobReference.SetProperties(setOptions) } func (c *AzureClient) Delete() error { - headers := map[string]string{} + containerReference := c.blobClient.GetContainerReference(c.containerName) + blobReference := containerReference.GetBlobReference(c.keyName) + options := &mainStorage.DeleteBlobOptions{} + if c.leaseID != "" { - headers["x-ms-lease-id"] = c.leaseID + options.LeaseID = c.leaseID } - return c.blobClient.DeleteBlob(c.containerName, c.keyName, headers) + return blobReference.Delete(options) } diff --git a/state/remote/azure_test.go b/state/remote/azure_test.go index 4e26f3d75..599f090c3 100644 --- a/state/remote/azure_test.go +++ b/state/remote/azure_test.go @@ -67,13 +67,18 @@ func TestAzureClientLease(t *testing.T) { } azureClient := client.(*AzureClient) + containerReference := azureClient.blobClient.GetContainerReference(azureClient.containerName) + blobReference := containerReference.GetBlobReference(azureClient.keyName) + // put empty blob so we can acquire lease against it - err = azureClient.blobClient.CreateBlockBlob(azureClient.containerName, azureClient.keyName) + options := &mainStorage.PutBlobOptions{} + err = blobReference.CreateBlockBlob(options) if err != nil { t.Fatalf("Error creating blob for leasing: %v", err) } - _, err = azureClient.blobClient.AcquireLease(azureClient.containerName, azureClient.keyName, -1, leaseID) + leaseOptions := &mainStorage.LeaseOptions{} + _, err = blobReference.AcquireLease(-1, leaseID, leaseOptions) if err != nil { t.Fatalf("Error acquiring lease: %v", err) } @@ -162,7 +167,12 @@ func setup(t *testing.T, conf map[string]string) { t.Fatalf("Error creating storage client for storage account %q: %s", conf["storage_account_name"], err) } blobClient := storageClient.GetBlobService() - _, err = blobClient.CreateContainerIfNotExists(conf["container_name"], mainStorage.ContainerAccessTypePrivate) + containerName := conf["container_name"] + containerReference := blobClient.GetContainerReference(containerName) + options := &mainStorage.CreateContainerOptions{ + Access: mainStorage.ContainerAccessTypePrivate, + } + _, err = containerReference.CreateIfNotExists(options) if err != nil { t.Fatalf("Couldn't create container with name %s: %s.", conf["container_name"], err) } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/client.go old mode 100644 new mode 100755 index 607a659db..bd5ca9d8b --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/client.go @@ -19,7 +19,7 @@ package cdn // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -31,9 +31,6 @@ import ( ) const ( - // APIVersion is the version of the Cdn - APIVersion = "2016-10-02" - // DefaultBaseURI is the default URI used for the service Cdn DefaultBaseURI = "https://management.azure.com" ) @@ -42,7 +39,6 @@ const ( type ManagementClient struct { autorest.Client BaseURI string - APIVersion string SubscriptionID string } @@ -56,7 +52,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, - APIVersion: APIVersion, SubscriptionID: subscriptionID, } } @@ -75,13 +70,15 @@ func (client ManagementClient) CheckNameAvailability(checkNameAvailabilityInput req, err := client.CheckNameAvailabilityPreparer(checkNameAvailabilityInput) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ManagementClient", "CheckNameAvailability", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.ManagementClient", "CheckNameAvailability", nil, "Failure preparing request") + return } resp, err := client.CheckNameAvailabilitySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.ManagementClient", "CheckNameAvailability", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.ManagementClient", "CheckNameAvailability", resp, "Failure sending request") + return } result, err = client.CheckNameAvailabilityResponder(resp) @@ -94,8 +91,9 @@ func (client ManagementClient) CheckNameAvailability(checkNameAvailabilityInput // CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. func (client ManagementClient) CheckNameAvailabilityPreparer(checkNameAvailabilityInput CheckNameAvailabilityInput) (*http.Request, error) { + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -127,100 +125,19 @@ func (client ManagementClient) CheckNameAvailabilityResponder(resp *http.Respons return } -// CheckResourceUsage check the quota and actual usage of the CDN profiles -// under the given subscription. -func (client ManagementClient) CheckResourceUsage() (result ResourceUsageListResult, err error) { - req, err := client.CheckResourceUsagePreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ManagementClient", "CheckResourceUsage", nil, "Failure preparing request") - } - - resp, err := client.CheckResourceUsageSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.ManagementClient", "CheckResourceUsage", resp, "Failure sending request") - } - - result, err = client.CheckResourceUsageResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.ManagementClient", "CheckResourceUsage", resp, "Failure responding to request") - } - - return -} - -// CheckResourceUsagePreparer prepares the CheckResourceUsage request. -func (client ManagementClient) CheckResourceUsagePreparer() (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/checkResourceUsage", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// CheckResourceUsageSender sends the CheckResourceUsage request. The method will close the -// http.Response Body if it receives an error. -func (client ManagementClient) CheckResourceUsageSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// CheckResourceUsageResponder handles the response to the CheckResourceUsage request. The method always -// closes the http.Response Body. -func (client ManagementClient) CheckResourceUsageResponder(resp *http.Response) (result ResourceUsageListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CheckResourceUsageNextResults retrieves the next set of results, if any. -func (client ManagementClient) CheckResourceUsageNextResults(lastResults ResourceUsageListResult) (result ResourceUsageListResult, err error) { - req, err := lastResults.ResourceUsageListResultPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ManagementClient", "CheckResourceUsage", nil, "Failure preparing next results request") - } - if req == nil { - return - } - - resp, err := client.CheckResourceUsageSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.ManagementClient", "CheckResourceUsage", resp, "Failure sending next results request") - } - - result, err = client.CheckResourceUsageResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.ManagementClient", "CheckResourceUsage", resp, "Failure responding to next results request") - } - - return -} - // ListOperations lists all of the available CDN REST API operations. func (client ManagementClient) ListOperations() (result OperationListResult, err error) { req, err := client.ListOperationsPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ManagementClient", "ListOperations", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.ManagementClient", "ListOperations", nil, "Failure preparing request") + return } resp, err := client.ListOperationsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.ManagementClient", "ListOperations", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.ManagementClient", "ListOperations", resp, "Failure sending request") + return } result, err = client.ListOperationsResponder(resp) @@ -233,8 +150,9 @@ func (client ManagementClient) ListOperations() (result OperationListResult, err // ListOperationsPreparer prepares the ListOperations request. func (client ManagementClient) ListOperationsPreparer() (*http.Request, error) { + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -287,3 +205,89 @@ func (client ManagementClient) ListOperationsNextResults(lastResults OperationLi return } + +// ListResourceUsage check the quota and actual usage of the CDN profiles under +// the given subscription. +func (client ManagementClient) ListResourceUsage() (result ResourceUsageListResult, err error) { + req, err := client.ListResourceUsagePreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.ManagementClient", "ListResourceUsage", nil, "Failure preparing request") + return + } + + resp, err := client.ListResourceUsageSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "cdn.ManagementClient", "ListResourceUsage", resp, "Failure sending request") + return + } + + result, err = client.ListResourceUsageResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.ManagementClient", "ListResourceUsage", resp, "Failure responding to request") + } + + return +} + +// ListResourceUsagePreparer prepares the ListResourceUsage request. +func (client ManagementClient) ListResourceUsagePreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-02" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/checkResourceUsage", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListResourceUsageSender sends the ListResourceUsage request. The method will close the +// http.Response Body if it receives an error. +func (client ManagementClient) ListResourceUsageSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResourceUsageResponder handles the response to the ListResourceUsage request. The method always +// closes the http.Response Body. +func (client ManagementClient) ListResourceUsageResponder(resp *http.Response) (result ResourceUsageListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListResourceUsageNextResults retrieves the next set of results, if any. +func (client ManagementClient) ListResourceUsageNextResults(lastResults ResourceUsageListResult) (result ResourceUsageListResult, err error) { + req, err := lastResults.ResourceUsageListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "cdn.ManagementClient", "ListResourceUsage", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListResourceUsageSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "cdn.ManagementClient", "ListResourceUsage", resp, "Failure sending next results request") + } + + result, err = client.ListResourceUsageResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.ManagementClient", "ListResourceUsage", resp, "Failure responding to next results request") + } + + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/customdomains.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/customdomains.go old mode 100644 new mode 100755 index 76cbecca6..688927217 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/customdomains.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/customdomains.go @@ -14,7 +14,7 @@ package cdn // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -55,7 +55,9 @@ func NewCustomDomainsClientWithBaseURI(baseURI string, subscriptionID string) Cu // which is unique globally. customDomainName is name of the custom domain // within an endpoint. customDomainProperties is properties required to create // a new custom domain. -func (client CustomDomainsClient) Create(resourceGroupName string, profileName string, endpointName string, customDomainName string, customDomainProperties CustomDomainParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client CustomDomainsClient) Create(resourceGroupName string, profileName string, endpointName string, customDomainName string, customDomainProperties CustomDomainParameters, cancel <-chan struct{}) (<-chan CustomDomain, <-chan error) { + resultChan := make(chan CustomDomain, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -64,26 +66,40 @@ func (client CustomDomainsClient) Create(resourceGroupName string, profileName s {TargetValue: customDomainProperties, Constraints: []validation.Constraint{{Target: "customDomainProperties.CustomDomainPropertiesParameters", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "customDomainProperties.CustomDomainPropertiesParameters.HostName", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "cdn.CustomDomainsClient", "Create") + errChan <- validation.NewErrorWithValidationError(err, "cdn.CustomDomainsClient", "Create") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreatePreparer(resourceGroupName, profileName, endpointName, customDomainName, customDomainProperties, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Create", nil, "Failure preparing request") - } + go func() { + var err error + var result CustomDomain + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(resourceGroupName, profileName, endpointName, customDomainName, customDomainProperties, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Create", nil, "Failure preparing request") + return + } - resp, err := client.CreateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Create", resp, "Failure sending request") - } + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Create", resp, "Failure sending request") + return + } - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Create", resp, "Failure responding to request") - } - - return + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreatePreparer prepares the Create request. @@ -96,8 +112,9 @@ func (client CustomDomainsClient) CreatePreparer(resourceGroupName string, profi "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -120,13 +137,14 @@ func (client CustomDomainsClient) CreateSender(req *http.Request) (*http.Respons // CreateResponder handles the response to the Create request. The method always // closes the http.Response Body. -func (client CustomDomainsClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client CustomDomainsClient) CreateResponder(resp *http.Response) (result CustomDomain, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -140,32 +158,48 @@ func (client CustomDomainsClient) CreateResponder(resp *http.Response) (result a // the resource group. endpointName is name of the endpoint under the profile // which is unique globally. customDomainName is name of the custom domain // within an endpoint. -func (client CustomDomainsClient) Delete(resourceGroupName string, profileName string, endpointName string, customDomainName string, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client CustomDomainsClient) Delete(resourceGroupName string, profileName string, endpointName string, customDomainName string, cancel <-chan struct{}) (<-chan CustomDomain, <-chan error) { + resultChan := make(chan CustomDomain, 1) + errChan := make(chan error, 1) 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.NewErrorWithValidationError(err, "cdn.CustomDomainsClient", "Delete") + errChan <- validation.NewErrorWithValidationError(err, "cdn.CustomDomainsClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.DeletePreparer(resourceGroupName, profileName, endpointName, customDomainName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Delete", nil, "Failure preparing request") - } + go func() { + var err error + var result CustomDomain + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, profileName, endpointName, customDomainName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -178,8 +212,9 @@ func (client CustomDomainsClient) DeletePreparer(resourceGroupName string, profi "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -200,13 +235,172 @@ func (client CustomDomainsClient) DeleteSender(req *http.Request) (*http.Respons // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client CustomDomainsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { +func (client CustomDomainsClient) DeleteResponder(resp *http.Response) (result CustomDomain, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} + return +} + +// DisableCustomHTTPS disable https delivery of the custom domain. +// +// resourceGroupName is name of the Resource group within the Azure +// subscription. profileName is name of the CDN profile which is unique within +// the resource group. endpointName is name of the endpoint under the profile +// which is unique globally. customDomainName is name of the custom domain +// within an endpoint. +func (client CustomDomainsClient) DisableCustomHTTPS(resourceGroupName string, profileName string, endpointName string, customDomainName string) (result CustomDomain, 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.NewErrorWithValidationError(err, "cdn.CustomDomainsClient", "DisableCustomHTTPS") + } + + req, err := client.DisableCustomHTTPSPreparer(resourceGroupName, profileName, endpointName, customDomainName) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "DisableCustomHTTPS", nil, "Failure preparing request") + return + } + + resp, err := client.DisableCustomHTTPSSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "DisableCustomHTTPS", resp, "Failure sending request") + return + } + + result, err = client.DisableCustomHTTPSResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "DisableCustomHTTPS", resp, "Failure responding to request") + } + + return +} + +// DisableCustomHTTPSPreparer prepares the DisableCustomHTTPS request. +func (client CustomDomainsClient) DisableCustomHTTPSPreparer(resourceGroupName string, profileName string, endpointName string, customDomainName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "customDomainName": autorest.Encode("path", customDomainName), + "endpointName": autorest.Encode("path", endpointName), + "profileName": autorest.Encode("path", profileName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-02" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}/disableCustomHttps", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DisableCustomHTTPSSender sends the DisableCustomHTTPS request. The method will close the +// http.Response Body if it receives an error. +func (client CustomDomainsClient) DisableCustomHTTPSSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DisableCustomHTTPSResponder handles the response to the DisableCustomHTTPS request. The method always +// closes the http.Response Body. +func (client CustomDomainsClient) DisableCustomHTTPSResponder(resp *http.Response) (result CustomDomain, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// EnableCustomHTTPS enable https delivery of the custom domain. +// +// resourceGroupName is name of the Resource group within the Azure +// subscription. profileName is name of the CDN profile which is unique within +// the resource group. endpointName is name of the endpoint under the profile +// which is unique globally. customDomainName is name of the custom domain +// within an endpoint. +func (client CustomDomainsClient) EnableCustomHTTPS(resourceGroupName string, profileName string, endpointName string, customDomainName string) (result CustomDomain, 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.NewErrorWithValidationError(err, "cdn.CustomDomainsClient", "EnableCustomHTTPS") + } + + req, err := client.EnableCustomHTTPSPreparer(resourceGroupName, profileName, endpointName, customDomainName) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "EnableCustomHTTPS", nil, "Failure preparing request") + return + } + + resp, err := client.EnableCustomHTTPSSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "EnableCustomHTTPS", resp, "Failure sending request") + return + } + + result, err = client.EnableCustomHTTPSResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "EnableCustomHTTPS", resp, "Failure responding to request") + } + + return +} + +// EnableCustomHTTPSPreparer prepares the EnableCustomHTTPS request. +func (client CustomDomainsClient) EnableCustomHTTPSPreparer(resourceGroupName string, profileName string, endpointName string, customDomainName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "customDomainName": autorest.Encode("path", customDomainName), + "endpointName": autorest.Encode("path", endpointName), + "profileName": autorest.Encode("path", profileName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-02" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}/enableCustomHttps", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// EnableCustomHTTPSSender sends the EnableCustomHTTPS request. The method will close the +// http.Response Body if it receives an error. +func (client CustomDomainsClient) EnableCustomHTTPSSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// EnableCustomHTTPSResponder handles the response to the EnableCustomHTTPS request. The method always +// closes the http.Response Body. +func (client CustomDomainsClient) EnableCustomHTTPSResponder(resp *http.Response) (result CustomDomain, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} return } @@ -228,13 +422,15 @@ func (client CustomDomainsClient) Get(resourceGroupName string, profileName stri req, err := client.GetPreparer(resourceGroupName, profileName, endpointName, customDomainName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -255,8 +451,9 @@ func (client CustomDomainsClient) GetPreparer(resourceGroupName string, profileN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -303,13 +500,15 @@ func (client CustomDomainsClient) ListByEndpoint(resourceGroupName string, profi req, err := client.ListByEndpointPreparer(resourceGroupName, profileName, endpointName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "ListByEndpoint", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "ListByEndpoint", nil, "Failure preparing request") + return } resp, err := client.ListByEndpointSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "ListByEndpoint", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "ListByEndpoint", resp, "Failure sending request") + return } result, err = client.ListByEndpointResponder(resp) @@ -329,8 +528,9 @@ func (client CustomDomainsClient) ListByEndpointPreparer(resourceGroupName strin "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/edgenodes.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/edgenodes.go old mode 100644 new mode 100755 index a4fb02a91..a68b5c189 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/edgenodes.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/edgenodes.go @@ -14,7 +14,7 @@ package cdn // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -46,13 +46,15 @@ func NewEdgeNodesClientWithBaseURI(baseURI string, subscriptionID string) EdgeNo func (client EdgeNodesClient) List() (result EdgenodeResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EdgeNodesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.EdgeNodesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.EdgeNodesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.EdgeNodesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -65,8 +67,9 @@ func (client EdgeNodesClient) List() (result EdgenodeResult, err error) { // ListPreparer prepares the List request. func (client EdgeNodesClient) ListPreparer() (*http.Request, error) { + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -95,3 +98,27 @@ func (client EdgeNodesClient) ListResponder(resp *http.Response) (result Edgenod result.Response = autorest.Response{Response: resp} return } + +// ListNextResults retrieves the next set of results, if any. +func (client EdgeNodesClient) ListNextResults(lastResults EdgenodeResult) (result EdgenodeResult, err error) { + req, err := lastResults.EdgenodeResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "cdn.EdgeNodesClient", "List", 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, "cdn.EdgeNodesClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EdgeNodesClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/endpoints.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/endpoints.go old mode 100644 new mode 100755 index 828dbc1e1..dcc411e05 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/endpoints.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/endpoints.go @@ -14,7 +14,7 @@ package cdn // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -53,7 +53,9 @@ func NewEndpointsClientWithBaseURI(baseURI string, subscriptionID string) Endpoi // subscription. profileName is name of the CDN profile which is unique within // the resource group. endpointName is name of the endpoint under the profile // which is unique globally. endpoint is endpoint properties -func (client EndpointsClient) Create(resourceGroupName string, profileName string, endpointName string, endpoint Endpoint, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client EndpointsClient) Create(resourceGroupName string, profileName string, endpointName string, endpoint Endpoint, cancel <-chan struct{}) (<-chan Endpoint, <-chan error) { + resultChan := make(chan Endpoint, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -62,26 +64,40 @@ func (client EndpointsClient) Create(resourceGroupName string, profileName strin {TargetValue: endpoint, Constraints: []validation.Constraint{{Target: "endpoint.EndpointProperties", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "endpoint.EndpointProperties.Origins", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Create") + errChan <- validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Create") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreatePreparer(resourceGroupName, profileName, endpointName, endpoint, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Create", nil, "Failure preparing request") - } + go func() { + var err error + var result Endpoint + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(resourceGroupName, profileName, endpointName, endpoint, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Create", nil, "Failure preparing request") + return + } - resp, err := client.CreateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Create", resp, "Failure sending request") - } + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Create", resp, "Failure sending request") + return + } - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Create", resp, "Failure responding to request") - } - - return + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreatePreparer prepares the Create request. @@ -93,8 +109,9 @@ func (client EndpointsClient) CreatePreparer(resourceGroupName string, profileNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -117,13 +134,14 @@ func (client EndpointsClient) CreateSender(req *http.Request) (*http.Response, e // CreateResponder handles the response to the Create request. The method always // closes the http.Response Body. -func (client EndpointsClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client EndpointsClient) CreateResponder(resp *http.Response) (result Endpoint, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -137,32 +155,48 @@ func (client EndpointsClient) CreateResponder(resp *http.Response) (result autor // subscription. profileName is name of the CDN profile which is unique within // the resource group. endpointName is name of the endpoint under the profile // which is unique globally. -func (client EndpointsClient) Delete(resourceGroupName string, profileName string, endpointName string, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client EndpointsClient) Delete(resourceGroupName string, profileName string, endpointName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) 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.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Delete") + errChan <- validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.DeletePreparer(resourceGroupName, profileName, endpointName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Delete", nil, "Failure preparing request") - } + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, profileName, endpointName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -174,8 +208,9 @@ func (client EndpointsClient) DeletePreparer(resourceGroupName string, profileNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -224,13 +259,15 @@ func (client EndpointsClient) Get(resourceGroupName string, profileName string, req, err := client.GetPreparer(resourceGroupName, profileName, endpointName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -250,8 +287,9 @@ func (client EndpointsClient) GetPreparer(resourceGroupName string, profileName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -297,13 +335,15 @@ func (client EndpointsClient) ListByProfile(resourceGroupName string, profileNam req, err := client.ListByProfilePreparer(resourceGroupName, profileName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListByProfile", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListByProfile", nil, "Failure preparing request") + return } resp, err := client.ListByProfileSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListByProfile", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListByProfile", resp, "Failure sending request") + return } result, err = client.ListByProfileResponder(resp) @@ -322,8 +362,9 @@ func (client EndpointsClient) ListByProfilePreparer(resourceGroupName string, pr "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -395,13 +436,15 @@ func (client EndpointsClient) ListResourceUsage(resourceGroupName string, profil req, err := client.ListResourceUsagePreparer(resourceGroupName, profileName, endpointName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListResourceUsage", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListResourceUsage", nil, "Failure preparing request") + return } resp, err := client.ListResourceUsageSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListResourceUsage", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListResourceUsage", resp, "Failure sending request") + return } result, err = client.ListResourceUsageResponder(resp) @@ -421,8 +464,9 @@ func (client EndpointsClient) ListResourceUsagePreparer(resourceGroupName string "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -487,7 +531,9 @@ func (client EndpointsClient) ListResourceUsageNextResults(lastResults ResourceU // which is unique globally. contentFilePaths is the path to the content to be // loaded. Path should be a full URL, e.g. ‘/pictires/city.png' which loads a // single file -func (client EndpointsClient) LoadContent(resourceGroupName string, profileName string, endpointName string, contentFilePaths LoadParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client EndpointsClient) LoadContent(resourceGroupName string, profileName string, endpointName string, contentFilePaths LoadParameters, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -495,26 +541,40 @@ func (client EndpointsClient) LoadContent(resourceGroupName string, profileName {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, {TargetValue: contentFilePaths, Constraints: []validation.Constraint{{Target: "contentFilePaths.ContentPaths", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "LoadContent") + errChan <- validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "LoadContent") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.LoadContentPreparer(resourceGroupName, profileName, endpointName, contentFilePaths, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "LoadContent", nil, "Failure preparing request") - } + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.LoadContentPreparer(resourceGroupName, profileName, endpointName, contentFilePaths, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "LoadContent", nil, "Failure preparing request") + return + } - resp, err := client.LoadContentSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "LoadContent", resp, "Failure sending request") - } + resp, err := client.LoadContentSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "LoadContent", resp, "Failure sending request") + return + } - result, err = client.LoadContentResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "LoadContent", resp, "Failure responding to request") - } - - return + result, err = client.LoadContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "LoadContent", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // LoadContentPreparer prepares the LoadContent request. @@ -526,8 +586,9 @@ func (client EndpointsClient) LoadContentPreparer(resourceGroupName string, prof "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -572,7 +633,9 @@ func (client EndpointsClient) LoadContentResponder(resp *http.Response) (result // purged. Path can be a full URL, e.g. '/pictures/city.png' which removes a // single file, or a directory with a wildcard, e.g. '/pictures/*' which // removes all folders and files in the directory. -func (client EndpointsClient) PurgeContent(resourceGroupName string, profileName string, endpointName string, contentFilePaths PurgeParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client EndpointsClient) PurgeContent(resourceGroupName string, profileName string, endpointName string, contentFilePaths PurgeParameters, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -580,26 +643,40 @@ func (client EndpointsClient) PurgeContent(resourceGroupName string, profileName {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, {TargetValue: contentFilePaths, Constraints: []validation.Constraint{{Target: "contentFilePaths.ContentPaths", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "PurgeContent") + errChan <- validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "PurgeContent") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.PurgeContentPreparer(resourceGroupName, profileName, endpointName, contentFilePaths, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "PurgeContent", nil, "Failure preparing request") - } + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.PurgeContentPreparer(resourceGroupName, profileName, endpointName, contentFilePaths, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "PurgeContent", nil, "Failure preparing request") + return + } - resp, err := client.PurgeContentSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "PurgeContent", resp, "Failure sending request") - } + resp, err := client.PurgeContentSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "PurgeContent", resp, "Failure sending request") + return + } - result, err = client.PurgeContentResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "PurgeContent", resp, "Failure responding to request") - } - - return + result, err = client.PurgeContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "PurgeContent", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // PurgeContentPreparer prepares the PurgeContent request. @@ -611,8 +688,9 @@ func (client EndpointsClient) PurgeContentPreparer(resourceGroupName string, pro "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -654,32 +732,48 @@ func (client EndpointsClient) PurgeContentResponder(resp *http.Response) (result // subscription. profileName is name of the CDN profile which is unique within // the resource group. endpointName is name of the endpoint under the profile // which is unique globally. -func (client EndpointsClient) Start(resourceGroupName string, profileName string, endpointName string, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client EndpointsClient) Start(resourceGroupName string, profileName string, endpointName string, cancel <-chan struct{}) (<-chan Endpoint, <-chan error) { + resultChan := make(chan Endpoint, 1) + errChan := make(chan error, 1) 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.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Start") + errChan <- validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Start") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.StartPreparer(resourceGroupName, profileName, endpointName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Start", nil, "Failure preparing request") - } + go func() { + var err error + var result Endpoint + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.StartPreparer(resourceGroupName, profileName, endpointName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Start", nil, "Failure preparing request") + return + } - resp, err := client.StartSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Start", resp, "Failure sending request") - } + resp, err := client.StartSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Start", resp, "Failure sending request") + return + } - result, err = client.StartResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Start", resp, "Failure responding to request") - } - - return + result, err = client.StartResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Start", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // StartPreparer prepares the Start request. @@ -691,8 +785,9 @@ func (client EndpointsClient) StartPreparer(resourceGroupName string, profileNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -713,13 +808,14 @@ func (client EndpointsClient) StartSender(req *http.Request) (*http.Response, er // StartResponder handles the response to the Start request. The method always // closes the http.Response Body. -func (client EndpointsClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { +func (client EndpointsClient) StartResponder(resp *http.Response) (result Endpoint, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -732,32 +828,48 @@ func (client EndpointsClient) StartResponder(resp *http.Response) (result autore // subscription. profileName is name of the CDN profile which is unique within // the resource group. endpointName is name of the endpoint under the profile // which is unique globally. -func (client EndpointsClient) Stop(resourceGroupName string, profileName string, endpointName string, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client EndpointsClient) Stop(resourceGroupName string, profileName string, endpointName string, cancel <-chan struct{}) (<-chan Endpoint, <-chan error) { + resultChan := make(chan Endpoint, 1) + errChan := make(chan error, 1) 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.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Stop") + errChan <- validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Stop") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.StopPreparer(resourceGroupName, profileName, endpointName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Stop", nil, "Failure preparing request") - } + go func() { + var err error + var result Endpoint + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.StopPreparer(resourceGroupName, profileName, endpointName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Stop", nil, "Failure preparing request") + return + } - resp, err := client.StopSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Stop", resp, "Failure sending request") - } + resp, err := client.StopSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Stop", resp, "Failure sending request") + return + } - result, err = client.StopResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Stop", resp, "Failure responding to request") - } - - return + result, err = client.StopResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Stop", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // StopPreparer prepares the Stop request. @@ -769,8 +881,9 @@ func (client EndpointsClient) StopPreparer(resourceGroupName string, profileName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -791,13 +904,14 @@ func (client EndpointsClient) StopSender(req *http.Request) (*http.Response, err // StopResponder handles the response to the Stop request. The method always // closes the http.Response Body. -func (client EndpointsClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { +func (client EndpointsClient) StopResponder(resp *http.Response) (result Endpoint, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -814,32 +928,48 @@ func (client EndpointsClient) StopResponder(resp *http.Response) (result autores // the resource group. endpointName is name of the endpoint under the profile // which is unique globally. endpointUpdateProperties is endpoint update // properties -func (client EndpointsClient) Update(resourceGroupName string, profileName string, endpointName string, endpointUpdateProperties EndpointUpdateParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client EndpointsClient) Update(resourceGroupName string, profileName string, endpointName string, endpointUpdateProperties EndpointUpdateParameters, cancel <-chan struct{}) (<-chan Endpoint, <-chan error) { + resultChan := make(chan Endpoint, 1) + errChan := make(chan error, 1) 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.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Update") + errChan <- validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Update") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.UpdatePreparer(resourceGroupName, profileName, endpointName, endpointUpdateProperties, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Update", nil, "Failure preparing request") - } + go func() { + var err error + var result Endpoint + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.UpdatePreparer(resourceGroupName, profileName, endpointName, endpointUpdateProperties, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Update", nil, "Failure preparing request") + return + } - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Update", resp, "Failure sending request") - } + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Update", resp, "Failure sending request") + return + } - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Update", resp, "Failure responding to request") - } - - return + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Update", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // UpdatePreparer prepares the Update request. @@ -851,8 +981,9 @@ func (client EndpointsClient) UpdatePreparer(resourceGroupName string, profileNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -875,13 +1006,14 @@ func (client EndpointsClient) UpdateSender(req *http.Request) (*http.Response, e // UpdateResponder handles the response to the Update request. The method always // closes the http.Response Body. -func (client EndpointsClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client EndpointsClient) UpdateResponder(resp *http.Response) (result Endpoint, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -906,13 +1038,15 @@ func (client EndpointsClient) ValidateCustomDomain(resourceGroupName string, pro req, err := client.ValidateCustomDomainPreparer(resourceGroupName, profileName, endpointName, customDomainProperties) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ValidateCustomDomain", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ValidateCustomDomain", nil, "Failure preparing request") + return } resp, err := client.ValidateCustomDomainSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ValidateCustomDomain", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ValidateCustomDomain", resp, "Failure sending request") + return } result, err = client.ValidateCustomDomainResponder(resp) @@ -932,8 +1066,9 @@ func (client EndpointsClient) ValidateCustomDomainPreparer(resourceGroupName str "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/models.go old mode 100644 new mode 100755 index 3479c2b6e..f291f8c52 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/models.go @@ -14,7 +14,7 @@ package cdn // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -37,6 +37,26 @@ const ( Deleting CustomDomainResourceState = "Deleting" ) +// CustomHTTPSProvisioningState enumerates the values for custom https +// provisioning state. +type CustomHTTPSProvisioningState string + +const ( + // Disabled specifies the disabled state for custom https provisioning + // state. + Disabled CustomHTTPSProvisioningState = "Disabled" + // Disabling specifies the disabling state for custom https provisioning + // state. + Disabling CustomHTTPSProvisioningState = "Disabling" + // Enabled specifies the enabled state for custom https provisioning state. + Enabled CustomHTTPSProvisioningState = "Enabled" + // Enabling specifies the enabling state for custom https provisioning + // state. + Enabling CustomHTTPSProvisioningState = "Enabling" + // Failed specifies the failed state for custom https provisioning state. + Failed CustomHTTPSProvisioningState = "Failed" +) + // EndpointResourceState enumerates the values for endpoint resource state. type EndpointResourceState string @@ -209,10 +229,11 @@ type CustomDomainParameters struct { // CustomDomainProperties is the JSON object that contains the properties of // the custom domain to create. type CustomDomainProperties struct { - HostName *string `json:"hostName,omitempty"` - ResourceState CustomDomainResourceState `json:"resourceState,omitempty"` - ValidationData *string `json:"validationData,omitempty"` - ProvisioningState *string `json:"provisioningState,omitempty"` + HostName *string `json:"hostName,omitempty"` + ResourceState CustomDomainResourceState `json:"resourceState,omitempty"` + CustomHTTPSProvisioningState CustomHTTPSProvisioningState `json:"customHttpsProvisioningState,omitempty"` + ValidationData *string `json:"validationData,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` } // CustomDomainPropertiesParameters is the JSON object that contains the @@ -256,6 +277,19 @@ type EdgeNodeProperties struct { type EdgenodeResult struct { autorest.Response `json:"-"` Value *[]EdgeNode `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// EdgenodeResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client EdgenodeResult) EdgenodeResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) } // Endpoint is cDN endpoint is the entity within a CDN profile containing diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/origins.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/origins.go old mode 100644 new mode 100755 index 518263dc1..f9fa1ff5c --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/origins.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/origins.go @@ -14,7 +14,7 @@ package cdn // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -60,13 +60,15 @@ func (client OriginsClient) Get(resourceGroupName string, profileName string, en req, err := client.GetPreparer(resourceGroupName, profileName, endpointName, originName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.OriginsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.OriginsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.OriginsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.OriginsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -87,8 +89,9 @@ func (client OriginsClient) GetPreparer(resourceGroupName string, profileName st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -135,13 +138,15 @@ func (client OriginsClient) ListByEndpoint(resourceGroupName string, profileName req, err := client.ListByEndpointPreparer(resourceGroupName, profileName, endpointName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.OriginsClient", "ListByEndpoint", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.OriginsClient", "ListByEndpoint", nil, "Failure preparing request") + return } resp, err := client.ListByEndpointSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.OriginsClient", "ListByEndpoint", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.OriginsClient", "ListByEndpoint", resp, "Failure sending request") + return } result, err = client.ListByEndpointResponder(resp) @@ -161,8 +166,9 @@ func (client OriginsClient) ListByEndpointPreparer(resourceGroupName string, pro "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -226,32 +232,48 @@ func (client OriginsClient) ListByEndpointNextResults(lastResults OriginListResu // the resource group. endpointName is name of the endpoint under the profile // which is unique globally. originName is name of the origin which is unique // within the endpoint. originUpdateProperties is origin properties -func (client OriginsClient) Update(resourceGroupName string, profileName string, endpointName string, originName string, originUpdateProperties OriginUpdateParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client OriginsClient) Update(resourceGroupName string, profileName string, endpointName string, originName string, originUpdateProperties OriginUpdateParameters, cancel <-chan struct{}) (<-chan Origin, <-chan error) { + resultChan := make(chan Origin, 1) + errChan := make(chan error, 1) 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.NewErrorWithValidationError(err, "cdn.OriginsClient", "Update") + errChan <- validation.NewErrorWithValidationError(err, "cdn.OriginsClient", "Update") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.UpdatePreparer(resourceGroupName, profileName, endpointName, originName, originUpdateProperties, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.OriginsClient", "Update", nil, "Failure preparing request") - } + go func() { + var err error + var result Origin + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.UpdatePreparer(resourceGroupName, profileName, endpointName, originName, originUpdateProperties, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.OriginsClient", "Update", nil, "Failure preparing request") + return + } - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.OriginsClient", "Update", resp, "Failure sending request") - } + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "cdn.OriginsClient", "Update", resp, "Failure sending request") + return + } - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.OriginsClient", "Update", resp, "Failure responding to request") - } - - return + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.OriginsClient", "Update", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // UpdatePreparer prepares the Update request. @@ -264,8 +286,9 @@ func (client OriginsClient) UpdatePreparer(resourceGroupName string, profileName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -288,12 +311,13 @@ func (client OriginsClient) UpdateSender(req *http.Request) (*http.Response, err // UpdateResponder handles the response to the Update request. The method always // closes the http.Response Body. -func (client OriginsClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client OriginsClient) UpdateResponder(resp *http.Response) (result Origin, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/profiles.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/profiles.go old mode 100644 new mode 100755 index c69b6ce50..c166a1b73 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/profiles.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/profiles.go @@ -14,7 +14,7 @@ package cdn // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -52,7 +52,9 @@ func NewProfilesClientWithBaseURI(baseURI string, subscriptionID string) Profile // subscription. profileName is name of the CDN profile which is unique within // the resource group. profile is profile properties needed to create a new // profile. -func (client ProfilesClient) Create(resourceGroupName string, profileName string, profile Profile, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client ProfilesClient) Create(resourceGroupName string, profileName string, profile Profile, cancel <-chan struct{}) (<-chan Profile, <-chan error) { + resultChan := make(chan Profile, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -60,26 +62,40 @@ func (client ProfilesClient) Create(resourceGroupName string, profileName string {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, {TargetValue: profile, Constraints: []validation.Constraint{{Target: "profile.Sku", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "cdn.ProfilesClient", "Create") + errChan <- validation.NewErrorWithValidationError(err, "cdn.ProfilesClient", "Create") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreatePreparer(resourceGroupName, profileName, profile, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Create", nil, "Failure preparing request") - } + go func() { + var err error + var result Profile + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(resourceGroupName, profileName, profile, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Create", nil, "Failure preparing request") + return + } - resp, err := client.CreateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Create", resp, "Failure sending request") - } + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Create", resp, "Failure sending request") + return + } - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Create", resp, "Failure responding to request") - } - - return + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreatePreparer prepares the Create request. @@ -90,8 +106,9 @@ func (client ProfilesClient) CreatePreparer(resourceGroupName string, profileNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -114,13 +131,14 @@ func (client ProfilesClient) CreateSender(req *http.Request) (*http.Response, er // CreateResponder handles the response to the Create request. The method always // closes the http.Response Body. -func (client ProfilesClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ProfilesClient) CreateResponder(resp *http.Response) (result Profile, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -134,32 +152,48 @@ func (client ProfilesClient) CreateResponder(resp *http.Response) (result autore // resourceGroupName is name of the Resource group within the Azure // subscription. profileName is name of the CDN profile which is unique within // the resource group. -func (client ProfilesClient) Delete(resourceGroupName string, profileName string, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client ProfilesClient) Delete(resourceGroupName string, profileName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) 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.NewErrorWithValidationError(err, "cdn.ProfilesClient", "Delete") + errChan <- validation.NewErrorWithValidationError(err, "cdn.ProfilesClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.DeletePreparer(resourceGroupName, profileName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Delete", nil, "Failure preparing request") - } + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, profileName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -170,8 +204,9 @@ func (client ProfilesClient) DeletePreparer(resourceGroupName string, profileNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -223,13 +258,15 @@ func (client ProfilesClient) GenerateSsoURI(resourceGroupName string, profileNam req, err := client.GenerateSsoURIPreparer(resourceGroupName, profileName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "GenerateSsoURI", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "GenerateSsoURI", nil, "Failure preparing request") + return } resp, err := client.GenerateSsoURISender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "GenerateSsoURI", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "GenerateSsoURI", resp, "Failure sending request") + return } result, err = client.GenerateSsoURIResponder(resp) @@ -248,8 +285,9 @@ func (client ProfilesClient) GenerateSsoURIPreparer(resourceGroupName string, pr "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -296,13 +334,15 @@ func (client ProfilesClient) Get(resourceGroupName string, profileName string) ( req, err := client.GetPreparer(resourceGroupName, profileName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -321,8 +361,9 @@ func (client ProfilesClient) GetPreparer(resourceGroupName string, profileName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -356,13 +397,15 @@ func (client ProfilesClient) GetResponder(resp *http.Response) (result Profile, func (client ProfilesClient) List() (result ProfileListResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -379,8 +422,9 @@ func (client ProfilesClient) ListPreparer() (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -449,13 +493,15 @@ func (client ProfilesClient) ListByResourceGroup(resourceGroupName string) (resu req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -473,8 +519,9 @@ func (client ProfilesClient) ListByResourceGroupPreparer(resourceGroupName strin "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -545,13 +592,15 @@ func (client ProfilesClient) ListResourceUsage(resourceGroupName string, profile req, err := client.ListResourceUsagePreparer(resourceGroupName, profileName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "ListResourceUsage", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "ListResourceUsage", nil, "Failure preparing request") + return } resp, err := client.ListResourceUsageSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "ListResourceUsage", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "ListResourceUsage", resp, "Failure sending request") + return } result, err = client.ListResourceUsageResponder(resp) @@ -570,8 +619,9 @@ func (client ProfilesClient) ListResourceUsagePreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -635,32 +685,48 @@ func (client ProfilesClient) ListResourceUsageNextResults(lastResults ResourceUs // subscription. profileName is name of the CDN profile which is unique within // the resource group. profileUpdateParameters is profile properties needed to // update an existing profile. -func (client ProfilesClient) Update(resourceGroupName string, profileName string, profileUpdateParameters ProfileUpdateParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client ProfilesClient) Update(resourceGroupName string, profileName string, profileUpdateParameters ProfileUpdateParameters, cancel <-chan struct{}) (<-chan Profile, <-chan error) { + resultChan := make(chan Profile, 1) + errChan := make(chan error, 1) 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.NewErrorWithValidationError(err, "cdn.ProfilesClient", "Update") + errChan <- validation.NewErrorWithValidationError(err, "cdn.ProfilesClient", "Update") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.UpdatePreparer(resourceGroupName, profileName, profileUpdateParameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Update", nil, "Failure preparing request") - } + go func() { + var err error + var result Profile + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.UpdatePreparer(resourceGroupName, profileName, profileUpdateParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Update", nil, "Failure preparing request") + return + } - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Update", resp, "Failure sending request") - } + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Update", resp, "Failure sending request") + return + } - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Update", resp, "Failure responding to request") - } - - return + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Update", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // UpdatePreparer prepares the Update request. @@ -671,8 +737,9 @@ func (client ProfilesClient) UpdatePreparer(resourceGroupName string, profileNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-10-02" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -695,12 +762,13 @@ func (client ProfilesClient) UpdateSender(req *http.Request) (*http.Response, er // UpdateResponder handles the response to the Update request. The method always // closes the http.Response Body. -func (client ProfilesClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ProfilesClient) UpdateResponder(resp *http.Response) (result Profile, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/version.go old mode 100644 new mode 100755 index 6039f3fed..afea5d841 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/version.go @@ -18,43 +18,12 @@ package cdn // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -import ( - "bytes" - "fmt" - "strings" -) - -const ( - major = "8" - minor = "1" - patch = "0" - tag = "beta" - userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" -) - -// cached results of UserAgent and Version to prevent repeated operations. -var ( - userAgent string - version string -) - // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - if userAgent == "" { - userAgent = fmt.Sprintf(userAgentFormat, Version(), "cdn", "2016-10-02") - } - return userAgent + return "Azure-SDK-For-Go/v10.0.2-beta arm-cdn/2016-10-02" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - if version == "" { - versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) - if tag != "" { - versionBuilder.WriteRune('-') - versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) - } - version = string(versionBuilder.Bytes()) - } - return version + return "v10.0.2-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/availabilitysets.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/availabilitysets.go old mode 100644 new mode 100755 index 1188c8b7c..738c2c61e --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/availabilitysets.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/availabilitysets.go @@ -49,13 +49,15 @@ func NewAvailabilitySetsClientWithBaseURI(baseURI string, subscriptionID string) func (client AvailabilitySetsClient) CreateOrUpdate(resourceGroupName string, name string, parameters AvailabilitySet) (result AvailabilitySet, err error) { req, err := client.CreateOrUpdatePreparer(resourceGroupName, name, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -74,8 +76,9 @@ func (client AvailabilitySetsClient) CreateOrUpdatePreparer(resourceGroupName st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -114,13 +117,15 @@ func (client AvailabilitySetsClient) CreateOrUpdateResponder(resp *http.Response func (client AvailabilitySetsClient) Delete(resourceGroupName string, availabilitySetName string) (result OperationStatusResponse, err error) { req, err := client.DeletePreparer(resourceGroupName, availabilitySetName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -139,8 +144,9 @@ func (client AvailabilitySetsClient) DeletePreparer(resourceGroupName string, av "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -177,13 +183,15 @@ func (client AvailabilitySetsClient) DeleteResponder(resp *http.Response) (resul func (client AvailabilitySetsClient) Get(resourceGroupName string, availabilitySetName string) (result AvailabilitySet, err error) { req, err := client.GetPreparer(resourceGroupName, availabilitySetName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -202,8 +210,9 @@ func (client AvailabilitySetsClient) GetPreparer(resourceGroupName string, avail "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -239,13 +248,15 @@ func (client AvailabilitySetsClient) GetResponder(resp *http.Response) (result A func (client AvailabilitySetsClient) List(resourceGroupName string) (result AvailabilitySetListResult, err error) { req, err := client.ListPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -263,8 +274,9 @@ func (client AvailabilitySetsClient) ListPreparer(resourceGroupName string) (*ht "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -302,13 +314,15 @@ func (client AvailabilitySetsClient) ListResponder(resp *http.Response) (result func (client AvailabilitySetsClient) ListAvailableSizes(resourceGroupName string, availabilitySetName string) (result VirtualMachineSizeListResult, err error) { req, err := client.ListAvailableSizesPreparer(resourceGroupName, availabilitySetName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", nil, "Failure preparing request") + return } resp, err := client.ListAvailableSizesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", resp, "Failure sending request") + return } result, err = client.ListAvailableSizesResponder(resp) @@ -327,8 +341,9 @@ func (client AvailabilitySetsClient) ListAvailableSizesPreparer(resourceGroupNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/client.go old mode 100644 new mode 100755 index bbe0af39c..c60452b9d --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/client.go @@ -27,9 +27,6 @@ import ( ) const ( - // APIVersion is the version of the Compute - APIVersion = "2016-04-30-preview" - // DefaultBaseURI is the default URI used for the service Compute DefaultBaseURI = "https://management.azure.com" ) @@ -38,7 +35,6 @@ const ( type ManagementClient struct { autorest.Client BaseURI string - APIVersion string SubscriptionID string } @@ -52,7 +48,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, - APIVersion: APIVersion, SubscriptionID: subscriptionID, } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/images.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/images.go old mode 100644 new mode 100755 index b585467cd..64f14dd08 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/images.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/images.go @@ -48,33 +48,49 @@ func NewImagesClientWithBaseURI(baseURI string, subscriptionID string) ImagesCli // resourceGroupName is the name of the resource group. imageName is the name // of the image. parameters is parameters supplied to the Create Image // operation. -func (client ImagesClient) CreateOrUpdate(resourceGroupName string, imageName string, parameters Image, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client ImagesClient) CreateOrUpdate(resourceGroupName string, imageName string, parameters Image, cancel <-chan struct{}) (<-chan Image, <-chan error) { + resultChan := make(chan Image, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.ImageProperties", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.ImageProperties.StorageProfile", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.ImageProperties.StorageProfile.OsDisk", Name: validation.Null, Rule: true, Chain: nil}}}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "compute.ImagesClient", "CreateOrUpdate") + errChan <- validation.NewErrorWithValidationError(err, "compute.ImagesClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, imageName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "CreateOrUpdate", nil, "Failure preparing request") - } + go func() { + var err error + var result Image + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, imageName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.ImagesClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -85,8 +101,9 @@ func (client ImagesClient) CreateOrUpdatePreparer(resourceGroupName string, imag "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -109,13 +126,14 @@ func (client ImagesClient) CreateOrUpdateSender(req *http.Request) (*http.Respon // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client ImagesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ImagesClient) CreateOrUpdateResponder(resp *http.Response) (result Image, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -125,24 +143,37 @@ func (client ImagesClient) CreateOrUpdateResponder(resp *http.Response) (result // // resourceGroupName is the name of the resource group. imageName is the name // of the image. -func (client ImagesClient) Delete(resourceGroupName string, imageName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, imageName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "Delete", nil, "Failure preparing request") - } +func (client ImagesClient) Delete(resourceGroupName string, imageName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, imageName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.ImagesClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -153,8 +184,9 @@ func (client ImagesClient) DeletePreparer(resourceGroupName string, imageName st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -175,13 +207,14 @@ func (client ImagesClient) DeleteSender(req *http.Request) (*http.Response, erro // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client ImagesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ImagesClient) DeleteResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -192,13 +225,15 @@ func (client ImagesClient) DeleteResponder(resp *http.Response) (result autorest func (client ImagesClient) Get(resourceGroupName string, imageName string, expand string) (result Image, err error) { req, err := client.GetPreparer(resourceGroupName, imageName, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -217,8 +252,9 @@ func (client ImagesClient) GetPreparer(resourceGroupName string, imageName strin "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(expand) > 0 { queryParameters["$expand"] = autorest.Encode("query", expand) @@ -257,13 +293,15 @@ func (client ImagesClient) GetResponder(resp *http.Response) (result Image, err func (client ImagesClient) List() (result ImageListResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -280,8 +318,9 @@ func (client ImagesClient) ListPreparer() (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -341,13 +380,15 @@ func (client ImagesClient) ListNextResults(lastResults ImageListResult) (result func (client ImagesClient) ListByResourceGroup(resourceGroupName string) (result ImageListResult, err error) { req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -365,8 +406,9 @@ func (client ImagesClient) ListByResourceGroupPreparer(resourceGroupName string) "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/models.go old mode 100644 new mode 100755 index 405048772..a9524daef --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/models.go @@ -107,6 +107,15 @@ const ( HTTPS ProtocolTypes = "Https" ) +// ResourceIdentityType enumerates the values for resource identity type. +type ResourceIdentityType string + +const ( + // SystemAssigned specifies the system assigned state for resource identity + // type. + SystemAssigned ResourceIdentityType = "SystemAssigned" +) + // SettingNames enumerates the values for setting names. type SettingNames string @@ -783,6 +792,7 @@ type VirtualMachine struct { Plan *Plan `json:"plan,omitempty"` *VirtualMachineProperties `json:"properties,omitempty"` Resources *[]VirtualMachineExtension `json:"resources,omitempty"` + Identity *VirtualMachineIdentity `json:"identity,omitempty"` } // VirtualMachineAgentInstanceView is the instance view of the VM Agent running @@ -877,6 +887,13 @@ type VirtualMachineExtensionProperties struct { InstanceView *VirtualMachineExtensionInstanceView `json:"instanceView,omitempty"` } +// VirtualMachineIdentity is identity for the virtual machine. +type VirtualMachineIdentity struct { + PrincipalID *string `json:"principalId,omitempty"` + TenantID *string `json:"tenantId,omitempty"` + Type ResourceIdentityType `json:"type,omitempty"` +} + // VirtualMachineImage is describes a Virtual Machine Image. type VirtualMachineImage struct { autorest.Response `json:"-"` @@ -959,6 +976,7 @@ type VirtualMachineScaleSet struct { Sku *Sku `json:"sku,omitempty"` Plan *Plan `json:"plan,omitempty"` *VirtualMachineScaleSetProperties `json:"properties,omitempty"` + Identity *VirtualMachineScaleSetIdentity `json:"identity,omitempty"` } // VirtualMachineScaleSetDataDisk is describes a virtual machine scale set data @@ -998,6 +1016,14 @@ type VirtualMachineScaleSetExtensionProperties struct { ProvisioningState *string `json:"provisioningState,omitempty"` } +// VirtualMachineScaleSetIdentity is identity for the virtual machine scale +// set. +type VirtualMachineScaleSetIdentity struct { + PrincipalID *string `json:"principalId,omitempty"` + TenantID *string `json:"tenantId,omitempty"` + Type ResourceIdentityType `json:"type,omitempty"` +} + // VirtualMachineScaleSetInstanceView is the instance view of a virtual machine // scale set. type VirtualMachineScaleSetInstanceView struct { diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/usage.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/usage.go old mode 100644 new mode 100755 index 241b95bea..97c53e0ef --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/usage.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/usage.go @@ -54,13 +54,15 @@ func (client UsageClient) List(location string) (result ListUsagesResult, err er req, err := client.ListPreparer(location) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.UsageClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.UsageClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.UsageClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.UsageClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -78,8 +80,9 @@ func (client UsageClient) ListPreparer(location string) (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/version.go old mode 100644 new mode 100755 index b28e58d36..a5318ebf7 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/version.go @@ -18,43 +18,12 @@ package compute // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -import ( - "bytes" - "fmt" - "strings" -) - -const ( - major = "8" - minor = "1" - patch = "0" - tag = "beta" - userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" -) - -// cached results of UserAgent and Version to prevent repeated operations. -var ( - userAgent string - version string -) - // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - if userAgent == "" { - userAgent = fmt.Sprintf(userAgentFormat, Version(), "compute", "2016-04-30-preview") - } - return userAgent + return "Azure-SDK-For-Go/v10.0.2-beta arm-compute/2016-04-30-preview" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - if version == "" { - versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) - if tag != "" { - versionBuilder.WriteRune('-') - versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) - } - version = string(versionBuilder.Bytes()) - } - return version + return "v10.0.2-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineextensionimages.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineextensionimages.go old mode 100644 new mode 100755 index dc91c9b4b..fcd122704 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineextensionimages.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineextensionimages.go @@ -46,13 +46,15 @@ func NewVirtualMachineExtensionImagesClientWithBaseURI(baseURI string, subscript func (client VirtualMachineExtensionImagesClient) Get(location string, publisherName string, typeParameter string, version string) (result VirtualMachineExtensionImage, err error) { req, err := client.GetPreparer(location, publisherName, typeParameter, version) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -73,8 +75,9 @@ func (client VirtualMachineExtensionImagesClient) GetPreparer(location string, p "version": autorest.Encode("path", version), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -109,13 +112,15 @@ func (client VirtualMachineExtensionImagesClient) GetResponder(resp *http.Respon func (client VirtualMachineExtensionImagesClient) ListTypes(location string, publisherName string) (result ListVirtualMachineExtensionImage, err error) { req, err := client.ListTypesPreparer(location, publisherName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListTypes", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListTypes", nil, "Failure preparing request") + return } resp, err := client.ListTypesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListTypes", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListTypes", resp, "Failure sending request") + return } result, err = client.ListTypesResponder(resp) @@ -134,8 +139,9 @@ func (client VirtualMachineExtensionImagesClient) ListTypesPreparer(location str "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -171,13 +177,15 @@ func (client VirtualMachineExtensionImagesClient) ListTypesResponder(resp *http. func (client VirtualMachineExtensionImagesClient) ListVersions(location string, publisherName string, typeParameter string, filter string, top *int32, orderby string) (result ListVirtualMachineExtensionImage, err error) { req, err := client.ListVersionsPreparer(location, publisherName, typeParameter, filter, top, orderby) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListVersions", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListVersions", nil, "Failure preparing request") + return } resp, err := client.ListVersionsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListVersions", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListVersions", resp, "Failure sending request") + return } result, err = client.ListVersionsResponder(resp) @@ -197,8 +205,9 @@ func (client VirtualMachineExtensionImagesClient) ListVersionsPreparer(location "type": autorest.Encode("path", typeParameter), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineextensions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineextensions.go old mode 100644 new mode 100755 index 143877549..7a876cfef --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineextensions.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineextensions.go @@ -46,42 +46,56 @@ func NewVirtualMachineExtensionsClientWithBaseURI(baseURI string, subscriptionID // channel argument. The channel will be used to cancel polling and any // outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. vmName is the name of +// resourceGroupName is the name of the resource group. VMName is the name of // the virtual machine where the extension should be create or updated. -// vmExtensionName is the name of the virtual machine extension. +// VMExtensionName is the name of the virtual machine extension. // extensionParameters is parameters supplied to the Create Virtual Machine // Extension operation. -func (client VirtualMachineExtensionsClient) CreateOrUpdate(resourceGroupName string, vmName string, vmExtensionName string, extensionParameters VirtualMachineExtension, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateOrUpdatePreparer(resourceGroupName, vmName, vmExtensionName, extensionParameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", nil, "Failure preparing request") - } +func (client VirtualMachineExtensionsClient) CreateOrUpdate(resourceGroupName string, VMName string, VMExtensionName string, extensionParameters VirtualMachineExtension, cancel <-chan struct{}) (<-chan VirtualMachineExtension, <-chan error) { + resultChan := make(chan VirtualMachineExtension, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result VirtualMachineExtension + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, VMName, VMExtensionName, extensionParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client VirtualMachineExtensionsClient) CreateOrUpdatePreparer(resourceGroupName string, vmName string, vmExtensionName string, extensionParameters VirtualMachineExtension, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachineExtensionsClient) CreateOrUpdatePreparer(resourceGroupName string, VMName string, VMExtensionName string, extensionParameters VirtualMachineExtension, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmExtensionName": autorest.Encode("path", vmExtensionName), - "vmName": autorest.Encode("path", vmName), + "vmExtensionName": autorest.Encode("path", VMExtensionName), + "vmName": autorest.Encode("path", VMName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -104,13 +118,14 @@ func (client VirtualMachineExtensionsClient) CreateOrUpdateSender(req *http.Requ // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client VirtualMachineExtensionsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineExtensionsClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualMachineExtension, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -119,40 +134,54 @@ func (client VirtualMachineExtensionsClient) CreateOrUpdateResponder(resp *http. // The channel will be used to cancel polling and any outstanding HTTP // requests. // -// resourceGroupName is the name of the resource group. vmName is the name of -// the virtual machine where the extension should be deleted. vmExtensionName +// resourceGroupName is the name of the resource group. VMName is the name of +// the virtual machine where the extension should be deleted. VMExtensionName // is the name of the virtual machine extension. -func (client VirtualMachineExtensionsClient) Delete(resourceGroupName string, vmName string, vmExtensionName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, vmName, vmExtensionName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Delete", nil, "Failure preparing request") - } +func (client VirtualMachineExtensionsClient) Delete(resourceGroupName string, VMName string, VMExtensionName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, VMName, VMExtensionName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. -func (client VirtualMachineExtensionsClient) DeletePreparer(resourceGroupName string, vmName string, vmExtensionName string, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachineExtensionsClient) DeletePreparer(resourceGroupName string, VMName string, VMExtensionName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmExtensionName": autorest.Encode("path", vmExtensionName), - "vmName": autorest.Encode("path", vmName), + "vmExtensionName": autorest.Encode("path", VMExtensionName), + "vmName": autorest.Encode("path", VMName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -173,32 +202,35 @@ func (client VirtualMachineExtensionsClient) DeleteSender(req *http.Request) (*h // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client VirtualMachineExtensionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineExtensionsClient) DeleteResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } // Get the operation to get the extension. // -// resourceGroupName is the name of the resource group. vmName is the name of -// the virtual machine containing the extension. vmExtensionName is the name of +// resourceGroupName is the name of the resource group. VMName is the name of +// the virtual machine containing the extension. VMExtensionName is the name of // the virtual machine extension. expand is the expand expression to apply on // the operation. -func (client VirtualMachineExtensionsClient) Get(resourceGroupName string, vmName string, vmExtensionName string, expand string) (result VirtualMachineExtension, err error) { - req, err := client.GetPreparer(resourceGroupName, vmName, vmExtensionName, expand) +func (client VirtualMachineExtensionsClient) Get(resourceGroupName string, VMName string, VMExtensionName string, expand string) (result VirtualMachineExtension, err error) { + req, err := client.GetPreparer(resourceGroupName, VMName, VMExtensionName, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -210,16 +242,17 @@ func (client VirtualMachineExtensionsClient) Get(resourceGroupName string, vmNam } // GetPreparer prepares the Get request. -func (client VirtualMachineExtensionsClient) GetPreparer(resourceGroupName string, vmName string, vmExtensionName string, expand string) (*http.Request, error) { +func (client VirtualMachineExtensionsClient) GetPreparer(resourceGroupName string, VMName string, VMExtensionName string, expand string) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmExtensionName": autorest.Encode("path", vmExtensionName), - "vmName": autorest.Encode("path", vmName), + "vmExtensionName": autorest.Encode("path", VMExtensionName), + "vmName": autorest.Encode("path", VMName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(expand) > 0 { queryParameters["$expand"] = autorest.Encode("query", expand) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineimages.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineimages.go old mode 100644 new mode 100755 index 21562370b..6c090568f --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineimages.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineimages.go @@ -49,13 +49,15 @@ func NewVirtualMachineImagesClientWithBaseURI(baseURI string, subscriptionID str func (client VirtualMachineImagesClient) Get(location string, publisherName string, offer string, skus string, version string) (result VirtualMachineImage, err error) { req, err := client.GetPreparer(location, publisherName, offer, skus, version) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -77,8 +79,9 @@ func (client VirtualMachineImagesClient) GetPreparer(location string, publisherN "version": autorest.Encode("path", version), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -117,13 +120,15 @@ func (client VirtualMachineImagesClient) GetResponder(resp *http.Response) (resu func (client VirtualMachineImagesClient) List(location string, publisherName string, offer string, skus string, filter string, top *int32, orderby string) (result ListVirtualMachineImageResource, err error) { req, err := client.ListPreparer(location, publisherName, offer, skus, filter, top, orderby) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -144,8 +149,9 @@ func (client VirtualMachineImagesClient) ListPreparer(location string, publisher "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -192,13 +198,15 @@ func (client VirtualMachineImagesClient) ListResponder(resp *http.Response) (res func (client VirtualMachineImagesClient) ListOffers(location string, publisherName string) (result ListVirtualMachineImageResource, err error) { req, err := client.ListOffersPreparer(location, publisherName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListOffers", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListOffers", nil, "Failure preparing request") + return } resp, err := client.ListOffersSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListOffers", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListOffers", resp, "Failure sending request") + return } result, err = client.ListOffersResponder(resp) @@ -217,8 +225,9 @@ func (client VirtualMachineImagesClient) ListOffersPreparer(location string, pub "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -255,13 +264,15 @@ func (client VirtualMachineImagesClient) ListOffersResponder(resp *http.Response func (client VirtualMachineImagesClient) ListPublishers(location string) (result ListVirtualMachineImageResource, err error) { req, err := client.ListPublishersPreparer(location) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListPublishers", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListPublishers", nil, "Failure preparing request") + return } resp, err := client.ListPublishersSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListPublishers", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListPublishers", resp, "Failure sending request") + return } result, err = client.ListPublishersResponder(resp) @@ -279,8 +290,9 @@ func (client VirtualMachineImagesClient) ListPublishersPreparer(location string) "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -318,13 +330,15 @@ func (client VirtualMachineImagesClient) ListPublishersResponder(resp *http.Resp func (client VirtualMachineImagesClient) ListSkus(location string, publisherName string, offer string) (result ListVirtualMachineImageResource, err error) { req, err := client.ListSkusPreparer(location, publisherName, offer) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListSkus", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListSkus", nil, "Failure preparing request") + return } resp, err := client.ListSkusSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListSkus", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListSkus", resp, "Failure sending request") + return } result, err = client.ListSkusResponder(resp) @@ -344,8 +358,9 @@ func (client VirtualMachineImagesClient) ListSkusPreparer(location string, publi "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachines.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachines.go old mode 100644 new mode 100755 index d1009f9d8..686b7ace2 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachines.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachines.go @@ -48,47 +48,64 @@ func NewVirtualMachinesClientWithBaseURI(baseURI string, subscriptionID string) // The channel will be used to cancel polling and any outstanding HTTP // requests. // -// resourceGroupName is the name of the resource group. vmName is the name of +// resourceGroupName is the name of the resource group. VMName is the name of // the virtual machine. parameters is parameters supplied to the Capture // Virtual Machine operation. -func (client VirtualMachinesClient) Capture(resourceGroupName string, vmName string, parameters VirtualMachineCaptureParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client VirtualMachinesClient) Capture(resourceGroupName string, VMName string, parameters VirtualMachineCaptureParameters, cancel <-chan struct{}) (<-chan VirtualMachineCaptureResult, <-chan error) { + resultChan := make(chan VirtualMachineCaptureResult, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.VhdPrefix", Name: validation.Null, Rule: true, Chain: nil}, {Target: "parameters.DestinationContainerName", Name: validation.Null, Rule: true, Chain: nil}, {Target: "parameters.OverwriteVhds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "compute.VirtualMachinesClient", "Capture") + errChan <- validation.NewErrorWithValidationError(err, "compute.VirtualMachinesClient", "Capture") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CapturePreparer(resourceGroupName, vmName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Capture", nil, "Failure preparing request") - } + go func() { + var err error + var result VirtualMachineCaptureResult + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CapturePreparer(resourceGroupName, VMName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Capture", nil, "Failure preparing request") + return + } - resp, err := client.CaptureSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Capture", resp, "Failure sending request") - } + resp, err := client.CaptureSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Capture", resp, "Failure sending request") + return + } - result, err = client.CaptureResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Capture", resp, "Failure responding to request") - } - - return + result, err = client.CaptureResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Capture", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CapturePreparer prepares the Capture request. -func (client VirtualMachinesClient) CapturePreparer(resourceGroupName string, vmName string, parameters VirtualMachineCaptureParameters, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachinesClient) CapturePreparer(resourceGroupName string, VMName string, parameters VirtualMachineCaptureParameters, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmName": autorest.Encode("path", vmName), + "vmName": autorest.Encode("path", VMName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -111,13 +128,14 @@ func (client VirtualMachinesClient) CaptureSender(req *http.Request) (*http.Resp // CaptureResponder handles the response to the Capture request. The method always // closes the http.Response Body. -func (client VirtualMachinesClient) CaptureResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachinesClient) CaptureResponder(resp *http.Response) (result VirtualMachineCaptureResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -127,38 +145,52 @@ func (client VirtualMachinesClient) CaptureResponder(resp *http.Response) (resul // passing the cancel channel argument. The channel will be used to cancel // polling and any outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. vmName is the name of +// resourceGroupName is the name of the resource group. VMName is the name of // the virtual machine. -func (client VirtualMachinesClient) ConvertToManagedDisks(resourceGroupName string, vmName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.ConvertToManagedDisksPreparer(resourceGroupName, vmName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ConvertToManagedDisks", nil, "Failure preparing request") - } +func (client VirtualMachinesClient) ConvertToManagedDisks(resourceGroupName string, VMName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ConvertToManagedDisksPreparer(resourceGroupName, VMName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ConvertToManagedDisks", nil, "Failure preparing request") + return + } - resp, err := client.ConvertToManagedDisksSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ConvertToManagedDisks", resp, "Failure sending request") - } + resp, err := client.ConvertToManagedDisksSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ConvertToManagedDisks", resp, "Failure sending request") + return + } - result, err = client.ConvertToManagedDisksResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ConvertToManagedDisks", resp, "Failure responding to request") - } - - return + result, err = client.ConvertToManagedDisksResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ConvertToManagedDisks", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // ConvertToManagedDisksPreparer prepares the ConvertToManagedDisks request. -func (client VirtualMachinesClient) ConvertToManagedDisksPreparer(resourceGroupName string, vmName string, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachinesClient) ConvertToManagedDisksPreparer(resourceGroupName string, VMName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmName": autorest.Encode("path", vmName), + "vmName": autorest.Encode("path", VMName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -179,13 +211,14 @@ func (client VirtualMachinesClient) ConvertToManagedDisksSender(req *http.Reques // ConvertToManagedDisksResponder handles the response to the ConvertToManagedDisks request. The method always // closes the http.Response Body. -func (client VirtualMachinesClient) ConvertToManagedDisksResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachinesClient) ConvertToManagedDisksResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -194,10 +227,12 @@ func (client VirtualMachinesClient) ConvertToManagedDisksResponder(resp *http.Re // cancel channel argument. The channel will be used to cancel polling and any // outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. vmName is the name of +// resourceGroupName is the name of the resource group. VMName is the name of // the virtual machine. parameters is parameters supplied to the Create Virtual // Machine operation. -func (client VirtualMachinesClient) CreateOrUpdate(resourceGroupName string, vmName string, parameters VirtualMachine, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client VirtualMachinesClient) CreateOrUpdate(resourceGroupName string, VMName string, parameters VirtualMachine, cancel <-chan struct{}) (<-chan VirtualMachine, <-chan error) { + resultChan := make(chan VirtualMachine, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.VirtualMachineProperties", Name: validation.Null, Rule: false, @@ -216,38 +251,53 @@ func (client VirtualMachinesClient) CreateOrUpdate(resourceGroupName string, vmN }}, }}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "compute.VirtualMachinesClient", "CreateOrUpdate") + errChan <- validation.NewErrorWithValidationError(err, "compute.VirtualMachinesClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, vmName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "CreateOrUpdate", nil, "Failure preparing request") - } + go func() { + var err error + var result VirtualMachine + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, VMName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client VirtualMachinesClient) CreateOrUpdatePreparer(resourceGroupName string, vmName string, parameters VirtualMachine, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachinesClient) CreateOrUpdatePreparer(resourceGroupName string, VMName string, parameters VirtualMachine, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmName": autorest.Encode("path", vmName), + "vmName": autorest.Encode("path", VMName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -270,13 +320,14 @@ func (client VirtualMachinesClient) CreateOrUpdateSender(req *http.Request) (*ht // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client VirtualMachinesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachinesClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualMachine, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -286,38 +337,52 @@ func (client VirtualMachinesClient) CreateOrUpdateResponder(resp *http.Response) // by passing the cancel channel argument. The channel will be used to cancel // polling and any outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. vmName is the name of +// resourceGroupName is the name of the resource group. VMName is the name of // the virtual machine. -func (client VirtualMachinesClient) Deallocate(resourceGroupName string, vmName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeallocatePreparer(resourceGroupName, vmName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Deallocate", nil, "Failure preparing request") - } +func (client VirtualMachinesClient) Deallocate(resourceGroupName string, VMName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeallocatePreparer(resourceGroupName, VMName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Deallocate", nil, "Failure preparing request") + return + } - resp, err := client.DeallocateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Deallocate", resp, "Failure sending request") - } + resp, err := client.DeallocateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Deallocate", resp, "Failure sending request") + return + } - result, err = client.DeallocateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Deallocate", resp, "Failure responding to request") - } - - return + result, err = client.DeallocateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Deallocate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeallocatePreparer prepares the Deallocate request. -func (client VirtualMachinesClient) DeallocatePreparer(resourceGroupName string, vmName string, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachinesClient) DeallocatePreparer(resourceGroupName string, VMName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmName": autorest.Encode("path", vmName), + "vmName": autorest.Encode("path", VMName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -338,13 +403,14 @@ func (client VirtualMachinesClient) DeallocateSender(req *http.Request) (*http.R // DeallocateResponder handles the response to the Deallocate request. The method always // closes the http.Response Body. -func (client VirtualMachinesClient) DeallocateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachinesClient) DeallocateResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -353,38 +419,52 @@ func (client VirtualMachinesClient) DeallocateResponder(resp *http.Response) (re // The channel will be used to cancel polling and any outstanding HTTP // requests. // -// resourceGroupName is the name of the resource group. vmName is the name of +// resourceGroupName is the name of the resource group. VMName is the name of // the virtual machine. -func (client VirtualMachinesClient) Delete(resourceGroupName string, vmName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, vmName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Delete", nil, "Failure preparing request") - } +func (client VirtualMachinesClient) Delete(resourceGroupName string, VMName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, VMName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. -func (client VirtualMachinesClient) DeletePreparer(resourceGroupName string, vmName string, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachinesClient) DeletePreparer(resourceGroupName string, VMName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmName": autorest.Encode("path", vmName), + "vmName": autorest.Encode("path", VMName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -405,30 +485,33 @@ func (client VirtualMachinesClient) DeleteSender(req *http.Request) (*http.Respo // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client VirtualMachinesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachinesClient) DeleteResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } // Generalize sets the state of the virtual machine to generalized. // -// resourceGroupName is the name of the resource group. vmName is the name of +// resourceGroupName is the name of the resource group. VMName is the name of // the virtual machine. -func (client VirtualMachinesClient) Generalize(resourceGroupName string, vmName string) (result OperationStatusResponse, err error) { - req, err := client.GeneralizePreparer(resourceGroupName, vmName) +func (client VirtualMachinesClient) Generalize(resourceGroupName string, VMName string) (result OperationStatusResponse, err error) { + req, err := client.GeneralizePreparer(resourceGroupName, VMName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Generalize", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Generalize", nil, "Failure preparing request") + return } resp, err := client.GeneralizeSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Generalize", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Generalize", resp, "Failure sending request") + return } result, err = client.GeneralizeResponder(resp) @@ -440,15 +523,16 @@ func (client VirtualMachinesClient) Generalize(resourceGroupName string, vmName } // GeneralizePreparer prepares the Generalize request. -func (client VirtualMachinesClient) GeneralizePreparer(resourceGroupName string, vmName string) (*http.Request, error) { +func (client VirtualMachinesClient) GeneralizePreparer(resourceGroupName string, VMName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmName": autorest.Encode("path", vmName), + "vmName": autorest.Encode("path", VMName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -481,19 +565,21 @@ func (client VirtualMachinesClient) GeneralizeResponder(resp *http.Response) (re // Get retrieves information about the model view or the instance view of a // virtual machine. // -// resourceGroupName is the name of the resource group. vmName is the name of +// resourceGroupName is the name of the resource group. VMName is the name of // the virtual machine. expand is the expand expression to apply on the // operation. -func (client VirtualMachinesClient) Get(resourceGroupName string, vmName string, expand InstanceViewTypes) (result VirtualMachine, err error) { - req, err := client.GetPreparer(resourceGroupName, vmName, expand) +func (client VirtualMachinesClient) Get(resourceGroupName string, VMName string, expand InstanceViewTypes) (result VirtualMachine, err error) { + req, err := client.GetPreparer(resourceGroupName, VMName, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -505,15 +591,16 @@ func (client VirtualMachinesClient) Get(resourceGroupName string, vmName string, } // GetPreparer prepares the Get request. -func (client VirtualMachinesClient) GetPreparer(resourceGroupName string, vmName string, expand InstanceViewTypes) (*http.Request, error) { +func (client VirtualMachinesClient) GetPreparer(resourceGroupName string, VMName string, expand InstanceViewTypes) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmName": autorest.Encode("path", vmName), + "vmName": autorest.Encode("path", VMName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(string(expand)) > 0 { queryParameters["$expand"] = autorest.Encode("query", expand) @@ -554,13 +641,15 @@ func (client VirtualMachinesClient) GetResponder(resp *http.Response) (result Vi func (client VirtualMachinesClient) List(resourceGroupName string) (result VirtualMachineListResult, err error) { req, err := client.ListPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -578,8 +667,9 @@ func (client VirtualMachinesClient) ListPreparer(resourceGroupName string) (*htt "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -639,13 +729,15 @@ func (client VirtualMachinesClient) ListNextResults(lastResults VirtualMachineLi func (client VirtualMachinesClient) ListAll() (result VirtualMachineListResult, err error) { req, err := client.ListAllPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ListAll", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ListAll", nil, "Failure preparing request") + return } resp, err := client.ListAllSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ListAll", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ListAll", resp, "Failure sending request") + return } result, err = client.ListAllResponder(resp) @@ -662,8 +754,9 @@ func (client VirtualMachinesClient) ListAllPreparer() (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -720,18 +813,20 @@ func (client VirtualMachinesClient) ListAllNextResults(lastResults VirtualMachin // ListAvailableSizes lists all available virtual machine sizes to which the // specified virtual machine can be resized. // -// resourceGroupName is the name of the resource group. vmName is the name of +// resourceGroupName is the name of the resource group. VMName is the name of // the virtual machine. -func (client VirtualMachinesClient) ListAvailableSizes(resourceGroupName string, vmName string) (result VirtualMachineSizeListResult, err error) { - req, err := client.ListAvailableSizesPreparer(resourceGroupName, vmName) +func (client VirtualMachinesClient) ListAvailableSizes(resourceGroupName string, VMName string) (result VirtualMachineSizeListResult, err error) { + req, err := client.ListAvailableSizesPreparer(resourceGroupName, VMName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ListAvailableSizes", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ListAvailableSizes", nil, "Failure preparing request") + return } resp, err := client.ListAvailableSizesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ListAvailableSizes", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ListAvailableSizes", resp, "Failure sending request") + return } result, err = client.ListAvailableSizesResponder(resp) @@ -743,15 +838,16 @@ func (client VirtualMachinesClient) ListAvailableSizes(resourceGroupName string, } // ListAvailableSizesPreparer prepares the ListAvailableSizes request. -func (client VirtualMachinesClient) ListAvailableSizesPreparer(resourceGroupName string, vmName string) (*http.Request, error) { +func (client VirtualMachinesClient) ListAvailableSizesPreparer(resourceGroupName string, VMName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmName": autorest.Encode("path", vmName), + "vmName": autorest.Encode("path", VMName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -787,38 +883,52 @@ func (client VirtualMachinesClient) ListAvailableSizesResponder(resp *http.Respo // Polling can be canceled by passing the cancel channel argument. The channel // will be used to cancel polling and any outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. vmName is the name of +// resourceGroupName is the name of the resource group. VMName is the name of // the virtual machine. -func (client VirtualMachinesClient) PowerOff(resourceGroupName string, vmName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.PowerOffPreparer(resourceGroupName, vmName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "PowerOff", nil, "Failure preparing request") - } +func (client VirtualMachinesClient) PowerOff(resourceGroupName string, VMName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.PowerOffPreparer(resourceGroupName, VMName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "PowerOff", nil, "Failure preparing request") + return + } - resp, err := client.PowerOffSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "PowerOff", resp, "Failure sending request") - } + resp, err := client.PowerOffSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "PowerOff", resp, "Failure sending request") + return + } - result, err = client.PowerOffResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "PowerOff", resp, "Failure responding to request") - } - - return + result, err = client.PowerOffResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "PowerOff", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // PowerOffPreparer prepares the PowerOff request. -func (client VirtualMachinesClient) PowerOffPreparer(resourceGroupName string, vmName string, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachinesClient) PowerOffPreparer(resourceGroupName string, VMName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmName": autorest.Encode("path", vmName), + "vmName": autorest.Encode("path", VMName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -839,13 +949,14 @@ func (client VirtualMachinesClient) PowerOffSender(req *http.Request) (*http.Res // PowerOffResponder handles the response to the PowerOff request. The method always // closes the http.Response Body. -func (client VirtualMachinesClient) PowerOffResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachinesClient) PowerOffResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -854,38 +965,52 @@ func (client VirtualMachinesClient) PowerOffResponder(resp *http.Response) (resu // argument. The channel will be used to cancel polling and any outstanding // HTTP requests. // -// resourceGroupName is the name of the resource group. vmName is the name of +// resourceGroupName is the name of the resource group. VMName is the name of // the virtual machine. -func (client VirtualMachinesClient) Redeploy(resourceGroupName string, vmName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.RedeployPreparer(resourceGroupName, vmName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Redeploy", nil, "Failure preparing request") - } +func (client VirtualMachinesClient) Redeploy(resourceGroupName string, VMName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.RedeployPreparer(resourceGroupName, VMName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Redeploy", nil, "Failure preparing request") + return + } - resp, err := client.RedeploySender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Redeploy", resp, "Failure sending request") - } + resp, err := client.RedeploySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Redeploy", resp, "Failure sending request") + return + } - result, err = client.RedeployResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Redeploy", resp, "Failure responding to request") - } - - return + result, err = client.RedeployResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Redeploy", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // RedeployPreparer prepares the Redeploy request. -func (client VirtualMachinesClient) RedeployPreparer(resourceGroupName string, vmName string, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachinesClient) RedeployPreparer(resourceGroupName string, VMName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmName": autorest.Encode("path", vmName), + "vmName": autorest.Encode("path", VMName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -906,13 +1031,14 @@ func (client VirtualMachinesClient) RedeploySender(req *http.Request) (*http.Res // RedeployResponder handles the response to the Redeploy request. The method always // closes the http.Response Body. -func (client VirtualMachinesClient) RedeployResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachinesClient) RedeployResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -921,38 +1047,52 @@ func (client VirtualMachinesClient) RedeployResponder(resp *http.Response) (resu // The channel will be used to cancel polling and any outstanding HTTP // requests. // -// resourceGroupName is the name of the resource group. vmName is the name of +// resourceGroupName is the name of the resource group. VMName is the name of // the virtual machine. -func (client VirtualMachinesClient) Restart(resourceGroupName string, vmName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.RestartPreparer(resourceGroupName, vmName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Restart", nil, "Failure preparing request") - } +func (client VirtualMachinesClient) Restart(resourceGroupName string, VMName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.RestartPreparer(resourceGroupName, VMName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Restart", nil, "Failure preparing request") + return + } - resp, err := client.RestartSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Restart", resp, "Failure sending request") - } + resp, err := client.RestartSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Restart", resp, "Failure sending request") + return + } - result, err = client.RestartResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Restart", resp, "Failure responding to request") - } - - return + result, err = client.RestartResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Restart", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // RestartPreparer prepares the Restart request. -func (client VirtualMachinesClient) RestartPreparer(resourceGroupName string, vmName string, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachinesClient) RestartPreparer(resourceGroupName string, VMName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmName": autorest.Encode("path", vmName), + "vmName": autorest.Encode("path", VMName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -973,13 +1113,14 @@ func (client VirtualMachinesClient) RestartSender(req *http.Request) (*http.Resp // RestartResponder handles the response to the Restart request. The method always // closes the http.Response Body. -func (client VirtualMachinesClient) RestartResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachinesClient) RestartResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -988,38 +1129,52 @@ func (client VirtualMachinesClient) RestartResponder(resp *http.Response) (resul // The channel will be used to cancel polling and any outstanding HTTP // requests. // -// resourceGroupName is the name of the resource group. vmName is the name of +// resourceGroupName is the name of the resource group. VMName is the name of // the virtual machine. -func (client VirtualMachinesClient) Start(resourceGroupName string, vmName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.StartPreparer(resourceGroupName, vmName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Start", nil, "Failure preparing request") - } +func (client VirtualMachinesClient) Start(resourceGroupName string, VMName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.StartPreparer(resourceGroupName, VMName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Start", nil, "Failure preparing request") + return + } - resp, err := client.StartSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Start", resp, "Failure sending request") - } + resp, err := client.StartSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Start", resp, "Failure sending request") + return + } - result, err = client.StartResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Start", resp, "Failure responding to request") - } - - return + result, err = client.StartResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Start", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // StartPreparer prepares the Start request. -func (client VirtualMachinesClient) StartPreparer(resourceGroupName string, vmName string, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachinesClient) StartPreparer(resourceGroupName string, VMName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmName": autorest.Encode("path", vmName), + "vmName": autorest.Encode("path", VMName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -1040,12 +1195,13 @@ func (client VirtualMachinesClient) StartSender(req *http.Request) (*http.Respon // StartResponder handles the response to the Start request. The method always // closes the http.Response Body. -func (client VirtualMachinesClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachinesClient) StartResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinescalesets.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinescalesets.go old mode 100644 new mode 100755 index 8e1705619..53700c8dd --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinescalesets.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinescalesets.go @@ -49,24 +49,37 @@ func NewVirtualMachineScaleSetsClientWithBaseURI(baseURI string, subscriptionID // // resourceGroupName is the name of the resource group. name is the name of the // VM scale set to create or update. parameters is the scale set object. -func (client VirtualMachineScaleSetsClient) CreateOrUpdate(resourceGroupName string, name string, parameters VirtualMachineScaleSet, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateOrUpdatePreparer(resourceGroupName, name, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "CreateOrUpdate", nil, "Failure preparing request") - } +func (client VirtualMachineScaleSetsClient) CreateOrUpdate(resourceGroupName string, name string, parameters VirtualMachineScaleSet, cancel <-chan struct{}) (<-chan VirtualMachineScaleSet, <-chan error) { + resultChan := make(chan VirtualMachineScaleSet, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result VirtualMachineScaleSet + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, name, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -77,8 +90,9 @@ func (client VirtualMachineScaleSetsClient) CreateOrUpdatePreparer(resourceGroup "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -101,13 +115,14 @@ func (client VirtualMachineScaleSetsClient) CreateOrUpdateSender(req *http.Reque // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualMachineScaleSet, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -118,39 +133,53 @@ func (client VirtualMachineScaleSetsClient) CreateOrUpdateResponder(resp *http.R // passing the cancel channel argument. The channel will be used to cancel // polling and any outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. vmScaleSetName is the -// name of the VM scale set. vmInstanceIDs is a list of virtual machine +// resourceGroupName is the name of the resource group. VMScaleSetName is the +// name of the VM scale set. VMInstanceIDs is a list of virtual machine // instance IDs from the VM scale set. -func (client VirtualMachineScaleSetsClient) Deallocate(resourceGroupName string, vmScaleSetName string, vmInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeallocatePreparer(resourceGroupName, vmScaleSetName, vmInstanceIDs, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Deallocate", nil, "Failure preparing request") - } +func (client VirtualMachineScaleSetsClient) Deallocate(resourceGroupName string, VMScaleSetName string, VMInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeallocatePreparer(resourceGroupName, VMScaleSetName, VMInstanceIDs, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Deallocate", nil, "Failure preparing request") + return + } - resp, err := client.DeallocateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Deallocate", resp, "Failure sending request") - } + resp, err := client.DeallocateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Deallocate", resp, "Failure sending request") + return + } - result, err = client.DeallocateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Deallocate", resp, "Failure responding to request") - } - - return + result, err = client.DeallocateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Deallocate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeallocatePreparer prepares the Deallocate request. -func (client VirtualMachineScaleSetsClient) DeallocatePreparer(resourceGroupName string, vmScaleSetName string, vmInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachineScaleSetsClient) DeallocatePreparer(resourceGroupName string, VMScaleSetName string, VMInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + "vmScaleSetName": autorest.Encode("path", VMScaleSetName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -159,9 +188,9 @@ func (client VirtualMachineScaleSetsClient) DeallocatePreparer(resourceGroupName autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate", pathParameters), autorest.WithQueryParameters(queryParameters)) - if vmInstanceIDs != nil { + if VMInstanceIDs != nil { preparer = autorest.DecoratePreparer(preparer, - autorest.WithJSON(vmInstanceIDs)) + autorest.WithJSON(VMInstanceIDs)) } return preparer.Prepare(&http.Request{Cancel: cancel}) } @@ -176,13 +205,14 @@ func (client VirtualMachineScaleSetsClient) DeallocateSender(req *http.Request) // DeallocateResponder handles the response to the Deallocate request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetsClient) DeallocateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) DeallocateResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -190,38 +220,52 @@ func (client VirtualMachineScaleSetsClient) DeallocateResponder(resp *http.Respo // can be canceled by passing the cancel channel argument. The channel will be // used to cancel polling and any outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. vmScaleSetName is the +// resourceGroupName is the name of the resource group. VMScaleSetName is the // name of the VM scale set. -func (client VirtualMachineScaleSetsClient) Delete(resourceGroupName string, vmScaleSetName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, vmScaleSetName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Delete", nil, "Failure preparing request") - } +func (client VirtualMachineScaleSetsClient) Delete(resourceGroupName string, VMScaleSetName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, VMScaleSetName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. -func (client VirtualMachineScaleSetsClient) DeletePreparer(resourceGroupName string, vmScaleSetName string, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachineScaleSetsClient) DeletePreparer(resourceGroupName string, VMScaleSetName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + "vmScaleSetName": autorest.Encode("path", VMScaleSetName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -242,13 +286,14 @@ func (client VirtualMachineScaleSetsClient) DeleteSender(req *http.Request) (*ht // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) DeleteResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -257,45 +302,62 @@ func (client VirtualMachineScaleSetsClient) DeleteResponder(resp *http.Response) // argument. The channel will be used to cancel polling and any outstanding // HTTP requests. // -// resourceGroupName is the name of the resource group. vmScaleSetName is the -// name of the VM scale set. vmInstanceIDs is a list of virtual machine +// resourceGroupName is the name of the resource group. VMScaleSetName is the +// name of the VM scale set. VMInstanceIDs is a list of virtual machine // instance IDs from the VM scale set. -func (client VirtualMachineScaleSetsClient) DeleteInstances(resourceGroupName string, vmScaleSetName string, vmInstanceIDs VirtualMachineScaleSetVMInstanceRequiredIDs, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) DeleteInstances(resourceGroupName string, VMScaleSetName string, VMInstanceIDs VirtualMachineScaleSetVMInstanceRequiredIDs, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ - {TargetValue: vmInstanceIDs, - Constraints: []validation.Constraint{{Target: "vmInstanceIDs.InstanceIds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "compute.VirtualMachineScaleSetsClient", "DeleteInstances") + {TargetValue: VMInstanceIDs, + Constraints: []validation.Constraint{{Target: "VMInstanceIDs.InstanceIds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "compute.VirtualMachineScaleSetsClient", "DeleteInstances") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.DeleteInstancesPreparer(resourceGroupName, vmScaleSetName, vmInstanceIDs, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "DeleteInstances", nil, "Failure preparing request") - } + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeleteInstancesPreparer(resourceGroupName, VMScaleSetName, VMInstanceIDs, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "DeleteInstances", nil, "Failure preparing request") + return + } - resp, err := client.DeleteInstancesSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "DeleteInstances", resp, "Failure sending request") - } + resp, err := client.DeleteInstancesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "DeleteInstances", resp, "Failure sending request") + return + } - result, err = client.DeleteInstancesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "DeleteInstances", resp, "Failure responding to request") - } - - return + result, err = client.DeleteInstancesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "DeleteInstances", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeleteInstancesPreparer prepares the DeleteInstances request. -func (client VirtualMachineScaleSetsClient) DeleteInstancesPreparer(resourceGroupName string, vmScaleSetName string, vmInstanceIDs VirtualMachineScaleSetVMInstanceRequiredIDs, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachineScaleSetsClient) DeleteInstancesPreparer(resourceGroupName string, VMScaleSetName string, VMInstanceIDs VirtualMachineScaleSetVMInstanceRequiredIDs, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + "vmScaleSetName": autorest.Encode("path", VMScaleSetName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -303,7 +365,7 @@ func (client VirtualMachineScaleSetsClient) DeleteInstancesPreparer(resourceGrou autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete", pathParameters), - autorest.WithJSON(vmInstanceIDs), + autorest.WithJSON(VMInstanceIDs), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{Cancel: cancel}) } @@ -318,30 +380,33 @@ func (client VirtualMachineScaleSetsClient) DeleteInstancesSender(req *http.Requ // DeleteInstancesResponder handles the response to the DeleteInstances request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetsClient) DeleteInstancesResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) DeleteInstancesResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } // Get display information about a virtual machine scale set. // -// resourceGroupName is the name of the resource group. vmScaleSetName is the +// resourceGroupName is the name of the resource group. VMScaleSetName is the // name of the VM scale set. -func (client VirtualMachineScaleSetsClient) Get(resourceGroupName string, vmScaleSetName string) (result VirtualMachineScaleSet, err error) { - req, err := client.GetPreparer(resourceGroupName, vmScaleSetName) +func (client VirtualMachineScaleSetsClient) Get(resourceGroupName string, VMScaleSetName string) (result VirtualMachineScaleSet, err error) { + req, err := client.GetPreparer(resourceGroupName, VMScaleSetName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -353,15 +418,16 @@ func (client VirtualMachineScaleSetsClient) Get(resourceGroupName string, vmScal } // GetPreparer prepares the Get request. -func (client VirtualMachineScaleSetsClient) GetPreparer(resourceGroupName string, vmScaleSetName string) (*http.Request, error) { +func (client VirtualMachineScaleSetsClient) GetPreparer(resourceGroupName string, VMScaleSetName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + "vmScaleSetName": autorest.Encode("path", VMScaleSetName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -393,18 +459,20 @@ func (client VirtualMachineScaleSetsClient) GetResponder(resp *http.Response) (r // GetInstanceView gets the status of a VM scale set instance. // -// resourceGroupName is the name of the resource group. vmScaleSetName is the +// resourceGroupName is the name of the resource group. VMScaleSetName is the // name of the VM scale set. -func (client VirtualMachineScaleSetsClient) GetInstanceView(resourceGroupName string, vmScaleSetName string) (result VirtualMachineScaleSetInstanceView, err error) { - req, err := client.GetInstanceViewPreparer(resourceGroupName, vmScaleSetName) +func (client VirtualMachineScaleSetsClient) GetInstanceView(resourceGroupName string, VMScaleSetName string) (result VirtualMachineScaleSetInstanceView, err error) { + req, err := client.GetInstanceViewPreparer(resourceGroupName, VMScaleSetName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "GetInstanceView", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "GetInstanceView", nil, "Failure preparing request") + return } resp, err := client.GetInstanceViewSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "GetInstanceView", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "GetInstanceView", resp, "Failure sending request") + return } result, err = client.GetInstanceViewResponder(resp) @@ -416,15 +484,16 @@ func (client VirtualMachineScaleSetsClient) GetInstanceView(resourceGroupName st } // GetInstanceViewPreparer prepares the GetInstanceView request. -func (client VirtualMachineScaleSetsClient) GetInstanceViewPreparer(resourceGroupName string, vmScaleSetName string) (*http.Request, error) { +func (client VirtualMachineScaleSetsClient) GetInstanceViewPreparer(resourceGroupName string, VMScaleSetName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + "vmScaleSetName": autorest.Encode("path", VMScaleSetName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -460,13 +529,15 @@ func (client VirtualMachineScaleSetsClient) GetInstanceViewResponder(resp *http. func (client VirtualMachineScaleSetsClient) List(resourceGroupName string) (result VirtualMachineScaleSetListResult, err error) { req, err := client.ListPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -484,8 +555,9 @@ func (client VirtualMachineScaleSetsClient) ListPreparer(resourceGroupName strin "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -546,13 +618,15 @@ func (client VirtualMachineScaleSetsClient) ListNextResults(lastResults VirtualM func (client VirtualMachineScaleSetsClient) ListAll() (result VirtualMachineScaleSetListWithLinkResult, err error) { req, err := client.ListAllPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ListAll", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ListAll", nil, "Failure preparing request") + return } resp, err := client.ListAllSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ListAll", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ListAll", resp, "Failure sending request") + return } result, err = client.ListAllResponder(resp) @@ -569,8 +643,9 @@ func (client VirtualMachineScaleSetsClient) ListAllPreparer() (*http.Request, er "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -627,18 +702,20 @@ func (client VirtualMachineScaleSetsClient) ListAllNextResults(lastResults Virtu // ListSkus gets a list of SKUs available for your VM scale set, including the // minimum and maximum VM instances allowed for each SKU. // -// resourceGroupName is the name of the resource group. vmScaleSetName is the +// resourceGroupName is the name of the resource group. VMScaleSetName is the // name of the VM scale set. -func (client VirtualMachineScaleSetsClient) ListSkus(resourceGroupName string, vmScaleSetName string) (result VirtualMachineScaleSetListSkusResult, err error) { - req, err := client.ListSkusPreparer(resourceGroupName, vmScaleSetName) +func (client VirtualMachineScaleSetsClient) ListSkus(resourceGroupName string, VMScaleSetName string) (result VirtualMachineScaleSetListSkusResult, err error) { + req, err := client.ListSkusPreparer(resourceGroupName, VMScaleSetName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ListSkus", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ListSkus", nil, "Failure preparing request") + return } resp, err := client.ListSkusSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ListSkus", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ListSkus", resp, "Failure sending request") + return } result, err = client.ListSkusResponder(resp) @@ -650,15 +727,16 @@ func (client VirtualMachineScaleSetsClient) ListSkus(resourceGroupName string, v } // ListSkusPreparer prepares the ListSkus request. -func (client VirtualMachineScaleSetsClient) ListSkusPreparer(resourceGroupName string, vmScaleSetName string) (*http.Request, error) { +func (client VirtualMachineScaleSetsClient) ListSkusPreparer(resourceGroupName string, VMScaleSetName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + "vmScaleSetName": autorest.Encode("path", VMScaleSetName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -719,39 +797,53 @@ func (client VirtualMachineScaleSetsClient) ListSkusNextResults(lastResults Virt // cancel channel argument. The channel will be used to cancel polling and any // outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. vmScaleSetName is the -// name of the VM scale set. vmInstanceIDs is a list of virtual machine +// resourceGroupName is the name of the resource group. VMScaleSetName is the +// name of the VM scale set. VMInstanceIDs is a list of virtual machine // instance IDs from the VM scale set. -func (client VirtualMachineScaleSetsClient) PowerOff(resourceGroupName string, vmScaleSetName string, vmInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.PowerOffPreparer(resourceGroupName, vmScaleSetName, vmInstanceIDs, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "PowerOff", nil, "Failure preparing request") - } +func (client VirtualMachineScaleSetsClient) PowerOff(resourceGroupName string, VMScaleSetName string, VMInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.PowerOffPreparer(resourceGroupName, VMScaleSetName, VMInstanceIDs, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "PowerOff", nil, "Failure preparing request") + return + } - resp, err := client.PowerOffSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "PowerOff", resp, "Failure sending request") - } + resp, err := client.PowerOffSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "PowerOff", resp, "Failure sending request") + return + } - result, err = client.PowerOffResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "PowerOff", resp, "Failure responding to request") - } - - return + result, err = client.PowerOffResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "PowerOff", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // PowerOffPreparer prepares the PowerOff request. -func (client VirtualMachineScaleSetsClient) PowerOffPreparer(resourceGroupName string, vmScaleSetName string, vmInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachineScaleSetsClient) PowerOffPreparer(resourceGroupName string, VMScaleSetName string, VMInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + "vmScaleSetName": autorest.Encode("path", VMScaleSetName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -760,9 +852,9 @@ func (client VirtualMachineScaleSetsClient) PowerOffPreparer(resourceGroupName s autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff", pathParameters), autorest.WithQueryParameters(queryParameters)) - if vmInstanceIDs != nil { + if VMInstanceIDs != nil { preparer = autorest.DecoratePreparer(preparer, - autorest.WithJSON(vmInstanceIDs)) + autorest.WithJSON(VMInstanceIDs)) } return preparer.Prepare(&http.Request{Cancel: cancel}) } @@ -777,13 +869,14 @@ func (client VirtualMachineScaleSetsClient) PowerOffSender(req *http.Request) (* // PowerOffResponder handles the response to the PowerOff request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetsClient) PowerOffResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) PowerOffResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -792,38 +885,52 @@ func (client VirtualMachineScaleSetsClient) PowerOffResponder(resp *http.Respons // canceled by passing the cancel channel argument. The channel will be used to // cancel polling and any outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. vmScaleSetName is the +// resourceGroupName is the name of the resource group. VMScaleSetName is the // name of the VM scale set. -func (client VirtualMachineScaleSetsClient) Reimage(resourceGroupName string, vmScaleSetName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.ReimagePreparer(resourceGroupName, vmScaleSetName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Reimage", nil, "Failure preparing request") - } +func (client VirtualMachineScaleSetsClient) Reimage(resourceGroupName string, VMScaleSetName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ReimagePreparer(resourceGroupName, VMScaleSetName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Reimage", nil, "Failure preparing request") + return + } - resp, err := client.ReimageSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Reimage", resp, "Failure sending request") - } + resp, err := client.ReimageSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Reimage", resp, "Failure sending request") + return + } - result, err = client.ReimageResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Reimage", resp, "Failure responding to request") - } - - return + result, err = client.ReimageResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Reimage", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // ReimagePreparer prepares the Reimage request. -func (client VirtualMachineScaleSetsClient) ReimagePreparer(resourceGroupName string, vmScaleSetName string, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachineScaleSetsClient) ReimagePreparer(resourceGroupName string, VMScaleSetName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + "vmScaleSetName": autorest.Encode("path", VMScaleSetName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -844,13 +951,14 @@ func (client VirtualMachineScaleSetsClient) ReimageSender(req *http.Request) (*h // ReimageResponder handles the response to the Reimage request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetsClient) ReimageResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) ReimageResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -860,38 +968,52 @@ func (client VirtualMachineScaleSetsClient) ReimageResponder(resp *http.Response // canceled by passing the cancel channel argument. The channel will be used to // cancel polling and any outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. vmScaleSetName is the +// resourceGroupName is the name of the resource group. VMScaleSetName is the // name of the VM scale set. -func (client VirtualMachineScaleSetsClient) ReimageAll(resourceGroupName string, vmScaleSetName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.ReimageAllPreparer(resourceGroupName, vmScaleSetName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ReimageAll", nil, "Failure preparing request") - } +func (client VirtualMachineScaleSetsClient) ReimageAll(resourceGroupName string, VMScaleSetName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ReimageAllPreparer(resourceGroupName, VMScaleSetName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ReimageAll", nil, "Failure preparing request") + return + } - resp, err := client.ReimageAllSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ReimageAll", resp, "Failure sending request") - } + resp, err := client.ReimageAllSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ReimageAll", resp, "Failure sending request") + return + } - result, err = client.ReimageAllResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ReimageAll", resp, "Failure responding to request") - } - - return + result, err = client.ReimageAllResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ReimageAll", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // ReimageAllPreparer prepares the ReimageAll request. -func (client VirtualMachineScaleSetsClient) ReimageAllPreparer(resourceGroupName string, vmScaleSetName string, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachineScaleSetsClient) ReimageAllPreparer(resourceGroupName string, VMScaleSetName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + "vmScaleSetName": autorest.Encode("path", VMScaleSetName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -912,13 +1034,14 @@ func (client VirtualMachineScaleSetsClient) ReimageAllSender(req *http.Request) // ReimageAllResponder handles the response to the ReimageAll request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetsClient) ReimageAllResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) ReimageAllResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -927,39 +1050,53 @@ func (client VirtualMachineScaleSetsClient) ReimageAllResponder(resp *http.Respo // channel argument. The channel will be used to cancel polling and any // outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. vmScaleSetName is the -// name of the VM scale set. vmInstanceIDs is a list of virtual machine +// resourceGroupName is the name of the resource group. VMScaleSetName is the +// name of the VM scale set. VMInstanceIDs is a list of virtual machine // instance IDs from the VM scale set. -func (client VirtualMachineScaleSetsClient) Restart(resourceGroupName string, vmScaleSetName string, vmInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.RestartPreparer(resourceGroupName, vmScaleSetName, vmInstanceIDs, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Restart", nil, "Failure preparing request") - } +func (client VirtualMachineScaleSetsClient) Restart(resourceGroupName string, VMScaleSetName string, VMInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.RestartPreparer(resourceGroupName, VMScaleSetName, VMInstanceIDs, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Restart", nil, "Failure preparing request") + return + } - resp, err := client.RestartSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Restart", resp, "Failure sending request") - } + resp, err := client.RestartSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Restart", resp, "Failure sending request") + return + } - result, err = client.RestartResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Restart", resp, "Failure responding to request") - } - - return + result, err = client.RestartResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Restart", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // RestartPreparer prepares the Restart request. -func (client VirtualMachineScaleSetsClient) RestartPreparer(resourceGroupName string, vmScaleSetName string, vmInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachineScaleSetsClient) RestartPreparer(resourceGroupName string, VMScaleSetName string, VMInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + "vmScaleSetName": autorest.Encode("path", VMScaleSetName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -968,9 +1105,9 @@ func (client VirtualMachineScaleSetsClient) RestartPreparer(resourceGroupName st autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart", pathParameters), autorest.WithQueryParameters(queryParameters)) - if vmInstanceIDs != nil { + if VMInstanceIDs != nil { preparer = autorest.DecoratePreparer(preparer, - autorest.WithJSON(vmInstanceIDs)) + autorest.WithJSON(VMInstanceIDs)) } return preparer.Prepare(&http.Request{Cancel: cancel}) } @@ -985,13 +1122,14 @@ func (client VirtualMachineScaleSetsClient) RestartSender(req *http.Request) (*h // RestartResponder handles the response to the Restart request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetsClient) RestartResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) RestartResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -1000,39 +1138,53 @@ func (client VirtualMachineScaleSetsClient) RestartResponder(resp *http.Response // argument. The channel will be used to cancel polling and any outstanding // HTTP requests. // -// resourceGroupName is the name of the resource group. vmScaleSetName is the -// name of the VM scale set. vmInstanceIDs is a list of virtual machine +// resourceGroupName is the name of the resource group. VMScaleSetName is the +// name of the VM scale set. VMInstanceIDs is a list of virtual machine // instance IDs from the VM scale set. -func (client VirtualMachineScaleSetsClient) Start(resourceGroupName string, vmScaleSetName string, vmInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.StartPreparer(resourceGroupName, vmScaleSetName, vmInstanceIDs, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Start", nil, "Failure preparing request") - } +func (client VirtualMachineScaleSetsClient) Start(resourceGroupName string, VMScaleSetName string, VMInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.StartPreparer(resourceGroupName, VMScaleSetName, VMInstanceIDs, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Start", nil, "Failure preparing request") + return + } - resp, err := client.StartSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Start", resp, "Failure sending request") - } + resp, err := client.StartSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Start", resp, "Failure sending request") + return + } - result, err = client.StartResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Start", resp, "Failure responding to request") - } - - return + result, err = client.StartResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Start", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // StartPreparer prepares the Start request. -func (client VirtualMachineScaleSetsClient) StartPreparer(resourceGroupName string, vmScaleSetName string, vmInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachineScaleSetsClient) StartPreparer(resourceGroupName string, VMScaleSetName string, VMInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + "vmScaleSetName": autorest.Encode("path", VMScaleSetName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -1041,9 +1193,9 @@ func (client VirtualMachineScaleSetsClient) StartPreparer(resourceGroupName stri autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start", pathParameters), autorest.WithQueryParameters(queryParameters)) - if vmInstanceIDs != nil { + if VMInstanceIDs != nil { preparer = autorest.DecoratePreparer(preparer, - autorest.WithJSON(vmInstanceIDs)) + autorest.WithJSON(VMInstanceIDs)) } return preparer.Prepare(&http.Request{Cancel: cancel}) } @@ -1058,13 +1210,14 @@ func (client VirtualMachineScaleSetsClient) StartSender(req *http.Request) (*htt // StartResponder handles the response to the Start request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetsClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) StartResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -1073,45 +1226,62 @@ func (client VirtualMachineScaleSetsClient) StartResponder(resp *http.Response) // be canceled by passing the cancel channel argument. The channel will be used // to cancel polling and any outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. vmScaleSetName is the -// name of the VM scale set. vmInstanceIDs is a list of virtual machine +// resourceGroupName is the name of the resource group. VMScaleSetName is the +// name of the VM scale set. VMInstanceIDs is a list of virtual machine // instance IDs from the VM scale set. -func (client VirtualMachineScaleSetsClient) UpdateInstances(resourceGroupName string, vmScaleSetName string, vmInstanceIDs VirtualMachineScaleSetVMInstanceRequiredIDs, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) UpdateInstances(resourceGroupName string, VMScaleSetName string, VMInstanceIDs VirtualMachineScaleSetVMInstanceRequiredIDs, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ - {TargetValue: vmInstanceIDs, - Constraints: []validation.Constraint{{Target: "vmInstanceIDs.InstanceIds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "compute.VirtualMachineScaleSetsClient", "UpdateInstances") + {TargetValue: VMInstanceIDs, + Constraints: []validation.Constraint{{Target: "VMInstanceIDs.InstanceIds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "compute.VirtualMachineScaleSetsClient", "UpdateInstances") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.UpdateInstancesPreparer(resourceGroupName, vmScaleSetName, vmInstanceIDs, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "UpdateInstances", nil, "Failure preparing request") - } + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.UpdateInstancesPreparer(resourceGroupName, VMScaleSetName, VMInstanceIDs, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "UpdateInstances", nil, "Failure preparing request") + return + } - resp, err := client.UpdateInstancesSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "UpdateInstances", resp, "Failure sending request") - } + resp, err := client.UpdateInstancesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "UpdateInstances", resp, "Failure sending request") + return + } - result, err = client.UpdateInstancesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "UpdateInstances", resp, "Failure responding to request") - } - - return + result, err = client.UpdateInstancesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "UpdateInstances", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // UpdateInstancesPreparer prepares the UpdateInstances request. -func (client VirtualMachineScaleSetsClient) UpdateInstancesPreparer(resourceGroupName string, vmScaleSetName string, vmInstanceIDs VirtualMachineScaleSetVMInstanceRequiredIDs, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachineScaleSetsClient) UpdateInstancesPreparer(resourceGroupName string, VMScaleSetName string, VMInstanceIDs VirtualMachineScaleSetVMInstanceRequiredIDs, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + "vmScaleSetName": autorest.Encode("path", VMScaleSetName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -1119,7 +1289,7 @@ func (client VirtualMachineScaleSetsClient) UpdateInstancesPreparer(resourceGrou autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade", pathParameters), - autorest.WithJSON(vmInstanceIDs), + autorest.WithJSON(VMInstanceIDs), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{Cancel: cancel}) } @@ -1134,12 +1304,13 @@ func (client VirtualMachineScaleSetsClient) UpdateInstancesSender(req *http.Requ // UpdateInstancesResponder handles the response to the UpdateInstances request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetsClient) UpdateInstancesResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) UpdateInstancesResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinescalesetvms.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinescalesetvms.go old mode 100644 new mode 100755 index 1b9e34177..34e0934dc --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinescalesetvms.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinescalesetvms.go @@ -48,40 +48,54 @@ func NewVirtualMachineScaleSetVMsClientWithBaseURI(baseURI string, subscriptionI // passing the cancel channel argument. The channel will be used to cancel // polling and any outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. vmScaleSetName is the +// resourceGroupName is the name of the resource group. VMScaleSetName is the // name of the VM scale set. instanceID is the instance ID of the virtual // machine. -func (client VirtualMachineScaleSetVMsClient) Deallocate(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeallocatePreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Deallocate", nil, "Failure preparing request") - } +func (client VirtualMachineScaleSetVMsClient) Deallocate(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeallocatePreparer(resourceGroupName, VMScaleSetName, instanceID, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Deallocate", nil, "Failure preparing request") + return + } - resp, err := client.DeallocateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Deallocate", resp, "Failure sending request") - } + resp, err := client.DeallocateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Deallocate", resp, "Failure sending request") + return + } - result, err = client.DeallocateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Deallocate", resp, "Failure responding to request") - } - - return + result, err = client.DeallocateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Deallocate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeallocatePreparer prepares the Deallocate request. -func (client VirtualMachineScaleSetVMsClient) DeallocatePreparer(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachineScaleSetVMsClient) DeallocatePreparer(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "instanceId": autorest.Encode("path", instanceID), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + "vmScaleSetName": autorest.Encode("path", VMScaleSetName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -102,13 +116,14 @@ func (client VirtualMachineScaleSetVMsClient) DeallocateSender(req *http.Request // DeallocateResponder handles the response to the Deallocate request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetVMsClient) DeallocateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetVMsClient) DeallocateResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -117,40 +132,54 @@ func (client VirtualMachineScaleSetVMsClient) DeallocateResponder(resp *http.Res // argument. The channel will be used to cancel polling and any outstanding // HTTP requests. // -// resourceGroupName is the name of the resource group. vmScaleSetName is the +// resourceGroupName is the name of the resource group. VMScaleSetName is the // name of the VM scale set. instanceID is the instance ID of the virtual // machine. -func (client VirtualMachineScaleSetVMsClient) Delete(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Delete", nil, "Failure preparing request") - } +func (client VirtualMachineScaleSetVMsClient) Delete(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, VMScaleSetName, instanceID, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. -func (client VirtualMachineScaleSetVMsClient) DeletePreparer(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachineScaleSetVMsClient) DeletePreparer(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "instanceId": autorest.Encode("path", instanceID), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + "vmScaleSetName": autorest.Encode("path", VMScaleSetName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -171,31 +200,34 @@ func (client VirtualMachineScaleSetVMsClient) DeleteSender(req *http.Request) (* // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetVMsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetVMsClient) DeleteResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } // Get gets a virtual machine from a VM scale set. // -// resourceGroupName is the name of the resource group. vmScaleSetName is the +// resourceGroupName is the name of the resource group. VMScaleSetName is the // name of the VM scale set. instanceID is the instance ID of the virtual // machine. -func (client VirtualMachineScaleSetVMsClient) Get(resourceGroupName string, vmScaleSetName string, instanceID string) (result VirtualMachineScaleSetVM, err error) { - req, err := client.GetPreparer(resourceGroupName, vmScaleSetName, instanceID) +func (client VirtualMachineScaleSetVMsClient) Get(resourceGroupName string, VMScaleSetName string, instanceID string) (result VirtualMachineScaleSetVM, err error) { + req, err := client.GetPreparer(resourceGroupName, VMScaleSetName, instanceID) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -207,16 +239,17 @@ func (client VirtualMachineScaleSetVMsClient) Get(resourceGroupName string, vmSc } // GetPreparer prepares the Get request. -func (client VirtualMachineScaleSetVMsClient) GetPreparer(resourceGroupName string, vmScaleSetName string, instanceID string) (*http.Request, error) { +func (client VirtualMachineScaleSetVMsClient) GetPreparer(resourceGroupName string, VMScaleSetName string, instanceID string) (*http.Request, error) { pathParameters := map[string]interface{}{ "instanceId": autorest.Encode("path", instanceID), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + "vmScaleSetName": autorest.Encode("path", VMScaleSetName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -248,19 +281,21 @@ func (client VirtualMachineScaleSetVMsClient) GetResponder(resp *http.Response) // GetInstanceView gets the status of a virtual machine from a VM scale set. // -// resourceGroupName is the name of the resource group. vmScaleSetName is the +// resourceGroupName is the name of the resource group. VMScaleSetName is the // name of the VM scale set. instanceID is the instance ID of the virtual // machine. -func (client VirtualMachineScaleSetVMsClient) GetInstanceView(resourceGroupName string, vmScaleSetName string, instanceID string) (result VirtualMachineScaleSetVMInstanceView, err error) { - req, err := client.GetInstanceViewPreparer(resourceGroupName, vmScaleSetName, instanceID) +func (client VirtualMachineScaleSetVMsClient) GetInstanceView(resourceGroupName string, VMScaleSetName string, instanceID string) (result VirtualMachineScaleSetVMInstanceView, err error) { + req, err := client.GetInstanceViewPreparer(resourceGroupName, VMScaleSetName, instanceID) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "GetInstanceView", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "GetInstanceView", nil, "Failure preparing request") + return } resp, err := client.GetInstanceViewSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "GetInstanceView", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "GetInstanceView", resp, "Failure sending request") + return } result, err = client.GetInstanceViewResponder(resp) @@ -272,16 +307,17 @@ func (client VirtualMachineScaleSetVMsClient) GetInstanceView(resourceGroupName } // GetInstanceViewPreparer prepares the GetInstanceView request. -func (client VirtualMachineScaleSetVMsClient) GetInstanceViewPreparer(resourceGroupName string, vmScaleSetName string, instanceID string) (*http.Request, error) { +func (client VirtualMachineScaleSetVMsClient) GetInstanceViewPreparer(resourceGroupName string, VMScaleSetName string, instanceID string) (*http.Request, error) { pathParameters := map[string]interface{}{ "instanceId": autorest.Encode("path", instanceID), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + "vmScaleSetName": autorest.Encode("path", VMScaleSetName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -320,13 +356,15 @@ func (client VirtualMachineScaleSetVMsClient) GetInstanceViewResponder(resp *htt func (client VirtualMachineScaleSetVMsClient) List(resourceGroupName string, virtualMachineScaleSetName string, filter string, selectParameter string, expand string) (result VirtualMachineScaleSetVMListResult, err error) { req, err := client.ListPreparer(resourceGroupName, virtualMachineScaleSetName, filter, selectParameter, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -345,8 +383,9 @@ func (client VirtualMachineScaleSetVMsClient) ListPreparer(resourceGroupName str "virtualMachineScaleSetName": autorest.Encode("path", virtualMachineScaleSetName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -416,40 +455,54 @@ func (client VirtualMachineScaleSetVMsClient) ListNextResults(lastResults Virtua // channel argument. The channel will be used to cancel polling and any // outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. vmScaleSetName is the +// resourceGroupName is the name of the resource group. VMScaleSetName is the // name of the VM scale set. instanceID is the instance ID of the virtual // machine. -func (client VirtualMachineScaleSetVMsClient) PowerOff(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.PowerOffPreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "PowerOff", nil, "Failure preparing request") - } +func (client VirtualMachineScaleSetVMsClient) PowerOff(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.PowerOffPreparer(resourceGroupName, VMScaleSetName, instanceID, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "PowerOff", nil, "Failure preparing request") + return + } - resp, err := client.PowerOffSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "PowerOff", resp, "Failure sending request") - } + resp, err := client.PowerOffSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "PowerOff", resp, "Failure sending request") + return + } - result, err = client.PowerOffResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "PowerOff", resp, "Failure responding to request") - } - - return + result, err = client.PowerOffResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "PowerOff", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // PowerOffPreparer prepares the PowerOff request. -func (client VirtualMachineScaleSetVMsClient) PowerOffPreparer(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachineScaleSetVMsClient) PowerOffPreparer(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "instanceId": autorest.Encode("path", instanceID), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + "vmScaleSetName": autorest.Encode("path", VMScaleSetName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -470,13 +523,14 @@ func (client VirtualMachineScaleSetVMsClient) PowerOffSender(req *http.Request) // PowerOffResponder handles the response to the PowerOff request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetVMsClient) PowerOffResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetVMsClient) PowerOffResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -485,40 +539,54 @@ func (client VirtualMachineScaleSetVMsClient) PowerOffResponder(resp *http.Respo // canceled by passing the cancel channel argument. The channel will be used to // cancel polling and any outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. vmScaleSetName is the +// resourceGroupName is the name of the resource group. VMScaleSetName is the // name of the VM scale set. instanceID is the instance ID of the virtual // machine. -func (client VirtualMachineScaleSetVMsClient) Reimage(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.ReimagePreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", nil, "Failure preparing request") - } +func (client VirtualMachineScaleSetVMsClient) Reimage(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ReimagePreparer(resourceGroupName, VMScaleSetName, instanceID, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", nil, "Failure preparing request") + return + } - resp, err := client.ReimageSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", resp, "Failure sending request") - } + resp, err := client.ReimageSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", resp, "Failure sending request") + return + } - result, err = client.ReimageResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", resp, "Failure responding to request") - } - - return + result, err = client.ReimageResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // ReimagePreparer prepares the Reimage request. -func (client VirtualMachineScaleSetVMsClient) ReimagePreparer(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachineScaleSetVMsClient) ReimagePreparer(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "instanceId": autorest.Encode("path", instanceID), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + "vmScaleSetName": autorest.Encode("path", VMScaleSetName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -539,13 +607,14 @@ func (client VirtualMachineScaleSetVMsClient) ReimageSender(req *http.Request) ( // ReimageResponder handles the response to the Reimage request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetVMsClient) ReimageResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetVMsClient) ReimageResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -555,40 +624,54 @@ func (client VirtualMachineScaleSetVMsClient) ReimageResponder(resp *http.Respon // canceled by passing the cancel channel argument. The channel will be used to // cancel polling and any outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. vmScaleSetName is the +// resourceGroupName is the name of the resource group. VMScaleSetName is the // name of the VM scale set. instanceID is the instance ID of the virtual // machine. -func (client VirtualMachineScaleSetVMsClient) ReimageAll(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.ReimageAllPreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "ReimageAll", nil, "Failure preparing request") - } +func (client VirtualMachineScaleSetVMsClient) ReimageAll(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ReimageAllPreparer(resourceGroupName, VMScaleSetName, instanceID, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "ReimageAll", nil, "Failure preparing request") + return + } - resp, err := client.ReimageAllSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "ReimageAll", resp, "Failure sending request") - } + resp, err := client.ReimageAllSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "ReimageAll", resp, "Failure sending request") + return + } - result, err = client.ReimageAllResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "ReimageAll", resp, "Failure responding to request") - } - - return + result, err = client.ReimageAllResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "ReimageAll", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // ReimageAllPreparer prepares the ReimageAll request. -func (client VirtualMachineScaleSetVMsClient) ReimageAllPreparer(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachineScaleSetVMsClient) ReimageAllPreparer(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "instanceId": autorest.Encode("path", instanceID), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + "vmScaleSetName": autorest.Encode("path", VMScaleSetName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -609,13 +692,14 @@ func (client VirtualMachineScaleSetVMsClient) ReimageAllSender(req *http.Request // ReimageAllResponder handles the response to the ReimageAll request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetVMsClient) ReimageAllResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetVMsClient) ReimageAllResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -624,40 +708,54 @@ func (client VirtualMachineScaleSetVMsClient) ReimageAllResponder(resp *http.Res // argument. The channel will be used to cancel polling and any outstanding // HTTP requests. // -// resourceGroupName is the name of the resource group. vmScaleSetName is the +// resourceGroupName is the name of the resource group. VMScaleSetName is the // name of the VM scale set. instanceID is the instance ID of the virtual // machine. -func (client VirtualMachineScaleSetVMsClient) Restart(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.RestartPreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Restart", nil, "Failure preparing request") - } +func (client VirtualMachineScaleSetVMsClient) Restart(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.RestartPreparer(resourceGroupName, VMScaleSetName, instanceID, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Restart", nil, "Failure preparing request") + return + } - resp, err := client.RestartSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Restart", resp, "Failure sending request") - } + resp, err := client.RestartSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Restart", resp, "Failure sending request") + return + } - result, err = client.RestartResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Restart", resp, "Failure responding to request") - } - - return + result, err = client.RestartResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Restart", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // RestartPreparer prepares the Restart request. -func (client VirtualMachineScaleSetVMsClient) RestartPreparer(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachineScaleSetVMsClient) RestartPreparer(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "instanceId": autorest.Encode("path", instanceID), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + "vmScaleSetName": autorest.Encode("path", VMScaleSetName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -678,13 +776,14 @@ func (client VirtualMachineScaleSetVMsClient) RestartSender(req *http.Request) ( // RestartResponder handles the response to the Restart request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetVMsClient) RestartResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetVMsClient) RestartResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -693,40 +792,54 @@ func (client VirtualMachineScaleSetVMsClient) RestartResponder(resp *http.Respon // The channel will be used to cancel polling and any outstanding HTTP // requests. // -// resourceGroupName is the name of the resource group. vmScaleSetName is the +// resourceGroupName is the name of the resource group. VMScaleSetName is the // name of the VM scale set. instanceID is the instance ID of the virtual // machine. -func (client VirtualMachineScaleSetVMsClient) Start(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.StartPreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Start", nil, "Failure preparing request") - } +func (client VirtualMachineScaleSetVMsClient) Start(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.StartPreparer(resourceGroupName, VMScaleSetName, instanceID, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Start", nil, "Failure preparing request") + return + } - resp, err := client.StartSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Start", resp, "Failure sending request") - } + resp, err := client.StartSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Start", resp, "Failure sending request") + return + } - result, err = client.StartResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Start", resp, "Failure responding to request") - } - - return + result, err = client.StartResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Start", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // StartPreparer prepares the Start request. -func (client VirtualMachineScaleSetVMsClient) StartPreparer(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { +func (client VirtualMachineScaleSetVMsClient) StartPreparer(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "instanceId": autorest.Encode("path", instanceID), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + "vmScaleSetName": autorest.Encode("path", VMScaleSetName), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -747,12 +860,13 @@ func (client VirtualMachineScaleSetVMsClient) StartSender(req *http.Request) (*h // StartResponder handles the response to the Start request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetVMsClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetVMsClient) StartResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinesizes.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinesizes.go old mode 100644 new mode 100755 index 169b79286..c76b203e7 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinesizes.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinesizes.go @@ -55,13 +55,15 @@ func (client VirtualMachineSizesClient) List(location string) (result VirtualMac req, err := client.ListPreparer(location) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineSizesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineSizesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineSizesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineSizesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -79,8 +81,9 @@ func (client VirtualMachineSizesClient) ListPreparer(location string) (*http.Req "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/client.go old mode 100644 new mode 100755 index 986e763f3..e5e99db67 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/client.go @@ -1,5 +1,5 @@ // Package containerregistry implements the Azure ARM Containerregistry service -// API version 2016-06-27-preview. +// API version 2017-03-01. // // package containerregistry @@ -27,9 +27,6 @@ import ( ) const ( - // APIVersion is the version of the Containerregistry - APIVersion = "2016-06-27-preview" - // DefaultBaseURI is the default URI used for the service Containerregistry DefaultBaseURI = "https://management.azure.com" ) @@ -38,7 +35,6 @@ const ( type ManagementClient struct { autorest.Client BaseURI string - APIVersion string SubscriptionID string } @@ -52,7 +48,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, - APIVersion: APIVersion, SubscriptionID: subscriptionID, } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/models.go old mode 100644 new mode 100755 index 9d201d73e..66edd68c5 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/models.go @@ -25,6 +25,75 @@ import ( "net/http" ) +// PasswordName enumerates the values for password name. +type PasswordName string + +const ( + // Password specifies the password state for password name. + Password PasswordName = "password" + // Password2 specifies the password 2 state for password name. + Password2 PasswordName = "password2" +) + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // Creating specifies the creating state for provisioning state. + Creating ProvisioningState = "Creating" + // Succeeded specifies the succeeded state for provisioning state. + Succeeded ProvisioningState = "Succeeded" +) + +// SkuTier enumerates the values for sku tier. +type SkuTier string + +const ( + // Basic specifies the basic state for sku tier. + Basic SkuTier = "Basic" +) + +// OperationDefinition is the definition of a container registry operation. +type OperationDefinition struct { + Name *string `json:"name,omitempty"` + Display *OperationDisplayDefinition `json:"display,omitempty"` +} + +// OperationDisplayDefinition is the display information for a container +// registry operation. +type OperationDisplayDefinition struct { + Provider *string `json:"provider,omitempty"` + Resource *string `json:"resource,omitempty"` + Operation *string `json:"operation,omitempty"` + Description *string `json:"description,omitempty"` +} + +// OperationListResult is the result of a request to list container registry +// operations. +type OperationListResult struct { + autorest.Response `json:"-"` + Value *[]OperationDefinition `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client OperationListResult) OperationListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// RegenerateCredentialParameters is the parameters used to regenerate the +// login credential. +type RegenerateCredentialParameters struct { + Name PasswordName `json:"name,omitempty"` +} + // Registry is an object that represents a container registry. type Registry struct { autorest.Response `json:"-"` @@ -33,15 +102,25 @@ type Registry struct { Type *string `json:"type,omitempty"` Location *string `json:"location,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` + Sku *Sku `json:"sku,omitempty"` *RegistryProperties `json:"properties,omitempty"` } -// RegistryCredentials is the result of a request to get the administrator -// login credentials for a container registry. -type RegistryCredentials struct { +// RegistryCreateParameters is the parameters for creating a container +// registry. +type RegistryCreateParameters struct { + Tags *map[string]*string `json:"tags,omitempty"` + Location *string `json:"location,omitempty"` + Sku *Sku `json:"sku,omitempty"` + *RegistryPropertiesCreateParameters `json:"properties,omitempty"` +} + +// RegistryListCredentialsResult is the response from the ListCredentials +// operation. +type RegistryListCredentialsResult struct { autorest.Response `json:"-"` - Username *string `json:"username,omitempty"` - Password *string `json:"password,omitempty"` + Username *string `json:"username,omitempty"` + Passwords *[]RegistryPassword `json:"passwords,omitempty"` } // RegistryListResult is the result of a request to list container registries. @@ -63,8 +142,8 @@ func (client RegistryListResult) RegistryListResultPreparer() (*http.Request, er autorest.WithBaseURL(to.String(client.NextLink))) } -// RegistryNameCheckRequest is a request to check whether the container -// registry name is available. +// RegistryNameCheckRequest is a request to check whether a container registry +// name is available. type RegistryNameCheckRequest struct { Name *string `json:"name,omitempty"` Type *string `json:"type,omitempty"` @@ -79,19 +158,33 @@ type RegistryNameStatus struct { Message *string `json:"message,omitempty"` } +// RegistryPassword is the login password for the container registry. +type RegistryPassword struct { + Name PasswordName `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} + // RegistryProperties is the properties of a container registry. type RegistryProperties struct { - LoginServer *string `json:"loginServer,omitempty"` - CreationDate *date.Time `json:"creationDate,omitempty"` + LoginServer *string `json:"loginServer,omitempty"` + CreationDate *date.Time `json:"creationDate,omitempty"` + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"` + StorageAccount *StorageAccountProperties `json:"storageAccount,omitempty"` +} + +// RegistryPropertiesCreateParameters is the parameters for creating the +// properties of a container registry. +type RegistryPropertiesCreateParameters struct { AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"` - StorageAccount *StorageAccountProperties `json:"storageAccount,omitempty"` + StorageAccount *StorageAccountParameters `json:"storageAccount,omitempty"` } // RegistryPropertiesUpdateParameters is the parameters for updating the // properties of a container registry. type RegistryPropertiesUpdateParameters struct { AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"` - StorageAccount *StorageAccountProperties `json:"storageAccount,omitempty"` + StorageAccount *StorageAccountParameters `json:"storageAccount,omitempty"` } // RegistryUpdateParameters is the parameters for updating a container @@ -110,9 +203,21 @@ type Resource struct { Tags *map[string]*string `json:"tags,omitempty"` } -// StorageAccountProperties is the properties of a storage account for a +// Sku is the SKU of a container registry. +type Sku struct { + Name *string `json:"name,omitempty"` + Tier SkuTier `json:"tier,omitempty"` +} + +// StorageAccountParameters is the parameters of a storage account for a // container registry. -type StorageAccountProperties struct { +type StorageAccountParameters struct { Name *string `json:"name,omitempty"` AccessKey *string `json:"accessKey,omitempty"` } + +// StorageAccountProperties is the properties of a storage account for a +// container registry. +type StorageAccountProperties struct { + Name *string `json:"name,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/operations.go new file mode 100755 index 000000000..a1694180c --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/operations.go @@ -0,0 +1,124 @@ +package containerregistry + +// 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OperationsClient is the client for the Operations methods of the +// Containerregistry service. +type OperationsClient struct { + ManagementClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient +// client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available Azure Container Registry REST API +// operations. +func (client OperationsClient) List() (result OperationListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer() (*http.Request, error) { + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.ContainerRegistry/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, 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 OperationsClient) ListNextResults(lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.OperationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "List", 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, "containerregistry.OperationsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/registries.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/registries.go old mode 100644 new mode 100755 index 58b16d9dc..fe03ba338 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/registries.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/registries.go @@ -51,20 +51,26 @@ func NewRegistriesClientWithBaseURI(baseURI string, subscriptionID string) Regis func (client RegistriesClient) CheckNameAvailability(registryNameCheckRequest RegistryNameCheckRequest) (result RegistryNameStatus, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: registryNameCheckRequest, - Constraints: []validation.Constraint{{Target: "registryNameCheckRequest.Name", Name: validation.Null, Rule: true, Chain: nil}, + Constraints: []validation.Constraint{{Target: "registryNameCheckRequest.Name", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "registryNameCheckRequest.Name", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryNameCheckRequest.Name", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryNameCheckRequest.Name", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}, + }}, {Target: "registryNameCheckRequest.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "CheckNameAvailability") } req, err := client.CheckNameAvailabilityPreparer(registryNameCheckRequest) if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", nil, "Failure preparing request") + return } resp, err := client.CheckNameAvailabilitySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", resp, "Failure sending request") + return } result, err = client.CheckNameAvailabilityResponder(resp) @@ -81,8 +87,9 @@ func (client RegistriesClient) CheckNameAvailabilityPreparer(registryNameCheckRe "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -114,53 +121,80 @@ func (client RegistriesClient) CheckNameAvailabilityResponder(resp *http.Respons return } -// CreateOrUpdate creates or updates a container registry with the specified -// parameters. +// Create creates a container registry with the specified parameters. This +// method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. // // resourceGroupName is the name of the resource group to which the container // registry belongs. registryName is the name of the container registry. -// registry is the parameters for creating or updating a container registry. -func (client RegistriesClient) CreateOrUpdate(resourceGroupName string, registryName string, registry Registry) (result Registry, err error) { +// registryCreateParameters is the parameters for creating a container +// registry. +func (client RegistriesClient) Create(resourceGroupName string, registryName string, registryCreateParameters RegistryCreateParameters, cancel <-chan struct{}) (<-chan Registry, <-chan error) { + resultChan := make(chan Registry, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ - {TargetValue: registry, - Constraints: []validation.Constraint{{Target: "registry.RegistryProperties", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "registry.RegistryProperties.StorageAccount", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "registry.RegistryProperties.StorageAccount.Name", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "registry.RegistryProperties.StorageAccount.AccessKey", Name: validation.Null, Rule: true, Chain: nil}, - }}, - }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "CreateOrUpdate") + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, + {TargetValue: registryCreateParameters, + Constraints: []validation.Constraint{{Target: "registryCreateParameters.Location", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "registryCreateParameters.Sku", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "registryCreateParameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "registryCreateParameters.RegistryPropertiesCreateParameters", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "registryCreateParameters.RegistryPropertiesCreateParameters.StorageAccount", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "registryCreateParameters.RegistryPropertiesCreateParameters.StorageAccount.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "registryCreateParameters.RegistryPropertiesCreateParameters.StorageAccount.AccessKey", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "Create") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, registryName, registry) - if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CreateOrUpdate", nil, "Failure preparing request") - } + go func() { + var err error + var result Registry + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(resourceGroupName, registryName, registryCreateParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Create", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Create", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan } -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client RegistriesClient) CreateOrUpdatePreparer(resourceGroupName string, registryName string, registry Registry) (*http.Request, error) { +// CreatePreparer prepares the Create request. +func (client RegistriesClient) CreatePreparer(resourceGroupName string, registryName string, registryCreateParameters RegistryCreateParameters, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "registryName": autorest.Encode("path", registryName), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -168,20 +202,22 @@ func (client RegistriesClient) CreateOrUpdatePreparer(resourceGroupName string, autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters), - autorest.WithJSON(registry), + autorest.WithJSON(registryCreateParameters), autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) + return preparer.Prepare(&http.Request{Cancel: cancel}) } -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// CreateSender sends the Create request. The method will close the // http.Response Body if it receives an error. -func (client RegistriesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) +func (client RegistriesClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) } -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// CreateResponder handles the response to the Create request. The method always // closes the http.Response Body. -func (client RegistriesClient) CreateOrUpdateResponder(resp *http.Response) (result Registry, err error) { +func (client RegistriesClient) CreateResponder(resp *http.Response) (result Registry, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -197,15 +233,25 @@ func (client RegistriesClient) CreateOrUpdateResponder(resp *http.Response) (res // resourceGroupName is the name of the resource group to which the container // registry belongs. registryName is the name of the container registry. func (client RegistriesClient) Delete(resourceGroupName string, registryName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "Delete") + } + req, err := client.DeletePreparer(resourceGroupName, registryName) if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -224,8 +270,9 @@ func (client RegistriesClient) DeletePreparer(resourceGroupName string, registry "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -254,104 +301,51 @@ func (client RegistriesClient) DeleteResponder(resp *http.Response) (result auto return } -// GetCredentials gets the administrator login credentials for the specified -// container registry. +// Get gets the properties of the specified container registry. // // resourceGroupName is the name of the resource group to which the container // registry belongs. registryName is the name of the container registry. -func (client RegistriesClient) GetCredentials(resourceGroupName string, registryName string) (result RegistryCredentials, err error) { - req, err := client.GetCredentialsPreparer(resourceGroupName, registryName) - if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetCredentials", nil, "Failure preparing request") +func (client RegistriesClient) Get(resourceGroupName string, registryName string) (result Registry, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "Get") } - resp, err := client.GetCredentialsSender(req) + req, err := client.GetPreparer(resourceGroupName, registryName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetCredentials", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", resp, "Failure sending request") + return } - result, err = client.GetCredentialsResponder(resp) + result, err = client.GetResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetCredentials", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", resp, "Failure responding to request") } return } -// GetCredentialsPreparer prepares the GetCredentials request. -func (client RegistriesClient) GetCredentialsPreparer(resourceGroupName string, registryName string) (*http.Request, error) { +// GetPreparer prepares the Get request. +func (client RegistriesClient) GetPreparer(resourceGroupName string, registryName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "registryName": autorest.Encode("path", registryName), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/getCredentials", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// GetCredentialsSender sends the GetCredentials request. The method will close the -// http.Response Body if it receives an error. -func (client RegistriesClient) GetCredentialsSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// GetCredentialsResponder handles the response to the GetCredentials request. The method always -// closes the http.Response Body. -func (client RegistriesClient) GetCredentialsResponder(resp *http.Response) (result RegistryCredentials, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetProperties gets the properties of the specified container registry. -// -// resourceGroupName is the name of the resource group to which the container -// registry belongs. registryName is the name of the container registry. -func (client RegistriesClient) GetProperties(resourceGroupName string, registryName string) (result Registry, err error) { - req, err := client.GetPropertiesPreparer(resourceGroupName, registryName) - if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetProperties", nil, "Failure preparing request") - } - - resp, err := client.GetPropertiesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetProperties", resp, "Failure sending request") - } - - result, err = client.GetPropertiesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetProperties", resp, "Failure responding to request") - } - - return -} - -// GetPropertiesPreparer prepares the GetProperties request. -func (client RegistriesClient) GetPropertiesPreparer(resourceGroupName string, registryName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "registryName": autorest.Encode("path", registryName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -362,15 +356,15 @@ func (client RegistriesClient) GetPropertiesPreparer(resourceGroupName string, r return preparer.Prepare(&http.Request{}) } -// GetPropertiesSender sends the GetProperties request. The method will close the +// GetSender sends the Get request. The method will close the // http.Response Body if it receives an error. -func (client RegistriesClient) GetPropertiesSender(req *http.Request) (*http.Response, error) { +func (client RegistriesClient) GetSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// GetPropertiesResponder handles the response to the GetProperties request. The method always +// GetResponder handles the response to the Get request. The method always // closes the http.Response Body. -func (client RegistriesClient) GetPropertiesResponder(resp *http.Response) (result Registry, err error) { +func (client RegistriesClient) GetResponder(resp *http.Response) (result Registry, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -381,18 +375,19 @@ func (client RegistriesClient) GetPropertiesResponder(resp *http.Response) (resu return } -// List lists all the available container registries under the specified -// subscription. +// List lists all the container registries under the specified subscription. func (client RegistriesClient) List() (result RegistryListResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -409,8 +404,9 @@ func (client RegistriesClient) ListPreparer() (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -464,21 +460,23 @@ func (client RegistriesClient) ListNextResults(lastResults RegistryListResult) ( return } -// ListByResourceGroup lists all the available container registries under the -// specified resource group. +// ListByResourceGroup lists all the container registries under the specified +// resource group. // // resourceGroupName is the name of the resource group to which the container // registry belongs. func (client RegistriesClient) ListByResourceGroup(resourceGroupName string) (result RegistryListResult, err error) { req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -496,8 +494,9 @@ func (client RegistriesClient) ListByResourceGroupPreparer(resourceGroupName str "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -551,60 +550,150 @@ func (client RegistriesClient) ListByResourceGroupNextResults(lastResults Regist return } -// RegenerateCredentials regenerates the administrator login credentials for -// the specified container registry. +// ListCredentials lists the login credentials for the specified container +// registry. // // resourceGroupName is the name of the resource group to which the container // registry belongs. registryName is the name of the container registry. -func (client RegistriesClient) RegenerateCredentials(resourceGroupName string, registryName string) (result RegistryCredentials, err error) { - req, err := client.RegenerateCredentialsPreparer(resourceGroupName, registryName) - if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredentials", nil, "Failure preparing request") +func (client RegistriesClient) ListCredentials(resourceGroupName string, registryName string) (result RegistryListCredentialsResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "ListCredentials") } - resp, err := client.RegenerateCredentialsSender(req) + req, err := client.ListCredentialsPreparer(resourceGroupName, registryName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", nil, "Failure preparing request") + return + } + + resp, err := client.ListCredentialsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredentials", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", resp, "Failure sending request") + return } - result, err = client.RegenerateCredentialsResponder(resp) + result, err = client.ListCredentialsResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredentials", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", resp, "Failure responding to request") } return } -// RegenerateCredentialsPreparer prepares the RegenerateCredentials request. -func (client RegistriesClient) RegenerateCredentialsPreparer(resourceGroupName string, registryName string) (*http.Request, error) { +// ListCredentialsPreparer prepares the ListCredentials request. +func (client RegistriesClient) ListCredentialsPreparer(resourceGroupName string, registryName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "registryName": autorest.Encode("path", registryName), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredentials", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{}) } -// RegenerateCredentialsSender sends the RegenerateCredentials request. The method will close the +// ListCredentialsSender sends the ListCredentials request. The method will close the // http.Response Body if it receives an error. -func (client RegistriesClient) RegenerateCredentialsSender(req *http.Request) (*http.Response, error) { +func (client RegistriesClient) ListCredentialsSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// RegenerateCredentialsResponder handles the response to the RegenerateCredentials request. The method always +// ListCredentialsResponder handles the response to the ListCredentials request. The method always // closes the http.Response Body. -func (client RegistriesClient) RegenerateCredentialsResponder(resp *http.Response) (result RegistryCredentials, err error) { +func (client RegistriesClient) ListCredentialsResponder(resp *http.Response) (result RegistryListCredentialsResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RegenerateCredential regenerates one of the login credentials for the +// specified container registry. +// +// resourceGroupName is the name of the resource group to which the container +// registry belongs. registryName is the name of the container registry. +// regenerateCredentialParameters is specifies name of the password which +// should be regenerated -- password or password2. +func (client RegistriesClient) RegenerateCredential(resourceGroupName string, registryName string, regenerateCredentialParameters RegenerateCredentialParameters) (result RegistryListCredentialsResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "RegenerateCredential") + } + + req, err := client.RegenerateCredentialPreparer(resourceGroupName, registryName, regenerateCredentialParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", nil, "Failure preparing request") + return + } + + resp, err := client.RegenerateCredentialSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", resp, "Failure sending request") + return + } + + result, err = client.RegenerateCredentialResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", resp, "Failure responding to request") + } + + return +} + +// RegenerateCredentialPreparer prepares the RegenerateCredential request. +func (client RegistriesClient) RegenerateCredentialPreparer(resourceGroupName string, registryName string, regenerateCredentialParameters RegenerateCredentialParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "registryName": autorest.Encode("path", registryName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential", pathParameters), + autorest.WithJSON(regenerateCredentialParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// RegenerateCredentialSender sends the RegenerateCredential request. The method will close the +// http.Response Body if it receives an error. +func (client RegistriesClient) RegenerateCredentialSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// RegenerateCredentialResponder handles the response to the RegenerateCredential request. The method always +// closes the http.Response Body. +func (client RegistriesClient) RegenerateCredentialResponder(resp *http.Response) (result RegistryListCredentialsResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -622,15 +711,25 @@ func (client RegistriesClient) RegenerateCredentialsResponder(resp *http.Respons // registryUpdateParameters is the parameters for updating a container // registry. func (client RegistriesClient) Update(resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters) (result Registry, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "Update") + } + req, err := client.UpdatePreparer(resourceGroupName, registryName, registryUpdateParameters) if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -649,8 +748,9 @@ func (client RegistriesClient) UpdatePreparer(resourceGroupName string, registry "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/version.go old mode 100644 new mode 100755 index 1de3b5d8e..e586a01ce --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/version.go @@ -18,43 +18,12 @@ package containerregistry // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -import ( - "bytes" - "fmt" - "strings" -) - -const ( - major = "8" - minor = "1" - patch = "0" - tag = "beta" - userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" -) - -// cached results of UserAgent and Version to prevent repeated operations. -var ( - userAgent string - version string -) - // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - if userAgent == "" { - userAgent = fmt.Sprintf(userAgentFormat, Version(), "containerregistry", "2016-06-27-preview") - } - return userAgent + return "Azure-SDK-For-Go/v10.0.2-beta arm-containerregistry/2017-03-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - if version == "" { - versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) - if tag != "" { - versionBuilder.WriteRune('-') - versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) - } - version = string(versionBuilder.Bytes()) - } - return version + return "v10.0.2-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/client.go old mode 100644 new mode 100755 index 56fa7aecd..7aefda8a8 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/client.go @@ -27,9 +27,6 @@ import ( ) const ( - // APIVersion is the version of the Containerservice - APIVersion = "2017-01-31" - // DefaultBaseURI is the default URI used for the service Containerservice DefaultBaseURI = "https://management.azure.com" ) @@ -38,7 +35,6 @@ const ( type ManagementClient struct { autorest.Client BaseURI string - APIVersion string SubscriptionID string } @@ -52,7 +48,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, - APIVersion: APIVersion, SubscriptionID: subscriptionID, } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/containerservices.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/containerservices.go old mode 100644 new mode 100755 index 772a6aeb4..6fca953c8 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/containerservices.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/containerservices.go @@ -52,7 +52,9 @@ func NewContainerServicesClientWithBaseURI(baseURI string, subscriptionID string // the name of the container service in the specified subscription and resource // group. parameters is parameters supplied to the Create or Update a Container // Service operation. -func (client ContainerServicesClient) CreateOrUpdate(resourceGroupName string, containerServiceName string, parameters ContainerService, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client ContainerServicesClient) CreateOrUpdate(resourceGroupName string, containerServiceName string, parameters ContainerService, cancel <-chan struct{}) (<-chan ContainerService, <-chan error) { + resultChan := make(chan ContainerService, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.Properties", Name: validation.Null, Rule: false, @@ -82,26 +84,40 @@ func (client ContainerServicesClient) CreateOrUpdate(resourceGroupName string, c Chain: []validation.Constraint{{Target: "parameters.Properties.DiagnosticsProfile.VMDiagnostics.Enabled", Name: validation.Null, Rule: true, Chain: nil}}}, }}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "containerservice.ContainerServicesClient", "CreateOrUpdate") + errChan <- validation.NewErrorWithValidationError(err, "containerservice.ContainerServicesClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, containerServiceName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "CreateOrUpdate", nil, "Failure preparing request") - } + go func() { + var err error + var result ContainerService + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, containerServiceName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -112,8 +128,9 @@ func (client ContainerServicesClient) CreateOrUpdatePreparer(resourceGroupName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-31" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -136,13 +153,14 @@ func (client ContainerServicesClient) CreateOrUpdateSender(req *http.Request) (* // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client ContainerServicesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ContainerServicesClient) CreateOrUpdateResponder(resp *http.Response) (result ContainerService, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -158,24 +176,37 @@ func (client ContainerServicesClient) CreateOrUpdateResponder(resp *http.Respons // resourceGroupName is the name of the resource group. containerServiceName is // the name of the container service in the specified subscription and resource // group. -func (client ContainerServicesClient) Delete(resourceGroupName string, containerServiceName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, containerServiceName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Delete", nil, "Failure preparing request") - } +func (client ContainerServicesClient) Delete(resourceGroupName string, containerServiceName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, containerServiceName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -186,8 +217,9 @@ func (client ContainerServicesClient) DeletePreparer(resourceGroupName string, c "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-31" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -229,13 +261,15 @@ func (client ContainerServicesClient) DeleteResponder(resp *http.Response) (resu func (client ContainerServicesClient) Get(resourceGroupName string, containerServiceName string) (result ContainerService, err error) { req, err := client.GetPreparer(resourceGroupName, containerServiceName) if err != nil { - return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -254,8 +288,9 @@ func (client ContainerServicesClient) GetPreparer(resourceGroupName string, cont "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-31" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -291,13 +326,15 @@ func (client ContainerServicesClient) GetResponder(resp *http.Response) (result func (client ContainerServicesClient) List() (result ListResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -314,8 +351,9 @@ func (client ContainerServicesClient) ListPreparer() (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-31" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -378,13 +416,15 @@ func (client ContainerServicesClient) ListNextResults(lastResults ListResult) (r func (client ContainerServicesClient) ListByResourceGroup(resourceGroupName string) (result ListResult, err error) { req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -402,8 +442,9 @@ func (client ContainerServicesClient) ListByResourceGroupPreparer(resourceGroupN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-31" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/models.go old mode 100644 new mode 100755 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/version.go old mode 100644 new mode 100755 index fc81f62f5..a678060b4 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/version.go @@ -18,43 +18,12 @@ package containerservice // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -import ( - "bytes" - "fmt" - "strings" -) - -const ( - major = "8" - minor = "1" - patch = "0" - tag = "beta" - userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" -) - -// cached results of UserAgent and Version to prevent repeated operations. -var ( - userAgent string - version string -) - // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - if userAgent == "" { - userAgent = fmt.Sprintf(userAgentFormat, Version(), "containerservice", "2017-01-31") - } - return userAgent + return "Azure-SDK-For-Go/v10.0.2-beta arm-containerservice/2017-01-31" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - if version == "" { - versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) - if tag != "" { - versionBuilder.WriteRune('-') - versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) - } - version = string(versionBuilder.Bytes()) - } - return version + return "v10.0.2-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/client.go old mode 100644 new mode 100755 index d64eb2287..8bab7acc1 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/client.go @@ -27,9 +27,6 @@ import ( ) const ( - // APIVersion is the version of the Disk - APIVersion = "2016-04-30-preview" - // DefaultBaseURI is the default URI used for the service Disk DefaultBaseURI = "https://management.azure.com" ) @@ -38,7 +35,6 @@ const ( type ManagementClient struct { autorest.Client BaseURI string - APIVersion string SubscriptionID string } @@ -52,7 +48,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, - APIVersion: APIVersion, SubscriptionID: subscriptionID, } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/disks.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/disks.go old mode 100644 new mode 100755 index 6fb03876f..4f7fce74f --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/disks.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/disks.go @@ -48,7 +48,9 @@ func NewDisksClientWithBaseURI(baseURI string, subscriptionID string) DisksClien // resourceGroupName is the name of the resource group. diskName is the name of // the disk within the given subscription and resource group. diskParameter is // disk object supplied in the body of the Put disk operation. -func (client DisksClient) CreateOrUpdate(resourceGroupName string, diskName string, diskParameter Model, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client DisksClient) CreateOrUpdate(resourceGroupName string, diskName string, diskParameter Model, cancel <-chan struct{}) (<-chan Model, <-chan error) { + resultChan := make(chan Model, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: diskParameter, Constraints: []validation.Constraint{{Target: "diskParameter.Properties", Name: validation.Null, Rule: false, @@ -67,26 +69,40 @@ func (client DisksClient) CreateOrUpdate(resourceGroupName string, diskName stri }}, }}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "disk.DisksClient", "CreateOrUpdate") + errChan <- validation.NewErrorWithValidationError(err, "disk.DisksClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, diskName, diskParameter, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "CreateOrUpdate", nil, "Failure preparing request") - } + go func() { + var err error + var result Model + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, diskName, diskParameter, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.DisksClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "disk.DisksClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "disk.DisksClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.DisksClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -97,8 +113,9 @@ func (client DisksClient) CreateOrUpdatePreparer(resourceGroupName string, diskN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -121,13 +138,14 @@ func (client DisksClient) CreateOrUpdateSender(req *http.Request) (*http.Respons // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client DisksClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client DisksClient) CreateOrUpdateResponder(resp *http.Response) (result Model, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -137,24 +155,37 @@ func (client DisksClient) CreateOrUpdateResponder(resp *http.Response) (result a // // resourceGroupName is the name of the resource group. diskName is the name of // the disk within the given subscription and resource group. -func (client DisksClient) Delete(resourceGroupName string, diskName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, diskName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "Delete", nil, "Failure preparing request") - } +func (client DisksClient) Delete(resourceGroupName string, diskName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, diskName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.DisksClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "disk.DisksClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "disk.DisksClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.DisksClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -165,8 +196,9 @@ func (client DisksClient) DeletePreparer(resourceGroupName string, diskName stri "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -187,13 +219,14 @@ func (client DisksClient) DeleteSender(req *http.Request) (*http.Response, error // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client DisksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { +func (client DisksClient) DeleteResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -204,13 +237,15 @@ func (client DisksClient) DeleteResponder(resp *http.Response) (result autorest. func (client DisksClient) Get(resourceGroupName string, diskName string) (result Model, err error) { req, err := client.GetPreparer(resourceGroupName, diskName) if err != nil { - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "disk.DisksClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "disk.DisksClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -229,8 +264,9 @@ func (client DisksClient) GetPreparer(resourceGroupName string, diskName string) "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -267,30 +303,46 @@ func (client DisksClient) GetResponder(resp *http.Response) (result Model, err e // resourceGroupName is the name of the resource group. diskName is the name of // the disk within the given subscription and resource group. grantAccessData // is access data object supplied in the body of the get disk access operation. -func (client DisksClient) GrantAccess(resourceGroupName string, diskName string, grantAccessData GrantAccessData, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client DisksClient) GrantAccess(resourceGroupName string, diskName string, grantAccessData GrantAccessData, cancel <-chan struct{}) (<-chan AccessURI, <-chan error) { + resultChan := make(chan AccessURI, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: grantAccessData, Constraints: []validation.Constraint{{Target: "grantAccessData.DurationInSeconds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "disk.DisksClient", "GrantAccess") + errChan <- validation.NewErrorWithValidationError(err, "disk.DisksClient", "GrantAccess") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.GrantAccessPreparer(resourceGroupName, diskName, grantAccessData, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "GrantAccess", nil, "Failure preparing request") - } + go func() { + var err error + var result AccessURI + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.GrantAccessPreparer(resourceGroupName, diskName, grantAccessData, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.DisksClient", "GrantAccess", nil, "Failure preparing request") + return + } - resp, err := client.GrantAccessSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "GrantAccess", resp, "Failure sending request") - } + resp, err := client.GrantAccessSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "disk.DisksClient", "GrantAccess", resp, "Failure sending request") + return + } - result, err = client.GrantAccessResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "disk.DisksClient", "GrantAccess", resp, "Failure responding to request") - } - - return + result, err = client.GrantAccessResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.DisksClient", "GrantAccess", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // GrantAccessPreparer prepares the GrantAccess request. @@ -301,8 +353,9 @@ func (client DisksClient) GrantAccessPreparer(resourceGroupName string, diskName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -325,13 +378,14 @@ func (client DisksClient) GrantAccessSender(req *http.Request) (*http.Response, // GrantAccessResponder handles the response to the GrantAccess request. The method always // closes the http.Response Body. -func (client DisksClient) GrantAccessResponder(resp *http.Response) (result autorest.Response, err error) { +func (client DisksClient) GrantAccessResponder(resp *http.Response) (result AccessURI, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -339,13 +393,15 @@ func (client DisksClient) GrantAccessResponder(resp *http.Response) (result auto func (client DisksClient) List() (result ListType, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "disk.DisksClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "disk.DisksClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -362,8 +418,9 @@ func (client DisksClient) ListPreparer() (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -423,13 +480,15 @@ func (client DisksClient) ListNextResults(lastResults ListType) (result ListType func (client DisksClient) ListByResourceGroup(resourceGroupName string) (result ListType, err error) { req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "disk.DisksClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "disk.DisksClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -447,8 +506,9 @@ func (client DisksClient) ListByResourceGroupPreparer(resourceGroupName string) "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -508,24 +568,37 @@ func (client DisksClient) ListByResourceGroupNextResults(lastResults ListType) ( // // resourceGroupName is the name of the resource group. diskName is the name of // the disk within the given subscription and resource group. -func (client DisksClient) RevokeAccess(resourceGroupName string, diskName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.RevokeAccessPreparer(resourceGroupName, diskName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "RevokeAccess", nil, "Failure preparing request") - } +func (client DisksClient) RevokeAccess(resourceGroupName string, diskName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.RevokeAccessPreparer(resourceGroupName, diskName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.DisksClient", "RevokeAccess", nil, "Failure preparing request") + return + } - resp, err := client.RevokeAccessSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "RevokeAccess", resp, "Failure sending request") - } + resp, err := client.RevokeAccessSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "disk.DisksClient", "RevokeAccess", resp, "Failure sending request") + return + } - result, err = client.RevokeAccessResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "disk.DisksClient", "RevokeAccess", resp, "Failure responding to request") - } - - return + result, err = client.RevokeAccessResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.DisksClient", "RevokeAccess", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // RevokeAccessPreparer prepares the RevokeAccess request. @@ -536,8 +609,9 @@ func (client DisksClient) RevokeAccessPreparer(resourceGroupName string, diskNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -558,13 +632,14 @@ func (client DisksClient) RevokeAccessSender(req *http.Request) (*http.Response, // RevokeAccessResponder handles the response to the RevokeAccess request. The method always // closes the http.Response Body. -func (client DisksClient) RevokeAccessResponder(resp *http.Response) (result autorest.Response, err error) { +func (client DisksClient) RevokeAccessResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -575,24 +650,37 @@ func (client DisksClient) RevokeAccessResponder(resp *http.Response) (result aut // resourceGroupName is the name of the resource group. diskName is the name of // the disk within the given subscription and resource group. diskParameter is // disk object supplied in the body of the Patch disk operation. -func (client DisksClient) Update(resourceGroupName string, diskName string, diskParameter UpdateType, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.UpdatePreparer(resourceGroupName, diskName, diskParameter, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "Update", nil, "Failure preparing request") - } +func (client DisksClient) Update(resourceGroupName string, diskName string, diskParameter UpdateType, cancel <-chan struct{}) (<-chan Model, <-chan error) { + resultChan := make(chan Model, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result Model + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.UpdatePreparer(resourceGroupName, diskName, diskParameter, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.DisksClient", "Update", nil, "Failure preparing request") + return + } - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "Update", resp, "Failure sending request") - } + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "disk.DisksClient", "Update", resp, "Failure sending request") + return + } - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "disk.DisksClient", "Update", resp, "Failure responding to request") - } - - return + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.DisksClient", "Update", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // UpdatePreparer prepares the Update request. @@ -603,8 +691,9 @@ func (client DisksClient) UpdatePreparer(resourceGroupName string, diskName stri "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -627,12 +716,13 @@ func (client DisksClient) UpdateSender(req *http.Request) (*http.Response, error // UpdateResponder handles the response to the Update request. The method always // closes the http.Response Body. -func (client DisksClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client DisksClient) UpdateResponder(resp *http.Response) (result Model, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/models.go old mode 100644 new mode 100755 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/snapshots.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/snapshots.go old mode 100644 new mode 100755 index 20e6ec758..f4e5579d0 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/snapshots.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/snapshots.go @@ -49,7 +49,9 @@ func NewSnapshotsClientWithBaseURI(baseURI string, subscriptionID string) Snapsh // resourceGroupName is the name of the resource group. snapshotName is the // name of the snapshot within the given subscription and resource group. // snapshot is snapshot object supplied in the body of the Put disk operation. -func (client SnapshotsClient) CreateOrUpdate(resourceGroupName string, snapshotName string, snapshot Snapshot, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client SnapshotsClient) CreateOrUpdate(resourceGroupName string, snapshotName string, snapshot Snapshot, cancel <-chan struct{}) (<-chan Snapshot, <-chan error) { + resultChan := make(chan Snapshot, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: snapshot, Constraints: []validation.Constraint{{Target: "snapshot.Properties", Name: validation.Null, Rule: false, @@ -68,26 +70,40 @@ func (client SnapshotsClient) CreateOrUpdate(resourceGroupName string, snapshotN }}, }}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "disk.SnapshotsClient", "CreateOrUpdate") + errChan <- validation.NewErrorWithValidationError(err, "disk.SnapshotsClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, snapshotName, snapshot, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "CreateOrUpdate", nil, "Failure preparing request") - } + go func() { + var err error + var result Snapshot + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, snapshotName, snapshot, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -98,8 +114,9 @@ func (client SnapshotsClient) CreateOrUpdatePreparer(resourceGroupName string, s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -122,13 +139,14 @@ func (client SnapshotsClient) CreateOrUpdateSender(req *http.Request) (*http.Res // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client SnapshotsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client SnapshotsClient) CreateOrUpdateResponder(resp *http.Response) (result Snapshot, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -138,24 +156,37 @@ func (client SnapshotsClient) CreateOrUpdateResponder(resp *http.Response) (resu // // resourceGroupName is the name of the resource group. snapshotName is the // name of the snapshot within the given subscription and resource group. -func (client SnapshotsClient) Delete(resourceGroupName string, snapshotName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, snapshotName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Delete", nil, "Failure preparing request") - } +func (client SnapshotsClient) Delete(resourceGroupName string, snapshotName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, snapshotName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -166,8 +197,9 @@ func (client SnapshotsClient) DeletePreparer(resourceGroupName string, snapshotN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -188,13 +220,14 @@ func (client SnapshotsClient) DeleteSender(req *http.Request) (*http.Response, e // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client SnapshotsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { +func (client SnapshotsClient) DeleteResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -205,13 +238,15 @@ func (client SnapshotsClient) DeleteResponder(resp *http.Response) (result autor func (client SnapshotsClient) Get(resourceGroupName string, snapshotName string) (result Snapshot, err error) { req, err := client.GetPreparer(resourceGroupName, snapshotName) if err != nil { - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -230,8 +265,9 @@ func (client SnapshotsClient) GetPreparer(resourceGroupName string, snapshotName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -270,30 +306,46 @@ func (client SnapshotsClient) GetResponder(resp *http.Response) (result Snapshot // name of the snapshot within the given subscription and resource group. // grantAccessData is access data object supplied in the body of the get // snapshot access operation. -func (client SnapshotsClient) GrantAccess(resourceGroupName string, snapshotName string, grantAccessData GrantAccessData, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client SnapshotsClient) GrantAccess(resourceGroupName string, snapshotName string, grantAccessData GrantAccessData, cancel <-chan struct{}) (<-chan AccessURI, <-chan error) { + resultChan := make(chan AccessURI, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: grantAccessData, Constraints: []validation.Constraint{{Target: "grantAccessData.DurationInSeconds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "disk.SnapshotsClient", "GrantAccess") + errChan <- validation.NewErrorWithValidationError(err, "disk.SnapshotsClient", "GrantAccess") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.GrantAccessPreparer(resourceGroupName, snapshotName, grantAccessData, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "GrantAccess", nil, "Failure preparing request") - } + go func() { + var err error + var result AccessURI + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.GrantAccessPreparer(resourceGroupName, snapshotName, grantAccessData, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "GrantAccess", nil, "Failure preparing request") + return + } - resp, err := client.GrantAccessSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "GrantAccess", resp, "Failure sending request") - } + resp, err := client.GrantAccessSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "GrantAccess", resp, "Failure sending request") + return + } - result, err = client.GrantAccessResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "GrantAccess", resp, "Failure responding to request") - } - - return + result, err = client.GrantAccessResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "GrantAccess", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // GrantAccessPreparer prepares the GrantAccess request. @@ -304,8 +356,9 @@ func (client SnapshotsClient) GrantAccessPreparer(resourceGroupName string, snap "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -328,13 +381,14 @@ func (client SnapshotsClient) GrantAccessSender(req *http.Request) (*http.Respon // GrantAccessResponder handles the response to the GrantAccess request. The method always // closes the http.Response Body. -func (client SnapshotsClient) GrantAccessResponder(resp *http.Response) (result autorest.Response, err error) { +func (client SnapshotsClient) GrantAccessResponder(resp *http.Response) (result AccessURI, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -342,13 +396,15 @@ func (client SnapshotsClient) GrantAccessResponder(resp *http.Response) (result func (client SnapshotsClient) List() (result SnapshotList, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -365,8 +421,9 @@ func (client SnapshotsClient) ListPreparer() (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -426,13 +483,15 @@ func (client SnapshotsClient) ListNextResults(lastResults SnapshotList) (result func (client SnapshotsClient) ListByResourceGroup(resourceGroupName string) (result SnapshotList, err error) { req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -450,8 +509,9 @@ func (client SnapshotsClient) ListByResourceGroupPreparer(resourceGroupName stri "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -512,24 +572,37 @@ func (client SnapshotsClient) ListByResourceGroupNextResults(lastResults Snapsho // // resourceGroupName is the name of the resource group. snapshotName is the // name of the snapshot within the given subscription and resource group. -func (client SnapshotsClient) RevokeAccess(resourceGroupName string, snapshotName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.RevokeAccessPreparer(resourceGroupName, snapshotName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "RevokeAccess", nil, "Failure preparing request") - } +func (client SnapshotsClient) RevokeAccess(resourceGroupName string, snapshotName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.RevokeAccessPreparer(resourceGroupName, snapshotName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "RevokeAccess", nil, "Failure preparing request") + return + } - resp, err := client.RevokeAccessSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "RevokeAccess", resp, "Failure sending request") - } + resp, err := client.RevokeAccessSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "RevokeAccess", resp, "Failure sending request") + return + } - result, err = client.RevokeAccessResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "RevokeAccess", resp, "Failure responding to request") - } - - return + result, err = client.RevokeAccessResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "RevokeAccess", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // RevokeAccessPreparer prepares the RevokeAccess request. @@ -540,8 +613,9 @@ func (client SnapshotsClient) RevokeAccessPreparer(resourceGroupName string, sna "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -562,13 +636,14 @@ func (client SnapshotsClient) RevokeAccessSender(req *http.Request) (*http.Respo // RevokeAccessResponder handles the response to the RevokeAccess request. The method always // closes the http.Response Body. -func (client SnapshotsClient) RevokeAccessResponder(resp *http.Response) (result autorest.Response, err error) { +func (client SnapshotsClient) RevokeAccessResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -580,24 +655,37 @@ func (client SnapshotsClient) RevokeAccessResponder(resp *http.Response) (result // name of the snapshot within the given subscription and resource group. // snapshot is snapshot object supplied in the body of the Patch snapshot // operation. -func (client SnapshotsClient) Update(resourceGroupName string, snapshotName string, snapshot SnapshotUpdate, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.UpdatePreparer(resourceGroupName, snapshotName, snapshot, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Update", nil, "Failure preparing request") - } +func (client SnapshotsClient) Update(resourceGroupName string, snapshotName string, snapshot SnapshotUpdate, cancel <-chan struct{}) (<-chan Snapshot, <-chan error) { + resultChan := make(chan Snapshot, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result Snapshot + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.UpdatePreparer(resourceGroupName, snapshotName, snapshot, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Update", nil, "Failure preparing request") + return + } - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Update", resp, "Failure sending request") - } + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Update", resp, "Failure sending request") + return + } - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Update", resp, "Failure responding to request") - } - - return + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Update", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // UpdatePreparer prepares the Update request. @@ -608,8 +696,9 @@ func (client SnapshotsClient) UpdatePreparer(resourceGroupName string, snapshotN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-30-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -632,12 +721,13 @@ func (client SnapshotsClient) UpdateSender(req *http.Request) (*http.Response, e // UpdateResponder handles the response to the Update request. The method always // closes the http.Response Body. -func (client SnapshotsClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client SnapshotsClient) UpdateResponder(resp *http.Response) (result Snapshot, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/version.go old mode 100644 new mode 100755 index 9b5497d54..a78b351a0 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/version.go @@ -18,43 +18,12 @@ package disk // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -import ( - "bytes" - "fmt" - "strings" -) - -const ( - major = "8" - minor = "1" - patch = "0" - tag = "beta" - userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" -) - -// cached results of UserAgent and Version to prevent repeated operations. -var ( - userAgent string - version string -) - // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - if userAgent == "" { - userAgent = fmt.Sprintf(userAgentFormat, Version(), "disk", "2016-04-30-preview") - } - return userAgent + return "Azure-SDK-For-Go/v10.0.2-beta arm-disk/2016-04-30-preview" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - if version == "" { - versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) - if tag != "" { - versionBuilder.WriteRune('-') - versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) - } - version = string(versionBuilder.Bytes()) - } - return version + return "v10.0.2-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/client.go old mode 100644 new mode 100755 index 5eb6b5401..204ad6729 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/client.go @@ -18,7 +18,7 @@ package eventhub // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -27,9 +27,6 @@ import ( ) const ( - // APIVersion is the version of the Eventhub - APIVersion = "2015-08-01" - // DefaultBaseURI is the default URI used for the service Eventhub DefaultBaseURI = "https://management.azure.com" ) @@ -38,7 +35,6 @@ const ( type ManagementClient struct { autorest.Client BaseURI string - APIVersion string SubscriptionID string } @@ -52,7 +48,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, - APIVersion: APIVersion, SubscriptionID: subscriptionID, } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/consumergroups.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/consumergroups.go old mode 100644 new mode 100755 index e355a354f..e9a194ba9 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/consumergroups.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/consumergroups.go @@ -14,7 +14,7 @@ package eventhub // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -43,14 +43,26 @@ func NewConsumerGroupsClientWithBaseURI(baseURI string, subscriptionID string) C } // CreateOrUpdate creates or updates an Event Hubs consumer group as a nested -// resource within a namespace. +// resource within a Namespace. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. eventHubName is the Event Hub name. consumerGroupName is -// the consumer group name. parameters is parameters supplied to create a -// consumer group resource. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name consumerGroupName is the consumer group name parameters is +// parameters supplied to create or update a consumer group resource. func (client ConsumerGroupsClient) CreateOrUpdate(resourceGroupName string, namespaceName string, eventHubName string, consumerGroupName string, parameters ConsumerGroupCreateOrUpdateParameters) (result ConsumerGroupResource, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: eventHubName, + Constraints: []validation.Constraint{{Target: "eventHubName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "eventHubName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: consumerGroupName, + Constraints: []validation.Constraint{{Target: "consumerGroupName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "consumerGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "eventhub.ConsumerGroupsClient", "CreateOrUpdate") @@ -58,13 +70,15 @@ func (client ConsumerGroupsClient) CreateOrUpdate(resourceGroupName string, name req, err := client.CreateOrUpdatePreparer(resourceGroupName, namespaceName, eventHubName, consumerGroupName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -85,8 +99,9 @@ func (client ConsumerGroupsClient) CreateOrUpdatePreparer(resourceGroupName stri "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -121,19 +136,37 @@ func (client ConsumerGroupsClient) CreateOrUpdateResponder(resp *http.Response) // Delete deletes a consumer group from the specified Event Hub and resource // group. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. eventHubName is the Event Hub name. consumerGroupName is -// the Cconsumer group name. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name consumerGroupName is the consumer group name func (client ConsumerGroupsClient) Delete(resourceGroupName string, namespaceName string, eventHubName string, consumerGroupName 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: eventHubName, + Constraints: []validation.Constraint{{Target: "eventHubName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "eventHubName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: consumerGroupName, + Constraints: []validation.Constraint{{Target: "consumerGroupName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "consumerGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.ConsumerGroupsClient", "Delete") + } + req, err := client.DeletePreparer(resourceGroupName, namespaceName, eventHubName, consumerGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -154,8 +187,9 @@ func (client ConsumerGroupsClient) DeletePreparer(resourceGroupName string, name "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -186,19 +220,37 @@ func (client ConsumerGroupsClient) DeleteResponder(resp *http.Response) (result // Get gets a description for the specified consumer group. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. eventHubName is the Event Hub name. consumerGroupName is -// the consumer group name. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name consumerGroupName is the consumer group name func (client ConsumerGroupsClient) Get(resourceGroupName string, namespaceName string, eventHubName string, consumerGroupName string) (result ConsumerGroupResource, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: eventHubName, + Constraints: []validation.Constraint{{Target: "eventHubName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "eventHubName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: consumerGroupName, + Constraints: []validation.Constraint{{Target: "consumerGroupName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "consumerGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.ConsumerGroupsClient", "Get") + } + req, err := client.GetPreparer(resourceGroupName, namespaceName, eventHubName, consumerGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -219,8 +271,9 @@ func (client ConsumerGroupsClient) GetPreparer(resourceGroupName string, namespa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -250,21 +303,37 @@ func (client ConsumerGroupsClient) GetResponder(resp *http.Response) (result Con return } -// ListAll gets all the consumer groups in a namespace. An empty feed is -// returned if no consumer group exists in the namespace. +// ListAll gets all the consumer groups in a Namespace. An empty feed is +// returned if no consumer group exists in the Namespace. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. eventHubName is the Event Hub name. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name func (client ConsumerGroupsClient) ListAll(resourceGroupName string, namespaceName string, eventHubName string) (result ConsumerGroupListResult, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: eventHubName, + Constraints: []validation.Constraint{{Target: "eventHubName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "eventHubName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.ConsumerGroupsClient", "ListAll") + } + req, err := client.ListAllPreparer(resourceGroupName, namespaceName, eventHubName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "ListAll", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "ListAll", nil, "Failure preparing request") + return } resp, err := client.ListAllSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "ListAll", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "ListAll", resp, "Failure sending request") + return } result, err = client.ListAllResponder(resp) @@ -284,8 +353,9 @@ func (client ConsumerGroupsClient) ListAllPreparer(resourceGroupName string, nam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/eventhubs.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/eventhubs.go old mode 100644 new mode 100755 index 11cd8c61d..359e0da10 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/eventhubs.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/eventhubs.go @@ -14,7 +14,7 @@ package eventhub // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -42,13 +42,22 @@ func NewEventHubsClientWithBaseURI(baseURI string, subscriptionID string) EventH } // CreateOrUpdate creates or updates a new Event Hub as a nested resource -// within a namespace. +// within a Namespace. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. eventHubName is the Event Hub name. parameters is -// parameters supplied to create an Event Hub resource. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name parameters is parameters supplied to create an Event Hub resource. func (client EventHubsClient) CreateOrUpdate(resourceGroupName string, namespaceName string, eventHubName string, parameters CreateOrUpdateParameters) (result ResourceType, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: eventHubName, + Constraints: []validation.Constraint{{Target: "eventHubName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "eventHubName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "eventhub.EventHubsClient", "CreateOrUpdate") @@ -56,13 +65,15 @@ func (client EventHubsClient) CreateOrUpdate(resourceGroupName string, namespace req, err := client.CreateOrUpdatePreparer(resourceGroupName, namespaceName, eventHubName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -82,8 +93,9 @@ func (client EventHubsClient) CreateOrUpdatePreparer(resourceGroupName string, n "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -115,15 +127,27 @@ func (client EventHubsClient) CreateOrUpdateResponder(resp *http.Response) (resu return } -// CreateOrUpdateAuthorizationRule creates or updates an authorization rule -// for the specified Event Hub. +// CreateOrUpdateAuthorizationRule creates or updates an AuthorizationRule for +// the specified Event Hub. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. eventHubName is the Event Hub name. authorizationRuleName -// is the authorization rule name. parameters is the shared access -// authorization rule. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name authorizationRuleName is the authorization rule name. parameters is +// the shared access AuthorizationRule. func (client EventHubsClient) CreateOrUpdateAuthorizationRule(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters) (result SharedAccessAuthorizationRuleResource, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: eventHubName, + Constraints: []validation.Constraint{{Target: "eventHubName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "eventHubName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.SharedAccessAuthorizationRuleProperties", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.SharedAccessAuthorizationRuleProperties.Rights", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { @@ -132,13 +156,15 @@ func (client EventHubsClient) CreateOrUpdateAuthorizationRule(resourceGroupName req, err := client.CreateOrUpdateAuthorizationRulePreparer(resourceGroupName, namespaceName, eventHubName, authorizationRuleName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateAuthorizationRuleSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "CreateOrUpdateAuthorizationRule", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "CreateOrUpdateAuthorizationRule", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateAuthorizationRuleResponder(resp) @@ -159,8 +185,9 @@ func (client EventHubsClient) CreateOrUpdateAuthorizationRulePreparer(resourceGr "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -192,20 +219,36 @@ func (client EventHubsClient) CreateOrUpdateAuthorizationRuleResponder(resp *htt return } -// Delete deletes an Event Hub from the specified namespace and resource group. +// Delete deletes an Event Hub from the specified Namespace and resource group. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. eventHubName is the name of the Event Hub to delete. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name func (client EventHubsClient) Delete(resourceGroupName string, namespaceName string, eventHubName 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: eventHubName, + Constraints: []validation.Constraint{{Target: "eventHubName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "eventHubName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.EventHubsClient", "Delete") + } + req, err := client.DeletePreparer(resourceGroupName, namespaceName, eventHubName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -225,8 +268,9 @@ func (client EventHubsClient) DeletePreparer(resourceGroupName string, namespace "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -255,21 +299,39 @@ func (client EventHubsClient) DeleteResponder(resp *http.Response) (result autor return } -// DeleteAuthorizationRule deletes an Event Hubs authorization rule. +// DeleteAuthorizationRule deletes an Event Hub AuthorizationRule. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. eventHubName is the Event Hub name. authorizationRuleName -// is the authorization rule name. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name authorizationRuleName is the authorization rule name. func (client EventHubsClient) DeleteAuthorizationRule(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: eventHubName, + Constraints: []validation.Constraint{{Target: "eventHubName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "eventHubName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.EventHubsClient", "DeleteAuthorizationRule") + } + req, err := client.DeleteAuthorizationRulePreparer(resourceGroupName, namespaceName, eventHubName, authorizationRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "DeleteAuthorizationRule", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "DeleteAuthorizationRule", nil, "Failure preparing request") + return } resp, err := client.DeleteAuthorizationRuleSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "DeleteAuthorizationRule", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "DeleteAuthorizationRule", resp, "Failure sending request") + return } result, err = client.DeleteAuthorizationRuleResponder(resp) @@ -290,8 +352,9 @@ func (client EventHubsClient) DeleteAuthorizationRulePreparer(resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -322,18 +385,34 @@ func (client EventHubsClient) DeleteAuthorizationRuleResponder(resp *http.Respon // Get gets an Event Hubs description for the specified Event Hub. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. eventHubName is the Event Hub name. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name func (client EventHubsClient) Get(resourceGroupName string, namespaceName string, eventHubName string) (result ResourceType, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: eventHubName, + Constraints: []validation.Constraint{{Target: "eventHubName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "eventHubName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.EventHubsClient", "Get") + } + req, err := client.GetPreparer(resourceGroupName, namespaceName, eventHubName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -353,8 +432,9 @@ func (client EventHubsClient) GetPreparer(resourceGroupName string, namespaceNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -384,22 +464,40 @@ func (client EventHubsClient) GetResponder(resp *http.Response) (result Resource return } -// GetAuthorizationRule gets an authorization rule for an Event Hub by rule +// GetAuthorizationRule gets an AuthorizationRule for an Event Hub by rule // name. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. eventHubName is the Event Hub name. authorizationRuleName -// is the authorization rule name. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name authorizationRuleName is the authorization rule name. func (client EventHubsClient) GetAuthorizationRule(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string) (result SharedAccessAuthorizationRuleResource, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: eventHubName, + Constraints: []validation.Constraint{{Target: "eventHubName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "eventHubName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.EventHubsClient", "GetAuthorizationRule") + } + req, err := client.GetAuthorizationRulePreparer(resourceGroupName, namespaceName, eventHubName, authorizationRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "GetAuthorizationRule", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "GetAuthorizationRule", nil, "Failure preparing request") + return } resp, err := client.GetAuthorizationRuleSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "GetAuthorizationRule", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "GetAuthorizationRule", resp, "Failure sending request") + return } result, err = client.GetAuthorizationRuleResponder(resp) @@ -420,8 +518,9 @@ func (client EventHubsClient) GetAuthorizationRulePreparer(resourceGroupName str "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -451,20 +550,32 @@ func (client EventHubsClient) GetAuthorizationRuleResponder(resp *http.Response) return } -// ListAll gets all the Event Hubs in a namespace. +// ListAll gets all the Event Hubs in a Namespace. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name func (client EventHubsClient) ListAll(resourceGroupName string, namespaceName string) (result ListResult, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.EventHubsClient", "ListAll") + } + req, err := client.ListAllPreparer(resourceGroupName, namespaceName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAll", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAll", nil, "Failure preparing request") + return } resp, err := client.ListAllSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAll", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAll", resp, "Failure sending request") + return } result, err = client.ListAllResponder(resp) @@ -483,8 +594,9 @@ func (client EventHubsClient) ListAllPreparer(resourceGroupName string, namespac "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -540,18 +652,34 @@ func (client EventHubsClient) ListAllNextResults(lastResults ListResult) (result // ListAuthorizationRules gets the authorization rules for an Event Hub. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name eventHubName is the Event Hub name. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name func (client EventHubsClient) ListAuthorizationRules(resourceGroupName string, namespaceName string, eventHubName string) (result SharedAccessAuthorizationRuleListResult, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: eventHubName, + Constraints: []validation.Constraint{{Target: "eventHubName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "eventHubName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.EventHubsClient", "ListAuthorizationRules") + } + req, err := client.ListAuthorizationRulesPreparer(resourceGroupName, namespaceName, eventHubName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAuthorizationRules", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAuthorizationRules", nil, "Failure preparing request") + return } resp, err := client.ListAuthorizationRulesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAuthorizationRules", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAuthorizationRules", resp, "Failure sending request") + return } result, err = client.ListAuthorizationRulesResponder(resp) @@ -571,8 +699,9 @@ func (client EventHubsClient) ListAuthorizationRulesPreparer(resourceGroupName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -628,20 +757,37 @@ func (client EventHubsClient) ListAuthorizationRulesNextResults(lastResults Shar // ListKeys gets the ACS and SAS connection strings for the Event Hub. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. eventHubName is the Event Hub name. authorizationRuleName -// is the connection string of the namespace for the specified authorization -// rule. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name authorizationRuleName is the authorization rule name. func (client EventHubsClient) ListKeys(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string) (result ResourceListKeys, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: eventHubName, + Constraints: []validation.Constraint{{Target: "eventHubName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "eventHubName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.EventHubsClient", "ListKeys") + } + req, err := client.ListKeysPreparer(resourceGroupName, namespaceName, eventHubName, authorizationRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListKeys", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListKeys", nil, "Failure preparing request") + return } resp, err := client.ListKeysSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListKeys", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListKeys", resp, "Failure sending request") + return } result, err = client.ListKeysResponder(resp) @@ -662,8 +808,9 @@ func (client EventHubsClient) ListKeysPreparer(resourceGroupName string, namespa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -696,21 +843,39 @@ func (client EventHubsClient) ListKeysResponder(resp *http.Response) (result Res // RegenerateKeys regenerates the ACS and SAS connection strings for the Event // Hub. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. eventHubName is the Event Hub name. authorizationRuleName -// is the connection string of the Event Hub for the specified authorization -// rule. parameters is parameters supplied to regenerate the authorization -// rule. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name authorizationRuleName is the authorization rule name. parameters is +// parameters supplied to regenerate the AuthorizationRule Keys +// (PrimaryKey/SecondaryKey). func (client EventHubsClient) RegenerateKeys(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string, parameters RegenerateKeysParameters) (result ResourceListKeys, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: eventHubName, + Constraints: []validation.Constraint{{Target: "eventHubName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "eventHubName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.EventHubsClient", "RegenerateKeys") + } + req, err := client.RegenerateKeysPreparer(resourceGroupName, namespaceName, eventHubName, authorizationRuleName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "RegenerateKeys", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "RegenerateKeys", nil, "Failure preparing request") + return } resp, err := client.RegenerateKeysSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "RegenerateKeys", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "RegenerateKeys", resp, "Failure sending request") + return } result, err = client.RegenerateKeysResponder(resp) @@ -731,8 +896,9 @@ func (client EventHubsClient) RegenerateKeysPreparer(resourceGroupName string, n "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/models.go old mode 100644 new mode 100755 index ec1c5b117..299bb5e87 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/models.go @@ -14,7 +14,7 @@ package eventhub // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -122,8 +122,6 @@ type SkuName string const ( // Basic specifies the basic state for sku name. Basic SkuName = "Basic" - // Premium specifies the premium state for sku name. - Premium SkuName = "Premium" // Standard specifies the standard state for sku name. Standard SkuName = "Standard" ) @@ -140,6 +138,42 @@ const ( SkuTierStandard SkuTier = "Standard" ) +// UnavailableReason enumerates the values for unavailable reason. +type UnavailableReason string + +const ( + // InvalidName specifies the invalid name state for unavailable reason. + InvalidName UnavailableReason = "InvalidName" + // NameInLockdown specifies the name in lockdown state for unavailable + // reason. + NameInLockdown UnavailableReason = "NameInLockdown" + // NameInUse specifies the name in use state for unavailable reason. + NameInUse UnavailableReason = "NameInUse" + // None specifies the none state for unavailable reason. + None UnavailableReason = "None" + // SubscriptionIsDisabled specifies the subscription is disabled state for + // unavailable reason. + SubscriptionIsDisabled UnavailableReason = "SubscriptionIsDisabled" + // TooManyNamespaceInCurrentSubscription specifies the too many namespace + // in current subscription state for unavailable reason. + TooManyNamespaceInCurrentSubscription UnavailableReason = "TooManyNamespaceInCurrentSubscription" +) + +// CheckNameAvailabilityParameter is parameter supplied to check Namespace name +// availability operation +type CheckNameAvailabilityParameter struct { + Name *string `json:"name,omitempty"` +} + +// CheckNameAvailabilityResult is the Result of the CheckNameAvailability +// operation +type CheckNameAvailabilityResult struct { + autorest.Response `json:"-"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason UnavailableReason `json:"reason,omitempty"` + Message *string `json:"message,omitempty"` +} + // ConsumerGroupCreateOrUpdateParameters is parameters supplied to the Create // Or Update Consumer Group operation. type ConsumerGroupCreateOrUpdateParameters struct { @@ -149,8 +183,7 @@ type ConsumerGroupCreateOrUpdateParameters struct { *ConsumerGroupProperties `json:"properties,omitempty"` } -// ConsumerGroupListResult is the response to the List Consumer Group -// operation. +// ConsumerGroupListResult is the result to the List Consumer Group operation. type ConsumerGroupListResult struct { autorest.Response `json:"-"` Value *[]ConsumerGroupResource `json:"value,omitempty"` @@ -169,7 +202,8 @@ func (client ConsumerGroupListResult) ConsumerGroupListResultPreparer() (*http.R autorest.WithBaseURL(to.String(client.NextLink))) } -// ConsumerGroupProperties is +// ConsumerGroupProperties is properties supplied to the Create Or Update +// Consumer Group operation. type ConsumerGroupProperties struct { CreatedAt *date.Time `json:"createdAt,omitempty"` EventHubPath *string `json:"eventHubPath,omitempty"` @@ -177,27 +211,26 @@ type ConsumerGroupProperties struct { UserMetadata *string `json:"userMetadata,omitempty"` } -// ConsumerGroupResource is description of the consumer group resource. +// ConsumerGroupResource is single item in List or Get Consumer group operation type ConsumerGroupResource struct { autorest.Response `json:"-"` - ID *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` - Tags *map[string]*string `json:"tags,omitempty"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Type *string `json:"type,omitempty"` *ConsumerGroupProperties `json:"properties,omitempty"` } // CreateOrUpdateParameters is parameters supplied to the Create Or Update // Event Hub operation. type CreateOrUpdateParameters struct { - Location *string `json:"location,omitempty"` - Type *string `json:"type,omitempty"` - Name *string `json:"name,omitempty"` - Properties *Properties `json:"properties,omitempty"` + Location *string `json:"location,omitempty"` + Type *string `json:"type,omitempty"` + Name *string `json:"name,omitempty"` + *Properties `json:"properties,omitempty"` } -// ListResult is the response of the List Event Hubs operation. +// ListResult is the result of the List EventHubs operation. type ListResult struct { autorest.Response `json:"-"` Value *[]ResourceType `json:"value,omitempty"` @@ -244,30 +277,73 @@ func (client NamespaceListResult) NamespaceListResultPreparer() (*http.Request, autorest.WithBaseURL(to.String(client.NextLink))) } -// NamespaceProperties is properties of the namespace. +// NamespaceProperties is properties of the Namespace supplied for create or +// update Namespace operation type NamespaceProperties struct { - ProvisioningState *string `json:"provisioningState,omitempty"` Status NamespaceState `json:"status,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` CreatedAt *date.Time `json:"createdAt,omitempty"` UpdatedAt *date.Time `json:"updatedAt,omitempty"` ServiceBusEndpoint *string `json:"serviceBusEndpoint,omitempty"` - CreateACSNamespace *bool `json:"createACSNamespace,omitempty"` + MetricID *string `json:"metricId,omitempty"` Enabled *bool `json:"enabled,omitempty"` } -// NamespaceResource is description of a namespace resource. +// NamespaceResource is single Namespace item in List or Get Operation type NamespaceResource struct { autorest.Response `json:"-"` ID *string `json:"id,omitempty"` Name *string `json:"name,omitempty"` - Type *string `json:"type,omitempty"` Location *string `json:"location,omitempty"` + Type *string `json:"type,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` Sku *Sku `json:"sku,omitempty"` *NamespaceProperties `json:"properties,omitempty"` } -// Properties is +// NamespaceUpdateParameter is parameters supplied to the Patch/update +// Namespace operation. +type NamespaceUpdateParameter struct { + Tags *map[string]*string `json:"tags,omitempty"` + Sku *Sku `json:"sku,omitempty"` +} + +// Operation is a Event Hub REST API operation +type Operation struct { + Name *string `json:"name,omitempty"` + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay is the object that represents the operation. +type OperationDisplay struct { + Provider *string `json:"provider,omitempty"` + Resource *string `json:"resource,omitempty"` + Operation *string `json:"operation,omitempty"` +} + +// OperationListResult is result of the request to list Event Hub operations. +// It contains a list of operations and a URL link to get the next set of +// results. +type OperationListResult struct { + autorest.Response `json:"-"` + Value *[]Operation `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client OperationListResult) OperationListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// Properties is properties supplied to the Create Or Update Event Hub +// operation. type Properties struct { CreatedAt *date.Time `json:"createdAt,omitempty"` MessageRetentionInDays *int64 `json:"messageRetentionInDays,omitempty"` @@ -278,18 +354,17 @@ type Properties struct { } // RegenerateKeysParameters is parameters supplied to the Regenerate -// Authorization Rule operation. +// Authorization Rule keys operation. type RegenerateKeysParameters struct { - Policykey Policykey `json:"Policykey,omitempty"` + Policykey Policykey `json:"policykey,omitempty"` } -// Resource is +// Resource is the Resource definition type Resource struct { - ID *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` - Tags *map[string]*string `json:"tags,omitempty"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Type *string `json:"type,omitempty"` } // ResourceListKeys is namespace/EventHub Connection String @@ -302,19 +377,18 @@ type ResourceListKeys struct { KeyName *string `json:"keyName,omitempty"` } -// ResourceType is description of the Event Hub resource. +// ResourceType is single item in List or Get Event Hub operation type ResourceType struct { autorest.Response `json:"-"` - ID *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` - Tags *map[string]*string `json:"tags,omitempty"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Type *string `json:"type,omitempty"` *Properties `json:"properties,omitempty"` } -// SharedAccessAuthorizationRuleCreateOrUpdateParameters is parameters -// supplied to the Create Or Update Authorization Rules operation. +// SharedAccessAuthorizationRuleCreateOrUpdateParameters is parameters supplied +// to the Create Or Update Authorization Rules operation. type SharedAccessAuthorizationRuleCreateOrUpdateParameters struct { Location *string `json:"location,omitempty"` Name *string `json:"name,omitempty"` @@ -341,27 +415,35 @@ func (client SharedAccessAuthorizationRuleListResult) SharedAccessAuthorizationR autorest.WithBaseURL(to.String(client.NextLink))) } -// SharedAccessAuthorizationRuleProperties is sharedAccessAuthorizationRule -// properties. +// SharedAccessAuthorizationRuleProperties is properties supplied to create or +// update SharedAccessAuthorizationRule type SharedAccessAuthorizationRuleProperties struct { Rights *[]AccessRights `json:"rights,omitempty"` } -// SharedAccessAuthorizationRuleResource is description of a namespace -// authorization rule. +// SharedAccessAuthorizationRuleResource is single item in a List or Get +// AuthorizationRule operation type SharedAccessAuthorizationRuleResource struct { autorest.Response `json:"-"` - ID *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` - Tags *map[string]*string `json:"tags,omitempty"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Type *string `json:"type,omitempty"` *SharedAccessAuthorizationRuleProperties `json:"properties,omitempty"` } -// Sku is sKU of the namespace. +// Sku is sKU parameters supplied to the create Namespace operation type Sku struct { Name SkuName `json:"name,omitempty"` Tier SkuTier `json:"tier,omitempty"` Capacity *int32 `json:"capacity,omitempty"` } + +// TrackedResource is definition of Resource +type TrackedResource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Type *string `json:"type,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/namespaces.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/namespaces.go old mode 100644 new mode 100755 index be52e0d89..2f1f3bcbb --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/namespaces.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/namespaces.go @@ -14,7 +14,7 @@ package eventhub // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -41,41 +41,134 @@ func NewNamespacesClientWithBaseURI(baseURI string, subscriptionID string) Names return NamespacesClient{NewWithBaseURI(baseURI, subscriptionID)} } -// CreateOrUpdate creates or updates a namespace. Once created, this -// namespace's resource manifest is immutable. This operation is idempotent. -// This method may poll for completion. Polling can be canceled by passing -// the cancel channel argument. The channel will be used to cancel polling -// and any outstanding HTTP requests. +// CheckNameAvailability check the give Namespace name availability. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. parameters is parameters for creating a namespace -// resource. -func (client NamespacesClient) CreateOrUpdate(resourceGroupName string, namespaceName string, parameters NamespaceCreateOrUpdateParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +// parameters is parameters to check availability of the given Namespace name +func (client NamespacesClient) CheckNameAvailability(parameters CheckNameAvailabilityParameter) (result CheckNameAvailabilityResult, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "CreateOrUpdate") + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "CheckNameAvailability") } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, namespaceName, parameters, cancel) + req, err := client.CheckNameAvailabilityPreparer(parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CheckNameAvailability", nil, "Failure preparing request") + return } - resp, err := client.CreateOrUpdateSender(req) + resp, err := client.CheckNameAvailabilitySender(req) if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdate", resp, "Failure sending request") + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CheckNameAvailability", resp, "Failure sending request") + return } - result, err = client.CreateOrUpdateResponder(resp) + result, err = client.CheckNameAvailabilityResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdate", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CheckNameAvailability", resp, "Failure responding to request") } return } +// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. +func (client NamespacesClient) CheckNameAvailabilityPreparer(parameters CheckNameAvailabilityParameter) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventHub/CheckNameAvailability", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client NamespacesClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always +// closes the http.Response Body. +func (client NamespacesClient) CheckNameAvailabilityResponder(resp *http.Response) (result CheckNameAvailabilityResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate creates or updates a namespace. Once created, this +// namespace's resource manifest is immutable. This operation is idempotent. +// This method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name parameters is parameters +// for creating a namespace resource. +func (client NamespacesClient) CreateOrUpdate(resourceGroupName string, namespaceName string, parameters NamespaceCreateOrUpdateParameters, cancel <-chan struct{}) (<-chan NamespaceResource, <-chan error) { + resultChan := make(chan NamespaceResource, 1) + errChan := make(chan error, 1) + 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result NamespaceResource + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, namespaceName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client NamespacesClient) CreateOrUpdatePreparer(resourceGroupName string, namespaceName string, parameters NamespaceCreateOrUpdateParameters, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ @@ -84,8 +177,9 @@ func (client NamespacesClient) CreateOrUpdatePreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -108,25 +202,35 @@ func (client NamespacesClient) CreateOrUpdateSender(req *http.Request) (*http.Re // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client NamespacesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client NamespacesClient) CreateOrUpdateResponder(resp *http.Response) (result NamespaceResource, err error) { err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } -// CreateOrUpdateAuthorizationRule creates or updates an authorization rule -// for a namespace. +// CreateOrUpdateAuthorizationRule creates or updates an AuthorizationRule for +// a Namespace. // -// resourceGroupName is the name of the resource group in which the namespace -// lives. namespaceName is the namespace name. authorizationRuleName is -// namespace authorization rule name. parameters is the shared access -// authorization rule. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name authorizationRuleName is +// the authorization rule name. parameters is the shared access +// AuthorizationRule. func (client NamespacesClient) CreateOrUpdateAuthorizationRule(resourceGroupName string, namespaceName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters) (result SharedAccessAuthorizationRuleResource, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.SharedAccessAuthorizationRuleProperties", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.SharedAccessAuthorizationRuleProperties.Rights", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { @@ -135,13 +239,15 @@ func (client NamespacesClient) CreateOrUpdateAuthorizationRule(resourceGroupName req, err := client.CreateOrUpdateAuthorizationRulePreparer(resourceGroupName, namespaceName, authorizationRuleName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateAuthorizationRuleSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdateAuthorizationRule", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdateAuthorizationRule", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateAuthorizationRuleResponder(resp) @@ -161,8 +267,9 @@ func (client NamespacesClient) CreateOrUpdateAuthorizationRulePreparer(resourceG "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -196,30 +303,56 @@ func (client NamespacesClient) CreateOrUpdateAuthorizationRuleResponder(resp *ht // Delete deletes an existing namespace. This operation also removes all // associated resources under the namespace. This method may poll for -// completion. Polling can be canceled by passing the cancel channel -// argument. The channel will be used to cancel polling and any outstanding -// HTTP requests. +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. // -// resourceGroupName is the name of the resource group in which the namespace -// lives. namespaceName is the name of the namespace to delete. -func (client NamespacesClient) Delete(resourceGroupName string, namespaceName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, namespaceName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Delete", nil, "Failure preparing request") +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name +func (client NamespacesClient) Delete(resourceGroupName string, namespaceName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Delete", resp, "Failure sending request") - } + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, namespaceName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Delete", nil, "Failure preparing request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Delete", resp, "Failure responding to request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Delete", resp, "Failure sending request") + return + } - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -230,8 +363,9 @@ func (client NamespacesClient) DeletePreparer(resourceGroupName string, namespac "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -262,21 +396,36 @@ func (client NamespacesClient) DeleteResponder(resp *http.Response) (result auto return } -// DeleteAuthorizationRule deletes an authorization rule for a namespace. +// DeleteAuthorizationRule deletes an AuthorizationRule for a Namespace. // -// resourceGroupName is the name of the resource group in which the namespace -// lives. namespaceName is the namespace name. authorizationRuleName is -// authorization rule name. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name authorizationRuleName is +// the authorization rule name. func (client NamespacesClient) DeleteAuthorizationRule(resourceGroupName string, namespaceName string, authorizationRuleName 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "DeleteAuthorizationRule") + } + req, err := client.DeleteAuthorizationRulePreparer(resourceGroupName, namespaceName, authorizationRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "DeleteAuthorizationRule", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "DeleteAuthorizationRule", nil, "Failure preparing request") + return } resp, err := client.DeleteAuthorizationRuleSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "DeleteAuthorizationRule", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "DeleteAuthorizationRule", resp, "Failure sending request") + return } result, err = client.DeleteAuthorizationRuleResponder(resp) @@ -296,8 +445,9 @@ func (client NamespacesClient) DeleteAuthorizationRulePreparer(resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -328,18 +478,30 @@ func (client NamespacesClient) DeleteAuthorizationRuleResponder(resp *http.Respo // Get gets the description of the specified namespace. // -// resourceGroupName is the name of the resource group in which the namespace -// lives. namespaceName is the name of the specified namespace. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name func (client NamespacesClient) Get(resourceGroupName string, namespaceName string) (result NamespaceResource, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "Get") + } + req, err := client.GetPreparer(resourceGroupName, namespaceName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -358,8 +520,9 @@ func (client NamespacesClient) GetPreparer(resourceGroupName string, namespaceNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -382,29 +545,43 @@ func (client NamespacesClient) GetResponder(resp *http.Response) (result Namespa err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return } -// GetAuthorizationRule gets an authorization rule for a namespace by rule -// name. +// GetAuthorizationRule gets an AuthorizationRule for a Namespace by rule name. // -// resourceGroupName is the name of the resource group in which the namespace -// lives. namespaceName is the namespace name. authorizationRuleName is -// authorization rule name. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name authorizationRuleName is +// the authorization rule name. func (client NamespacesClient) GetAuthorizationRule(resourceGroupName string, namespaceName string, authorizationRuleName string) (result SharedAccessAuthorizationRuleResource, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "GetAuthorizationRule") + } + req, err := client.GetAuthorizationRulePreparer(resourceGroupName, namespaceName, authorizationRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "GetAuthorizationRule", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "GetAuthorizationRule", nil, "Failure preparing request") + return } resp, err := client.GetAuthorizationRuleSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "GetAuthorizationRule", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "GetAuthorizationRule", resp, "Failure sending request") + return } result, err = client.GetAuthorizationRuleResponder(resp) @@ -424,8 +601,9 @@ func (client NamespacesClient) GetAuthorizationRulePreparer(resourceGroupName st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -455,20 +633,32 @@ func (client NamespacesClient) GetAuthorizationRuleResponder(resp *http.Response return } -// ListAuthorizationRules gets a list of authorization rules for a namespace. +// ListAuthorizationRules gets a list of authorization rules for a Namespace. // -// resourceGroupName is the name of the resource group in which the namespace -// lives. namespaceName is the namespace name. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name func (client NamespacesClient) ListAuthorizationRules(resourceGroupName string, namespaceName string) (result SharedAccessAuthorizationRuleListResult, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "ListAuthorizationRules") + } + req, err := client.ListAuthorizationRulesPreparer(resourceGroupName, namespaceName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListAuthorizationRules", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListAuthorizationRules", nil, "Failure preparing request") + return } resp, err := client.ListAuthorizationRulesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListAuthorizationRules", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListAuthorizationRules", resp, "Failure sending request") + return } result, err = client.ListAuthorizationRulesResponder(resp) @@ -487,8 +677,9 @@ func (client NamespacesClient) ListAuthorizationRulesPreparer(resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -542,19 +733,29 @@ func (client NamespacesClient) ListAuthorizationRulesNextResults(lastResults Sha return } -// ListByResourceGroup lists the available namespaces within a resource group. +// ListByResourceGroup lists the available Namespaces within a resource group. // -// resourceGroupName is the name of the resource group. +// resourceGroupName is name of the resource group within the azure +// subscription. func (client NamespacesClient) ListByResourceGroup(resourceGroupName string) (result NamespaceListResult, 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}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "ListByResourceGroup") + } + req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -572,8 +773,9 @@ func (client NamespacesClient) ListByResourceGroupPreparer(resourceGroupName str "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -627,18 +829,20 @@ func (client NamespacesClient) ListByResourceGroupNextResults(lastResults Namesp return } -// ListBySubscription lists all the available namespaces within a -// subscription, irrespective of the resource groups. +// ListBySubscription lists all the available Namespaces within a subscription, +// irrespective of the resource groups. func (client NamespacesClient) ListBySubscription() (result NamespaceListResult, err error) { req, err := client.ListBySubscriptionPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListBySubscription", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListBySubscription", nil, "Failure preparing request") + return } resp, err := client.ListBySubscriptionSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListBySubscription", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListBySubscription", resp, "Failure sending request") + return } result, err = client.ListBySubscriptionResponder(resp) @@ -655,8 +859,9 @@ func (client NamespacesClient) ListBySubscriptionPreparer() (*http.Request, erro "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -711,21 +916,36 @@ func (client NamespacesClient) ListBySubscriptionNextResults(lastResults Namespa } // ListKeys gets the primary and secondary connection strings for the -// namespace. +// Namespace. // -// resourceGroupName is the name of the resource group in which the namespace -// lives. namespaceName is the namespace name. authorizationRuleName is the -// authorization rule name. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name authorizationRuleName is +// the authorization rule name. func (client NamespacesClient) ListKeys(resourceGroupName string, namespaceName string, authorizationRuleName string) (result ResourceListKeys, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "ListKeys") + } + req, err := client.ListKeysPreparer(resourceGroupName, namespaceName, authorizationRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListKeys", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListKeys", nil, "Failure preparing request") + return } resp, err := client.ListKeysSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListKeys", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListKeys", resp, "Failure sending request") + return } result, err = client.ListKeysResponder(resp) @@ -745,8 +965,9 @@ func (client NamespacesClient) ListKeysPreparer(resourceGroupName string, namesp "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -777,22 +998,37 @@ func (client NamespacesClient) ListKeysResponder(resp *http.Response) (result Re } // RegenerateKeys regenerates the primary or secondary connection strings for -// the specified namespace. +// the specified Namespace. // -// resourceGroupName is the name of the resource group in which the namespace -// lives. namespaceName is the namespace name. authorizationRuleName is the -// authorization rule name. parameters is parameters required to regenerate +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name authorizationRuleName is +// the authorization rule name. parameters is parameters required to regenerate // the connection string. func (client NamespacesClient) RegenerateKeys(resourceGroupName string, namespaceName string, authorizationRuleName string, parameters RegenerateKeysParameters) (result ResourceListKeys, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "RegenerateKeys") + } + req, err := client.RegenerateKeysPreparer(resourceGroupName, namespaceName, authorizationRuleName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "RegenerateKeys", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "RegenerateKeys", nil, "Failure preparing request") + return } resp, err := client.RegenerateKeysSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "RegenerateKeys", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "RegenerateKeys", resp, "Failure sending request") + return } result, err = client.RegenerateKeysResponder(resp) @@ -812,8 +1048,9 @@ func (client NamespacesClient) RegenerateKeysPreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -844,3 +1081,83 @@ func (client NamespacesClient) RegenerateKeysResponder(resp *http.Response) (res result.Response = autorest.Response{Response: resp} return } + +// Update creates or updates a namespace. Once created, this namespace's +// resource manifest is immutable. This operation is idempotent. +// +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name parameters is parameters +// for updating a namespace resource. +func (client NamespacesClient) Update(resourceGroupName string, namespaceName string, parameters NamespaceUpdateParameter) (result NamespaceResource, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, namespaceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client NamespacesClient) UpdatePreparer(resourceGroupName string, namespaceName string, parameters NamespaceUpdateParameter) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "namespaceName": autorest.Encode("path", namespaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client NamespacesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client NamespacesClient) UpdateResponder(resp *http.Response) (result NamespaceResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusCreated, 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/arm/eventhub/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/operations.go new file mode 100755 index 000000000..c86a01619 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/operations.go @@ -0,0 +1,122 @@ +package eventhub + +// 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OperationsClient is the azure Event Hubs client +type OperationsClient struct { + ManagementClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient +// client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available Event Hub REST API operations. +func (client OperationsClient) List() (result OperationListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "eventhub.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer() (*http.Request, error) { + const APIVersion = "2015-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.EventHub/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, 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 OperationsClient) ListNextResults(lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.OperationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "eventhub.OperationsClient", "List", 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, "eventhub.OperationsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.OperationsClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/version.go old mode 100644 new mode 100755 index 780c4c754..58298d4eb --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/version.go @@ -18,43 +18,12 @@ package eventhub // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -import ( - "bytes" - "fmt" - "strings" -) - -const ( - major = "8" - minor = "1" - patch = "0" - tag = "beta" - userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" -) - -// cached results of UserAgent and Version to prevent repeated operations. -var ( - userAgent string - version string -) - // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - if userAgent == "" { - userAgent = fmt.Sprintf(userAgentFormat, Version(), "eventhub", "2015-08-01") - } - return userAgent + return "Azure-SDK-For-Go/v10.0.2-beta arm-eventhub/2015-08-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - if version == "" { - versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) - if tag != "" { - versionBuilder.WriteRune('-') - versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) - } - version = string(versionBuilder.Bytes()) - } - return version + return "v10.0.2-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/client.go old mode 100644 new mode 100755 index f6f46b867..7bca66be4 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/client.go @@ -28,9 +28,6 @@ import ( ) const ( - // APIVersion is the version of the Keyvault - APIVersion = "2015-06-01" - // DefaultBaseURI is the default URI used for the service Keyvault DefaultBaseURI = "https://management.azure.com" ) @@ -39,7 +36,6 @@ const ( type ManagementClient struct { autorest.Client BaseURI string - APIVersion string SubscriptionID string } @@ -53,7 +49,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, - APIVersion: APIVersion, SubscriptionID: subscriptionID, } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/models.go old mode 100644 new mode 100755 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/vaults.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/vaults.go old mode 100644 new mode 100755 index 8266b44ac..5b8c021ed --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/vaults.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/vaults.go @@ -64,13 +64,15 @@ func (client VaultsClient) CreateOrUpdate(resourceGroupName string, vaultName st req, err := client.CreateOrUpdatePreparer(resourceGroupName, vaultName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -89,8 +91,9 @@ func (client VaultsClient) CreateOrUpdatePreparer(resourceGroupName string, vaul "vaultName": autorest.Encode("path", vaultName), } + const APIVersion = "2015-06-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -129,13 +132,15 @@ func (client VaultsClient) CreateOrUpdateResponder(resp *http.Response) (result func (client VaultsClient) Delete(resourceGroupName string, vaultName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, vaultName) if err != nil { - return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -154,8 +159,9 @@ func (client VaultsClient) DeletePreparer(resourceGroupName string, vaultName st "vaultName": autorest.Encode("path", vaultName), } + const APIVersion = "2015-06-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -191,13 +197,15 @@ func (client VaultsClient) DeleteResponder(resp *http.Response) (result autorest func (client VaultsClient) Get(resourceGroupName string, vaultName string) (result Vault, err error) { req, err := client.GetPreparer(resourceGroupName, vaultName) if err != nil { - return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -216,8 +224,9 @@ func (client VaultsClient) GetPreparer(resourceGroupName string, vaultName strin "vaultName": autorest.Encode("path", vaultName), } + const APIVersion = "2015-06-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -255,13 +264,15 @@ func (client VaultsClient) GetResponder(resp *http.Response) (result Vault, err func (client VaultsClient) List(filter string, top *int32) (result ResourceListResult, err error) { req, err := client.ListPreparer(filter, top) if err != nil { - return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -278,9 +289,10 @@ func (client VaultsClient) ListPreparer(filter string, top *int32) (*http.Reques "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-11-01" queryParameters := map[string]interface{}{ "$filter": autorest.Encode("query", filter), - "api-version": client.APIVersion, + "api-version": APIVersion, } if top != nil { queryParameters["$top"] = autorest.Encode("query", *top) @@ -345,13 +357,15 @@ func (client VaultsClient) ListNextResults(lastResults ResourceListResult) (resu func (client VaultsClient) ListByResourceGroup(resourceGroupName string, top *int32) (result VaultListResult, err error) { req, err := client.ListByResourceGroupPreparer(resourceGroupName, top) if err != nil { - return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -369,8 +383,9 @@ func (client VaultsClient) ListByResourceGroupPreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-06-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if top != nil { queryParameters["$top"] = autorest.Encode("query", *top) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/version.go old mode 100644 new mode 100755 index c23629339..cf5e06aad --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/version.go @@ -18,43 +18,12 @@ package keyvault // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -import ( - "bytes" - "fmt" - "strings" -) - -const ( - major = "8" - minor = "1" - patch = "0" - tag = "beta" - userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" -) - -// cached results of UserAgent and Version to prevent repeated operations. -var ( - userAgent string - version string -) - // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - if userAgent == "" { - userAgent = fmt.Sprintf(userAgentFormat, Version(), "keyvault", "2015-06-01") - } - return userAgent + return "Azure-SDK-For-Go/v10.0.2-beta arm-keyvault/2015-06-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - if version == "" { - versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) - if tag != "" { - versionBuilder.WriteRune('-') - versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) - } - version = string(versionBuilder.Bytes()) - } - return version + return "v10.0.2-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/applicationgateways.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/applicationgateways.go old mode 100644 new mode 100755 index 4610ed52a..4ab4e0734 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/applicationgateways.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/applicationgateways.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -25,11 +25,7 @@ import ( "net/http" ) -// ApplicationGatewaysClient is the the Microsoft Azure Network management API -// provides a RESTful set of web services that interact with Microsoft Azure -// Networks service to manage your network resources. The API has entities -// that capture the relationship between an end user and the Microsoft Azure -// Networks service. +// ApplicationGatewaysClient is the composite Swagger for Network Client type ApplicationGatewaysClient struct { ManagementClient } @@ -48,30 +44,43 @@ func NewApplicationGatewaysClientWithBaseURI(baseURI string, subscriptionID stri // BackendHealth gets the backend health of the specified application gateway // in a resource group. This method may poll for completion. Polling can be -// canceled by passing the cancel channel argument. The channel will be used -// to cancel polling and any outstanding HTTP requests. +// canceled by passing the cancel channel argument. The channel will be used to +// cancel polling and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group. applicationGatewayName -// is the name of the application gateway. expand is expands -// BackendAddressPool and BackendHttpSettings referenced in backend health. -func (client ApplicationGatewaysClient) BackendHealth(resourceGroupName string, applicationGatewayName string, expand string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.BackendHealthPreparer(resourceGroupName, applicationGatewayName, expand, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "BackendHealth", nil, "Failure preparing request") - } +// is the name of the application gateway. expand is expands BackendAddressPool +// and BackendHttpSettings referenced in backend health. +func (client ApplicationGatewaysClient) BackendHealth(resourceGroupName string, applicationGatewayName string, expand string, cancel <-chan struct{}) (<-chan ApplicationGatewayBackendHealth, <-chan error) { + resultChan := make(chan ApplicationGatewayBackendHealth, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ApplicationGatewayBackendHealth + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.BackendHealthPreparer(resourceGroupName, applicationGatewayName, expand, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "BackendHealth", nil, "Failure preparing request") + return + } - resp, err := client.BackendHealthSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "BackendHealth", resp, "Failure sending request") - } + resp, err := client.BackendHealthSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "BackendHealth", resp, "Failure sending request") + return + } - result, err = client.BackendHealthResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "BackendHealth", resp, "Failure responding to request") - } - - return + result, err = client.BackendHealthResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "BackendHealth", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // BackendHealthPreparer prepares the BackendHealth request. @@ -82,8 +91,9 @@ func (client ApplicationGatewaysClient) BackendHealthPreparer(resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(expand) > 0 { queryParameters["$expand"] = autorest.Encode("query", expand) @@ -107,51 +117,71 @@ func (client ApplicationGatewaysClient) BackendHealthSender(req *http.Request) ( // BackendHealthResponder handles the response to the BackendHealth request. The method always // closes the http.Response Body. -func (client ApplicationGatewaysClient) BackendHealthResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ApplicationGatewaysClient) BackendHealthResponder(resp *http.Response) (result ApplicationGatewayBackendHealth, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } // CreateOrUpdate creates or updates the specified application gateway. This // method may poll for completion. Polling can be canceled by passing the -// cancel channel argument. The channel will be used to cancel polling and -// any outstanding HTTP requests. +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. // // resourceGroupName is the name of the resource group. applicationGatewayName -// is the name of the application gateway. parameters is parameters supplied -// to the create or update application gateway operation. -func (client ApplicationGatewaysClient) CreateOrUpdate(resourceGroupName string, applicationGatewayName string, parameters ApplicationGateway, cancel <-chan struct{}) (result autorest.Response, err error) { +// is the name of the application gateway. parameters is parameters supplied to +// the create or update application gateway operation. +func (client ApplicationGatewaysClient) CreateOrUpdate(resourceGroupName string, applicationGatewayName string, parameters ApplicationGateway, cancel <-chan struct{}) (<-chan ApplicationGateway, <-chan error) { + resultChan := make(chan ApplicationGateway, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.ApplicationGatewayPropertiesFormat", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.ApplicationGatewayPropertiesFormat.WebApplicationFirewallConfiguration", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.ApplicationGatewayPropertiesFormat.WebApplicationFirewallConfiguration.Enabled", Name: validation.Null, Rule: true, Chain: nil}}}, + Chain: []validation.Constraint{{Target: "parameters.ApplicationGatewayPropertiesFormat.WebApplicationFirewallConfiguration.Enabled", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ApplicationGatewayPropertiesFormat.WebApplicationFirewallConfiguration.RuleSetType", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ApplicationGatewayPropertiesFormat.WebApplicationFirewallConfiguration.RuleSetVersion", Name: validation.Null, Rule: true, Chain: nil}, + }}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "network.ApplicationGatewaysClient", "CreateOrUpdate") + errChan <- validation.NewErrorWithValidationError(err, "network.ApplicationGatewaysClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, applicationGatewayName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request") - } + go func() { + var err error + var result ApplicationGateway + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, applicationGatewayName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -162,8 +192,9 @@ func (client ApplicationGatewaysClient) CreateOrUpdatePreparer(resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -186,41 +217,55 @@ func (client ApplicationGatewaysClient) CreateOrUpdateSender(req *http.Request) // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client ApplicationGatewaysClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ApplicationGatewaysClient) CreateOrUpdateResponder(resp *http.Response) (result ApplicationGateway, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } // Delete deletes the specified application gateway. This method may poll for -// completion. Polling can be canceled by passing the cancel channel -// argument. The channel will be used to cancel polling and any outstanding -// HTTP requests. +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. // // resourceGroupName is the name of the resource group. applicationGatewayName // is the name of the application gateway. -func (client ApplicationGatewaysClient) Delete(resourceGroupName string, applicationGatewayName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, applicationGatewayName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Delete", nil, "Failure preparing request") - } +func (client ApplicationGatewaysClient) Delete(resourceGroupName string, applicationGatewayName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, applicationGatewayName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -231,8 +276,9 @@ func (client ApplicationGatewaysClient) DeletePreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -270,13 +316,15 @@ func (client ApplicationGatewaysClient) DeleteResponder(resp *http.Response) (re func (client ApplicationGatewaysClient) Get(resourceGroupName string, applicationGatewayName string) (result ApplicationGateway, err error) { req, err := client.GetPreparer(resourceGroupName, applicationGatewayName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -295,8 +343,9 @@ func (client ApplicationGatewaysClient) GetPreparer(resourceGroupName string, ap "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -332,13 +381,15 @@ func (client ApplicationGatewaysClient) GetResponder(resp *http.Response) (resul func (client ApplicationGatewaysClient) List(resourceGroupName string) (result ApplicationGatewayListResult, err error) { req, err := client.ListPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -356,8 +407,9 @@ func (client ApplicationGatewaysClient) ListPreparer(resourceGroupName string) ( "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -415,13 +467,15 @@ func (client ApplicationGatewaysClient) ListNextResults(lastResults ApplicationG func (client ApplicationGatewaysClient) ListAll() (result ApplicationGatewayListResult, err error) { req, err := client.ListAllPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "ListAll", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "ListAll", nil, "Failure preparing request") + return } resp, err := client.ListAllSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "ListAll", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "ListAll", resp, "Failure sending request") + return } result, err = client.ListAllResponder(resp) @@ -438,8 +492,9 @@ func (client ApplicationGatewaysClient) ListAllPreparer() (*http.Request, error) "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -493,33 +548,108 @@ func (client ApplicationGatewaysClient) ListAllNextResults(lastResults Applicati return } -// Start starts the specified application gateway. This method may poll for -// completion. Polling can be canceled by passing the cancel channel -// argument. The channel will be used to cancel polling and any outstanding -// HTTP requests. -// -// resourceGroupName is the name of the resource group. applicationGatewayName -// is the name of the application gateway. -func (client ApplicationGatewaysClient) Start(resourceGroupName string, applicationGatewayName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.StartPreparer(resourceGroupName, applicationGatewayName, cancel) +// ListAvailableWafRuleSets lists all available web application firewall rule +// sets. +func (client ApplicationGatewaysClient) ListAvailableWafRuleSets() (result ApplicationGatewayAvailableWafRuleSetsResult, err error) { + req, err := client.ListAvailableWafRuleSetsPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Start", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "ListAvailableWafRuleSets", nil, "Failure preparing request") + return } - resp, err := client.StartSender(req) + resp, err := client.ListAvailableWafRuleSetsSender(req) if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Start", resp, "Failure sending request") + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "ListAvailableWafRuleSets", resp, "Failure sending request") + return } - result, err = client.StartResponder(resp) + result, err = client.ListAvailableWafRuleSetsResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Start", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "ListAvailableWafRuleSets", resp, "Failure responding to request") } return } +// ListAvailableWafRuleSetsPreparer prepares the ListAvailableWafRuleSets request. +func (client ApplicationGatewaysClient) ListAvailableWafRuleSetsPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/applicationGatewayAvailableWafRuleSets", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListAvailableWafRuleSetsSender sends the ListAvailableWafRuleSets request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationGatewaysClient) ListAvailableWafRuleSetsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListAvailableWafRuleSetsResponder handles the response to the ListAvailableWafRuleSets request. The method always +// closes the http.Response Body. +func (client ApplicationGatewaysClient) ListAvailableWafRuleSetsResponder(resp *http.Response) (result ApplicationGatewayAvailableWafRuleSetsResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Start starts the specified application gateway. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// resourceGroupName is the name of the resource group. applicationGatewayName +// is the name of the application gateway. +func (client ApplicationGatewaysClient) Start(resourceGroupName string, applicationGatewayName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.StartPreparer(resourceGroupName, applicationGatewayName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Start", nil, "Failure preparing request") + return + } + + resp, err := client.StartSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Start", resp, "Failure sending request") + return + } + + result, err = client.StartResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Start", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + // StartPreparer prepares the Start request. func (client ApplicationGatewaysClient) StartPreparer(resourceGroupName string, applicationGatewayName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ @@ -528,8 +658,9 @@ func (client ApplicationGatewaysClient) StartPreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -562,29 +693,42 @@ func (client ApplicationGatewaysClient) StartResponder(resp *http.Response) (res // Stop stops the specified application gateway in a resource group. This // method may poll for completion. Polling can be canceled by passing the -// cancel channel argument. The channel will be used to cancel polling and -// any outstanding HTTP requests. +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. // // resourceGroupName is the name of the resource group. applicationGatewayName // is the name of the application gateway. -func (client ApplicationGatewaysClient) Stop(resourceGroupName string, applicationGatewayName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.StopPreparer(resourceGroupName, applicationGatewayName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Stop", nil, "Failure preparing request") - } +func (client ApplicationGatewaysClient) Stop(resourceGroupName string, applicationGatewayName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.StopPreparer(resourceGroupName, applicationGatewayName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Stop", nil, "Failure preparing request") + return + } - resp, err := client.StopSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Stop", resp, "Failure sending request") - } + resp, err := client.StopSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Stop", resp, "Failure sending request") + return + } - result, err = client.StopResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Stop", resp, "Failure responding to request") - } - - return + result, err = client.StopResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Stop", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // StopPreparer prepares the Stop request. @@ -595,8 +739,9 @@ func (client ApplicationGatewaysClient) StopPreparer(resourceGroupName string, a "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/bgpservicecommunities.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/bgpservicecommunities.go new file mode 100755 index 000000000..5024f5164 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/bgpservicecommunities.go @@ -0,0 +1,127 @@ +package network + +// 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// BgpServiceCommunitiesClient is the composite Swagger for Network Client +type BgpServiceCommunitiesClient struct { + ManagementClient +} + +// NewBgpServiceCommunitiesClient creates an instance of the +// BgpServiceCommunitiesClient client. +func NewBgpServiceCommunitiesClient(subscriptionID string) BgpServiceCommunitiesClient { + return NewBgpServiceCommunitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBgpServiceCommunitiesClientWithBaseURI creates an instance of the +// BgpServiceCommunitiesClient client. +func NewBgpServiceCommunitiesClientWithBaseURI(baseURI string, subscriptionID string) BgpServiceCommunitiesClient { + return BgpServiceCommunitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List gets all the available bgp service communities. +func (client BgpServiceCommunitiesClient) List() (result BgpServiceCommunityListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "network.BgpServiceCommunitiesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.BgpServiceCommunitiesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.BgpServiceCommunitiesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client BgpServiceCommunitiesClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/bgpServiceCommunities", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client BgpServiceCommunitiesClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client BgpServiceCommunitiesClient) ListResponder(resp *http.Response) (result BgpServiceCommunityListResult, 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 BgpServiceCommunitiesClient) ListNextResults(lastResults BgpServiceCommunityListResult) (result BgpServiceCommunityListResult, err error) { + req, err := lastResults.BgpServiceCommunityListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "network.BgpServiceCommunitiesClient", "List", 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, "network.BgpServiceCommunitiesClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.BgpServiceCommunitiesClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/client.go old mode 100644 new mode 100755 index 74e3d7e49..ec5bf7ced --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/client.go @@ -1,10 +1,6 @@ -// Package network implements the Azure ARM Network service API version -// 2016-09-01. +// Package network implements the Azure ARM Network service API version . // -// The Microsoft Azure Network management API provides a RESTful set of web -// services that interact with Microsoft Azure Networks service to manage -// your network resources. The API has entities that capture the relationship -// between an end user and the Microsoft Azure Networks service. +// Composite Swagger for Network Client package network // Copyright (c) Microsoft and contributors. All rights reserved. @@ -21,7 +17,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -32,9 +28,6 @@ import ( ) const ( - // APIVersion is the version of the Network - APIVersion = "2016-09-01" - // DefaultBaseURI is the default URI used for the service Network DefaultBaseURI = "https://management.azure.com" ) @@ -43,7 +36,6 @@ const ( type ManagementClient struct { autorest.Client BaseURI string - APIVersion string SubscriptionID string } @@ -57,7 +49,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, - APIVersion: APIVersion, SubscriptionID: subscriptionID, } } @@ -71,13 +62,15 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { func (client ManagementClient) CheckDNSNameAvailability(location string, domainNameLabel string) (result DNSNameAvailabilityResult, err error) { req, err := client.CheckDNSNameAvailabilityPreparer(location, domainNameLabel) if err != nil { - return result, autorest.NewErrorWithError(err, "network.ManagementClient", "CheckDNSNameAvailability", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.ManagementClient", "CheckDNSNameAvailability", nil, "Failure preparing request") + return } resp, err := client.CheckDNSNameAvailabilitySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.ManagementClient", "CheckDNSNameAvailability", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.ManagementClient", "CheckDNSNameAvailability", resp, "Failure sending request") + return } result, err = client.CheckDNSNameAvailabilityResponder(resp) @@ -95,8 +88,9 @@ func (client ManagementClient) CheckDNSNameAvailabilityPreparer(location string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(domainNameLabel) > 0 { queryParameters["domainNameLabel"] = autorest.Encode("query", domainNameLabel) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuitauthorizations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuitauthorizations.go old mode 100644 new mode 100755 index eb0a2a075..feb974fb9 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuitauthorizations.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuitauthorizations.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -24,11 +24,8 @@ import ( "net/http" ) -// ExpressRouteCircuitAuthorizationsClient is the the Microsoft Azure Network -// management API provides a RESTful set of web services that interact with -// Microsoft Azure Networks service to manage your network resources. The API -// has entities that capture the relationship between an end user and the -// Microsoft Azure Networks service. +// ExpressRouteCircuitAuthorizationsClient is the composite Swagger for Network +// Client type ExpressRouteCircuitAuthorizationsClient struct { ManagementClient } @@ -39,39 +36,52 @@ func NewExpressRouteCircuitAuthorizationsClient(subscriptionID string) ExpressRo return NewExpressRouteCircuitAuthorizationsClientWithBaseURI(DefaultBaseURI, subscriptionID) } -// NewExpressRouteCircuitAuthorizationsClientWithBaseURI creates an instance -// of the ExpressRouteCircuitAuthorizationsClient client. +// NewExpressRouteCircuitAuthorizationsClientWithBaseURI creates an instance of +// the ExpressRouteCircuitAuthorizationsClient client. func NewExpressRouteCircuitAuthorizationsClientWithBaseURI(baseURI string, subscriptionID string) ExpressRouteCircuitAuthorizationsClient { return ExpressRouteCircuitAuthorizationsClient{NewWithBaseURI(baseURI, subscriptionID)} } // CreateOrUpdate creates or updates an authorization in the specified express -// route circuit. This method may poll for completion. Polling can be -// canceled by passing the cancel channel argument. The channel will be used -// to cancel polling and any outstanding HTTP requests. +// route circuit. This method may poll for completion. Polling can be canceled +// by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. circuitName is the -// name of the express route circuit. authorizationName is the name of the -// authorization. authorizationParameters is parameters supplied to the -// create or update express route circuit authorization operation. -func (client ExpressRouteCircuitAuthorizationsClient) CreateOrUpdate(resourceGroupName string, circuitName string, authorizationName string, authorizationParameters ExpressRouteCircuitAuthorization, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateOrUpdatePreparer(resourceGroupName, circuitName, authorizationName, authorizationParameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "CreateOrUpdate", nil, "Failure preparing request") - } +// resourceGroupName is the name of the resource group. circuitName is the name +// of the express route circuit. authorizationName is the name of the +// authorization. authorizationParameters is parameters supplied to the create +// or update express route circuit authorization operation. +func (client ExpressRouteCircuitAuthorizationsClient) CreateOrUpdate(resourceGroupName string, circuitName string, authorizationName string, authorizationParameters ExpressRouteCircuitAuthorization, cancel <-chan struct{}) (<-chan ExpressRouteCircuitAuthorization, <-chan error) { + resultChan := make(chan ExpressRouteCircuitAuthorization, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ExpressRouteCircuitAuthorization + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, circuitName, authorizationName, authorizationParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -83,8 +93,9 @@ func (client ExpressRouteCircuitAuthorizationsClient) CreateOrUpdatePreparer(res "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -107,13 +118,14 @@ func (client ExpressRouteCircuitAuthorizationsClient) CreateOrUpdateSender(req * // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client ExpressRouteCircuitAuthorizationsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ExpressRouteCircuitAuthorizationsClient) CreateOrUpdateResponder(resp *http.Response) (result ExpressRouteCircuitAuthorization, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -122,27 +134,40 @@ func (client ExpressRouteCircuitAuthorizationsClient) CreateOrUpdateResponder(re // passing the cancel channel argument. The channel will be used to cancel // polling and any outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. circuitName is the -// name of the express route circuit. authorizationName is the name of the +// resourceGroupName is the name of the resource group. circuitName is the name +// of the express route circuit. authorizationName is the name of the // authorization. -func (client ExpressRouteCircuitAuthorizationsClient) Delete(resourceGroupName string, circuitName string, authorizationName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, circuitName, authorizationName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "Delete", nil, "Failure preparing request") - } +func (client ExpressRouteCircuitAuthorizationsClient) Delete(resourceGroupName string, circuitName string, authorizationName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, circuitName, authorizationName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -154,8 +179,9 @@ func (client ExpressRouteCircuitAuthorizationsClient) DeletePreparer(resourceGro "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -189,19 +215,21 @@ func (client ExpressRouteCircuitAuthorizationsClient) DeleteResponder(resp *http // Get gets the specified authorization from the specified express route // circuit. // -// resourceGroupName is the name of the resource group. circuitName is the -// name of the express route circuit. authorizationName is the name of the +// resourceGroupName is the name of the resource group. circuitName is the name +// of the express route circuit. authorizationName is the name of the // authorization. func (client ExpressRouteCircuitAuthorizationsClient) Get(resourceGroupName string, circuitName string, authorizationName string) (result ExpressRouteCircuitAuthorization, err error) { req, err := client.GetPreparer(resourceGroupName, circuitName, authorizationName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -221,8 +249,9 @@ func (client ExpressRouteCircuitAuthorizationsClient) GetPreparer(resourceGroupN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -254,18 +283,20 @@ func (client ExpressRouteCircuitAuthorizationsClient) GetResponder(resp *http.Re // List gets all authorizations in an express route circuit. // -// resourceGroupName is the name of the resource group. circuitName is the -// name of the circuit. +// resourceGroupName is the name of the resource group. circuitName is the name +// of the circuit. func (client ExpressRouteCircuitAuthorizationsClient) List(resourceGroupName string, circuitName string) (result AuthorizationListResult, err error) { req, err := client.ListPreparer(resourceGroupName, circuitName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -284,8 +315,9 @@ func (client ExpressRouteCircuitAuthorizationsClient) ListPreparer(resourceGroup "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuitpeerings.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuitpeerings.go old mode 100644 new mode 100755 index a459574b8..28b926f24 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuitpeerings.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuitpeerings.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -24,11 +24,8 @@ import ( "net/http" ) -// ExpressRouteCircuitPeeringsClient is the the Microsoft Azure Network -// management API provides a RESTful set of web services that interact with -// Microsoft Azure Networks service to manage your network resources. The API -// has entities that capture the relationship between an end user and the -// Microsoft Azure Networks service. +// ExpressRouteCircuitPeeringsClient is the composite Swagger for Network +// Client type ExpressRouteCircuitPeeringsClient struct { ManagementClient } @@ -50,28 +47,41 @@ func NewExpressRouteCircuitPeeringsClientWithBaseURI(baseURI string, subscriptio // passing the cancel channel argument. The channel will be used to cancel // polling and any outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. circuitName is the -// name of the express route circuit. peeringName is the name of the peering. +// resourceGroupName is the name of the resource group. circuitName is the name +// of the express route circuit. peeringName is the name of the peering. // peeringParameters is parameters supplied to the create or update express // route circuit peering operation. -func (client ExpressRouteCircuitPeeringsClient) CreateOrUpdate(resourceGroupName string, circuitName string, peeringName string, peeringParameters ExpressRouteCircuitPeering, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateOrUpdatePreparer(resourceGroupName, circuitName, peeringName, peeringParameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "CreateOrUpdate", nil, "Failure preparing request") - } +func (client ExpressRouteCircuitPeeringsClient) CreateOrUpdate(resourceGroupName string, circuitName string, peeringName string, peeringParameters ExpressRouteCircuitPeering, cancel <-chan struct{}) (<-chan ExpressRouteCircuitPeering, <-chan error) { + resultChan := make(chan ExpressRouteCircuitPeering, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ExpressRouteCircuitPeering + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, circuitName, peeringName, peeringParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -83,8 +93,9 @@ func (client ExpressRouteCircuitPeeringsClient) CreateOrUpdatePreparer(resourceG "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -107,13 +118,14 @@ func (client ExpressRouteCircuitPeeringsClient) CreateOrUpdateSender(req *http.R // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client ExpressRouteCircuitPeeringsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ExpressRouteCircuitPeeringsClient) CreateOrUpdateResponder(resp *http.Response) (result ExpressRouteCircuitPeering, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -122,26 +134,39 @@ func (client ExpressRouteCircuitPeeringsClient) CreateOrUpdateResponder(resp *ht // passing the cancel channel argument. The channel will be used to cancel // polling and any outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. circuitName is the -// name of the express route circuit. peeringName is the name of the peering. -func (client ExpressRouteCircuitPeeringsClient) Delete(resourceGroupName string, circuitName string, peeringName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, circuitName, peeringName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "Delete", nil, "Failure preparing request") - } +// resourceGroupName is the name of the resource group. circuitName is the name +// of the express route circuit. peeringName is the name of the peering. +func (client ExpressRouteCircuitPeeringsClient) Delete(resourceGroupName string, circuitName string, peeringName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, circuitName, peeringName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -153,8 +178,9 @@ func (client ExpressRouteCircuitPeeringsClient) DeletePreparer(resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -188,18 +214,20 @@ func (client ExpressRouteCircuitPeeringsClient) DeleteResponder(resp *http.Respo // Get gets the specified authorization from the specified express route // circuit. // -// resourceGroupName is the name of the resource group. circuitName is the -// name of the express route circuit. peeringName is the name of the peering. +// resourceGroupName is the name of the resource group. circuitName is the name +// of the express route circuit. peeringName is the name of the peering. func (client ExpressRouteCircuitPeeringsClient) Get(resourceGroupName string, circuitName string, peeringName string) (result ExpressRouteCircuitPeering, err error) { req, err := client.GetPreparer(resourceGroupName, circuitName, peeringName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -219,8 +247,9 @@ func (client ExpressRouteCircuitPeeringsClient) GetPreparer(resourceGroupName st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -252,18 +281,20 @@ func (client ExpressRouteCircuitPeeringsClient) GetResponder(resp *http.Response // List gets all peerings in a specified express route circuit. // -// resourceGroupName is the name of the resource group. circuitName is the -// name of the express route circuit. +// resourceGroupName is the name of the resource group. circuitName is the name +// of the express route circuit. func (client ExpressRouteCircuitPeeringsClient) List(resourceGroupName string, circuitName string) (result ExpressRouteCircuitPeeringListResult, err error) { req, err := client.ListPreparer(resourceGroupName, circuitName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -282,8 +313,9 @@ func (client ExpressRouteCircuitPeeringsClient) ListPreparer(resourceGroupName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuits.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuits.go old mode 100644 new mode 100755 index 6572e92b6..b60aa10a4 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuits.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuits.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -24,11 +24,7 @@ import ( "net/http" ) -// ExpressRouteCircuitsClient is the the Microsoft Azure Network management -// API provides a RESTful set of web services that interact with Microsoft -// Azure Networks service to manage your network resources. The API has -// entities that capture the relationship between an end user and the -// Microsoft Azure Networks service. +// ExpressRouteCircuitsClient is the composite Swagger for Network Client type ExpressRouteCircuitsClient struct { ManagementClient } @@ -50,27 +46,40 @@ func NewExpressRouteCircuitsClientWithBaseURI(baseURI string, subscriptionID str // argument. The channel will be used to cancel polling and any outstanding // HTTP requests. // -// resourceGroupName is the name of the resource group. circuitName is the -// name of the circuit. parameters is parameters supplied to the create or -// update express route circuit operation. -func (client ExpressRouteCircuitsClient) CreateOrUpdate(resourceGroupName string, circuitName string, parameters ExpressRouteCircuit, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateOrUpdatePreparer(resourceGroupName, circuitName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "CreateOrUpdate", nil, "Failure preparing request") - } +// resourceGroupName is the name of the resource group. circuitName is the name +// of the circuit. parameters is parameters supplied to the create or update +// express route circuit operation. +func (client ExpressRouteCircuitsClient) CreateOrUpdate(resourceGroupName string, circuitName string, parameters ExpressRouteCircuit, cancel <-chan struct{}) (<-chan ExpressRouteCircuit, <-chan error) { + resultChan := make(chan ExpressRouteCircuit, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ExpressRouteCircuit + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, circuitName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -81,8 +90,9 @@ func (client ExpressRouteCircuitsClient) CreateOrUpdatePreparer(resourceGroupNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -105,41 +115,55 @@ func (client ExpressRouteCircuitsClient) CreateOrUpdateSender(req *http.Request) // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client ExpressRouteCircuitsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ExpressRouteCircuitsClient) CreateOrUpdateResponder(resp *http.Response) (result ExpressRouteCircuit, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } -// Delete deletes the specified express route circuit. This method may poll -// for completion. Polling can be canceled by passing the cancel channel -// argument. The channel will be used to cancel polling and any outstanding -// HTTP requests. +// Delete deletes the specified express route circuit. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. // -// resourceGroupName is the name of the resource group. circuitName is the -// name of the express route circuit. -func (client ExpressRouteCircuitsClient) Delete(resourceGroupName string, circuitName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, circuitName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "Delete", nil, "Failure preparing request") - } +// resourceGroupName is the name of the resource group. circuitName is the name +// of the express route circuit. +func (client ExpressRouteCircuitsClient) Delete(resourceGroupName string, circuitName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, circuitName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -150,8 +174,9 @@ func (client ExpressRouteCircuitsClient) DeletePreparer(resourceGroupName string "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -184,18 +209,20 @@ func (client ExpressRouteCircuitsClient) DeleteResponder(resp *http.Response) (r // Get gets information about the specified express route circuit. // -// resourceGroupName is the name of the resource group. circuitName is the -// name of express route circuit. +// resourceGroupName is the name of the resource group. circuitName is the name +// of express route circuit. func (client ExpressRouteCircuitsClient) Get(resourceGroupName string, circuitName string) (result ExpressRouteCircuit, err error) { req, err := client.GetPreparer(resourceGroupName, circuitName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -214,8 +241,9 @@ func (client ExpressRouteCircuitsClient) GetPreparer(resourceGroupName string, c "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -248,18 +276,20 @@ func (client ExpressRouteCircuitsClient) GetResponder(resp *http.Response) (resu // GetPeeringStats gets all stats from an express route circuit in a resource // group. // -// resourceGroupName is the name of the resource group. circuitName is the -// name of the express route circuit. peeringName is the name of the peering. +// resourceGroupName is the name of the resource group. circuitName is the name +// of the express route circuit. peeringName is the name of the peering. func (client ExpressRouteCircuitsClient) GetPeeringStats(resourceGroupName string, circuitName string, peeringName string) (result ExpressRouteCircuitStats, err error) { req, err := client.GetPeeringStatsPreparer(resourceGroupName, circuitName, peeringName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "GetPeeringStats", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "GetPeeringStats", nil, "Failure preparing request") + return } resp, err := client.GetPeeringStatsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "GetPeeringStats", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "GetPeeringStats", resp, "Failure sending request") + return } result, err = client.GetPeeringStatsResponder(resp) @@ -279,8 +309,9 @@ func (client ExpressRouteCircuitsClient) GetPeeringStatsPreparer(resourceGroupNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -313,18 +344,20 @@ func (client ExpressRouteCircuitsClient) GetPeeringStatsResponder(resp *http.Res // GetStats gets all the stats from an express route circuit in a resource // group. // -// resourceGroupName is the name of the resource group. circuitName is the -// name of the express route circuit. +// resourceGroupName is the name of the resource group. circuitName is the name +// of the express route circuit. func (client ExpressRouteCircuitsClient) GetStats(resourceGroupName string, circuitName string) (result ExpressRouteCircuitStats, err error) { req, err := client.GetStatsPreparer(resourceGroupName, circuitName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "GetStats", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "GetStats", nil, "Failure preparing request") + return } resp, err := client.GetStatsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "GetStats", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "GetStats", resp, "Failure sending request") + return } result, err = client.GetStatsResponder(resp) @@ -343,8 +376,9 @@ func (client ExpressRouteCircuitsClient) GetStatsPreparer(resourceGroupName stri "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -380,13 +414,15 @@ func (client ExpressRouteCircuitsClient) GetStatsResponder(resp *http.Response) func (client ExpressRouteCircuitsClient) List(resourceGroupName string) (result ExpressRouteCircuitListResult, err error) { req, err := client.ListPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -404,8 +440,9 @@ func (client ExpressRouteCircuitsClient) ListPreparer(resourceGroupName string) "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -463,13 +500,15 @@ func (client ExpressRouteCircuitsClient) ListNextResults(lastResults ExpressRout func (client ExpressRouteCircuitsClient) ListAll() (result ExpressRouteCircuitListResult, err error) { req, err := client.ListAllPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListAll", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListAll", nil, "Failure preparing request") + return } resp, err := client.ListAllSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListAll", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListAll", resp, "Failure sending request") + return } result, err = client.ListAllResponder(resp) @@ -486,8 +525,9 @@ func (client ExpressRouteCircuitsClient) ListAllPreparer() (*http.Request, error "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -543,31 +583,44 @@ func (client ExpressRouteCircuitsClient) ListAllNextResults(lastResults ExpressR // ListArpTable gets the currently advertised ARP table associated with the // express route circuit in a resource group. This method may poll for -// completion. Polling can be canceled by passing the cancel channel -// argument. The channel will be used to cancel polling and any outstanding -// HTTP requests. +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. // -// resourceGroupName is the name of the resource group. circuitName is the -// name of the express route circuit. peeringName is the name of the peering. +// resourceGroupName is the name of the resource group. circuitName is the name +// of the express route circuit. peeringName is the name of the peering. // devicePath is the path of the device. -func (client ExpressRouteCircuitsClient) ListArpTable(resourceGroupName string, circuitName string, peeringName string, devicePath string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.ListArpTablePreparer(resourceGroupName, circuitName, peeringName, devicePath, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListArpTable", nil, "Failure preparing request") - } +func (client ExpressRouteCircuitsClient) ListArpTable(resourceGroupName string, circuitName string, peeringName string, devicePath string, cancel <-chan struct{}) (<-chan ExpressRouteCircuitsArpTableListResult, <-chan error) { + resultChan := make(chan ExpressRouteCircuitsArpTableListResult, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ExpressRouteCircuitsArpTableListResult + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ListArpTablePreparer(resourceGroupName, circuitName, peeringName, devicePath, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListArpTable", nil, "Failure preparing request") + return + } - resp, err := client.ListArpTableSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListArpTable", resp, "Failure sending request") - } + resp, err := client.ListArpTableSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListArpTable", resp, "Failure sending request") + return + } - result, err = client.ListArpTableResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListArpTable", resp, "Failure responding to request") - } - - return + result, err = client.ListArpTableResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListArpTable", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // ListArpTablePreparer prepares the ListArpTable request. @@ -580,8 +633,9 @@ func (client ExpressRouteCircuitsClient) ListArpTablePreparer(resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -602,43 +656,57 @@ func (client ExpressRouteCircuitsClient) ListArpTableSender(req *http.Request) ( // ListArpTableResponder handles the response to the ListArpTable request. The method always // closes the http.Response Body. -func (client ExpressRouteCircuitsClient) ListArpTableResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ExpressRouteCircuitsClient) ListArpTableResponder(resp *http.Response) (result ExpressRouteCircuitsArpTableListResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } // ListRoutesTable gets the currently advertised routes table associated with // the express route circuit in a resource group. This method may poll for -// completion. Polling can be canceled by passing the cancel channel -// argument. The channel will be used to cancel polling and any outstanding -// HTTP requests. +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. // -// resourceGroupName is the name of the resource group. circuitName is the -// name of the express route circuit. peeringName is the name of the peering. +// resourceGroupName is the name of the resource group. circuitName is the name +// of the express route circuit. peeringName is the name of the peering. // devicePath is the path of the device. -func (client ExpressRouteCircuitsClient) ListRoutesTable(resourceGroupName string, circuitName string, peeringName string, devicePath string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.ListRoutesTablePreparer(resourceGroupName, circuitName, peeringName, devicePath, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTable", nil, "Failure preparing request") - } +func (client ExpressRouteCircuitsClient) ListRoutesTable(resourceGroupName string, circuitName string, peeringName string, devicePath string, cancel <-chan struct{}) (<-chan ExpressRouteCircuitsRoutesTableListResult, <-chan error) { + resultChan := make(chan ExpressRouteCircuitsRoutesTableListResult, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ExpressRouteCircuitsRoutesTableListResult + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ListRoutesTablePreparer(resourceGroupName, circuitName, peeringName, devicePath, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTable", nil, "Failure preparing request") + return + } - resp, err := client.ListRoutesTableSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTable", resp, "Failure sending request") - } + resp, err := client.ListRoutesTableSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTable", resp, "Failure sending request") + return + } - result, err = client.ListRoutesTableResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTable", resp, "Failure responding to request") - } - - return + result, err = client.ListRoutesTableResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTable", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // ListRoutesTablePreparer prepares the ListRoutesTable request. @@ -651,8 +719,9 @@ func (client ExpressRouteCircuitsClient) ListRoutesTablePreparer(resourceGroupNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -673,13 +742,14 @@ func (client ExpressRouteCircuitsClient) ListRoutesTableSender(req *http.Request // ListRoutesTableResponder handles the response to the ListRoutesTable request. The method always // closes the http.Response Body. -func (client ExpressRouteCircuitsClient) ListRoutesTableResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ExpressRouteCircuitsClient) ListRoutesTableResponder(resp *http.Response) (result ExpressRouteCircuitsRoutesTableListResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -689,27 +759,40 @@ func (client ExpressRouteCircuitsClient) ListRoutesTableResponder(resp *http.Res // channel argument. The channel will be used to cancel polling and any // outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. circuitName is the -// name of the express route circuit. peeringName is the name of the peering. +// resourceGroupName is the name of the resource group. circuitName is the name +// of the express route circuit. peeringName is the name of the peering. // devicePath is the path of the device. -func (client ExpressRouteCircuitsClient) ListRoutesTableSummary(resourceGroupName string, circuitName string, peeringName string, devicePath string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.ListRoutesTableSummaryPreparer(resourceGroupName, circuitName, peeringName, devicePath, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTableSummary", nil, "Failure preparing request") - } +func (client ExpressRouteCircuitsClient) ListRoutesTableSummary(resourceGroupName string, circuitName string, peeringName string, devicePath string, cancel <-chan struct{}) (<-chan ExpressRouteCircuitsRoutesTableSummaryListResult, <-chan error) { + resultChan := make(chan ExpressRouteCircuitsRoutesTableSummaryListResult, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ExpressRouteCircuitsRoutesTableSummaryListResult + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ListRoutesTableSummaryPreparer(resourceGroupName, circuitName, peeringName, devicePath, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTableSummary", nil, "Failure preparing request") + return + } - resp, err := client.ListRoutesTableSummarySender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTableSummary", resp, "Failure sending request") - } + resp, err := client.ListRoutesTableSummarySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTableSummary", resp, "Failure sending request") + return + } - result, err = client.ListRoutesTableSummaryResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTableSummary", resp, "Failure responding to request") - } - - return + result, err = client.ListRoutesTableSummaryResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTableSummary", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // ListRoutesTableSummaryPreparer prepares the ListRoutesTableSummary request. @@ -722,8 +805,9 @@ func (client ExpressRouteCircuitsClient) ListRoutesTableSummaryPreparer(resource "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -744,12 +828,13 @@ func (client ExpressRouteCircuitsClient) ListRoutesTableSummarySender(req *http. // ListRoutesTableSummaryResponder handles the response to the ListRoutesTableSummary request. The method always // closes the http.Response Body. -func (client ExpressRouteCircuitsClient) ListRoutesTableSummaryResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ExpressRouteCircuitsClient) ListRoutesTableSummaryResponder(resp *http.Response) (result ExpressRouteCircuitsRoutesTableSummaryListResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressrouteserviceproviders.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressrouteserviceproviders.go old mode 100644 new mode 100755 index 9d0450ecf..94db9a4f6 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressrouteserviceproviders.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressrouteserviceproviders.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -24,11 +24,8 @@ import ( "net/http" ) -// ExpressRouteServiceProvidersClient is the the Microsoft Azure Network -// management API provides a RESTful set of web services that interact with -// Microsoft Azure Networks service to manage your network resources. The API -// has entities that capture the relationship between an end user and the -// Microsoft Azure Networks service. +// ExpressRouteServiceProvidersClient is the composite Swagger for Network +// Client type ExpressRouteServiceProvidersClient struct { ManagementClient } @@ -49,13 +46,15 @@ func NewExpressRouteServiceProvidersClientWithBaseURI(baseURI string, subscripti func (client ExpressRouteServiceProvidersClient) List() (result ExpressRouteServiceProviderListResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteServiceProvidersClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.ExpressRouteServiceProvidersClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.ExpressRouteServiceProvidersClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.ExpressRouteServiceProvidersClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -72,8 +71,9 @@ func (client ExpressRouteServiceProvidersClient) ListPreparer() (*http.Request, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/interfaces.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/interfaces.go old mode 100644 new mode 100755 index 90f0b8e4e..8918c08b4 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/interfaces.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/interfaces.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -24,11 +24,7 @@ import ( "net/http" ) -// InterfacesClient is the the Microsoft Azure Network management API provides -// a RESTful set of web services that interact with Microsoft Azure Networks -// service to manage your network resources. The API has entities that -// capture the relationship between an end user and the Microsoft Azure -// Networks service. +// InterfacesClient is the composite Swagger for Network Client type InterfacesClient struct { ManagementClient } @@ -49,27 +45,40 @@ func NewInterfacesClientWithBaseURI(baseURI string, subscriptionID string) Inter // argument. The channel will be used to cancel polling and any outstanding // HTTP requests. // -// resourceGroupName is the name of the resource group. networkInterfaceName -// is the name of the network interface. parameters is parameters supplied to -// the create or update network interface operation. -func (client InterfacesClient) CreateOrUpdate(resourceGroupName string, networkInterfaceName string, parameters Interface, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateOrUpdatePreparer(resourceGroupName, networkInterfaceName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "CreateOrUpdate", nil, "Failure preparing request") - } +// resourceGroupName is the name of the resource group. networkInterfaceName is +// the name of the network interface. parameters is parameters supplied to the +// create or update network interface operation. +func (client InterfacesClient) CreateOrUpdate(resourceGroupName string, networkInterfaceName string, parameters Interface, cancel <-chan struct{}) (<-chan Interface, <-chan error) { + resultChan := make(chan Interface, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result Interface + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, networkInterfaceName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.InterfacesClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -80,8 +89,9 @@ func (client InterfacesClient) CreateOrUpdatePreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -104,41 +114,55 @@ func (client InterfacesClient) CreateOrUpdateSender(req *http.Request) (*http.Re // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client InterfacesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client InterfacesClient) CreateOrUpdateResponder(resp *http.Response) (result Interface, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } // Delete deletes the specified network interface. This method may poll for -// completion. Polling can be canceled by passing the cancel channel -// argument. The channel will be used to cancel polling and any outstanding -// HTTP requests. +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. // -// resourceGroupName is the name of the resource group. networkInterfaceName -// is the name of the network interface. -func (client InterfacesClient) Delete(resourceGroupName string, networkInterfaceName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, networkInterfaceName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "Delete", nil, "Failure preparing request") - } +// resourceGroupName is the name of the resource group. networkInterfaceName is +// the name of the network interface. +func (client InterfacesClient) Delete(resourceGroupName string, networkInterfaceName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, networkInterfaceName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.InterfacesClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -149,8 +173,9 @@ func (client InterfacesClient) DeletePreparer(resourceGroupName string, networkI "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -183,19 +208,20 @@ func (client InterfacesClient) DeleteResponder(resp *http.Response) (result auto // Get gets information about the specified network interface. // -// resourceGroupName is the name of the resource group. networkInterfaceName -// is the name of the network interface. expand is expands referenced -// resources. +// resourceGroupName is the name of the resource group. networkInterfaceName is +// the name of the network interface. expand is expands referenced resources. func (client InterfacesClient) Get(resourceGroupName string, networkInterfaceName string, expand string) (result Interface, err error) { req, err := client.GetPreparer(resourceGroupName, networkInterfaceName, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -214,8 +240,9 @@ func (client InterfacesClient) GetPreparer(resourceGroupName string, networkInte "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(expand) > 0 { queryParameters["$expand"] = autorest.Encode("query", expand) @@ -248,31 +275,44 @@ func (client InterfacesClient) GetResponder(resp *http.Response) (result Interfa return } -// GetEffectiveRouteTable gets all route tables applied to a network -// interface. This method may poll for completion. Polling can be canceled by -// passing the cancel channel argument. The channel will be used to cancel -// polling and any outstanding HTTP requests. +// GetEffectiveRouteTable gets all route tables applied to a network interface. +// This method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. networkInterfaceName -// is the name of the network interface. -func (client InterfacesClient) GetEffectiveRouteTable(resourceGroupName string, networkInterfaceName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.GetEffectiveRouteTablePreparer(resourceGroupName, networkInterfaceName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "GetEffectiveRouteTable", nil, "Failure preparing request") - } +// resourceGroupName is the name of the resource group. networkInterfaceName is +// the name of the network interface. +func (client InterfacesClient) GetEffectiveRouteTable(resourceGroupName string, networkInterfaceName string, cancel <-chan struct{}) (<-chan EffectiveRouteListResult, <-chan error) { + resultChan := make(chan EffectiveRouteListResult, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result EffectiveRouteListResult + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.GetEffectiveRouteTablePreparer(resourceGroupName, networkInterfaceName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "GetEffectiveRouteTable", nil, "Failure preparing request") + return + } - resp, err := client.GetEffectiveRouteTableSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "GetEffectiveRouteTable", resp, "Failure sending request") - } + resp, err := client.GetEffectiveRouteTableSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "GetEffectiveRouteTable", resp, "Failure sending request") + return + } - result, err = client.GetEffectiveRouteTableResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.InterfacesClient", "GetEffectiveRouteTable", resp, "Failure responding to request") - } - - return + result, err = client.GetEffectiveRouteTableResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "GetEffectiveRouteTable", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // GetEffectiveRouteTablePreparer prepares the GetEffectiveRouteTable request. @@ -283,8 +323,9 @@ func (client InterfacesClient) GetEffectiveRouteTablePreparer(resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -305,13 +346,14 @@ func (client InterfacesClient) GetEffectiveRouteTableSender(req *http.Request) ( // GetEffectiveRouteTableResponder handles the response to the GetEffectiveRouteTable request. The method always // closes the http.Response Body. -func (client InterfacesClient) GetEffectiveRouteTableResponder(resp *http.Response) (result autorest.Response, err error) { +func (client InterfacesClient) GetEffectiveRouteTableResponder(resp *http.Response) (result EffectiveRouteListResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -325,13 +367,15 @@ func (client InterfacesClient) GetEffectiveRouteTableResponder(resp *http.Respon func (client InterfacesClient) GetVirtualMachineScaleSetNetworkInterface(resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string, networkInterfaceName string, expand string) (result Interface, err error) { req, err := client.GetVirtualMachineScaleSetNetworkInterfacePreparer(resourceGroupName, virtualMachineScaleSetName, virtualmachineIndex, networkInterfaceName, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "GetVirtualMachineScaleSetNetworkInterface", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "GetVirtualMachineScaleSetNetworkInterface", nil, "Failure preparing request") + return } resp, err := client.GetVirtualMachineScaleSetNetworkInterfaceSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "GetVirtualMachineScaleSetNetworkInterface", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "GetVirtualMachineScaleSetNetworkInterface", resp, "Failure sending request") + return } result, err = client.GetVirtualMachineScaleSetNetworkInterfaceResponder(resp) @@ -352,8 +396,9 @@ func (client InterfacesClient) GetVirtualMachineScaleSetNetworkInterfacePreparer "virtualMachineScaleSetName": autorest.Encode("path", virtualMachineScaleSetName), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(expand) > 0 { queryParameters["$expand"] = autorest.Encode("query", expand) @@ -392,13 +437,15 @@ func (client InterfacesClient) GetVirtualMachineScaleSetNetworkInterfaceResponde func (client InterfacesClient) List(resourceGroupName string) (result InterfaceListResult, err error) { req, err := client.ListPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -416,8 +463,9 @@ func (client InterfacesClient) ListPreparer(resourceGroupName string) (*http.Req "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -475,13 +523,15 @@ func (client InterfacesClient) ListNextResults(lastResults InterfaceListResult) func (client InterfacesClient) ListAll() (result InterfaceListResult, err error) { req, err := client.ListAllPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "ListAll", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "ListAll", nil, "Failure preparing request") + return } resp, err := client.ListAllSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "ListAll", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "ListAll", resp, "Failure sending request") + return } result, err = client.ListAllResponder(resp) @@ -498,8 +548,9 @@ func (client InterfacesClient) ListAllPreparer() (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -554,30 +605,43 @@ func (client InterfacesClient) ListAllNextResults(lastResults InterfaceListResul } // ListEffectiveNetworkSecurityGroups gets all network security groups applied -// to a network interface. This method may poll for completion. Polling can -// be canceled by passing the cancel channel argument. The channel will be -// used to cancel polling and any outstanding HTTP requests. +// to a network interface. This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to +// cancel polling and any outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. networkInterfaceName -// is the name of the network interface. -func (client InterfacesClient) ListEffectiveNetworkSecurityGroups(resourceGroupName string, networkInterfaceName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.ListEffectiveNetworkSecurityGroupsPreparer(resourceGroupName, networkInterfaceName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "ListEffectiveNetworkSecurityGroups", nil, "Failure preparing request") - } +// resourceGroupName is the name of the resource group. networkInterfaceName is +// the name of the network interface. +func (client InterfacesClient) ListEffectiveNetworkSecurityGroups(resourceGroupName string, networkInterfaceName string, cancel <-chan struct{}) (<-chan EffectiveNetworkSecurityGroupListResult, <-chan error) { + resultChan := make(chan EffectiveNetworkSecurityGroupListResult, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result EffectiveNetworkSecurityGroupListResult + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ListEffectiveNetworkSecurityGroupsPreparer(resourceGroupName, networkInterfaceName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "ListEffectiveNetworkSecurityGroups", nil, "Failure preparing request") + return + } - resp, err := client.ListEffectiveNetworkSecurityGroupsSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "ListEffectiveNetworkSecurityGroups", resp, "Failure sending request") - } + resp, err := client.ListEffectiveNetworkSecurityGroupsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "ListEffectiveNetworkSecurityGroups", resp, "Failure sending request") + return + } - result, err = client.ListEffectiveNetworkSecurityGroupsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.InterfacesClient", "ListEffectiveNetworkSecurityGroups", resp, "Failure responding to request") - } - - return + result, err = client.ListEffectiveNetworkSecurityGroupsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "ListEffectiveNetworkSecurityGroups", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // ListEffectiveNetworkSecurityGroupsPreparer prepares the ListEffectiveNetworkSecurityGroups request. @@ -588,8 +652,9 @@ func (client InterfacesClient) ListEffectiveNetworkSecurityGroupsPreparer(resour "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -610,31 +675,34 @@ func (client InterfacesClient) ListEffectiveNetworkSecurityGroupsSender(req *htt // ListEffectiveNetworkSecurityGroupsResponder handles the response to the ListEffectiveNetworkSecurityGroups request. The method always // closes the http.Response Body. -func (client InterfacesClient) ListEffectiveNetworkSecurityGroupsResponder(resp *http.Response) (result autorest.Response, err error) { +func (client InterfacesClient) ListEffectiveNetworkSecurityGroupsResponder(resp *http.Response) (result EffectiveNetworkSecurityGroupListResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } -// ListVirtualMachineScaleSetNetworkInterfaces gets all network interfaces in -// a virtual machine scale set. +// ListVirtualMachineScaleSetNetworkInterfaces gets all network interfaces in a +// virtual machine scale set. // // resourceGroupName is the name of the resource group. // virtualMachineScaleSetName is the name of the virtual machine scale set. func (client InterfacesClient) ListVirtualMachineScaleSetNetworkInterfaces(resourceGroupName string, virtualMachineScaleSetName string) (result InterfaceListResult, err error) { req, err := client.ListVirtualMachineScaleSetNetworkInterfacesPreparer(resourceGroupName, virtualMachineScaleSetName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "ListVirtualMachineScaleSetNetworkInterfaces", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "ListVirtualMachineScaleSetNetworkInterfaces", nil, "Failure preparing request") + return } resp, err := client.ListVirtualMachineScaleSetNetworkInterfacesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "ListVirtualMachineScaleSetNetworkInterfaces", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "ListVirtualMachineScaleSetNetworkInterfaces", resp, "Failure sending request") + return } result, err = client.ListVirtualMachineScaleSetNetworkInterfacesResponder(resp) @@ -653,8 +721,9 @@ func (client InterfacesClient) ListVirtualMachineScaleSetNetworkInterfacesPrepar "virtualMachineScaleSetName": autorest.Encode("path", virtualMachineScaleSetName), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -717,13 +786,15 @@ func (client InterfacesClient) ListVirtualMachineScaleSetNetworkInterfacesNextRe func (client InterfacesClient) ListVirtualMachineScaleSetVMNetworkInterfaces(resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string) (result InterfaceListResult, err error) { req, err := client.ListVirtualMachineScaleSetVMNetworkInterfacesPreparer(resourceGroupName, virtualMachineScaleSetName, virtualmachineIndex) if err != nil { - return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "ListVirtualMachineScaleSetVMNetworkInterfaces", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "ListVirtualMachineScaleSetVMNetworkInterfaces", nil, "Failure preparing request") + return } resp, err := client.ListVirtualMachineScaleSetVMNetworkInterfacesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "ListVirtualMachineScaleSetVMNetworkInterfaces", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.InterfacesClient", "ListVirtualMachineScaleSetVMNetworkInterfaces", resp, "Failure sending request") + return } result, err = client.ListVirtualMachineScaleSetVMNetworkInterfacesResponder(resp) @@ -743,8 +814,9 @@ func (client InterfacesClient) ListVirtualMachineScaleSetVMNetworkInterfacesPrep "virtualMachineScaleSetName": autorest.Encode("path", virtualMachineScaleSetName), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/loadbalancers.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/loadbalancers.go old mode 100644 new mode 100755 index 30012ff35..11d649b27 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/loadbalancers.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/loadbalancers.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -24,11 +24,7 @@ import ( "net/http" ) -// LoadBalancersClient is the the Microsoft Azure Network management API -// provides a RESTful set of web services that interact with Microsoft Azure -// Networks service to manage your network resources. The API has entities -// that capture the relationship between an end user and the Microsoft Azure -// Networks service. +// LoadBalancersClient is the composite Swagger for Network Client type LoadBalancersClient struct { ManagementClient } @@ -46,31 +42,44 @@ func NewLoadBalancersClientWithBaseURI(baseURI string, subscriptionID string) Lo } // CreateOrUpdate creates or updates a load balancer. This method may poll for -// completion. Polling can be canceled by passing the cancel channel -// argument. The channel will be used to cancel polling and any outstanding -// HTTP requests. +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. // -// resourceGroupName is the name of the resource group. loadBalancerName is -// the name of the load balancer. parameters is parameters supplied to the -// create or update load balancer operation. -func (client LoadBalancersClient) CreateOrUpdate(resourceGroupName string, loadBalancerName string, parameters LoadBalancer, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateOrUpdatePreparer(resourceGroupName, loadBalancerName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "CreateOrUpdate", nil, "Failure preparing request") - } +// resourceGroupName is the name of the resource group. loadBalancerName is the +// name of the load balancer. parameters is parameters supplied to the create +// or update load balancer operation. +func (client LoadBalancersClient) CreateOrUpdate(resourceGroupName string, loadBalancerName string, parameters LoadBalancer, cancel <-chan struct{}) (<-chan LoadBalancer, <-chan error) { + resultChan := make(chan LoadBalancer, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result LoadBalancer + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, loadBalancerName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -81,8 +90,9 @@ func (client LoadBalancersClient) CreateOrUpdatePreparer(resourceGroupName strin "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -105,41 +115,55 @@ func (client LoadBalancersClient) CreateOrUpdateSender(req *http.Request) (*http // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client LoadBalancersClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client LoadBalancersClient) CreateOrUpdateResponder(resp *http.Response) (result LoadBalancer, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } // Delete deletes the specified load balancer. This method may poll for -// completion. Polling can be canceled by passing the cancel channel -// argument. The channel will be used to cancel polling and any outstanding -// HTTP requests. +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. // -// resourceGroupName is the name of the resource group. loadBalancerName is -// the name of the load balancer. -func (client LoadBalancersClient) Delete(resourceGroupName string, loadBalancerName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, loadBalancerName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "Delete", nil, "Failure preparing request") - } +// resourceGroupName is the name of the resource group. loadBalancerName is the +// name of the load balancer. +func (client LoadBalancersClient) Delete(resourceGroupName string, loadBalancerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, loadBalancerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -150,8 +174,9 @@ func (client LoadBalancersClient) DeletePreparer(resourceGroupName string, loadB "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -184,18 +209,20 @@ func (client LoadBalancersClient) DeleteResponder(resp *http.Response) (result a // Get gets the specified load balancer. // -// resourceGroupName is the name of the resource group. loadBalancerName is -// the name of the load balancer. expand is expands referenced resources. +// resourceGroupName is the name of the resource group. loadBalancerName is the +// name of the load balancer. expand is expands referenced resources. func (client LoadBalancersClient) Get(resourceGroupName string, loadBalancerName string, expand string) (result LoadBalancer, err error) { req, err := client.GetPreparer(resourceGroupName, loadBalancerName, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -214,8 +241,9 @@ func (client LoadBalancersClient) GetPreparer(resourceGroupName string, loadBala "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(expand) > 0 { queryParameters["$expand"] = autorest.Encode("query", expand) @@ -254,13 +282,15 @@ func (client LoadBalancersClient) GetResponder(resp *http.Response) (result Load func (client LoadBalancersClient) List(resourceGroupName string) (result LoadBalancerListResult, err error) { req, err := client.ListPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -278,8 +308,9 @@ func (client LoadBalancersClient) ListPreparer(resourceGroupName string) (*http. "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -337,13 +368,15 @@ func (client LoadBalancersClient) ListNextResults(lastResults LoadBalancerListRe func (client LoadBalancersClient) ListAll() (result LoadBalancerListResult, err error) { req, err := client.ListAllPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "ListAll", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "ListAll", nil, "Failure preparing request") + return } resp, err := client.ListAllSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "ListAll", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "ListAll", resp, "Failure sending request") + return } result, err = client.ListAllResponder(resp) @@ -360,8 +393,9 @@ func (client LoadBalancersClient) ListAllPreparer() (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/localnetworkgateways.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/localnetworkgateways.go old mode 100644 new mode 100755 index ff75fa219..c1e66076e --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/localnetworkgateways.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/localnetworkgateways.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -25,11 +25,7 @@ import ( "net/http" ) -// LocalNetworkGatewaysClient is the the Microsoft Azure Network management -// API provides a RESTful set of web services that interact with Microsoft -// Azure Networks service to manage your network resources. The API has -// entities that capture the relationship between an end user and the -// Microsoft Azure Networks service. +// LocalNetworkGatewaysClient is the composite Swagger for Network Client type LocalNetworkGatewaysClient struct { ManagementClient } @@ -47,39 +43,55 @@ func NewLocalNetworkGatewaysClientWithBaseURI(baseURI string, subscriptionID str } // CreateOrUpdate creates or updates a local network gateway in the specified -// resource group. This method may poll for completion. Polling can be -// canceled by passing the cancel channel argument. The channel will be used -// to cancel polling and any outstanding HTTP requests. +// resource group. This method may poll for completion. Polling can be canceled +// by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. -// localNetworkGatewayName is the name of the local network gateway. -// parameters is parameters supplied to the create or update local network -// gateway operation. -func (client LocalNetworkGatewaysClient) CreateOrUpdate(resourceGroupName string, localNetworkGatewayName string, parameters LocalNetworkGateway, cancel <-chan struct{}) (result autorest.Response, err error) { +// resourceGroupName is the name of the resource group. localNetworkGatewayName +// is the name of the local network gateway. parameters is parameters supplied +// to the create or update local network gateway operation. +func (client LocalNetworkGatewaysClient) CreateOrUpdate(resourceGroupName string, localNetworkGatewayName string, parameters LocalNetworkGateway, cancel <-chan struct{}) (<-chan LocalNetworkGateway, <-chan error) { + resultChan := make(chan LocalNetworkGateway, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ + {TargetValue: localNetworkGatewayName, + Constraints: []validation.Constraint{{Target: "localNetworkGatewayName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.LocalNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.LocalNetworkGatewayPropertiesFormat.LocalNetworkAddressSpace", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "network.LocalNetworkGatewaysClient", "CreateOrUpdate") + Constraints: []validation.Constraint{{Target: "parameters.LocalNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "network.LocalNetworkGatewaysClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, localNetworkGatewayName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request") - } + go func() { + var err error + var result LocalNetworkGateway + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, localNetworkGatewayName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -90,8 +102,9 @@ func (client LocalNetworkGatewaysClient) CreateOrUpdatePreparer(resourceGroupNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -114,41 +127,64 @@ func (client LocalNetworkGatewaysClient) CreateOrUpdateSender(req *http.Request) // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client LocalNetworkGatewaysClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client LocalNetworkGatewaysClient) CreateOrUpdateResponder(resp *http.Response) (result LocalNetworkGateway, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } -// Delete deletes the specified local network gateway. This method may poll -// for completion. Polling can be canceled by passing the cancel channel -// argument. The channel will be used to cancel polling and any outstanding -// HTTP requests. +// Delete deletes the specified local network gateway. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. // -// resourceGroupName is the name of the resource group. -// localNetworkGatewayName is the name of the local network gateway. -func (client LocalNetworkGatewaysClient) Delete(resourceGroupName string, localNetworkGatewayName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, localNetworkGatewayName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Delete", nil, "Failure preparing request") +// resourceGroupName is the name of the resource group. localNetworkGatewayName +// is the name of the local network gateway. +func (client LocalNetworkGatewaysClient) Delete(resourceGroupName string, localNetworkGatewayName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: localNetworkGatewayName, + Constraints: []validation.Constraint{{Target: "localNetworkGatewayName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "network.LocalNetworkGatewaysClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Delete", resp, "Failure sending request") - } + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, localNetworkGatewayName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Delete", nil, "Failure preparing request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Delete", resp, "Failure responding to request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Delete", resp, "Failure sending request") + return + } - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -159,8 +195,9 @@ func (client LocalNetworkGatewaysClient) DeletePreparer(resourceGroupName string "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -193,18 +230,26 @@ func (client LocalNetworkGatewaysClient) DeleteResponder(resp *http.Response) (r // Get gets the specified local network gateway in a resource group. // -// resourceGroupName is the name of the resource group. -// localNetworkGatewayName is the name of the local network gateway. +// resourceGroupName is the name of the resource group. localNetworkGatewayName +// is the name of the local network gateway. func (client LocalNetworkGatewaysClient) Get(resourceGroupName string, localNetworkGatewayName string) (result LocalNetworkGateway, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: localNetworkGatewayName, + Constraints: []validation.Constraint{{Target: "localNetworkGatewayName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "network.LocalNetworkGatewaysClient", "Get") + } + req, err := client.GetPreparer(resourceGroupName, localNetworkGatewayName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -223,8 +268,9 @@ func (client LocalNetworkGatewaysClient) GetPreparer(resourceGroupName string, l "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -260,13 +306,15 @@ func (client LocalNetworkGatewaysClient) GetResponder(resp *http.Response) (resu func (client LocalNetworkGatewaysClient) List(resourceGroupName string) (result LocalNetworkGatewayListResult, err error) { req, err := client.ListPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -284,8 +332,9 @@ func (client LocalNetworkGatewaysClient) ListPreparer(resourceGroupName string) "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/models.go old mode 100644 new mode 100755 index bb514f796..505691db0 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/models.go @@ -14,16 +14,27 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. import ( "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" "github.com/Azure/go-autorest/autorest/to" "net/http" ) +// Access enumerates the values for access. +type Access string + +const ( + // Allow specifies the allow state for access. + Allow Access = "Allow" + // Deny specifies the deny state for access. + Deny Access = "Deny" +) + // ApplicationGatewayBackendHealthServerHealth enumerates the values for // application gateway backend health server health. type ApplicationGatewayBackendHealthServerHealth string @@ -32,6 +43,9 @@ const ( // Down specifies the down state for application gateway backend health // server health. Down ApplicationGatewayBackendHealthServerHealth = "Down" + // Draining specifies the draining state for application gateway backend + // health server health. + Draining ApplicationGatewayBackendHealthServerHealth = "Draining" // Partial specifies the partial state for application gateway backend // health server health. Partial ApplicationGatewayBackendHealthServerHealth = "Partial" @@ -51,18 +65,18 @@ const ( // Disabled specifies the disabled state for application gateway cookie // based affinity. Disabled ApplicationGatewayCookieBasedAffinity = "Disabled" - // Enabled specifies the enabled state for application gateway cookie - // based affinity. + // Enabled specifies the enabled state for application gateway cookie based + // affinity. Enabled ApplicationGatewayCookieBasedAffinity = "Enabled" ) -// ApplicationGatewayFirewallMode enumerates the values for application -// gateway firewall mode. +// ApplicationGatewayFirewallMode enumerates the values for application gateway +// firewall mode. type ApplicationGatewayFirewallMode string const ( - // Detection specifies the detection state for application gateway - // firewall mode. + // Detection specifies the detection state for application gateway firewall + // mode. Detection ApplicationGatewayFirewallMode = "Detection" // Prevention specifies the prevention state for application gateway // firewall mode. @@ -117,14 +131,14 @@ const ( type ApplicationGatewaySkuName string const ( - // StandardLarge specifies the standard large state for application - // gateway sku name. + // StandardLarge specifies the standard large state for application gateway + // sku name. StandardLarge ApplicationGatewaySkuName = "Standard_Large" // StandardMedium specifies the standard medium state for application // gateway sku name. StandardMedium ApplicationGatewaySkuName = "Standard_Medium" - // StandardSmall specifies the standard small state for application - // gateway sku name. + // StandardSmall specifies the standard small state for application gateway + // sku name. StandardSmall ApplicationGatewaySkuName = "Standard_Small" // WAFLarge specifies the waf large state for application gateway sku name. WAFLarge ApplicationGatewaySkuName = "WAF_Large" @@ -159,6 +173,16 @@ const ( WAF ApplicationGatewayTier = "WAF" ) +// AssociationType enumerates the values for association type. +type AssociationType string + +const ( + // Associated specifies the associated state for association type. + Associated AssociationType = "Associated" + // Contains specifies the contains state for association type. + Contains AssociationType = "Contains" +) + // AuthorizationUseStatus enumerates the values for authorization use status. type AuthorizationUseStatus string @@ -169,18 +193,71 @@ const ( InUse AuthorizationUseStatus = "InUse" ) +// BgpPeerState enumerates the values for bgp peer state. +type BgpPeerState string + +const ( + // BgpPeerStateConnected specifies the bgp peer state connected state for + // bgp peer state. + BgpPeerStateConnected BgpPeerState = "Connected" + // BgpPeerStateConnecting specifies the bgp peer state connecting state for + // bgp peer state. + BgpPeerStateConnecting BgpPeerState = "Connecting" + // BgpPeerStateIdle specifies the bgp peer state idle state for bgp peer + // state. + BgpPeerStateIdle BgpPeerState = "Idle" + // BgpPeerStateStopped specifies the bgp peer state stopped state for bgp + // peer state. + BgpPeerStateStopped BgpPeerState = "Stopped" + // BgpPeerStateUnknown specifies the bgp peer state unknown state for bgp + // peer state. + BgpPeerStateUnknown BgpPeerState = "Unknown" +) + +// DhGroup enumerates the values for dh group. +type DhGroup string + +const ( + // DHGroup1 specifies the dh group 1 state for dh group. + DHGroup1 DhGroup = "DHGroup1" + // DHGroup14 specifies the dh group 14 state for dh group. + DHGroup14 DhGroup = "DHGroup14" + // DHGroup2 specifies the dh group 2 state for dh group. + DHGroup2 DhGroup = "DHGroup2" + // DHGroup2048 specifies the dh group 2048 state for dh group. + DHGroup2048 DhGroup = "DHGroup2048" + // DHGroup24 specifies the dh group 24 state for dh group. + DHGroup24 DhGroup = "DHGroup24" + // ECP256 specifies the ecp256 state for dh group. + ECP256 DhGroup = "ECP256" + // ECP384 specifies the ecp384 state for dh group. + ECP384 DhGroup = "ECP384" + // None specifies the none state for dh group. + None DhGroup = "None" +) + +// Direction enumerates the values for direction. +type Direction string + +const ( + // Inbound specifies the inbound state for direction. + Inbound Direction = "Inbound" + // Outbound specifies the outbound state for direction. + Outbound Direction = "Outbound" +) + // EffectiveRouteSource enumerates the values for effective route source. type EffectiveRouteSource string const ( - // EffectiveRouteSourceDefault specifies the effective route source - // default state for effective route source. - EffectiveRouteSourceDefault EffectiveRouteSource = "Default" - // EffectiveRouteSourceUnknown specifies the effective route source - // unknown state for effective route source. - EffectiveRouteSourceUnknown EffectiveRouteSource = "Unknown" - // EffectiveRouteSourceUser specifies the effective route source user + // EffectiveRouteSourceDefault specifies the effective route source default // state for effective route source. + EffectiveRouteSourceDefault EffectiveRouteSource = "Default" + // EffectiveRouteSourceUnknown specifies the effective route source unknown + // state for effective route source. + EffectiveRouteSourceUnknown EffectiveRouteSource = "Unknown" + // EffectiveRouteSourceUser specifies the effective route source user state + // for effective route source. EffectiveRouteSourceUser EffectiveRouteSource = "User" // EffectiveRouteSourceVirtualNetworkGateway specifies the effective route // source virtual network gateway state for effective route source. @@ -211,8 +288,8 @@ const ( // NotConfigured specifies the not configured state for express route // circuit peering advertised public prefix state. NotConfigured ExpressRouteCircuitPeeringAdvertisedPublicPrefixState = "NotConfigured" - // ValidationNeeded specifies the validation needed state for express - // route circuit peering advertised public prefix state. + // ValidationNeeded specifies the validation needed state for express route + // circuit peering advertised public prefix state. ValidationNeeded ExpressRouteCircuitPeeringAdvertisedPublicPrefixState = "ValidationNeeded" ) @@ -242,13 +319,13 @@ const ( // AzurePublicPeering specifies the azure public peering state for express // route circuit peering type. AzurePublicPeering ExpressRouteCircuitPeeringType = "AzurePublicPeering" - // MicrosoftPeering specifies the microsoft peering state for express - // route circuit peering type. + // MicrosoftPeering specifies the microsoft peering state for express route + // circuit peering type. MicrosoftPeering ExpressRouteCircuitPeeringType = "MicrosoftPeering" ) -// ExpressRouteCircuitSkuFamily enumerates the values for express route -// circuit sku family. +// ExpressRouteCircuitSkuFamily enumerates the values for express route circuit +// sku family. type ExpressRouteCircuitSkuFamily string const ( @@ -273,6 +350,36 @@ const ( ExpressRouteCircuitSkuTierStandard ExpressRouteCircuitSkuTier = "Standard" ) +// IkeEncryption enumerates the values for ike encryption. +type IkeEncryption string + +const ( + // AES128 specifies the aes128 state for ike encryption. + AES128 IkeEncryption = "AES128" + // AES192 specifies the aes192 state for ike encryption. + AES192 IkeEncryption = "AES192" + // AES256 specifies the aes256 state for ike encryption. + AES256 IkeEncryption = "AES256" + // DES specifies the des state for ike encryption. + DES IkeEncryption = "DES" + // DES3 specifies the des3 state for ike encryption. + DES3 IkeEncryption = "DES3" +) + +// IkeIntegrity enumerates the values for ike integrity. +type IkeIntegrity string + +const ( + // MD5 specifies the md5 state for ike integrity. + MD5 IkeIntegrity = "MD5" + // SHA1 specifies the sha1 state for ike integrity. + SHA1 IkeIntegrity = "SHA1" + // SHA256 specifies the sha256 state for ike integrity. + SHA256 IkeIntegrity = "SHA256" + // SHA384 specifies the sha384 state for ike integrity. + SHA384 IkeIntegrity = "SHA384" +) + // IPAllocationMethod enumerates the values for ip allocation method. type IPAllocationMethod string @@ -283,6 +390,63 @@ const ( Static IPAllocationMethod = "Static" ) +// IpsecEncryption enumerates the values for ipsec encryption. +type IpsecEncryption string + +const ( + // IpsecEncryptionAES128 specifies the ipsec encryption aes128 state for + // ipsec encryption. + IpsecEncryptionAES128 IpsecEncryption = "AES128" + // IpsecEncryptionAES192 specifies the ipsec encryption aes192 state for + // ipsec encryption. + IpsecEncryptionAES192 IpsecEncryption = "AES192" + // IpsecEncryptionAES256 specifies the ipsec encryption aes256 state for + // ipsec encryption. + IpsecEncryptionAES256 IpsecEncryption = "AES256" + // IpsecEncryptionDES specifies the ipsec encryption des state for ipsec + // encryption. + IpsecEncryptionDES IpsecEncryption = "DES" + // IpsecEncryptionDES3 specifies the ipsec encryption des3 state for ipsec + // encryption. + IpsecEncryptionDES3 IpsecEncryption = "DES3" + // IpsecEncryptionGCMAES128 specifies the ipsec encryption gcmaes128 state + // for ipsec encryption. + IpsecEncryptionGCMAES128 IpsecEncryption = "GCMAES128" + // IpsecEncryptionGCMAES192 specifies the ipsec encryption gcmaes192 state + // for ipsec encryption. + IpsecEncryptionGCMAES192 IpsecEncryption = "GCMAES192" + // IpsecEncryptionGCMAES256 specifies the ipsec encryption gcmaes256 state + // for ipsec encryption. + IpsecEncryptionGCMAES256 IpsecEncryption = "GCMAES256" + // IpsecEncryptionNone specifies the ipsec encryption none state for ipsec + // encryption. + IpsecEncryptionNone IpsecEncryption = "None" +) + +// IpsecIntegrity enumerates the values for ipsec integrity. +type IpsecIntegrity string + +const ( + // IpsecIntegrityGCMAES128 specifies the ipsec integrity gcmaes128 state + // for ipsec integrity. + IpsecIntegrityGCMAES128 IpsecIntegrity = "GCMAES128" + // IpsecIntegrityGCMAES192 specifies the ipsec integrity gcmaes192 state + // for ipsec integrity. + IpsecIntegrityGCMAES192 IpsecIntegrity = "GCMAES192" + // IpsecIntegrityGCMAES256 specifies the ipsec integrity gcmaes256 state + // for ipsec integrity. + IpsecIntegrityGCMAES256 IpsecIntegrity = "GCMAES256" + // IpsecIntegrityMD5 specifies the ipsec integrity md5 state for ipsec + // integrity. + IpsecIntegrityMD5 IpsecIntegrity = "MD5" + // IpsecIntegritySHA1 specifies the ipsec integrity sha1 state for ipsec + // integrity. + IpsecIntegritySHA1 IpsecIntegrity = "SHA1" + // IpsecIntegritySHA256 specifies the ipsec integrity sha256 state for + // ipsec integrity. + IpsecIntegritySHA256 IpsecIntegrity = "SHA256" +) + // IPVersion enumerates the values for ip version. type IPVersion string @@ -306,6 +470,30 @@ const ( SourceIPProtocol LoadDistribution = "SourceIPProtocol" ) +// NextHopType enumerates the values for next hop type. +type NextHopType string + +const ( + // NextHopTypeHyperNetGateway specifies the next hop type hyper net gateway + // state for next hop type. + NextHopTypeHyperNetGateway NextHopType = "HyperNetGateway" + // NextHopTypeInternet specifies the next hop type internet state for next + // hop type. + NextHopTypeInternet NextHopType = "Internet" + // NextHopTypeNone specifies the next hop type none state for next hop + // type. + NextHopTypeNone NextHopType = "None" + // NextHopTypeVirtualAppliance specifies the next hop type virtual + // appliance state for next hop type. + NextHopTypeVirtualAppliance NextHopType = "VirtualAppliance" + // NextHopTypeVirtualNetworkGateway specifies the next hop type virtual + // network gateway state for next hop type. + NextHopTypeVirtualNetworkGateway NextHopType = "VirtualNetworkGateway" + // NextHopTypeVnetLocal specifies the next hop type vnet local state for + // next hop type. + NextHopTypeVnetLocal NextHopType = "VnetLocal" +) + // OperationStatus enumerates the values for operation status. type OperationStatus string @@ -318,6 +506,71 @@ const ( Succeeded OperationStatus = "Succeeded" ) +// PcError enumerates the values for pc error. +type PcError string + +const ( + // AgentStopped specifies the agent stopped state for pc error. + AgentStopped PcError = "AgentStopped" + // CaptureFailed specifies the capture failed state for pc error. + CaptureFailed PcError = "CaptureFailed" + // InternalError specifies the internal error state for pc error. + InternalError PcError = "InternalError" + // LocalFileFailed specifies the local file failed state for pc error. + LocalFileFailed PcError = "LocalFileFailed" + // StorageFailed specifies the storage failed state for pc error. + StorageFailed PcError = "StorageFailed" +) + +// PcProtocol enumerates the values for pc protocol. +type PcProtocol string + +const ( + // Any specifies the any state for pc protocol. + Any PcProtocol = "Any" + // TCP specifies the tcp state for pc protocol. + TCP PcProtocol = "TCP" + // UDP specifies the udp state for pc protocol. + UDP PcProtocol = "UDP" +) + +// PcStatus enumerates the values for pc status. +type PcStatus string + +const ( + // PcStatusError specifies the pc status error state for pc status. + PcStatusError PcStatus = "Error" + // PcStatusNotStarted specifies the pc status not started state for pc + // status. + PcStatusNotStarted PcStatus = "NotStarted" + // PcStatusRunning specifies the pc status running state for pc status. + PcStatusRunning PcStatus = "Running" + // PcStatusStopped specifies the pc status stopped state for pc status. + PcStatusStopped PcStatus = "Stopped" + // PcStatusUnknown specifies the pc status unknown state for pc status. + PcStatusUnknown PcStatus = "Unknown" +) + +// PfsGroup enumerates the values for pfs group. +type PfsGroup string + +const ( + // PfsGroupECP256 specifies the pfs group ecp256 state for pfs group. + PfsGroupECP256 PfsGroup = "ECP256" + // PfsGroupECP384 specifies the pfs group ecp384 state for pfs group. + PfsGroupECP384 PfsGroup = "ECP384" + // PfsGroupNone specifies the pfs group none state for pfs group. + PfsGroupNone PfsGroup = "None" + // PfsGroupPFS1 specifies the pfs group pfs1 state for pfs group. + PfsGroupPFS1 PfsGroup = "PFS1" + // PfsGroupPFS2 specifies the pfs group pfs2 state for pfs group. + PfsGroupPFS2 PfsGroup = "PFS2" + // PfsGroupPFS2048 specifies the pfs group pfs2048 state for pfs group. + PfsGroupPFS2048 PfsGroup = "PFS2048" + // PfsGroupPFS24 specifies the pfs group pfs24 state for pfs group. + PfsGroupPFS24 PfsGroup = "PFS24" +) + // ProbeProtocol enumerates the values for probe protocol. type ProbeProtocol string @@ -340,6 +593,34 @@ const ( X86 ProcessorArchitecture = "X86" ) +// Protocol enumerates the values for protocol. +type Protocol string + +const ( + // ProtocolTCP specifies the protocol tcp state for protocol. + ProtocolTCP Protocol = "TCP" + // ProtocolUDP specifies the protocol udp state for protocol. + ProtocolUDP Protocol = "UDP" +) + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // ProvisioningStateDeleting specifies the provisioning state deleting + // state for provisioning state. + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed specifies the provisioning state failed state + // for provisioning state. + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateSucceeded specifies the provisioning state succeeded + // state for provisioning state. + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating specifies the provisioning state updating + // state for provisioning state. + ProvisioningStateUpdating ProvisioningState = "Updating" +) + // RouteNextHopType enumerates the values for route next hop type. type RouteNextHopType string @@ -365,32 +646,39 @@ const ( type SecurityRuleAccess string const ( - // Allow specifies the allow state for security rule access. - Allow SecurityRuleAccess = "Allow" - // Deny specifies the deny state for security rule access. - Deny SecurityRuleAccess = "Deny" + // SecurityRuleAccessAllow specifies the security rule access allow state + // for security rule access. + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + // SecurityRuleAccessDeny specifies the security rule access deny state for + // security rule access. + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" ) // SecurityRuleDirection enumerates the values for security rule direction. type SecurityRuleDirection string const ( - // Inbound specifies the inbound state for security rule direction. - Inbound SecurityRuleDirection = "Inbound" - // Outbound specifies the outbound state for security rule direction. - Outbound SecurityRuleDirection = "Outbound" + // SecurityRuleDirectionInbound specifies the security rule direction + // inbound state for security rule direction. + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + // SecurityRuleDirectionOutbound specifies the security rule direction + // outbound state for security rule direction. + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" ) // SecurityRuleProtocol enumerates the values for security rule protocol. type SecurityRuleProtocol string const ( - // Asterisk specifies the asterisk state for security rule protocol. - Asterisk SecurityRuleProtocol = "*" - // TCP specifies the tcp state for security rule protocol. - TCP SecurityRuleProtocol = "Tcp" - // UDP specifies the udp state for security rule protocol. - UDP SecurityRuleProtocol = "Udp" + // SecurityRuleProtocolAsterisk specifies the security rule protocol + // asterisk state for security rule protocol. + SecurityRuleProtocolAsterisk SecurityRuleProtocol = "*" + // SecurityRuleProtocolTCP specifies the security rule protocol tcp state + // for security rule protocol. + SecurityRuleProtocolTCP SecurityRuleProtocol = "Tcp" + // SecurityRuleProtocolUDP specifies the security rule protocol udp state + // for security rule protocol. + SecurityRuleProtocolUDP SecurityRuleProtocol = "Udp" ) // ServiceProviderProvisioningState enumerates the values for service provider @@ -485,6 +773,15 @@ const ( // network gateway sku name ultra performance state for virtual network // gateway sku name. VirtualNetworkGatewaySkuNameUltraPerformance VirtualNetworkGatewaySkuName = "UltraPerformance" + // VirtualNetworkGatewaySkuNameVpnGw1 specifies the virtual network gateway + // sku name vpn gw 1 state for virtual network gateway sku name. + VirtualNetworkGatewaySkuNameVpnGw1 VirtualNetworkGatewaySkuName = "VpnGw1" + // VirtualNetworkGatewaySkuNameVpnGw2 specifies the virtual network gateway + // sku name vpn gw 2 state for virtual network gateway sku name. + VirtualNetworkGatewaySkuNameVpnGw2 VirtualNetworkGatewaySkuName = "VpnGw2" + // VirtualNetworkGatewaySkuNameVpnGw3 specifies the virtual network gateway + // sku name vpn gw 3 state for virtual network gateway sku name. + VirtualNetworkGatewaySkuNameVpnGw3 VirtualNetworkGatewaySkuName = "VpnGw3" ) // VirtualNetworkGatewaySkuTier enumerates the values for virtual network @@ -506,6 +803,15 @@ const ( // network gateway sku tier ultra performance state for virtual network // gateway sku tier. VirtualNetworkGatewaySkuTierUltraPerformance VirtualNetworkGatewaySkuTier = "UltraPerformance" + // VirtualNetworkGatewaySkuTierVpnGw1 specifies the virtual network gateway + // sku tier vpn gw 1 state for virtual network gateway sku tier. + VirtualNetworkGatewaySkuTierVpnGw1 VirtualNetworkGatewaySkuTier = "VpnGw1" + // VirtualNetworkGatewaySkuTierVpnGw2 specifies the virtual network gateway + // sku tier vpn gw 2 state for virtual network gateway sku tier. + VirtualNetworkGatewaySkuTierVpnGw2 VirtualNetworkGatewaySkuTier = "VpnGw2" + // VirtualNetworkGatewaySkuTierVpnGw3 specifies the virtual network gateway + // sku tier vpn gw 3 state for virtual network gateway sku tier. + VirtualNetworkGatewaySkuTierVpnGw3 VirtualNetworkGatewaySkuTier = "VpnGw3" ) // VirtualNetworkGatewayType enumerates the values for virtual network gateway @@ -521,8 +827,8 @@ const ( VirtualNetworkGatewayTypeVpn VirtualNetworkGatewayType = "Vpn" ) -// VirtualNetworkPeeringState enumerates the values for virtual network -// peering state. +// VirtualNetworkPeeringState enumerates the values for virtual network peering +// state. type VirtualNetworkPeeringState string const ( @@ -547,8 +853,8 @@ const ( RouteBased VpnType = "RouteBased" ) -// AddressSpace is addressSpace contains an array of IP address ranges that -// can be used by subnets of the virtual network. +// AddressSpace is addressSpace contains an array of IP address ranges that can +// be used by subnets of the virtual network. type AddressSpace struct { AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` } @@ -581,6 +887,13 @@ type ApplicationGatewayAuthenticationCertificatePropertiesFormat struct { ProvisioningState *string `json:"provisioningState,omitempty"` } +// ApplicationGatewayAvailableWafRuleSetsResult is response for +// ApplicationGatewayAvailableWafRuleSets API service call. +type ApplicationGatewayAvailableWafRuleSetsResult struct { + autorest.Response `json:"-"` + Value *[]ApplicationGatewayFirewallRuleSet `json:"value,omitempty"` +} + // ApplicationGatewayBackendAddress is backend address of an application // gateway. type ApplicationGatewayBackendAddress struct { @@ -634,8 +947,8 @@ type ApplicationGatewayBackendHealthServer struct { Health ApplicationGatewayBackendHealthServerHealth `json:"health,omitempty"` } -// ApplicationGatewayBackendHTTPSettings is backend address pool settings of -// an application gateway. +// ApplicationGatewayBackendHTTPSettings is backend address pool settings of an +// application gateway. type ApplicationGatewayBackendHTTPSettings struct { ID *string `json:"id,omitempty"` *ApplicationGatewayBackendHTTPSettingsPropertiesFormat `json:"properties,omitempty"` @@ -653,10 +966,59 @@ type ApplicationGatewayBackendHTTPSettingsPropertiesFormat struct { Probe *SubResource `json:"probe,omitempty"` AuthenticationCertificates *[]SubResource `json:"authenticationCertificates,omitempty"` ProvisioningState *string `json:"provisioningState,omitempty"` + ConnectionDraining *ApplicationGatewayConnectionDraining `json:"connectionDraining,omitempty"` } -// ApplicationGatewayFrontendIPConfiguration is frontend IP configuration of -// an application gateway. +// ApplicationGatewayConnectionDraining is connection draining allows open +// connections to a backend server to be active for a specified time after the +// backend server got removed from the configuration. +type ApplicationGatewayConnectionDraining struct { + Enabled *bool `json:"enabled,omitempty"` + DrainTimeoutInSec *int32 `json:"drainTimeoutInSec,omitempty"` +} + +// ApplicationGatewayFirewallDisabledRuleGroup is allows to disable rules +// within a rule group or an entire rule group. +type ApplicationGatewayFirewallDisabledRuleGroup struct { + RuleGroupName *string `json:"ruleGroupName,omitempty"` + Rules *[]int32 `json:"rules,omitempty"` +} + +// ApplicationGatewayFirewallRule is a web application firewall rule. +type ApplicationGatewayFirewallRule struct { + RuleID *int32 `json:"ruleId,omitempty"` + Description *string `json:"description,omitempty"` +} + +// ApplicationGatewayFirewallRuleGroup is a web application firewall rule +// group. +type ApplicationGatewayFirewallRuleGroup struct { + RuleGroupName *string `json:"ruleGroupName,omitempty"` + Description *string `json:"description,omitempty"` + Rules *[]ApplicationGatewayFirewallRule `json:"rules,omitempty"` +} + +// ApplicationGatewayFirewallRuleSet is a web application firewall rule set. +type ApplicationGatewayFirewallRuleSet struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *ApplicationGatewayFirewallRuleSetPropertiesFormat `json:"properties,omitempty"` +} + +// ApplicationGatewayFirewallRuleSetPropertiesFormat is properties of the web +// application firewall rule set. +type ApplicationGatewayFirewallRuleSetPropertiesFormat struct { + ProvisioningState *string `json:"provisioningState,omitempty"` + RuleSetType *string `json:"ruleSetType,omitempty"` + RuleSetVersion *string `json:"ruleSetVersion,omitempty"` + RuleGroups *[]ApplicationGatewayFirewallRuleGroup `json:"ruleGroups,omitempty"` +} + +// ApplicationGatewayFrontendIPConfiguration is frontend IP configuration of an +// application gateway. type ApplicationGatewayFrontendIPConfiguration struct { ID *string `json:"id,omitempty"` *ApplicationGatewayFrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` @@ -872,11 +1234,14 @@ type ApplicationGatewayURLPathMapPropertiesFormat struct { ProvisioningState *string `json:"provisioningState,omitempty"` } -// ApplicationGatewayWebApplicationFirewallConfiguration is application -// gateway web application firewall configuration. +// ApplicationGatewayWebApplicationFirewallConfiguration is application gateway +// web application firewall configuration. type ApplicationGatewayWebApplicationFirewallConfiguration struct { - Enabled *bool `json:"enabled,omitempty"` - FirewallMode ApplicationGatewayFirewallMode `json:"firewallMode,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + FirewallMode ApplicationGatewayFirewallMode `json:"firewallMode,omitempty"` + RuleSetType *string `json:"ruleSetType,omitempty"` + RuleSetVersion *string `json:"ruleSetVersion,omitempty"` + DisabledRuleGroups *[]ApplicationGatewayFirewallDisabledRuleGroup `json:"disabledRuleGroups,omitempty"` } // AuthorizationListResult is response for ListAuthorizations API service call @@ -907,13 +1272,13 @@ type AuthorizationPropertiesFormat struct { } // AzureAsyncOperationResult is the response body contains the status of the -// specified asynchronous operation, indicating whether it has succeeded, is -// in progress, or has failed. Note that this status is distinct from the -// HTTP status code returned for the Get Operation Status operation itself. -// If the asynchronous operation succeeded, the response body includes the -// HTTP status code for the successful request. If the asynchronous operation -// failed, the response body includes the HTTP status code for the failed -// request and error information regarding the failure. +// specified asynchronous operation, indicating whether it has succeeded, is in +// progress, or has failed. Note that this status is distinct from the HTTP +// status code returned for the Get Operation Status operation itself. If the +// asynchronous operation succeeded, the response body includes the HTTP status +// code for the successful request. If the asynchronous operation failed, the +// response body includes the HTTP status code for the failed request and error +// information regarding the failure. type AzureAsyncOperationResult struct { Status OperationStatus `json:"status,omitempty"` Error *Error `json:"error,omitempty"` @@ -936,14 +1301,78 @@ type BackendAddressPoolPropertiesFormat struct { ProvisioningState *string `json:"provisioningState,omitempty"` } -// BgpSettings is +// BGPCommunity is contains bgp community information offered in Service +// Community resources. +type BGPCommunity struct { + ServiceSupportedRegion *string `json:"serviceSupportedRegion,omitempty"` + CommunityName *string `json:"communityName,omitempty"` + CommunityValue *string `json:"communityValue,omitempty"` + CommunityPrefixes *[]string `json:"communityPrefixes,omitempty"` +} + +// BgpPeerStatus is bGP peer status details +type BgpPeerStatus struct { + LocalAddress *string `json:"localAddress,omitempty"` + Neighbor *string `json:"neighbor,omitempty"` + Asn *int32 `json:"asn,omitempty"` + State BgpPeerState `json:"state,omitempty"` + ConnectedDuration *string `json:"connectedDuration,omitempty"` + RoutesReceived *int64 `json:"routesReceived,omitempty"` + MessagesSent *int64 `json:"messagesSent,omitempty"` + MessagesReceived *int64 `json:"messagesReceived,omitempty"` +} + +// BgpPeerStatusListResult is response for list BGP peer status API service +// call +type BgpPeerStatusListResult struct { + autorest.Response `json:"-"` + Value *[]BgpPeerStatus `json:"value,omitempty"` +} + +// BgpServiceCommunity is service Community Properties. +type BgpServiceCommunity struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *BgpServiceCommunityPropertiesFormat `json:"properties,omitempty"` +} + +// BgpServiceCommunityListResult is response for the ListServiceCommunity API +// service call. +type BgpServiceCommunityListResult struct { + autorest.Response `json:"-"` + Value *[]BgpServiceCommunity `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// BgpServiceCommunityListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client BgpServiceCommunityListResult) BgpServiceCommunityListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// BgpServiceCommunityPropertiesFormat is properties of Service Community. +type BgpServiceCommunityPropertiesFormat struct { + ServiceName *string `json:"serviceName,omitempty"` + BgpCommunities *[]BGPCommunity `json:"bgpCommunities,omitempty"` +} + +// BgpSettings is bGP settings details type BgpSettings struct { Asn *int64 `json:"asn,omitempty"` BgpPeeringAddress *string `json:"bgpPeeringAddress,omitempty"` PeerWeight *int32 `json:"peerWeight,omitempty"` } -// ConnectionResetSharedKey is +// ConnectionResetSharedKey is the virtual network connection reset shared key type ConnectionResetSharedKey struct { autorest.Response `json:"-"` KeyLength *int32 `json:"keyLength,omitempty"` @@ -955,9 +1384,9 @@ type ConnectionSharedKey struct { Value *string `json:"value,omitempty"` } -// DhcpOptions is dhcpOptions contains an array of DNS servers available to -// VMs deployed in the virtual network. Standard DHCP option for a subnet -// overrides VNET DHCP options. +// DhcpOptions is dhcpOptions contains an array of DNS servers available to VMs +// deployed in the virtual network. Standard DHCP option for a subnet overrides +// VNET DHCP options. type DhcpOptions struct { DNSServers *[]string `json:"dnsServers,omitempty"` } @@ -1109,8 +1538,8 @@ type ExpressRouteCircuitPeeringConfig struct { RoutingRegistryName *string `json:"routingRegistryName,omitempty"` } -// ExpressRouteCircuitPeeringListResult is response for ListPeering API -// service call retrieves all peerings that belong to an ExpressRouteCircuit. +// ExpressRouteCircuitPeeringListResult is response for ListPeering API service +// call retrieves all peerings that belong to an ExpressRouteCircuit. type ExpressRouteCircuitPeeringListResult struct { autorest.Response `json:"-"` Value *[]ExpressRouteCircuitPeering `json:"value,omitempty"` @@ -1146,6 +1575,7 @@ type ExpressRouteCircuitPeeringPropertiesFormat struct { ProvisioningState *string `json:"provisioningState,omitempty"` GatewayManagerEtag *string `json:"gatewayManagerEtag,omitempty"` LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + RouteFilter *RouteFilter `json:"routeFilter,omitempty"` } // ExpressRouteCircuitPropertiesFormat is properties of ExpressRouteCircuit. @@ -1165,11 +1595,11 @@ type ExpressRouteCircuitPropertiesFormat struct { // ExpressRouteCircuitRoutesTable is the routes table associated with the // ExpressRouteCircuit type ExpressRouteCircuitRoutesTable struct { - Network *string `json:"network,omitempty"` - NextHop *string `json:"nextHop,omitempty"` - LocPrf *string `json:"locPrf,omitempty"` - Weight *int32 `json:"weight,omitempty"` - Path *string `json:"path,omitempty"` + NetworkProperty *string `json:"network,omitempty"` + NextHop *string `json:"nextHop,omitempty"` + LocPrf *string `json:"locPrf,omitempty"` + Weight *int32 `json:"weight,omitempty"` + Path *string `json:"path,omitempty"` } // ExpressRouteCircuitRoutesTableSummary is the routes table associated with @@ -1275,6 +1705,26 @@ type ExpressRouteServiceProviderPropertiesFormat struct { ProvisioningState *string `json:"provisioningState,omitempty"` } +// FlowLogInformation is information on the configuration of flow log. +type FlowLogInformation struct { + autorest.Response `json:"-"` + TargetResourceID *string `json:"targetResourceId,omitempty"` + *FlowLogProperties `json:"properties,omitempty"` +} + +// FlowLogProperties is parameters that define the configuration of flow log. +type FlowLogProperties struct { + StorageID *string `json:"storageId,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` +} + +// FlowLogStatusParameters is parameters that define a resource to query flow +// log status. +type FlowLogStatusParameters struct { + TargetResourceID *string `json:"targetResourceId,omitempty"` +} + // FrontendIPConfiguration is frontend IP address of the load balancer. type FrontendIPConfiguration struct { ID *string `json:"id,omitempty"` @@ -1297,6 +1747,23 @@ type FrontendIPConfigurationPropertiesFormat struct { ProvisioningState *string `json:"provisioningState,omitempty"` } +// GatewayRoute is gateway routing details +type GatewayRoute struct { + LocalAddress *string `json:"localAddress,omitempty"` + NetworkProperty *string `json:"network,omitempty"` + NextHop *string `json:"nextHop,omitempty"` + SourcePeer *string `json:"sourcePeer,omitempty"` + Origin *string `json:"origin,omitempty"` + AsPath *string `json:"asPath,omitempty"` + Weight *int32 `json:"weight,omitempty"` +} + +// GatewayRouteListResult is list of virtual network gateway routes +type GatewayRouteListResult struct { + autorest.Response `json:"-"` + Value *[]GatewayRoute `json:"value,omitempty"` +} + // InboundNatPool is inbound NAT pool of the load balancer. type InboundNatPool struct { ID *string `json:"id,omitempty"` @@ -1347,6 +1814,12 @@ type Interface struct { Etag *string `json:"etag,omitempty"` } +// InterfaceAssociation is network interface and its custom security rules. +type InterfaceAssociation struct { + ID *string `json:"id,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` +} + // InterfaceDNSSettings is dNS settings of a network interface. type InterfaceDNSSettings struct { DNSServers *[]string `json:"dnsServers,omitempty"` @@ -1437,6 +1910,19 @@ type IPConfigurationPropertiesFormat struct { ProvisioningState *string `json:"provisioningState,omitempty"` } +// IpsecPolicy is an IPSec Policy configuration for a virtual network gateway +// connection +type IpsecPolicy struct { + SaLifeTimeSeconds *int32 `json:"saLifeTimeSeconds,omitempty"` + SaDataSizeKilobytes *int32 `json:"saDataSizeKilobytes,omitempty"` + IpsecEncryption IpsecEncryption `json:"ipsecEncryption,omitempty"` + IpsecIntegrity IpsecIntegrity `json:"ipsecIntegrity,omitempty"` + IkeEncryption IkeEncryption `json:"ikeEncryption,omitempty"` + IkeIntegrity IkeIntegrity `json:"ikeIntegrity,omitempty"` + DhGroup DhGroup `json:"dhGroup,omitempty"` + PfsGroup PfsGroup `json:"pfsGroup,omitempty"` +} + // LoadBalancer is loadBalancer resource type LoadBalancer struct { autorest.Response `json:"-"` @@ -1544,6 +2030,23 @@ type LocalNetworkGatewayPropertiesFormat struct { ProvisioningState *string `json:"provisioningState,omitempty"` } +// NextHopParameters is parameters that define the source and destination +// endpoint. +type NextHopParameters struct { + TargetResourceID *string `json:"targetResourceId,omitempty"` + SourceIPAddress *string `json:"sourceIPAddress,omitempty"` + DestinationIPAddress *string `json:"destinationIPAddress,omitempty"` + TargetNicResourceID *string `json:"targetNicResourceId,omitempty"` +} + +// NextHopResult is the information about next hop from the specified VM. +type NextHopResult struct { + autorest.Response `json:"-"` + NextHopType NextHopType `json:"nextHopType,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + RouteTableID *string `json:"routeTableId,omitempty"` +} + // OutboundNatRule is outbound NAT pool of the load balancer. type OutboundNatRule struct { ID *string `json:"id,omitempty"` @@ -1560,6 +2063,97 @@ type OutboundNatRulePropertiesFormat struct { ProvisioningState *string `json:"provisioningState,omitempty"` } +// PacketCapture is parameters that define the create packet capture operation. +type PacketCapture struct { + *PacketCaptureParameters `json:"properties,omitempty"` +} + +// PacketCaptureFilter is filter that is applied to packet capture request. +// Multiple filters can be applied. +type PacketCaptureFilter struct { + Protocol PcProtocol `json:"protocol,omitempty"` + LocalIPAddress *string `json:"localIPAddress,omitempty"` + RemoteIPAddress *string `json:"remoteIPAddress,omitempty"` + LocalPort *string `json:"localPort,omitempty"` + RemotePort *string `json:"remotePort,omitempty"` +} + +// PacketCaptureListResult is list of packet capture sessions. +type PacketCaptureListResult struct { + autorest.Response `json:"-"` + Value *[]PacketCaptureResult `json:"value,omitempty"` +} + +// PacketCaptureParameters is parameters that define the create packet capture +// operation. +type PacketCaptureParameters struct { + Target *string `json:"target,omitempty"` + BytesToCapturePerPacket *int32 `json:"bytesToCapturePerPacket,omitempty"` + TotalBytesPerSession *int32 `json:"totalBytesPerSession,omitempty"` + TimeLimitInSeconds *int32 `json:"timeLimitInSeconds,omitempty"` + StorageLocation *PacketCaptureStorageLocation `json:"storageLocation,omitempty"` + Filters *[]PacketCaptureFilter `json:"filters,omitempty"` +} + +// PacketCaptureQueryStatusResult is status of packet capture session. +type PacketCaptureQueryStatusResult struct { + autorest.Response `json:"-"` + Name *string `json:"name,omitempty"` + ID *string `json:"id,omitempty"` + CaptureStartTime *date.Time `json:"captureStartTime,omitempty"` + PacketCaptureStatus PcStatus `json:"packetCaptureStatus,omitempty"` + StopReason *string `json:"stopReason,omitempty"` + PacketCaptureError *[]PcError `json:"packetCaptureError,omitempty"` +} + +// PacketCaptureResult is information about packet capture session. +type PacketCaptureResult struct { + autorest.Response `json:"-"` + Name *string `json:"name,omitempty"` + ID *string `json:"id,omitempty"` + Etag *string `json:"etag,omitempty"` + *PacketCaptureResultProperties `json:"properties,omitempty"` +} + +// PacketCaptureResultProperties is describes the properties of a packet +// capture session. +type PacketCaptureResultProperties struct { + Target *string `json:"target,omitempty"` + BytesToCapturePerPacket *int32 `json:"bytesToCapturePerPacket,omitempty"` + TotalBytesPerSession *int32 `json:"totalBytesPerSession,omitempty"` + TimeLimitInSeconds *int32 `json:"timeLimitInSeconds,omitempty"` + StorageLocation *PacketCaptureStorageLocation `json:"storageLocation,omitempty"` + Filters *[]PacketCaptureFilter `json:"filters,omitempty"` + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} + +// PacketCaptureStorageLocation is describes the storage location for a packet +// capture session. +type PacketCaptureStorageLocation struct { + StorageID *string `json:"storageId,omitempty"` + StoragePath *string `json:"storagePath,omitempty"` + FilePath *string `json:"filePath,omitempty"` +} + +// PatchRouteFilter is route Filter Resource. +type PatchRouteFilter struct { + ID *string `json:"id,omitempty"` + *RouteFilterPropertiesFormat `json:"properties,omitempty"` + Name *string `json:"name,omitempty"` + Etag *string `json:"etag,omitempty"` + Type *string `json:"type,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// PatchRouteFilterRule is route Filter Rule Resource +type PatchRouteFilterRule struct { + ID *string `json:"id,omitempty"` + *RouteFilterRulePropertiesFormat `json:"properties,omitempty"` + Name *string `json:"name,omitempty"` + Etag *string `json:"etag,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + // Probe is a load balancer probe. type Probe struct { ID *string `json:"id,omitempty"` @@ -1591,8 +2185,8 @@ type PublicIPAddress struct { Etag *string `json:"etag,omitempty"` } -// PublicIPAddressDNSSettings is contains the FQDN of the DNS record -// associated with the public IP address. +// PublicIPAddressDNSSettings is contains FQDN of the DNS record associated +// with the public IP address type PublicIPAddressDNSSettings struct { DomainNameLabel *string `json:"domainNameLabel,omitempty"` Fqdn *string `json:"fqdn,omitempty"` @@ -1631,6 +2225,12 @@ type PublicIPAddressPropertiesFormat struct { ProvisioningState *string `json:"provisioningState,omitempty"` } +// QueryTroubleshootingParameters is parameters that define the resource to +// query the troubleshooting result. +type QueryTroubleshootingParameters struct { + TargetResourceID *string `json:"targetResourceId,omitempty"` +} + // Resource is type Resource struct { ID *string `json:"id,omitempty"` @@ -1655,6 +2255,13 @@ type ResourceNavigationLinkFormat struct { ProvisioningState *string `json:"provisioningState,omitempty"` } +// RetentionPolicyParameters is parameters that define the retention policy for +// flow log. +type RetentionPolicyParameters struct { + Days *int32 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} + // Route is route resource type Route struct { autorest.Response `json:"-"` @@ -1664,6 +2271,83 @@ type Route struct { Etag *string `json:"etag,omitempty"` } +// RouteFilter is route Filter Resource. +type RouteFilter struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *RouteFilterPropertiesFormat `json:"properties,omitempty"` + Etag *string `json:"etag,omitempty"` +} + +// RouteFilterListResult is response for the ListRouteFilters API service call. +type RouteFilterListResult struct { + autorest.Response `json:"-"` + Value *[]RouteFilter `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// RouteFilterListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client RouteFilterListResult) RouteFilterListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// RouteFilterPropertiesFormat is route Filter Resource +type RouteFilterPropertiesFormat struct { + Rules *[]RouteFilterRule `json:"rules,omitempty"` + Peerings *[]ExpressRouteCircuitPeering `json:"peerings,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// RouteFilterRule is route Filter Rule Resource +type RouteFilterRule struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + *RouteFilterRulePropertiesFormat `json:"properties,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Etag *string `json:"etag,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// RouteFilterRuleListResult is response for the ListRouteFilterRules API +// service call +type RouteFilterRuleListResult struct { + autorest.Response `json:"-"` + Value *[]RouteFilterRule `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// RouteFilterRuleListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client RouteFilterRuleListResult) RouteFilterRuleListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// RouteFilterRulePropertiesFormat is route Filter Rule Resource +type RouteFilterRulePropertiesFormat struct { + Access Access `json:"access,omitempty"` + RouteFilterRuleType *string `json:"routeFilterRuleType,omitempty"` + Communities *[]string `json:"communities,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} + // RouteListResult is response for the ListRoute API service call type RouteListResult struct { autorest.Response `json:"-"` @@ -1761,6 +2445,13 @@ func (client SecurityGroupListResult) SecurityGroupListResultPreparer() (*http.R autorest.WithBaseURL(to.String(client.NextLink))) } +// SecurityGroupNetworkInterface is network interface and all its associated +// security rules. +type SecurityGroupNetworkInterface struct { + ID *string `json:"id,omitempty"` + SecurityRuleAssociations *SecurityRuleAssociations `json:"securityRuleAssociations,omitempty"` +} + // SecurityGroupPropertiesFormat is network Security Group resource. type SecurityGroupPropertiesFormat struct { SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` @@ -1771,6 +2462,19 @@ type SecurityGroupPropertiesFormat struct { ProvisioningState *string `json:"provisioningState,omitempty"` } +// SecurityGroupViewParameters is parameters that define the VM to check +// security groups for. +type SecurityGroupViewParameters struct { + TargetResourceID *string `json:"targetResourceId,omitempty"` +} + +// SecurityGroupViewResult is the information about security rules applied to +// the specified VM. +type SecurityGroupViewResult struct { + autorest.Response `json:"-"` + NetworkInterfaces *[]SecurityGroupNetworkInterface `json:"networkInterfaces,omitempty"` +} + // SecurityRule is network security rule. type SecurityRule struct { autorest.Response `json:"-"` @@ -1780,6 +2484,15 @@ type SecurityRule struct { Etag *string `json:"etag,omitempty"` } +// SecurityRuleAssociations is all security rules associated with the network +// interface. +type SecurityRuleAssociations struct { + NetworkInterfaceAssociation *InterfaceAssociation `json:"networkInterfaceAssociation,omitempty"` + SubnetAssociation *SubnetAssociation `json:"subnetAssociation,omitempty"` + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + EffectiveSecurityRules *[]EffectiveNetworkSecurityRule `json:"effectiveSecurityRules,omitempty"` +} + // SecurityRuleListResult is response for ListSecurityRule API service call. // Retrieves all security rules that belongs to a network security group. type SecurityRuleListResult struct { @@ -1829,6 +2542,12 @@ type Subnet struct { Etag *string `json:"etag,omitempty"` } +// SubnetAssociation is network interface and its custom security rules. +type SubnetAssociation struct { + ID *string `json:"id,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` +} + // SubnetListResult is response for ListSubnets API service callRetrieves all // subnet that belongs to a virtual network type SubnetListResult struct { @@ -1864,6 +2583,79 @@ type SubResource struct { ID *string `json:"id,omitempty"` } +// Topology is topology of the specified resource group. +type Topology struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + CreatedDateTime *date.Time `json:"createdDateTime,omitempty"` + LastModified *date.Time `json:"lastModified,omitempty"` + Resources *[]TopologyResource `json:"resources,omitempty"` +} + +// TopologyAssociation is resources that have an association with the parent +// resource. +type TopologyAssociation struct { + Name *string `json:"name,omitempty"` + ResourceID *string `json:"resourceId,omitempty"` + AssociationType AssociationType `json:"associationType,omitempty"` +} + +// TopologyParameters is parameters that define the representation of topology. +type TopologyParameters struct { + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` +} + +// TopologyResource is the network resource topology information for the given +// resource group. +type TopologyResource struct { + Name *string `json:"name,omitempty"` + ID *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Associations *[]TopologyAssociation `json:"associations,omitempty"` +} + +// TroubleshootingDetails is information gained from troubleshooting of +// specified resource. +type TroubleshootingDetails struct { + ID *string `json:"id,omitempty"` + ReasonType *string `json:"reasonType,omitempty"` + Summary *string `json:"summary,omitempty"` + Detail *string `json:"detail,omitempty"` + RecommendedActions *[]TroubleshootingRecommendedActions `json:"recommendedActions,omitempty"` +} + +// TroubleshootingParameters is parameters that define the resource to +// troubleshoot. +type TroubleshootingParameters struct { + TargetResourceID *string `json:"targetResourceId,omitempty"` + *TroubleshootingProperties `json:"properties,omitempty"` +} + +// TroubleshootingProperties is storage location provided for troubleshoot. +type TroubleshootingProperties struct { + StorageID *string `json:"storageId,omitempty"` + StoragePath *string `json:"storagePath,omitempty"` +} + +// TroubleshootingRecommendedActions is recommended actions based on discovered +// issues. +type TroubleshootingRecommendedActions struct { + ActionID *string `json:"actionId,omitempty"` + ActionText *string `json:"actionText,omitempty"` + ActionURI *string `json:"actionUri,omitempty"` + ActionURIText *string `json:"actionUriText,omitempty"` +} + +// TroubleshootingResult is troubleshooting information gained from specified +// resource. +type TroubleshootingResult struct { + autorest.Response `json:"-"` + StartTime *date.Time `json:"startTime,omitempty"` + EndTime *date.Time `json:"endTime,omitempty"` + Code *string `json:"code,omitempty"` + Results *[]TroubleshootingDetails `json:"results,omitempty"` +} + // TunnelConnectionHealth is virtualNetworkGatewayConnection properties type TunnelConnectionHealth struct { Tunnel *string `json:"tunnel,omitempty"` @@ -1906,6 +2698,27 @@ func (client UsagesListResult) UsagesListResultPreparer() (*http.Request, error) autorest.WithBaseURL(to.String(client.NextLink))) } +// VerificationIPFlowParameters is parameters that define the IP flow to be +// verified. +type VerificationIPFlowParameters struct { + TargetResourceID *string `json:"targetResourceId,omitempty"` + Direction Direction `json:"direction,omitempty"` + Protocol Protocol `json:"protocol,omitempty"` + LocalPort *string `json:"localPort,omitempty"` + RemotePort *string `json:"remotePort,omitempty"` + LocalIPAddress *string `json:"localIPAddress,omitempty"` + RemoteIPAddress *string `json:"remoteIPAddress,omitempty"` + TargetNicResourceID *string `json:"targetNicResourceId,omitempty"` +} + +// VerificationIPFlowResult is results of IP flow verification on the target +// resource. +type VerificationIPFlowResult struct { + autorest.Response `json:"-"` + Access Access `json:"access,omitempty"` + RuleName *string `json:"ruleName,omitempty"` +} + // VirtualNetwork is virtual Network resource. type VirtualNetwork struct { autorest.Response `json:"-"` @@ -1966,25 +2779,27 @@ func (client VirtualNetworkGatewayConnectionListResult) VirtualNetworkGatewayCon // VirtualNetworkGatewayConnectionPropertiesFormat is // virtualNetworkGatewayConnection properties type VirtualNetworkGatewayConnectionPropertiesFormat struct { - AuthorizationKey *string `json:"authorizationKey,omitempty"` - VirtualNetworkGateway1 *VirtualNetworkGateway `json:"virtualNetworkGateway1,omitempty"` - VirtualNetworkGateway2 *VirtualNetworkGateway `json:"virtualNetworkGateway2,omitempty"` - LocalNetworkGateway2 *LocalNetworkGateway `json:"localNetworkGateway2,omitempty"` - ConnectionType VirtualNetworkGatewayConnectionType `json:"connectionType,omitempty"` - RoutingWeight *int32 `json:"routingWeight,omitempty"` - SharedKey *string `json:"sharedKey,omitempty"` - ConnectionStatus VirtualNetworkGatewayConnectionStatus `json:"connectionStatus,omitempty"` - TunnelConnectionStatus *[]TunnelConnectionHealth `json:"tunnelConnectionStatus,omitempty"` - EgressBytesTransferred *int64 `json:"egressBytesTransferred,omitempty"` - IngressBytesTransferred *int64 `json:"ingressBytesTransferred,omitempty"` - Peer *SubResource `json:"peer,omitempty"` - EnableBgp *bool `json:"enableBgp,omitempty"` - ResourceGUID *string `json:"resourceGuid,omitempty"` - ProvisioningState *string `json:"provisioningState,omitempty"` + AuthorizationKey *string `json:"authorizationKey,omitempty"` + VirtualNetworkGateway1 *VirtualNetworkGateway `json:"virtualNetworkGateway1,omitempty"` + VirtualNetworkGateway2 *VirtualNetworkGateway `json:"virtualNetworkGateway2,omitempty"` + LocalNetworkGateway2 *LocalNetworkGateway `json:"localNetworkGateway2,omitempty"` + ConnectionType VirtualNetworkGatewayConnectionType `json:"connectionType,omitempty"` + RoutingWeight *int32 `json:"routingWeight,omitempty"` + SharedKey *string `json:"sharedKey,omitempty"` + ConnectionStatus VirtualNetworkGatewayConnectionStatus `json:"connectionStatus,omitempty"` + TunnelConnectionStatus *[]TunnelConnectionHealth `json:"tunnelConnectionStatus,omitempty"` + EgressBytesTransferred *int64 `json:"egressBytesTransferred,omitempty"` + IngressBytesTransferred *int64 `json:"ingressBytesTransferred,omitempty"` + Peer *SubResource `json:"peer,omitempty"` + EnableBgp *bool `json:"enableBgp,omitempty"` + UsePolicyBasedTrafficSelectors *bool `json:"usePolicyBasedTrafficSelectors,omitempty"` + IpsecPolicies *[]IpsecPolicy `json:"ipsecPolicies,omitempty"` + ResourceGUID *string `json:"resourceGuid,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` } -// VirtualNetworkGatewayIPConfiguration is iP configuration for virtual -// network gateway +// VirtualNetworkGatewayIPConfiguration is iP configuration for virtual network +// gateway type VirtualNetworkGatewayIPConfiguration struct { ID *string `json:"id,omitempty"` *VirtualNetworkGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` @@ -2043,8 +2858,8 @@ type VirtualNetworkGatewaySku struct { Capacity *int32 `json:"capacity,omitempty"` } -// VirtualNetworkListResult is response for the ListVirtualNetworks API -// service call. +// VirtualNetworkListResult is response for the ListVirtualNetworks API service +// call. type VirtualNetworkListResult struct { autorest.Response `json:"-"` Value *[]VirtualNetwork `json:"value,omitempty"` @@ -2120,9 +2935,9 @@ type VpnClientConfiguration struct { VpnClientRevokedCertificates *[]VpnClientRevokedCertificate `json:"vpnClientRevokedCertificates,omitempty"` } -// VpnClientParameters is vpnClientParameters +// VpnClientParameters is vpn Client Parameters for package generation type VpnClientParameters struct { - ProcessorArchitecture ProcessorArchitecture `json:"ProcessorArchitecture,omitempty"` + ProcessorArchitecture ProcessorArchitecture `json:"processorArchitecture,omitempty"` } // VpnClientRevokedCertificate is vPN client revoked certificate of virtual @@ -2134,8 +2949,8 @@ type VpnClientRevokedCertificate struct { Etag *string `json:"etag,omitempty"` } -// VpnClientRevokedCertificatePropertiesFormat is properties of the revoked -// VPN client certificate of virtual network gateway. +// VpnClientRevokedCertificatePropertiesFormat is properties of the revoked VPN +// client certificate of virtual network gateway. type VpnClientRevokedCertificatePropertiesFormat struct { Thumbprint *string `json:"thumbprint,omitempty"` ProvisioningState *string `json:"provisioningState,omitempty"` @@ -2156,3 +2971,26 @@ type VpnClientRootCertificatePropertiesFormat struct { PublicCertData *string `json:"publicCertData,omitempty"` ProvisioningState *string `json:"provisioningState,omitempty"` } + +// Watcher is network watcher in a resource group. +type Watcher struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + Etag *string `json:"etag,omitempty"` + *WatcherPropertiesFormat `json:"properties,omitempty"` +} + +// WatcherListResult is list of network watcher resources. +type WatcherListResult struct { + autorest.Response `json:"-"` + Value *[]Watcher `json:"value,omitempty"` +} + +// WatcherPropertiesFormat is the network watcher properties. +type WatcherPropertiesFormat struct { + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/packetcaptures.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/packetcaptures.go new file mode 100755 index 000000000..fbeb0d9ef --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/packetcaptures.go @@ -0,0 +1,526 @@ +package network + +// 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// PacketCapturesClient is the composite Swagger for Network Client +type PacketCapturesClient struct { + ManagementClient +} + +// NewPacketCapturesClient creates an instance of the PacketCapturesClient +// client. +func NewPacketCapturesClient(subscriptionID string) PacketCapturesClient { + return NewPacketCapturesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPacketCapturesClientWithBaseURI creates an instance of the +// PacketCapturesClient client. +func NewPacketCapturesClientWithBaseURI(baseURI string, subscriptionID string) PacketCapturesClient { + return PacketCapturesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create and start a packet capture on the specified VM. This method +// may poll for completion. Polling can be canceled by passing the cancel +// channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. networkWatcherName is +// the name of the network watcher. packetCaptureName is the name of the packet +// capture session. parameters is parameters that define the create packet +// capture operation. +func (client PacketCapturesClient) Create(resourceGroupName string, networkWatcherName string, packetCaptureName string, parameters PacketCapture, cancel <-chan struct{}) (<-chan PacketCaptureResult, <-chan error) { + resultChan := make(chan PacketCaptureResult, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.PacketCaptureParameters", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.PacketCaptureParameters.Target", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.PacketCaptureParameters.StorageLocation", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "network.PacketCapturesClient", "Create") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result PacketCaptureResult + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(resourceGroupName, networkWatcherName, packetCaptureName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreatePreparer prepares the Create request. +func (client PacketCapturesClient) CreatePreparer(resourceGroupName string, networkWatcherName string, packetCaptureName string, parameters PacketCapture, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "networkWatcherName": autorest.Encode("path", networkWatcherName), + "packetCaptureName": autorest.Encode("path", packetCaptureName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/packetCaptures/{packetCaptureName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client PacketCapturesClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client PacketCapturesClient) CreateResponder(resp *http.Response) (result PacketCaptureResult, 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 deletes the specified packet capture session. This method may poll +// for completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. +// +// resourceGroupName is the name of the resource group. networkWatcherName is +// the name of the network watcher. packetCaptureName is the name of the packet +// capture session. +func (client PacketCapturesClient) Delete(resourceGroupName string, networkWatcherName string, packetCaptureName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, networkWatcherName, packetCaptureName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client PacketCapturesClient) DeletePreparer(resourceGroupName string, networkWatcherName string, packetCaptureName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "networkWatcherName": autorest.Encode("path", networkWatcherName), + "packetCaptureName": autorest.Encode("path", packetCaptureName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/packetCaptures/{packetCaptureName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PacketCapturesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PacketCapturesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a packet capture session by name. +// +// resourceGroupName is the name of the resource group. networkWatcherName is +// the name of the network watcher. packetCaptureName is the name of the packet +// capture session. +func (client PacketCapturesClient) Get(resourceGroupName string, networkWatcherName string, packetCaptureName string) (result PacketCaptureResult, err error) { + req, err := client.GetPreparer(resourceGroupName, networkWatcherName, packetCaptureName) + if err != nil { + err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client PacketCapturesClient) GetPreparer(resourceGroupName string, networkWatcherName string, packetCaptureName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "networkWatcherName": autorest.Encode("path", networkWatcherName), + "packetCaptureName": autorest.Encode("path", packetCaptureName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/packetCaptures/{packetCaptureName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PacketCapturesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PacketCapturesClient) GetResponder(resp *http.Response) (result PacketCaptureResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetStatus query the status of a running packet capture session. This method +// may poll for completion. Polling can be canceled by passing the cancel +// channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. networkWatcherName is +// the name of the Network Watcher resource. packetCaptureName is the name +// given to the packet capture session. +func (client PacketCapturesClient) GetStatus(resourceGroupName string, networkWatcherName string, packetCaptureName string, cancel <-chan struct{}) (<-chan PacketCaptureQueryStatusResult, <-chan error) { + resultChan := make(chan PacketCaptureQueryStatusResult, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result PacketCaptureQueryStatusResult + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.GetStatusPreparer(resourceGroupName, networkWatcherName, packetCaptureName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "GetStatus", nil, "Failure preparing request") + return + } + + resp, err := client.GetStatusSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "GetStatus", resp, "Failure sending request") + return + } + + result, err = client.GetStatusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "GetStatus", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// GetStatusPreparer prepares the GetStatus request. +func (client PacketCapturesClient) GetStatusPreparer(resourceGroupName string, networkWatcherName string, packetCaptureName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "networkWatcherName": autorest.Encode("path", networkWatcherName), + "packetCaptureName": autorest.Encode("path", packetCaptureName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/packetCaptures/{packetCaptureName}/queryStatus", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// GetStatusSender sends the GetStatus request. The method will close the +// http.Response Body if it receives an error. +func (client PacketCapturesClient) GetStatusSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// GetStatusResponder handles the response to the GetStatus request. The method always +// closes the http.Response Body. +func (client PacketCapturesClient) GetStatusResponder(resp *http.Response) (result PacketCaptureQueryStatusResult, 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 +} + +// List lists all packet capture sessions within the specified resource group. +// +// resourceGroupName is the name of the resource group. networkWatcherName is +// the name of the Network Watcher resource. +func (client PacketCapturesClient) List(resourceGroupName string, networkWatcherName string) (result PacketCaptureListResult, err error) { + req, err := client.ListPreparer(resourceGroupName, networkWatcherName) + if err != nil { + err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client PacketCapturesClient) ListPreparer(resourceGroupName string, networkWatcherName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "networkWatcherName": autorest.Encode("path", networkWatcherName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/packetCaptures", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client PacketCapturesClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client PacketCapturesClient) ListResponder(resp *http.Response) (result PacketCaptureListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Stop stops a specified packet capture session. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// resourceGroupName is the name of the resource group. networkWatcherName is +// the name of the network watcher. packetCaptureName is the name of the packet +// capture session. +func (client PacketCapturesClient) Stop(resourceGroupName string, networkWatcherName string, packetCaptureName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.StopPreparer(resourceGroupName, networkWatcherName, packetCaptureName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "Stop", nil, "Failure preparing request") + return + } + + resp, err := client.StopSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "Stop", resp, "Failure sending request") + return + } + + result, err = client.StopResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "Stop", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// StopPreparer prepares the Stop request. +func (client PacketCapturesClient) StopPreparer(resourceGroupName string, networkWatcherName string, packetCaptureName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "networkWatcherName": autorest.Encode("path", networkWatcherName), + "packetCaptureName": autorest.Encode("path", packetCaptureName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/packetCaptures/{packetCaptureName}/stop", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// StopSender sends the Stop request. The method will close the +// http.Response Body if it receives an error. +func (client PacketCapturesClient) StopSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// StopResponder handles the response to the Stop request. The method always +// closes the http.Response Body. +func (client PacketCapturesClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/publicipaddresses.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/publicipaddresses.go old mode 100644 new mode 100755 index a117fedcb..896bc817d --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/publicipaddresses.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/publicipaddresses.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -25,11 +25,7 @@ import ( "net/http" ) -// PublicIPAddressesClient is the the Microsoft Azure Network management API -// provides a RESTful set of web services that interact with Microsoft Azure -// Networks service to manage your network resources. The API has entities -// that capture the relationship between an end user and the Microsoft Azure -// Networks service. +// PublicIPAddressesClient is the composite Swagger for Network Client type PublicIPAddressesClient struct { ManagementClient } @@ -47,14 +43,16 @@ func NewPublicIPAddressesClientWithBaseURI(baseURI string, subscriptionID string } // CreateOrUpdate creates or updates a static or dynamic public IP address. -// This method may poll for completion. Polling can be canceled by passing -// the cancel channel argument. The channel will be used to cancel polling -// and any outstanding HTTP requests. +// This method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. // // resourceGroupName is the name of the resource group. publicIPAddressName is -// the name of the public IP address. parameters is parameters supplied to -// the create or update public IP address operation. -func (client PublicIPAddressesClient) CreateOrUpdate(resourceGroupName string, publicIPAddressName string, parameters PublicIPAddress, cancel <-chan struct{}) (result autorest.Response, err error) { +// the name of the public IP address. parameters is parameters supplied to the +// create or update public IP address operation. +func (client PublicIPAddressesClient) CreateOrUpdate(resourceGroupName string, publicIPAddressName string, parameters PublicIPAddress, cancel <-chan struct{}) (<-chan PublicIPAddress, <-chan error) { + resultChan := make(chan PublicIPAddress, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.PublicIPAddressPropertiesFormat", Name: validation.Null, Rule: false, @@ -63,26 +61,40 @@ func (client PublicIPAddressesClient) CreateOrUpdate(resourceGroupName string, p Chain: []validation.Constraint{{Target: "parameters.PublicIPAddressPropertiesFormat.IPConfiguration.IPConfigurationPropertiesFormat.PublicIPAddress", Name: validation.Null, Rule: false, Chain: nil}}}, }}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "network.PublicIPAddressesClient", "CreateOrUpdate") + errChan <- validation.NewErrorWithValidationError(err, "network.PublicIPAddressesClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, publicIPAddressName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "CreateOrUpdate", nil, "Failure preparing request") - } + go func() { + var err error + var result PublicIPAddress + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, publicIPAddressName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -93,8 +105,9 @@ func (client PublicIPAddressesClient) CreateOrUpdatePreparer(resourceGroupName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -117,41 +130,55 @@ func (client PublicIPAddressesClient) CreateOrUpdateSender(req *http.Request) (* // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client PublicIPAddressesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client PublicIPAddressesClient) CreateOrUpdateResponder(resp *http.Response) (result PublicIPAddress, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } // Delete deletes the specified public IP address. This method may poll for -// completion. Polling can be canceled by passing the cancel channel -// argument. The channel will be used to cancel polling and any outstanding -// HTTP requests. +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. // // resourceGroupName is the name of the resource group. publicIPAddressName is // the name of the subnet. -func (client PublicIPAddressesClient) Delete(resourceGroupName string, publicIPAddressName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, publicIPAddressName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Delete", nil, "Failure preparing request") - } +func (client PublicIPAddressesClient) Delete(resourceGroupName string, publicIPAddressName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, publicIPAddressName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -162,8 +189,9 @@ func (client PublicIPAddressesClient) DeletePreparer(resourceGroupName string, p "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -201,13 +229,15 @@ func (client PublicIPAddressesClient) DeleteResponder(resp *http.Response) (resu func (client PublicIPAddressesClient) Get(resourceGroupName string, publicIPAddressName string, expand string) (result PublicIPAddress, err error) { req, err := client.GetPreparer(resourceGroupName, publicIPAddressName, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -226,8 +256,9 @@ func (client PublicIPAddressesClient) GetPreparer(resourceGroupName string, publ "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(expand) > 0 { queryParameters["$expand"] = autorest.Encode("query", expand) @@ -266,13 +297,15 @@ func (client PublicIPAddressesClient) GetResponder(resp *http.Response) (result func (client PublicIPAddressesClient) List(resourceGroupName string) (result PublicIPAddressListResult, err error) { req, err := client.ListPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -290,8 +323,9 @@ func (client PublicIPAddressesClient) ListPreparer(resourceGroupName string) (*h "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -349,13 +383,15 @@ func (client PublicIPAddressesClient) ListNextResults(lastResults PublicIPAddres func (client PublicIPAddressesClient) ListAll() (result PublicIPAddressListResult, err error) { req, err := client.ListAllPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "ListAll", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "ListAll", nil, "Failure preparing request") + return } resp, err := client.ListAllSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "ListAll", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "ListAll", resp, "Failure sending request") + return } result, err = client.ListAllResponder(resp) @@ -372,8 +408,9 @@ func (client PublicIPAddressesClient) ListAllPreparer() (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routefilterrules.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routefilterrules.go new file mode 100755 index 000000000..378a75bb2 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routefilterrules.go @@ -0,0 +1,468 @@ +package network + +// 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// RouteFilterRulesClient is the composite Swagger for Network Client +type RouteFilterRulesClient struct { + ManagementClient +} + +// NewRouteFilterRulesClient creates an instance of the RouteFilterRulesClient +// client. +func NewRouteFilterRulesClient(subscriptionID string) RouteFilterRulesClient { + return NewRouteFilterRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRouteFilterRulesClientWithBaseURI creates an instance of the +// RouteFilterRulesClient client. +func NewRouteFilterRulesClientWithBaseURI(baseURI string, subscriptionID string) RouteFilterRulesClient { + return RouteFilterRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a route in the specified route filter. +// This method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. routeFilterName is the +// name of the route filter. ruleName is the name of the route filter rule. +// routeFilterRuleParameters is parameters supplied to the create or update +// route filter rule operation. +func (client RouteFilterRulesClient) CreateOrUpdate(resourceGroupName string, routeFilterName string, ruleName string, routeFilterRuleParameters RouteFilterRule, cancel <-chan struct{}) (<-chan RouteFilterRule, <-chan error) { + resultChan := make(chan RouteFilterRule, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: routeFilterRuleParameters, + Constraints: []validation.Constraint{{Target: "routeFilterRuleParameters.RouteFilterRulePropertiesFormat", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "routeFilterRuleParameters.RouteFilterRulePropertiesFormat.RouteFilterRuleType", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "routeFilterRuleParameters.RouteFilterRulePropertiesFormat.Communities", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "network.RouteFilterRulesClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result RouteFilterRule + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, routeFilterName, ruleName, routeFilterRuleParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFilterRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.RouteFilterRulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFilterRulesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client RouteFilterRulesClient) CreateOrUpdatePreparer(resourceGroupName string, routeFilterName string, ruleName string, routeFilterRuleParameters RouteFilterRule, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "routeFilterName": autorest.Encode("path", routeFilterName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}/routeFilterRules/{ruleName}", pathParameters), + autorest.WithJSON(routeFilterRuleParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client RouteFilterRulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client RouteFilterRulesClient) CreateOrUpdateResponder(resp *http.Response) (result RouteFilterRule, 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 deletes the specified rule from a route filter. This method may poll +// for completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. +// +// resourceGroupName is the name of the resource group. routeFilterName is the +// name of the route filter. ruleName is the name of the rule. +func (client RouteFilterRulesClient) Delete(resourceGroupName string, routeFilterName string, ruleName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, routeFilterName, ruleName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFilterRulesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.RouteFilterRulesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFilterRulesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client RouteFilterRulesClient) DeletePreparer(resourceGroupName string, routeFilterName string, ruleName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "routeFilterName": autorest.Encode("path", routeFilterName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}/routeFilterRules/{ruleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client RouteFilterRulesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client RouteFilterRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the specified rule from a route filter. +// +// resourceGroupName is the name of the resource group. routeFilterName is the +// name of the route filter. ruleName is the name of the rule. +func (client RouteFilterRulesClient) Get(resourceGroupName string, routeFilterName string, ruleName string) (result RouteFilterRule, err error) { + req, err := client.GetPreparer(resourceGroupName, routeFilterName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFilterRulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.RouteFilterRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFilterRulesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RouteFilterRulesClient) GetPreparer(resourceGroupName string, routeFilterName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "routeFilterName": autorest.Encode("path", routeFilterName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}/routeFilterRules/{ruleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RouteFilterRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RouteFilterRulesClient) GetResponder(resp *http.Response) (result RouteFilterRule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByRouteFilter gets all RouteFilterRules in a route filter. +// +// resourceGroupName is the name of the resource group. routeFilterName is the +// name of the route filter. +func (client RouteFilterRulesClient) ListByRouteFilter(resourceGroupName string, routeFilterName string) (result RouteFilterRuleListResult, err error) { + req, err := client.ListByRouteFilterPreparer(resourceGroupName, routeFilterName) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFilterRulesClient", "ListByRouteFilter", nil, "Failure preparing request") + return + } + + resp, err := client.ListByRouteFilterSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.RouteFilterRulesClient", "ListByRouteFilter", resp, "Failure sending request") + return + } + + result, err = client.ListByRouteFilterResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFilterRulesClient", "ListByRouteFilter", resp, "Failure responding to request") + } + + return +} + +// ListByRouteFilterPreparer prepares the ListByRouteFilter request. +func (client RouteFilterRulesClient) ListByRouteFilterPreparer(resourceGroupName string, routeFilterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "routeFilterName": autorest.Encode("path", routeFilterName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}/routeFilterRules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByRouteFilterSender sends the ListByRouteFilter request. The method will close the +// http.Response Body if it receives an error. +func (client RouteFilterRulesClient) ListByRouteFilterSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByRouteFilterResponder handles the response to the ListByRouteFilter request. The method always +// closes the http.Response Body. +func (client RouteFilterRulesClient) ListByRouteFilterResponder(resp *http.Response) (result RouteFilterRuleListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByRouteFilterNextResults retrieves the next set of results, if any. +func (client RouteFilterRulesClient) ListByRouteFilterNextResults(lastResults RouteFilterRuleListResult) (result RouteFilterRuleListResult, err error) { + req, err := lastResults.RouteFilterRuleListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "network.RouteFilterRulesClient", "ListByRouteFilter", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByRouteFilterSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "network.RouteFilterRulesClient", "ListByRouteFilter", resp, "Failure sending next results request") + } + + result, err = client.ListByRouteFilterResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFilterRulesClient", "ListByRouteFilter", resp, "Failure responding to next results request") + } + + return +} + +// Update updates a route in the specified route filter. This method may poll +// for completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. +// +// resourceGroupName is the name of the resource group. routeFilterName is the +// name of the route filter. ruleName is the name of the route filter rule. +// routeFilterRuleParameters is parameters supplied to the update route filter +// rule operation. +func (client RouteFilterRulesClient) Update(resourceGroupName string, routeFilterName string, ruleName string, routeFilterRuleParameters PatchRouteFilterRule, cancel <-chan struct{}) (<-chan RouteFilterRule, <-chan error) { + resultChan := make(chan RouteFilterRule, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result RouteFilterRule + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.UpdatePreparer(resourceGroupName, routeFilterName, ruleName, routeFilterRuleParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFilterRulesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.RouteFilterRulesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFilterRulesClient", "Update", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// UpdatePreparer prepares the Update request. +func (client RouteFilterRulesClient) UpdatePreparer(resourceGroupName string, routeFilterName string, ruleName string, routeFilterRuleParameters PatchRouteFilterRule, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "routeFilterName": autorest.Encode("path", routeFilterName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}/routeFilterRules/{ruleName}", pathParameters), + autorest.WithJSON(routeFilterRuleParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client RouteFilterRulesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client RouteFilterRulesClient) UpdateResponder(resp *http.Response) (result RouteFilterRule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routefilters.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routefilters.go new file mode 100755 index 000000000..860ccae5c --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routefilters.go @@ -0,0 +1,535 @@ +package network + +// 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// RouteFiltersClient is the composite Swagger for Network Client +type RouteFiltersClient struct { + ManagementClient +} + +// NewRouteFiltersClient creates an instance of the RouteFiltersClient client. +func NewRouteFiltersClient(subscriptionID string) RouteFiltersClient { + return NewRouteFiltersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRouteFiltersClientWithBaseURI creates an instance of the +// RouteFiltersClient client. +func NewRouteFiltersClientWithBaseURI(baseURI string, subscriptionID string) RouteFiltersClient { + return RouteFiltersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a route filter in a specified resource +// group. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. routeFilterName is the +// name of the route filter. routeFilterParameters is parameters supplied to +// the create or update route filter operation. +func (client RouteFiltersClient) CreateOrUpdate(resourceGroupName string, routeFilterName string, routeFilterParameters RouteFilter, cancel <-chan struct{}) (<-chan RouteFilter, <-chan error) { + resultChan := make(chan RouteFilter, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result RouteFilter + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, routeFilterName, routeFilterParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFiltersClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.RouteFiltersClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFiltersClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client RouteFiltersClient) CreateOrUpdatePreparer(resourceGroupName string, routeFilterName string, routeFilterParameters RouteFilter, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "routeFilterName": autorest.Encode("path", routeFilterName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}", pathParameters), + autorest.WithJSON(routeFilterParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client RouteFiltersClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client RouteFiltersClient) CreateOrUpdateResponder(resp *http.Response) (result RouteFilter, 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 deletes the specified route filter. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// resourceGroupName is the name of the resource group. routeFilterName is the +// name of the route filter. +func (client RouteFiltersClient) Delete(resourceGroupName string, routeFilterName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, routeFilterName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFiltersClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.RouteFiltersClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFiltersClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client RouteFiltersClient) DeletePreparer(resourceGroupName string, routeFilterName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "routeFilterName": autorest.Encode("path", routeFilterName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client RouteFiltersClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client RouteFiltersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the specified route filter. +// +// resourceGroupName is the name of the resource group. routeFilterName is the +// name of the route filter. expand is expands referenced express route bgp +// peering resources. +func (client RouteFiltersClient) Get(resourceGroupName string, routeFilterName string, expand string) (result RouteFilter, err error) { + req, err := client.GetPreparer(resourceGroupName, routeFilterName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFiltersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.RouteFiltersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFiltersClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RouteFiltersClient) GetPreparer(resourceGroupName string, routeFilterName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "routeFilterName": autorest.Encode("path", routeFilterName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RouteFiltersClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RouteFiltersClient) GetResponder(resp *http.Response) (result RouteFilter, 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 gets all route filters in a subscription. +func (client RouteFiltersClient) List() (result RouteFilterListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFiltersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.RouteFiltersClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFiltersClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client RouteFiltersClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/routeFilters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client RouteFiltersClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RouteFiltersClient) ListResponder(resp *http.Response) (result RouteFilterListResult, 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 RouteFiltersClient) ListNextResults(lastResults RouteFilterListResult) (result RouteFilterListResult, err error) { + req, err := lastResults.RouteFilterListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "network.RouteFiltersClient", "List", 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, "network.RouteFiltersClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFiltersClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListByResourceGroup gets all route filters in a resource group. +// +// resourceGroupName is the name of the resource group. +func (client RouteFiltersClient) ListByResourceGroup(resourceGroupName string) (result RouteFilterListResult, err error) { + req, err := client.ListByResourceGroupPreparer(resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFiltersClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.RouteFiltersClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFiltersClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client RouteFiltersClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client RouteFiltersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client RouteFiltersClient) ListByResourceGroupResponder(resp *http.Response) (result RouteFilterListResult, 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 RouteFiltersClient) ListByResourceGroupNextResults(lastResults RouteFilterListResult) (result RouteFilterListResult, err error) { + req, err := lastResults.RouteFilterListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "network.RouteFiltersClient", "ListByResourceGroup", 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, "network.RouteFiltersClient", "ListByResourceGroup", resp, "Failure sending next results request") + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFiltersClient", "ListByResourceGroup", resp, "Failure responding to next results request") + } + + return +} + +// Update updates a route filter in a specified resource group. This method may +// poll for completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. +// +// resourceGroupName is the name of the resource group. routeFilterName is the +// name of the route filter. routeFilterParameters is parameters supplied to +// the update route filter operation. +func (client RouteFiltersClient) Update(resourceGroupName string, routeFilterName string, routeFilterParameters PatchRouteFilter, cancel <-chan struct{}) (<-chan RouteFilter, <-chan error) { + resultChan := make(chan RouteFilter, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result RouteFilter + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.UpdatePreparer(resourceGroupName, routeFilterName, routeFilterParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFiltersClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.RouteFiltersClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteFiltersClient", "Update", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// UpdatePreparer prepares the Update request. +func (client RouteFiltersClient) UpdatePreparer(resourceGroupName string, routeFilterName string, routeFilterParameters PatchRouteFilter, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "routeFilterName": autorest.Encode("path", routeFilterName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}", pathParameters), + autorest.WithJSON(routeFilterParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client RouteFiltersClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client RouteFiltersClient) UpdateResponder(resp *http.Response) (result RouteFilter, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routes.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routes.go old mode 100644 new mode 100755 index 9aa1cf505..1366d3c14 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routes.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routes.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -24,11 +24,7 @@ import ( "net/http" ) -// RoutesClient is the the Microsoft Azure Network management API provides a -// RESTful set of web services that interact with Microsoft Azure Networks -// service to manage your network resources. The API has entities that -// capture the relationship between an end user and the Microsoft Azure -// Networks service. +// RoutesClient is the composite Swagger for Network Client type RoutesClient struct { ManagementClient } @@ -43,33 +39,45 @@ func NewRoutesClientWithBaseURI(baseURI string, subscriptionID string) RoutesCli return RoutesClient{NewWithBaseURI(baseURI, subscriptionID)} } -// CreateOrUpdate creates or updates a route in the specified route table. -// This method may poll for completion. Polling can be canceled by passing -// the cancel channel argument. The channel will be used to cancel polling -// and any outstanding HTTP requests. +// CreateOrUpdate creates or updates a route in the specified route table. This +// method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. // // resourceGroupName is the name of the resource group. routeTableName is the -// name of the route table. routeName is the name of the route. -// routeParameters is parameters supplied to the create or update route -// operation. -func (client RoutesClient) CreateOrUpdate(resourceGroupName string, routeTableName string, routeName string, routeParameters Route, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateOrUpdatePreparer(resourceGroupName, routeTableName, routeName, routeParameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.RoutesClient", "CreateOrUpdate", nil, "Failure preparing request") - } +// name of the route table. routeName is the name of the route. routeParameters +// is parameters supplied to the create or update route operation. +func (client RoutesClient) CreateOrUpdate(resourceGroupName string, routeTableName string, routeName string, routeParameters Route, cancel <-chan struct{}) (<-chan Route, <-chan error) { + resultChan := make(chan Route, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result Route + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, routeTableName, routeName, routeParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RoutesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.RoutesClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.RoutesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.RoutesClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RoutesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -81,8 +89,9 @@ func (client RoutesClient) CreateOrUpdatePreparer(resourceGroupName string, rout "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -105,13 +114,14 @@ func (client RoutesClient) CreateOrUpdateSender(req *http.Request) (*http.Respon // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client RoutesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client RoutesClient) CreateOrUpdateResponder(resp *http.Response) (result Route, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -122,24 +132,37 @@ func (client RoutesClient) CreateOrUpdateResponder(resp *http.Response) (result // // resourceGroupName is the name of the resource group. routeTableName is the // name of the route table. routeName is the name of the route. -func (client RoutesClient) Delete(resourceGroupName string, routeTableName string, routeName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, routeTableName, routeName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.RoutesClient", "Delete", nil, "Failure preparing request") - } +func (client RoutesClient) Delete(resourceGroupName string, routeTableName string, routeName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, routeTableName, routeName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RoutesClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.RoutesClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.RoutesClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.RoutesClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RoutesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -151,8 +174,9 @@ func (client RoutesClient) DeletePreparer(resourceGroupName string, routeTableNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -190,13 +214,15 @@ func (client RoutesClient) DeleteResponder(resp *http.Response) (result autorest func (client RoutesClient) Get(resourceGroupName string, routeTableName string, routeName string) (result Route, err error) { req, err := client.GetPreparer(resourceGroupName, routeTableName, routeName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.RoutesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.RoutesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.RoutesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.RoutesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -216,8 +242,9 @@ func (client RoutesClient) GetPreparer(resourceGroupName string, routeTableName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -254,13 +281,15 @@ func (client RoutesClient) GetResponder(resp *http.Response) (result Route, err func (client RoutesClient) List(resourceGroupName string, routeTableName string) (result RouteListResult, err error) { req, err := client.ListPreparer(resourceGroupName, routeTableName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.RoutesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.RoutesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.RoutesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.RoutesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -279,8 +308,9 @@ func (client RoutesClient) ListPreparer(resourceGroupName string, routeTableName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routetables.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routetables.go old mode 100644 new mode 100755 index 2f3a1be1d..80339f207 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routetables.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routetables.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -24,11 +24,7 @@ import ( "net/http" ) -// RouteTablesClient is the the Microsoft Azure Network management API -// provides a RESTful set of web services that interact with Microsoft Azure -// Networks service to manage your network resources. The API has entities -// that capture the relationship between an end user and the Microsoft Azure -// Networks service. +// RouteTablesClient is the composite Swagger for Network Client type RouteTablesClient struct { ManagementClient } @@ -38,8 +34,8 @@ func NewRouteTablesClient(subscriptionID string) RouteTablesClient { return NewRouteTablesClientWithBaseURI(DefaultBaseURI, subscriptionID) } -// NewRouteTablesClientWithBaseURI creates an instance of the -// RouteTablesClient client. +// NewRouteTablesClientWithBaseURI creates an instance of the RouteTablesClient +// client. func NewRouteTablesClientWithBaseURI(baseURI string, subscriptionID string) RouteTablesClient { return RouteTablesClient{NewWithBaseURI(baseURI, subscriptionID)} } @@ -50,26 +46,39 @@ func NewRouteTablesClientWithBaseURI(baseURI string, subscriptionID string) Rout // polling and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group. routeTableName is the -// name of the route table. parameters is parameters supplied to the create -// or update route table operation. -func (client RouteTablesClient) CreateOrUpdate(resourceGroupName string, routeTableName string, parameters RouteTable, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateOrUpdatePreparer(resourceGroupName, routeTableName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "CreateOrUpdate", nil, "Failure preparing request") - } +// name of the route table. parameters is parameters supplied to the create or +// update route table operation. +func (client RouteTablesClient) CreateOrUpdate(resourceGroupName string, routeTableName string, parameters RouteTable, cancel <-chan struct{}) (<-chan RouteTable, <-chan error) { + resultChan := make(chan RouteTable, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result RouteTable + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, routeTableName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -80,8 +89,9 @@ func (client RouteTablesClient) CreateOrUpdatePreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -104,41 +114,55 @@ func (client RouteTablesClient) CreateOrUpdateSender(req *http.Request) (*http.R // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client RouteTablesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client RouteTablesClient) CreateOrUpdateResponder(resp *http.Response) (result RouteTable, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } // Delete deletes the specified route table. This method may poll for -// completion. Polling can be canceled by passing the cancel channel -// argument. The channel will be used to cancel polling and any outstanding -// HTTP requests. +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. // // resourceGroupName is the name of the resource group. routeTableName is the // name of the route table. -func (client RouteTablesClient) Delete(resourceGroupName string, routeTableName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, routeTableName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "Delete", nil, "Failure preparing request") - } +func (client RouteTablesClient) Delete(resourceGroupName string, routeTableName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, routeTableName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -149,8 +173,9 @@ func (client RouteTablesClient) DeletePreparer(resourceGroupName string, routeTa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -188,13 +213,15 @@ func (client RouteTablesClient) DeleteResponder(resp *http.Response) (result aut func (client RouteTablesClient) Get(resourceGroupName string, routeTableName string, expand string) (result RouteTable, err error) { req, err := client.GetPreparer(resourceGroupName, routeTableName, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -213,8 +240,9 @@ func (client RouteTablesClient) GetPreparer(resourceGroupName string, routeTable "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(expand) > 0 { queryParameters["$expand"] = autorest.Encode("query", expand) @@ -253,13 +281,15 @@ func (client RouteTablesClient) GetResponder(resp *http.Response) (result RouteT func (client RouteTablesClient) List(resourceGroupName string) (result RouteTableListResult, err error) { req, err := client.ListPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -277,8 +307,9 @@ func (client RouteTablesClient) ListPreparer(resourceGroupName string) (*http.Re "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -336,13 +367,15 @@ func (client RouteTablesClient) ListNextResults(lastResults RouteTableListResult func (client RouteTablesClient) ListAll() (result RouteTableListResult, err error) { req, err := client.ListAllPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "ListAll", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "ListAll", nil, "Failure preparing request") + return } resp, err := client.ListAllSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "ListAll", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "ListAll", resp, "Failure sending request") + return } result, err = client.ListAllResponder(resp) @@ -359,8 +392,9 @@ func (client RouteTablesClient) ListAllPreparer() (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/securitygroups.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/securitygroups.go old mode 100644 new mode 100755 index 4f05c4b23..3faaf007f --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/securitygroups.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/securitygroups.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -24,11 +24,7 @@ import ( "net/http" ) -// SecurityGroupsClient is the the Microsoft Azure Network management API -// provides a RESTful set of web services that interact with Microsoft Azure -// Networks service to manage your network resources. The API has entities -// that capture the relationship between an end user and the Microsoft Azure -// Networks service. +// SecurityGroupsClient is the composite Swagger for Network Client type SecurityGroupsClient struct { ManagementClient } @@ -46,32 +42,45 @@ func NewSecurityGroupsClientWithBaseURI(baseURI string, subscriptionID string) S } // CreateOrUpdate creates or updates a network security group in the specified -// resource group. This method may poll for completion. Polling can be -// canceled by passing the cancel channel argument. The channel will be used -// to cancel polling and any outstanding HTTP requests. +// resource group. This method may poll for completion. Polling can be canceled +// by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group. // networkSecurityGroupName is the name of the network security group. // parameters is parameters supplied to the create or update network security // group operation. -func (client SecurityGroupsClient) CreateOrUpdate(resourceGroupName string, networkSecurityGroupName string, parameters SecurityGroup, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateOrUpdatePreparer(resourceGroupName, networkSecurityGroupName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") - } +func (client SecurityGroupsClient) CreateOrUpdate(resourceGroupName string, networkSecurityGroupName string, parameters SecurityGroup, cancel <-chan struct{}) (<-chan SecurityGroup, <-chan error) { + resultChan := make(chan SecurityGroup, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result SecurityGroup + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, networkSecurityGroupName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -82,8 +91,9 @@ func (client SecurityGroupsClient) CreateOrUpdatePreparer(resourceGroupName stri "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -106,13 +116,14 @@ func (client SecurityGroupsClient) CreateOrUpdateSender(req *http.Request) (*htt // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client SecurityGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client SecurityGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result SecurityGroup, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -123,24 +134,37 @@ func (client SecurityGroupsClient) CreateOrUpdateResponder(resp *http.Response) // // resourceGroupName is the name of the resource group. // networkSecurityGroupName is the name of the network security group. -func (client SecurityGroupsClient) Delete(resourceGroupName string, networkSecurityGroupName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, networkSecurityGroupName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Delete", nil, "Failure preparing request") - } +func (client SecurityGroupsClient) Delete(resourceGroupName string, networkSecurityGroupName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, networkSecurityGroupName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -151,8 +175,9 @@ func (client SecurityGroupsClient) DeletePreparer(resourceGroupName string, netw "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -191,13 +216,15 @@ func (client SecurityGroupsClient) DeleteResponder(resp *http.Response) (result func (client SecurityGroupsClient) Get(resourceGroupName string, networkSecurityGroupName string, expand string) (result SecurityGroup, err error) { req, err := client.GetPreparer(resourceGroupName, networkSecurityGroupName, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -216,8 +243,9 @@ func (client SecurityGroupsClient) GetPreparer(resourceGroupName string, network "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(expand) > 0 { queryParameters["$expand"] = autorest.Encode("query", expand) @@ -256,13 +284,15 @@ func (client SecurityGroupsClient) GetResponder(resp *http.Response) (result Sec func (client SecurityGroupsClient) List(resourceGroupName string) (result SecurityGroupListResult, err error) { req, err := client.ListPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -280,8 +310,9 @@ func (client SecurityGroupsClient) ListPreparer(resourceGroupName string) (*http "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -339,13 +370,15 @@ func (client SecurityGroupsClient) ListNextResults(lastResults SecurityGroupList func (client SecurityGroupsClient) ListAll() (result SecurityGroupListResult, err error) { req, err := client.ListAllPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "ListAll", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "ListAll", nil, "Failure preparing request") + return } resp, err := client.ListAllSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "ListAll", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "ListAll", resp, "Failure sending request") + return } result, err = client.ListAllResponder(resp) @@ -362,8 +395,9 @@ func (client SecurityGroupsClient) ListAllPreparer() (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/securityrules.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/securityrules.go old mode 100644 new mode 100755 index 9603c3c1f..2e2738605 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/securityrules.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/securityrules.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -25,11 +25,7 @@ import ( "net/http" ) -// SecurityRulesClient is the the Microsoft Azure Network management API -// provides a RESTful set of web services that interact with Microsoft Azure -// Networks service to manage your network resources. The API has entities -// that capture the relationship between an end user and the Microsoft Azure -// Networks service. +// SecurityRulesClient is the composite Swagger for Network Client type SecurityRulesClient struct { ManagementClient } @@ -47,42 +43,57 @@ func NewSecurityRulesClientWithBaseURI(baseURI string, subscriptionID string) Se } // CreateOrUpdate creates or updates a security rule in the specified network -// security group. This method may poll for completion. Polling can be -// canceled by passing the cancel channel argument. The channel will be used -// to cancel polling and any outstanding HTTP requests. +// security group. This method may poll for completion. Polling can be canceled +// by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group. // networkSecurityGroupName is the name of the network security group. -// securityRuleName is the name of the security rule. securityRuleParameters -// is parameters supplied to the create or update network security rule -// operation. -func (client SecurityRulesClient) CreateOrUpdate(resourceGroupName string, networkSecurityGroupName string, securityRuleName string, securityRuleParameters SecurityRule, cancel <-chan struct{}) (result autorest.Response, err error) { +// securityRuleName is the name of the security rule. securityRuleParameters is +// parameters supplied to the create or update network security rule operation. +func (client SecurityRulesClient) CreateOrUpdate(resourceGroupName string, networkSecurityGroupName string, securityRuleName string, securityRuleParameters SecurityRule, cancel <-chan struct{}) (<-chan SecurityRule, <-chan error) { + resultChan := make(chan SecurityRule, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: securityRuleParameters, Constraints: []validation.Constraint{{Target: "securityRuleParameters.SecurityRulePropertiesFormat", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "securityRuleParameters.SecurityRulePropertiesFormat.SourceAddressPrefix", Name: validation.Null, Rule: true, Chain: nil}, {Target: "securityRuleParameters.SecurityRulePropertiesFormat.DestinationAddressPrefix", Name: validation.Null, Rule: true, Chain: nil}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "network.SecurityRulesClient", "CreateOrUpdate") + errChan <- validation.NewErrorWithValidationError(err, "network.SecurityRulesClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, networkSecurityGroupName, securityRuleName, securityRuleParameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "CreateOrUpdate", nil, "Failure preparing request") - } + go func() { + var err error + var result SecurityRule + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, networkSecurityGroupName, securityRuleName, securityRuleParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -94,8 +105,9 @@ func (client SecurityRulesClient) CreateOrUpdatePreparer(resourceGroupName strin "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -118,42 +130,56 @@ func (client SecurityRulesClient) CreateOrUpdateSender(req *http.Request) (*http // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client SecurityRulesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client SecurityRulesClient) CreateOrUpdateResponder(resp *http.Response) (result SecurityRule, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } -// Delete deletes the specified network security rule. This method may poll -// for completion. Polling can be canceled by passing the cancel channel -// argument. The channel will be used to cancel polling and any outstanding -// HTTP requests. +// Delete deletes the specified network security rule. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. // // resourceGroupName is the name of the resource group. // networkSecurityGroupName is the name of the network security group. // securityRuleName is the name of the security rule. -func (client SecurityRulesClient) Delete(resourceGroupName string, networkSecurityGroupName string, securityRuleName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, networkSecurityGroupName, securityRuleName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "Delete", nil, "Failure preparing request") - } +func (client SecurityRulesClient) Delete(resourceGroupName string, networkSecurityGroupName string, securityRuleName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, networkSecurityGroupName, securityRuleName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -165,8 +191,9 @@ func (client SecurityRulesClient) DeletePreparer(resourceGroupName string, netwo "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -205,13 +232,15 @@ func (client SecurityRulesClient) DeleteResponder(resp *http.Response) (result a func (client SecurityRulesClient) Get(resourceGroupName string, networkSecurityGroupName string, securityRuleName string) (result SecurityRule, err error) { req, err := client.GetPreparer(resourceGroupName, networkSecurityGroupName, securityRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -231,8 +260,9 @@ func (client SecurityRulesClient) GetPreparer(resourceGroupName string, networkS "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -269,13 +299,15 @@ func (client SecurityRulesClient) GetResponder(resp *http.Response) (result Secu func (client SecurityRulesClient) List(resourceGroupName string, networkSecurityGroupName string) (result SecurityRuleListResult, err error) { req, err := client.ListPreparer(resourceGroupName, networkSecurityGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -294,8 +326,9 @@ func (client SecurityRulesClient) ListPreparer(resourceGroupName string, network "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/subnets.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/subnets.go old mode 100644 new mode 100755 index 5114817a4..7d6ff882a --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/subnets.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/subnets.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -24,11 +24,7 @@ import ( "net/http" ) -// SubnetsClient is the the Microsoft Azure Network management API provides a -// RESTful set of web services that interact with Microsoft Azure Networks -// service to manage your network resources. The API has entities that -// capture the relationship between an end user and the Microsoft Azure -// Networks service. +// SubnetsClient is the composite Swagger for Network Client type SubnetsClient struct { ManagementClient } @@ -43,33 +39,46 @@ func NewSubnetsClientWithBaseURI(baseURI string, subscriptionID string) SubnetsC return SubnetsClient{NewWithBaseURI(baseURI, subscriptionID)} } -// CreateOrUpdate creates or updates a subnet in the specified virtual -// network. This method may poll for completion. Polling can be canceled by -// passing the cancel channel argument. The channel will be used to cancel -// polling and any outstanding HTTP requests. +// CreateOrUpdate creates or updates a subnet in the specified virtual network. +// This method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. // // resourceGroupName is the name of the resource group. virtualNetworkName is // the name of the virtual network. subnetName is the name of the subnet. // subnetParameters is parameters supplied to the create or update subnet // operation. -func (client SubnetsClient) CreateOrUpdate(resourceGroupName string, virtualNetworkName string, subnetName string, subnetParameters Subnet, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkName, subnetName, subnetParameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "CreateOrUpdate", nil, "Failure preparing request") - } +func (client SubnetsClient) CreateOrUpdate(resourceGroupName string, virtualNetworkName string, subnetName string, subnetParameters Subnet, cancel <-chan struct{}) (<-chan Subnet, <-chan error) { + resultChan := make(chan Subnet, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result Subnet + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkName, subnetName, subnetParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.SubnetsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.SubnetsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.SubnetsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.SubnetsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -81,8 +90,9 @@ func (client SubnetsClient) CreateOrUpdatePreparer(resourceGroupName string, vir "virtualNetworkName": autorest.Encode("path", virtualNetworkName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -105,40 +115,54 @@ func (client SubnetsClient) CreateOrUpdateSender(req *http.Request) (*http.Respo // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client SubnetsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client SubnetsClient) CreateOrUpdateResponder(resp *http.Response) (result Subnet, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } // Delete deletes the specified subnet. This method may poll for completion. -// Polling can be canceled by passing the cancel channel argument. The -// channel will be used to cancel polling and any outstanding HTTP requests. +// Polling can be canceled by passing the cancel channel argument. The channel +// will be used to cancel polling and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group. virtualNetworkName is // the name of the virtual network. subnetName is the name of the subnet. -func (client SubnetsClient) Delete(resourceGroupName string, virtualNetworkName string, subnetName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, virtualNetworkName, subnetName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "Delete", nil, "Failure preparing request") - } +func (client SubnetsClient) Delete(resourceGroupName string, virtualNetworkName string, subnetName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, virtualNetworkName, subnetName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.SubnetsClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.SubnetsClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.SubnetsClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.SubnetsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -150,8 +174,9 @@ func (client SubnetsClient) DeletePreparer(resourceGroupName string, virtualNetw "virtualNetworkName": autorest.Encode("path", virtualNetworkName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -190,13 +215,15 @@ func (client SubnetsClient) DeleteResponder(resp *http.Response) (result autores func (client SubnetsClient) Get(resourceGroupName string, virtualNetworkName string, subnetName string, expand string) (result Subnet, err error) { req, err := client.GetPreparer(resourceGroupName, virtualNetworkName, subnetName, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.SubnetsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.SubnetsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -216,8 +243,9 @@ func (client SubnetsClient) GetPreparer(resourceGroupName string, virtualNetwork "virtualNetworkName": autorest.Encode("path", virtualNetworkName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(expand) > 0 { queryParameters["$expand"] = autorest.Encode("query", expand) @@ -257,13 +285,15 @@ func (client SubnetsClient) GetResponder(resp *http.Response) (result Subnet, er func (client SubnetsClient) List(resourceGroupName string, virtualNetworkName string) (result SubnetListResult, err error) { req, err := client.ListPreparer(resourceGroupName, virtualNetworkName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.SubnetsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.SubnetsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -282,8 +312,9 @@ func (client SubnetsClient) ListPreparer(resourceGroupName string, virtualNetwor "virtualNetworkName": autorest.Encode("path", virtualNetworkName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/usages.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/usages.go old mode 100644 new mode 100755 index 016de70e1..34fa0df4b --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/usages.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/usages.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -25,11 +25,7 @@ import ( "net/http" ) -// UsagesClient is the the Microsoft Azure Network management API provides a -// RESTful set of web services that interact with Microsoft Azure Networks -// service to manage your network resources. The API has entities that -// capture the relationship between an end user and the Microsoft Azure -// Networks service. +// UsagesClient is the composite Swagger for Network Client type UsagesClient struct { ManagementClient } @@ -56,13 +52,15 @@ func (client UsagesClient) List(location string) (result UsagesListResult, err e req, err := client.ListPreparer(location) if err != nil { - return result, autorest.NewErrorWithError(err, "network.UsagesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.UsagesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.UsagesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.UsagesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -80,8 +78,9 @@ func (client UsagesClient) ListPreparer(location string) (*http.Request, error) "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/version.go old mode 100644 new mode 100755 index 551bd1a70..50b836179 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/version.go @@ -18,43 +18,12 @@ package network // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -import ( - "bytes" - "fmt" - "strings" -) - -const ( - major = "8" - minor = "1" - patch = "0" - tag = "beta" - userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" -) - -// cached results of UserAgent and Version to prevent repeated operations. -var ( - userAgent string - version string -) - // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - if userAgent == "" { - userAgent = fmt.Sprintf(userAgentFormat, Version(), "network", "2016-09-01") - } - return userAgent + return "Azure-SDK-For-Go/v10.0.2-beta arm-network/" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - if version == "" { - versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) - if tag != "" { - versionBuilder.WriteRune('-') - versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) - } - version = string(versionBuilder.Bytes()) - } - return version + return "v10.0.2-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkgatewayconnections.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkgatewayconnections.go old mode 100644 new mode 100755 index 922bd5732..13e1392d2 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkgatewayconnections.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkgatewayconnections.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -25,11 +25,8 @@ import ( "net/http" ) -// VirtualNetworkGatewayConnectionsClient is the the Microsoft Azure Network -// management API provides a RESTful set of web services that interact with -// Microsoft Azure Networks service to manage your network resources. The API -// has entities that capture the relationship between an end user and the -// Microsoft Azure Networks service. +// VirtualNetworkGatewayConnectionsClient is the composite Swagger for Network +// Client type VirtualNetworkGatewayConnectionsClient struct { ManagementClient } @@ -48,50 +45,60 @@ func NewVirtualNetworkGatewayConnectionsClientWithBaseURI(baseURI string, subscr // CreateOrUpdate creates or updates a virtual network gateway connection in // the specified resource group. This method may poll for completion. Polling -// can be canceled by passing the cancel channel argument. The channel will -// be used to cancel polling and any outstanding HTTP requests. +// can be canceled by passing the cancel channel argument. The channel will be +// used to cancel polling and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group. // virtualNetworkGatewayConnectionName is the name of the virtual network // gateway connection. parameters is parameters supplied to the create or // update virtual network gateway connection operation. -func (client VirtualNetworkGatewayConnectionsClient) CreateOrUpdate(resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters VirtualNetworkGatewayConnection, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client VirtualNetworkGatewayConnectionsClient) CreateOrUpdate(resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters VirtualNetworkGatewayConnection, cancel <-chan struct{}) (<-chan VirtualNetworkGatewayConnection, <-chan error) { + resultChan := make(chan VirtualNetworkGatewayConnection, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway1", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway1.VirtualNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway1.VirtualNetworkGatewayPropertiesFormat.IPConfigurations", Name: validation.Null, Rule: true, Chain: nil}}}, - }}, + Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway1.VirtualNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, Chain: nil}}}, {Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway2", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway2.VirtualNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway2.VirtualNetworkGatewayPropertiesFormat.IPConfigurations", Name: validation.Null, Rule: true, Chain: nil}}}, - }}, + Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway2.VirtualNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, Chain: nil}}}, {Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.LocalNetworkGateway2", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.LocalNetworkGateway2.LocalNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.LocalNetworkGateway2.LocalNetworkGatewayPropertiesFormat.LocalNetworkAddressSpace", Name: validation.Null, Rule: true, Chain: nil}}}, - }}, + Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.LocalNetworkGateway2.LocalNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, Chain: nil}}}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "network.VirtualNetworkGatewayConnectionsClient", "CreateOrUpdate") + errChan <- validation.NewErrorWithValidationError(err, "network.VirtualNetworkGatewayConnectionsClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") - } + go func() { + var err error + var result VirtualNetworkGatewayConnection + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -102,8 +109,9 @@ func (client VirtualNetworkGatewayConnectionsClient) CreateOrUpdatePreparer(reso "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -126,42 +134,56 @@ func (client VirtualNetworkGatewayConnectionsClient) CreateOrUpdateSender(req *h // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client VirtualNetworkGatewayConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualNetworkGatewayConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualNetworkGatewayConnection, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } -// Delete deletes the specified virtual network Gateway connection. This -// method may poll for completion. Polling can be canceled by passing the -// cancel channel argument. The channel will be used to cancel polling and -// any outstanding HTTP requests. +// Delete deletes the specified virtual network Gateway connection. This method +// may poll for completion. Polling can be canceled by passing the cancel +// channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. // // resourceGroupName is the name of the resource group. // virtualNetworkGatewayConnectionName is the name of the virtual network // gateway connection. -func (client VirtualNetworkGatewayConnectionsClient) Delete(resourceGroupName string, virtualNetworkGatewayConnectionName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, virtualNetworkGatewayConnectionName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Delete", nil, "Failure preparing request") - } +func (client VirtualNetworkGatewayConnectionsClient) Delete(resourceGroupName string, virtualNetworkGatewayConnectionName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, virtualNetworkGatewayConnectionName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -172,8 +194,9 @@ func (client VirtualNetworkGatewayConnectionsClient) DeletePreparer(resourceGrou "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -212,13 +235,15 @@ func (client VirtualNetworkGatewayConnectionsClient) DeleteResponder(resp *http. func (client VirtualNetworkGatewayConnectionsClient) Get(resourceGroupName string, virtualNetworkGatewayConnectionName string) (result VirtualNetworkGatewayConnection, err error) { req, err := client.GetPreparer(resourceGroupName, virtualNetworkGatewayConnectionName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -237,8 +262,9 @@ func (client VirtualNetworkGatewayConnectionsClient) GetPreparer(resourceGroupNa "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -269,8 +295,8 @@ func (client VirtualNetworkGatewayConnectionsClient) GetResponder(resp *http.Res } // GetSharedKey the Get VirtualNetworkGatewayConnectionSharedKey operation -// retrieves information about the specified virtual network gateway -// connection shared key through Network resource provider. +// retrieves information about the specified virtual network gateway connection +// shared key through Network resource provider. // // resourceGroupName is the name of the resource group. // virtualNetworkGatewayConnectionName is the virtual network gateway @@ -278,13 +304,15 @@ func (client VirtualNetworkGatewayConnectionsClient) GetResponder(resp *http.Res func (client VirtualNetworkGatewayConnectionsClient) GetSharedKey(resourceGroupName string, virtualNetworkGatewayConnectionName string) (result ConnectionSharedKey, err error) { req, err := client.GetSharedKeyPreparer(resourceGroupName, virtualNetworkGatewayConnectionName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "GetSharedKey", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "GetSharedKey", nil, "Failure preparing request") + return } resp, err := client.GetSharedKeySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "GetSharedKey", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "GetSharedKey", resp, "Failure sending request") + return } result, err = client.GetSharedKeyResponder(resp) @@ -303,8 +331,9 @@ func (client VirtualNetworkGatewayConnectionsClient) GetSharedKeyPreparer(resour "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -341,13 +370,15 @@ func (client VirtualNetworkGatewayConnectionsClient) GetSharedKeyResponder(resp func (client VirtualNetworkGatewayConnectionsClient) List(resourceGroupName string) (result VirtualNetworkGatewayConnectionListResult, err error) { req, err := client.ListPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -365,8 +396,9 @@ func (client VirtualNetworkGatewayConnectionsClient) ListPreparer(resourceGroupN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -421,44 +453,60 @@ func (client VirtualNetworkGatewayConnectionsClient) ListNextResults(lastResults } // ResetSharedKey the VirtualNetworkGatewayConnectionResetSharedKey operation -// resets the virtual network gateway connection shared key for passed -// virtual network gateway connection in the specified resource group through -// Network resource provider. This method may poll for completion. Polling -// can be canceled by passing the cancel channel argument. The channel will -// be used to cancel polling and any outstanding HTTP requests. +// resets the virtual network gateway connection shared key for passed virtual +// network gateway connection in the specified resource group through Network +// resource provider. This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to +// cancel polling and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group. // virtualNetworkGatewayConnectionName is the virtual network gateway // connection reset shared key Name. parameters is parameters supplied to the -// begin reset virtual network gateway connection shared key operation -// through network resource provider. -func (client VirtualNetworkGatewayConnectionsClient) ResetSharedKey(resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters ConnectionResetSharedKey, cancel <-chan struct{}) (result autorest.Response, err error) { +// begin reset virtual network gateway connection shared key operation through +// network resource provider. +func (client VirtualNetworkGatewayConnectionsClient) ResetSharedKey(resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters ConnectionResetSharedKey, cancel <-chan struct{}) (<-chan ConnectionResetSharedKey, <-chan error) { + resultChan := make(chan ConnectionResetSharedKey, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.KeyLength", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "parameters.KeyLength", Name: validation.InclusiveMaximum, Rule: 128, Chain: nil}, {Target: "parameters.KeyLength", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "network.VirtualNetworkGatewayConnectionsClient", "ResetSharedKey") + errChan <- validation.NewErrorWithValidationError(err, "network.VirtualNetworkGatewayConnectionsClient", "ResetSharedKey") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.ResetSharedKeyPreparer(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "ResetSharedKey", nil, "Failure preparing request") - } + go func() { + var err error + var result ConnectionResetSharedKey + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ResetSharedKeyPreparer(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "ResetSharedKey", nil, "Failure preparing request") + return + } - resp, err := client.ResetSharedKeySender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "ResetSharedKey", resp, "Failure sending request") - } + resp, err := client.ResetSharedKeySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "ResetSharedKey", resp, "Failure sending request") + return + } - result, err = client.ResetSharedKeyResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "ResetSharedKey", resp, "Failure responding to request") - } - - return + result, err = client.ResetSharedKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "ResetSharedKey", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // ResetSharedKeyPreparer prepares the ResetSharedKey request. @@ -469,8 +517,9 @@ func (client VirtualNetworkGatewayConnectionsClient) ResetSharedKeyPreparer(reso "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -493,52 +542,69 @@ func (client VirtualNetworkGatewayConnectionsClient) ResetSharedKeySender(req *h // ResetSharedKeyResponder handles the response to the ResetSharedKey request. The method always // closes the http.Response Body. -func (client VirtualNetworkGatewayConnectionsClient) ResetSharedKeyResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualNetworkGatewayConnectionsClient) ResetSharedKeyResponder(resp *http.Response) (result ConnectionResetSharedKey, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } -// SetSharedKey the Put VirtualNetworkGatewayConnectionSharedKey operation -// sets the virtual network gateway connection shared key for passed virtual -// network gateway connection in the specified resource group through Network -// resource provider. This method may poll for completion. Polling can be -// canceled by passing the cancel channel argument. The channel will be used -// to cancel polling and any outstanding HTTP requests. +// SetSharedKey the Put VirtualNetworkGatewayConnectionSharedKey operation sets +// the virtual network gateway connection shared key for passed virtual network +// gateway connection in the specified resource group through Network resource +// provider. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group. // virtualNetworkGatewayConnectionName is the virtual network gateway -// connection name. parameters is parameters supplied to the Begin Set -// Virtual Network Gateway connection Shared key operation throughNetwork -// resource provider. -func (client VirtualNetworkGatewayConnectionsClient) SetSharedKey(resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters ConnectionSharedKey, cancel <-chan struct{}) (result autorest.Response, err error) { +// connection name. parameters is parameters supplied to the Begin Set Virtual +// Network Gateway connection Shared key operation throughNetwork resource +// provider. +func (client VirtualNetworkGatewayConnectionsClient) SetSharedKey(resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters ConnectionSharedKey, cancel <-chan struct{}) (<-chan ConnectionSharedKey, <-chan error) { + resultChan := make(chan ConnectionSharedKey, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.Value", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "network.VirtualNetworkGatewayConnectionsClient", "SetSharedKey") + errChan <- validation.NewErrorWithValidationError(err, "network.VirtualNetworkGatewayConnectionsClient", "SetSharedKey") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.SetSharedKeyPreparer(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "SetSharedKey", nil, "Failure preparing request") - } + go func() { + var err error + var result ConnectionSharedKey + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.SetSharedKeyPreparer(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "SetSharedKey", nil, "Failure preparing request") + return + } - resp, err := client.SetSharedKeySender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "SetSharedKey", resp, "Failure sending request") - } + resp, err := client.SetSharedKeySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "SetSharedKey", resp, "Failure sending request") + return + } - result, err = client.SetSharedKeyResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "SetSharedKey", resp, "Failure responding to request") - } - - return + result, err = client.SetSharedKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "SetSharedKey", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // SetSharedKeyPreparer prepares the SetSharedKey request. @@ -549,8 +615,9 @@ func (client VirtualNetworkGatewayConnectionsClient) SetSharedKeyPreparer(resour "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -573,12 +640,13 @@ func (client VirtualNetworkGatewayConnectionsClient) SetSharedKeySender(req *htt // SetSharedKeyResponder handles the response to the SetSharedKey request. The method always // closes the http.Response Body. -func (client VirtualNetworkGatewayConnectionsClient) SetSharedKeyResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualNetworkGatewayConnectionsClient) SetSharedKeyResponder(resp *http.Response) (result ConnectionSharedKey, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkgateways.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkgateways.go old mode 100644 new mode 100755 index 3f128c1fa..720978e83 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkgateways.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkgateways.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -25,11 +25,7 @@ import ( "net/http" ) -// VirtualNetworkGatewaysClient is the the Microsoft Azure Network management -// API provides a RESTful set of web services that interact with Microsoft -// Azure Networks service to manage your network resources. The API has -// entities that capture the relationship between an end user and the -// Microsoft Azure Networks service. +// VirtualNetworkGatewaysClient is the composite Swagger for Network Client type VirtualNetworkGatewaysClient struct { ManagementClient } @@ -46,40 +42,55 @@ func NewVirtualNetworkGatewaysClientWithBaseURI(baseURI string, subscriptionID s return VirtualNetworkGatewaysClient{NewWithBaseURI(baseURI, subscriptionID)} } -// CreateOrUpdate creates or updates a virtual network gateway in the -// specified resource group. This method may poll for completion. Polling can -// be canceled by passing the cancel channel argument. The channel will be -// used to cancel polling and any outstanding HTTP requests. +// CreateOrUpdate creates or updates a virtual network gateway in the specified +// resource group. This method may poll for completion. Polling can be canceled +// by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group. // virtualNetworkGatewayName is the name of the virtual network gateway. // parameters is parameters supplied to create or update virtual network // gateway operation. -func (client VirtualNetworkGatewaysClient) CreateOrUpdate(resourceGroupName string, virtualNetworkGatewayName string, parameters VirtualNetworkGateway, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client VirtualNetworkGatewaysClient) CreateOrUpdate(resourceGroupName string, virtualNetworkGatewayName string, parameters VirtualNetworkGateway, cancel <-chan struct{}) (<-chan VirtualNetworkGateway, <-chan error) { + resultChan := make(chan VirtualNetworkGateway, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayPropertiesFormat.IPConfigurations", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate") + Constraints: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkGatewayName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request") - } + go func() { + var err error + var result VirtualNetworkGateway + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkGatewayName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -90,8 +101,9 @@ func (client VirtualNetworkGatewaysClient) CreateOrUpdatePreparer(resourceGroupN "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -114,13 +126,14 @@ func (client VirtualNetworkGatewaysClient) CreateOrUpdateSender(req *http.Reques // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client VirtualNetworkGatewaysClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualNetworkGatewaysClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualNetworkGateway, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -131,24 +144,37 @@ func (client VirtualNetworkGatewaysClient) CreateOrUpdateResponder(resp *http.Re // // resourceGroupName is the name of the resource group. // virtualNetworkGatewayName is the name of the virtual network gateway. -func (client VirtualNetworkGatewaysClient) Delete(resourceGroupName string, virtualNetworkGatewayName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, virtualNetworkGatewayName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Delete", nil, "Failure preparing request") - } +func (client VirtualNetworkGatewaysClient) Delete(resourceGroupName string, virtualNetworkGatewayName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, virtualNetworkGatewayName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -159,8 +185,9 @@ func (client VirtualNetworkGatewaysClient) DeletePreparer(resourceGroupName stri "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -201,13 +228,15 @@ func (client VirtualNetworkGatewaysClient) DeleteResponder(resp *http.Response) func (client VirtualNetworkGatewaysClient) Generatevpnclientpackage(resourceGroupName string, virtualNetworkGatewayName string, parameters VpnClientParameters) (result String, err error) { req, err := client.GeneratevpnclientpackagePreparer(resourceGroupName, virtualNetworkGatewayName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Generatevpnclientpackage", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Generatevpnclientpackage", nil, "Failure preparing request") + return } resp, err := client.GeneratevpnclientpackageSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Generatevpnclientpackage", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Generatevpnclientpackage", resp, "Failure sending request") + return } result, err = client.GeneratevpnclientpackageResponder(resp) @@ -226,8 +255,9 @@ func (client VirtualNetworkGatewaysClient) GeneratevpnclientpackagePreparer(reso "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -266,13 +296,15 @@ func (client VirtualNetworkGatewaysClient) GeneratevpnclientpackageResponder(res func (client VirtualNetworkGatewaysClient) Get(resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGateway, err error) { req, err := client.GetPreparer(resourceGroupName, virtualNetworkGatewayName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -291,8 +323,9 @@ func (client VirtualNetworkGatewaysClient) GetPreparer(resourceGroupName string, "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -322,19 +355,275 @@ func (client VirtualNetworkGatewaysClient) GetResponder(resp *http.Response) (re return } +// GetAdvertisedRoutes this operation retrieves a list of routes the virtual +// network gateway is advertising to the specified peer. This method may poll +// for completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. +// +// resourceGroupName is the name of the resource group. +// virtualNetworkGatewayName is the name of the virtual network gateway. peer +// is the IP address of the peer +func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutes(resourceGroupName string, virtualNetworkGatewayName string, peer string, cancel <-chan struct{}) (<-chan GatewayRouteListResult, <-chan error) { + resultChan := make(chan GatewayRouteListResult, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result GatewayRouteListResult + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.GetAdvertisedRoutesPreparer(resourceGroupName, virtualNetworkGatewayName, peer, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetAdvertisedRoutes", nil, "Failure preparing request") + return + } + + resp, err := client.GetAdvertisedRoutesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetAdvertisedRoutes", resp, "Failure sending request") + return + } + + result, err = client.GetAdvertisedRoutesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetAdvertisedRoutes", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// GetAdvertisedRoutesPreparer prepares the GetAdvertisedRoutes request. +func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutesPreparer(resourceGroupName string, virtualNetworkGatewayName string, peer string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "peer": autorest.Encode("query", peer), + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getAdvertisedRoutes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// GetAdvertisedRoutesSender sends the GetAdvertisedRoutes request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutesSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// GetAdvertisedRoutesResponder handles the response to the GetAdvertisedRoutes request. The method always +// closes the http.Response Body. +func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutesResponder(resp *http.Response) (result GatewayRouteListResult, 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 +} + +// GetBgpPeerStatus the GetBgpPeerStatus operation retrieves the status of all +// BGP peers. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. +// virtualNetworkGatewayName is the name of the virtual network gateway. peer +// is the IP address of the peer to retrieve the status of. +func (client VirtualNetworkGatewaysClient) GetBgpPeerStatus(resourceGroupName string, virtualNetworkGatewayName string, peer string, cancel <-chan struct{}) (<-chan BgpPeerStatusListResult, <-chan error) { + resultChan := make(chan BgpPeerStatusListResult, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result BgpPeerStatusListResult + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.GetBgpPeerStatusPreparer(resourceGroupName, virtualNetworkGatewayName, peer, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetBgpPeerStatus", nil, "Failure preparing request") + return + } + + resp, err := client.GetBgpPeerStatusSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetBgpPeerStatus", resp, "Failure sending request") + return + } + + result, err = client.GetBgpPeerStatusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetBgpPeerStatus", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// GetBgpPeerStatusPreparer prepares the GetBgpPeerStatus request. +func (client VirtualNetworkGatewaysClient) GetBgpPeerStatusPreparer(resourceGroupName string, virtualNetworkGatewayName string, peer string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(peer) > 0 { + queryParameters["peer"] = autorest.Encode("query", peer) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getBgpPeerStatus", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// GetBgpPeerStatusSender sends the GetBgpPeerStatus request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualNetworkGatewaysClient) GetBgpPeerStatusSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// GetBgpPeerStatusResponder handles the response to the GetBgpPeerStatus request. The method always +// closes the http.Response Body. +func (client VirtualNetworkGatewaysClient) GetBgpPeerStatusResponder(resp *http.Response) (result BgpPeerStatusListResult, 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 +} + +// GetLearnedRoutes this operation retrieves a list of routes the virtual +// network gateway has learned, including routes learned from BGP peers. This +// method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. +// virtualNetworkGatewayName is the name of the virtual network gateway. +func (client VirtualNetworkGatewaysClient) GetLearnedRoutes(resourceGroupName string, virtualNetworkGatewayName string, cancel <-chan struct{}) (<-chan GatewayRouteListResult, <-chan error) { + resultChan := make(chan GatewayRouteListResult, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result GatewayRouteListResult + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.GetLearnedRoutesPreparer(resourceGroupName, virtualNetworkGatewayName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetLearnedRoutes", nil, "Failure preparing request") + return + } + + resp, err := client.GetLearnedRoutesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetLearnedRoutes", resp, "Failure sending request") + return + } + + result, err = client.GetLearnedRoutesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetLearnedRoutes", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// GetLearnedRoutesPreparer prepares the GetLearnedRoutes request. +func (client VirtualNetworkGatewaysClient) GetLearnedRoutesPreparer(resourceGroupName string, virtualNetworkGatewayName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getLearnedRoutes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// GetLearnedRoutesSender sends the GetLearnedRoutes request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualNetworkGatewaysClient) GetLearnedRoutesSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// GetLearnedRoutesResponder handles the response to the GetLearnedRoutes request. The method always +// closes the http.Response Body. +func (client VirtualNetworkGatewaysClient) GetLearnedRoutesResponder(resp *http.Response) (result GatewayRouteListResult, 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 +} + // List gets all virtual network gateways by resource group. // // resourceGroupName is the name of the resource group. func (client VirtualNetworkGatewaysClient) List(resourceGroupName string) (result VirtualNetworkGatewayListResult, err error) { req, err := client.ListPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -352,8 +641,9 @@ func (client VirtualNetworkGatewaysClient) ListPreparer(resourceGroupName string "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -408,32 +698,45 @@ func (client VirtualNetworkGatewaysClient) ListNextResults(lastResults VirtualNe } // Reset resets the primary of the virtual network gateway in the specified -// resource group. This method may poll for completion. Polling can be -// canceled by passing the cancel channel argument. The channel will be used -// to cancel polling and any outstanding HTTP requests. +// resource group. This method may poll for completion. Polling can be canceled +// by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group. // virtualNetworkGatewayName is the name of the virtual network gateway. // gatewayVip is virtual network gateway vip address supplied to the begin // reset of the active-active feature enabled gateway. -func (client VirtualNetworkGatewaysClient) Reset(resourceGroupName string, virtualNetworkGatewayName string, gatewayVip string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.ResetPreparer(resourceGroupName, virtualNetworkGatewayName, gatewayVip, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", nil, "Failure preparing request") - } +func (client VirtualNetworkGatewaysClient) Reset(resourceGroupName string, virtualNetworkGatewayName string, gatewayVip string, cancel <-chan struct{}) (<-chan VirtualNetworkGateway, <-chan error) { + resultChan := make(chan VirtualNetworkGateway, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result VirtualNetworkGateway + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ResetPreparer(resourceGroupName, virtualNetworkGatewayName, gatewayVip, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", nil, "Failure preparing request") + return + } - resp, err := client.ResetSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", resp, "Failure sending request") - } + resp, err := client.ResetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", resp, "Failure sending request") + return + } - result, err = client.ResetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", resp, "Failure responding to request") - } - - return + result, err = client.ResetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // ResetPreparer prepares the Reset request. @@ -444,8 +747,9 @@ func (client VirtualNetworkGatewaysClient) ResetPreparer(resourceGroupName strin "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(gatewayVip) > 0 { queryParameters["gatewayVip"] = autorest.Encode("query", gatewayVip) @@ -469,12 +773,13 @@ func (client VirtualNetworkGatewaysClient) ResetSender(req *http.Request) (*http // ResetResponder handles the response to the Reset request. The method always // closes the http.Response Body. -func (client VirtualNetworkGatewaysClient) ResetResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualNetworkGatewaysClient) ResetResponder(resp *http.Response) (result VirtualNetworkGateway, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkpeerings.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkpeerings.go old mode 100644 new mode 100755 index bfed897a3..27fafdfd0 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkpeerings.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkpeerings.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -24,11 +24,7 @@ import ( "net/http" ) -// VirtualNetworkPeeringsClient is the the Microsoft Azure Network management -// API provides a RESTful set of web services that interact with Microsoft -// Azure Networks service to manage your network resources. The API has -// entities that capture the relationship between an end user and the -// Microsoft Azure Networks service. +// VirtualNetworkPeeringsClient is the composite Swagger for Network Client type VirtualNetworkPeeringsClient struct { ManagementClient } @@ -54,24 +50,37 @@ func NewVirtualNetworkPeeringsClientWithBaseURI(baseURI string, subscriptionID s // the name of the virtual network. virtualNetworkPeeringName is the name of // the peering. virtualNetworkPeeringParameters is parameters supplied to the // create or update virtual network peering operation. -func (client VirtualNetworkPeeringsClient) CreateOrUpdate(resourceGroupName string, virtualNetworkName string, virtualNetworkPeeringName string, virtualNetworkPeeringParameters VirtualNetworkPeering, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, virtualNetworkPeeringParameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "CreateOrUpdate", nil, "Failure preparing request") - } +func (client VirtualNetworkPeeringsClient) CreateOrUpdate(resourceGroupName string, virtualNetworkName string, virtualNetworkPeeringName string, virtualNetworkPeeringParameters VirtualNetworkPeering, cancel <-chan struct{}) (<-chan VirtualNetworkPeering, <-chan error) { + resultChan := make(chan VirtualNetworkPeering, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result VirtualNetworkPeering + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, virtualNetworkPeeringParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -83,8 +92,9 @@ func (client VirtualNetworkPeeringsClient) CreateOrUpdatePreparer(resourceGroupN "virtualNetworkPeeringName": autorest.Encode("path", virtualNetworkPeeringName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -107,13 +117,14 @@ func (client VirtualNetworkPeeringsClient) CreateOrUpdateSender(req *http.Reques // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client VirtualNetworkPeeringsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualNetworkPeeringsClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualNetworkPeering, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -125,24 +136,37 @@ func (client VirtualNetworkPeeringsClient) CreateOrUpdateResponder(resp *http.Re // resourceGroupName is the name of the resource group. virtualNetworkName is // the name of the virtual network. virtualNetworkPeeringName is the name of // the virtual network peering. -func (client VirtualNetworkPeeringsClient) Delete(resourceGroupName string, virtualNetworkName string, virtualNetworkPeeringName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "Delete", nil, "Failure preparing request") - } +func (client VirtualNetworkPeeringsClient) Delete(resourceGroupName string, virtualNetworkName string, virtualNetworkPeeringName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -154,8 +178,9 @@ func (client VirtualNetworkPeeringsClient) DeletePreparer(resourceGroupName stri "virtualNetworkPeeringName": autorest.Encode("path", virtualNetworkPeeringName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -194,13 +219,15 @@ func (client VirtualNetworkPeeringsClient) DeleteResponder(resp *http.Response) func (client VirtualNetworkPeeringsClient) Get(resourceGroupName string, virtualNetworkName string, virtualNetworkPeeringName string) (result VirtualNetworkPeering, err error) { req, err := client.GetPreparer(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -220,8 +247,9 @@ func (client VirtualNetworkPeeringsClient) GetPreparer(resourceGroupName string, "virtualNetworkPeeringName": autorest.Encode("path", virtualNetworkPeeringName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -258,13 +286,15 @@ func (client VirtualNetworkPeeringsClient) GetResponder(resp *http.Response) (re func (client VirtualNetworkPeeringsClient) List(resourceGroupName string, virtualNetworkName string) (result VirtualNetworkPeeringListResult, err error) { req, err := client.ListPreparer(resourceGroupName, virtualNetworkName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -283,8 +313,9 @@ func (client VirtualNetworkPeeringsClient) ListPreparer(resourceGroupName string "virtualNetworkName": autorest.Encode("path", virtualNetworkName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworks.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworks.go old mode 100644 new mode 100755 index 9046437af..eab048c72 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworks.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworks.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -24,11 +24,7 @@ import ( "net/http" ) -// VirtualNetworksClient is the the Microsoft Azure Network management API -// provides a RESTful set of web services that interact with Microsoft Azure -// Networks service to manage your network resources. The API has entities -// that capture the relationship between an end user and the Microsoft Azure -// Networks service. +// VirtualNetworksClient is the composite Swagger for Network Client type VirtualNetworksClient struct { ManagementClient } @@ -49,18 +45,20 @@ func NewVirtualNetworksClientWithBaseURI(baseURI string, subscriptionID string) // for use. // // resourceGroupName is the name of the resource group. virtualNetworkName is -// the name of the virtual network. ipAddress is the private IP address to be +// the name of the virtual network. IPAddress is the private IP address to be // verified. -func (client VirtualNetworksClient) CheckIPAddressAvailability(resourceGroupName string, virtualNetworkName string, ipAddress string) (result IPAddressAvailabilityResult, err error) { - req, err := client.CheckIPAddressAvailabilityPreparer(resourceGroupName, virtualNetworkName, ipAddress) +func (client VirtualNetworksClient) CheckIPAddressAvailability(resourceGroupName string, virtualNetworkName string, IPAddress string) (result IPAddressAvailabilityResult, err error) { + req, err := client.CheckIPAddressAvailabilityPreparer(resourceGroupName, virtualNetworkName, IPAddress) if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "CheckIPAddressAvailability", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "CheckIPAddressAvailability", nil, "Failure preparing request") + return } resp, err := client.CheckIPAddressAvailabilitySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "CheckIPAddressAvailability", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "CheckIPAddressAvailability", resp, "Failure sending request") + return } result, err = client.CheckIPAddressAvailabilityResponder(resp) @@ -72,18 +70,19 @@ func (client VirtualNetworksClient) CheckIPAddressAvailability(resourceGroupName } // CheckIPAddressAvailabilityPreparer prepares the CheckIPAddressAvailability request. -func (client VirtualNetworksClient) CheckIPAddressAvailabilityPreparer(resourceGroupName string, virtualNetworkName string, ipAddress string) (*http.Request, error) { +func (client VirtualNetworksClient) CheckIPAddressAvailabilityPreparer(resourceGroupName string, virtualNetworkName string, IPAddress string) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), "virtualNetworkName": autorest.Encode("path", virtualNetworkName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } - if len(ipAddress) > 0 { - queryParameters["ipAddress"] = autorest.Encode("query", ipAddress) + if len(IPAddress) > 0 { + queryParameters["ipAddress"] = autorest.Encode("query", IPAddress) } preparer := autorest.CreatePreparer( @@ -114,31 +113,44 @@ func (client VirtualNetworksClient) CheckIPAddressAvailabilityResponder(resp *ht } // CreateOrUpdate creates or updates a virtual network in the specified -// resource group. This method may poll for completion. Polling can be -// canceled by passing the cancel channel argument. The channel will be used -// to cancel polling and any outstanding HTTP requests. +// resource group. This method may poll for completion. Polling can be canceled +// by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group. virtualNetworkName is // the name of the virtual network. parameters is parameters supplied to the // create or update virtual network operation -func (client VirtualNetworksClient) CreateOrUpdate(resourceGroupName string, virtualNetworkName string, parameters VirtualNetwork, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "CreateOrUpdate", nil, "Failure preparing request") - } +func (client VirtualNetworksClient) CreateOrUpdate(resourceGroupName string, virtualNetworkName string, parameters VirtualNetwork, cancel <-chan struct{}) (<-chan VirtualNetwork, <-chan error) { + resultChan := make(chan VirtualNetwork, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result VirtualNetwork + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -149,8 +161,9 @@ func (client VirtualNetworksClient) CreateOrUpdatePreparer(resourceGroupName str "virtualNetworkName": autorest.Encode("path", virtualNetworkName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -173,41 +186,55 @@ func (client VirtualNetworksClient) CreateOrUpdateSender(req *http.Request) (*ht // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client VirtualNetworksClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualNetworksClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualNetwork, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } // Delete deletes the specified virtual network. This method may poll for -// completion. Polling can be canceled by passing the cancel channel -// argument. The channel will be used to cancel polling and any outstanding -// HTTP requests. +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. // // resourceGroupName is the name of the resource group. virtualNetworkName is // the name of the virtual network. -func (client VirtualNetworksClient) Delete(resourceGroupName string, virtualNetworkName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, virtualNetworkName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "Delete", nil, "Failure preparing request") - } +func (client VirtualNetworksClient) Delete(resourceGroupName string, virtualNetworkName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, virtualNetworkName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -218,8 +245,9 @@ func (client VirtualNetworksClient) DeletePreparer(resourceGroupName string, vir "virtualNetworkName": autorest.Encode("path", virtualNetworkName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -257,13 +285,15 @@ func (client VirtualNetworksClient) DeleteResponder(resp *http.Response) (result func (client VirtualNetworksClient) Get(resourceGroupName string, virtualNetworkName string, expand string) (result VirtualNetwork, err error) { req, err := client.GetPreparer(resourceGroupName, virtualNetworkName, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -282,8 +312,9 @@ func (client VirtualNetworksClient) GetPreparer(resourceGroupName string, virtua "virtualNetworkName": autorest.Encode("path", virtualNetworkName), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(expand) > 0 { queryParameters["$expand"] = autorest.Encode("query", expand) @@ -322,13 +353,15 @@ func (client VirtualNetworksClient) GetResponder(resp *http.Response) (result Vi func (client VirtualNetworksClient) List(resourceGroupName string) (result VirtualNetworkListResult, err error) { req, err := client.ListPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -346,8 +379,9 @@ func (client VirtualNetworksClient) ListPreparer(resourceGroupName string) (*htt "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -405,13 +439,15 @@ func (client VirtualNetworksClient) ListNextResults(lastResults VirtualNetworkLi func (client VirtualNetworksClient) ListAll() (result VirtualNetworkListResult, err error) { req, err := client.ListAllPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "ListAll", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "ListAll", nil, "Failure preparing request") + return } resp, err := client.ListAllSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "ListAll", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "ListAll", resp, "Failure sending request") + return } result, err = client.ListAllResponder(resp) @@ -428,8 +464,9 @@ func (client VirtualNetworksClient) ListAllPreparer() (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/watchers.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/watchers.go new file mode 100755 index 000000000..28febf847 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/watchers.go @@ -0,0 +1,1131 @@ +package network + +// 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// WatchersClient is the composite Swagger for Network Client +type WatchersClient struct { + ManagementClient +} + +// NewWatchersClient creates an instance of the WatchersClient client. +func NewWatchersClient(subscriptionID string) WatchersClient { + return NewWatchersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWatchersClientWithBaseURI creates an instance of the WatchersClient +// client. +func NewWatchersClientWithBaseURI(baseURI string, subscriptionID string) WatchersClient { + return WatchersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a network watcher in the specified +// resource group. +// +// resourceGroupName is the name of the resource group. networkWatcherName is +// the name of the network watcher. parameters is parameters that define the +// network watcher resource. +func (client WatchersClient) CreateOrUpdate(resourceGroupName string, networkWatcherName string, parameters Watcher) (result Watcher, err error) { + req, err := client.CreateOrUpdatePreparer(resourceGroupName, networkWatcherName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.WatchersClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client WatchersClient) CreateOrUpdatePreparer(resourceGroupName string, networkWatcherName string, parameters Watcher) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "networkWatcherName": autorest.Encode("path", networkWatcherName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client WatchersClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client WatchersClient) CreateOrUpdateResponder(resp *http.Response) (result Watcher, 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 deletes the specified network watcher resource. This method may poll +// for completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. +// +// resourceGroupName is the name of the resource group. networkWatcherName is +// the name of the network watcher. +func (client WatchersClient) Delete(resourceGroupName string, networkWatcherName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, networkWatcherName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "network.WatchersClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client WatchersClient) DeletePreparer(resourceGroupName string, networkWatcherName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "networkWatcherName": autorest.Encode("path", networkWatcherName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client WatchersClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WatchersClient) 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 gets the specified network watcher by resource group. +// +// resourceGroupName is the name of the resource group. networkWatcherName is +// the name of the network watcher. +func (client WatchersClient) Get(resourceGroupName string, networkWatcherName string) (result Watcher, err error) { + req, err := client.GetPreparer(resourceGroupName, networkWatcherName) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.WatchersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client WatchersClient) GetPreparer(resourceGroupName string, networkWatcherName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "networkWatcherName": autorest.Encode("path", networkWatcherName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client WatchersClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WatchersClient) GetResponder(resp *http.Response) (result Watcher, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetFlowLogStatus queries status of flow log on a specified resource. This +// method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the network watcher resource group. +// networkWatcherName is the name of the network watcher resource. parameters +// is parameters that define a resource to query flow log status. +func (client WatchersClient) GetFlowLogStatus(resourceGroupName string, networkWatcherName string, parameters FlowLogStatusParameters, cancel <-chan struct{}) (<-chan FlowLogInformation, <-chan error) { + resultChan := make(chan FlowLogInformation, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TargetResourceID", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "network.WatchersClient", "GetFlowLogStatus") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result FlowLogInformation + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.GetFlowLogStatusPreparer(resourceGroupName, networkWatcherName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetFlowLogStatus", nil, "Failure preparing request") + return + } + + resp, err := client.GetFlowLogStatusSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetFlowLogStatus", resp, "Failure sending request") + return + } + + result, err = client.GetFlowLogStatusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetFlowLogStatus", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// GetFlowLogStatusPreparer prepares the GetFlowLogStatus request. +func (client WatchersClient) GetFlowLogStatusPreparer(resourceGroupName string, networkWatcherName string, parameters FlowLogStatusParameters, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "networkWatcherName": autorest.Encode("path", networkWatcherName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/queryFlowLogStatus", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// GetFlowLogStatusSender sends the GetFlowLogStatus request. The method will close the +// http.Response Body if it receives an error. +func (client WatchersClient) GetFlowLogStatusSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// GetFlowLogStatusResponder handles the response to the GetFlowLogStatus request. The method always +// closes the http.Response Body. +func (client WatchersClient) GetFlowLogStatusResponder(resp *http.Response) (result FlowLogInformation, 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 +} + +// GetNextHop gets the next hop from the specified VM. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// resourceGroupName is the name of the resource group. networkWatcherName is +// the name of the network watcher. parameters is parameters that define the +// source and destination endpoint. +func (client WatchersClient) GetNextHop(resourceGroupName string, networkWatcherName string, parameters NextHopParameters, cancel <-chan struct{}) (<-chan NextHopResult, <-chan error) { + resultChan := make(chan NextHopResult, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TargetResourceID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.SourceIPAddress", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.DestinationIPAddress", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "network.WatchersClient", "GetNextHop") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result NextHopResult + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.GetNextHopPreparer(resourceGroupName, networkWatcherName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetNextHop", nil, "Failure preparing request") + return + } + + resp, err := client.GetNextHopSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetNextHop", resp, "Failure sending request") + return + } + + result, err = client.GetNextHopResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetNextHop", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// GetNextHopPreparer prepares the GetNextHop request. +func (client WatchersClient) GetNextHopPreparer(resourceGroupName string, networkWatcherName string, parameters NextHopParameters, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "networkWatcherName": autorest.Encode("path", networkWatcherName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/nextHop", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// GetNextHopSender sends the GetNextHop request. The method will close the +// http.Response Body if it receives an error. +func (client WatchersClient) GetNextHopSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// GetNextHopResponder handles the response to the GetNextHop request. The method always +// closes the http.Response Body. +func (client WatchersClient) GetNextHopResponder(resp *http.Response) (result NextHopResult, 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 +} + +// GetTopology gets the current network topology by resource group. +// +// resourceGroupName is the name of the resource group. networkWatcherName is +// the name of the network watcher. parameters is parameters that define the +// representation of topology. +func (client WatchersClient) GetTopology(resourceGroupName string, networkWatcherName string, parameters TopologyParameters) (result Topology, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TargetResourceGroupName", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "network.WatchersClient", "GetTopology") + } + + req, err := client.GetTopologyPreparer(resourceGroupName, networkWatcherName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetTopology", nil, "Failure preparing request") + return + } + + resp, err := client.GetTopologySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetTopology", resp, "Failure sending request") + return + } + + result, err = client.GetTopologyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetTopology", resp, "Failure responding to request") + } + + return +} + +// GetTopologyPreparer prepares the GetTopology request. +func (client WatchersClient) GetTopologyPreparer(resourceGroupName string, networkWatcherName string, parameters TopologyParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "networkWatcherName": autorest.Encode("path", networkWatcherName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/topology", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetTopologySender sends the GetTopology request. The method will close the +// http.Response Body if it receives an error. +func (client WatchersClient) GetTopologySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetTopologyResponder handles the response to the GetTopology request. The method always +// closes the http.Response Body. +func (client WatchersClient) GetTopologyResponder(resp *http.Response) (result Topology, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetTroubleshooting initiate troubleshooting on a specified resource This +// method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. networkWatcherName is +// the name of the network watcher resource. parameters is parameters that +// define the resource to troubleshoot. +func (client WatchersClient) GetTroubleshooting(resourceGroupName string, networkWatcherName string, parameters TroubleshootingParameters, cancel <-chan struct{}) (<-chan TroubleshootingResult, <-chan error) { + resultChan := make(chan TroubleshootingResult, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TargetResourceID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.TroubleshootingProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.TroubleshootingProperties.StorageID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.TroubleshootingProperties.StoragePath", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "network.WatchersClient", "GetTroubleshooting") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result TroubleshootingResult + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.GetTroubleshootingPreparer(resourceGroupName, networkWatcherName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetTroubleshooting", nil, "Failure preparing request") + return + } + + resp, err := client.GetTroubleshootingSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetTroubleshooting", resp, "Failure sending request") + return + } + + result, err = client.GetTroubleshootingResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetTroubleshooting", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// GetTroubleshootingPreparer prepares the GetTroubleshooting request. +func (client WatchersClient) GetTroubleshootingPreparer(resourceGroupName string, networkWatcherName string, parameters TroubleshootingParameters, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "networkWatcherName": autorest.Encode("path", networkWatcherName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/troubleshoot", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// GetTroubleshootingSender sends the GetTroubleshooting request. The method will close the +// http.Response Body if it receives an error. +func (client WatchersClient) GetTroubleshootingSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// GetTroubleshootingResponder handles the response to the GetTroubleshooting request. The method always +// closes the http.Response Body. +func (client WatchersClient) GetTroubleshootingResponder(resp *http.Response) (result TroubleshootingResult, 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 +} + +// GetTroubleshootingResult get the last completed troubleshooting result on a +// specified resource This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to +// cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. networkWatcherName is +// the name of the network watcher resource. parameters is parameters that +// define the resource to query the troubleshooting result. +func (client WatchersClient) GetTroubleshootingResult(resourceGroupName string, networkWatcherName string, parameters QueryTroubleshootingParameters, cancel <-chan struct{}) (<-chan TroubleshootingResult, <-chan error) { + resultChan := make(chan TroubleshootingResult, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TargetResourceID", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "network.WatchersClient", "GetTroubleshootingResult") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result TroubleshootingResult + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.GetTroubleshootingResultPreparer(resourceGroupName, networkWatcherName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetTroubleshootingResult", nil, "Failure preparing request") + return + } + + resp, err := client.GetTroubleshootingResultSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetTroubleshootingResult", resp, "Failure sending request") + return + } + + result, err = client.GetTroubleshootingResultResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetTroubleshootingResult", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// GetTroubleshootingResultPreparer prepares the GetTroubleshootingResult request. +func (client WatchersClient) GetTroubleshootingResultPreparer(resourceGroupName string, networkWatcherName string, parameters QueryTroubleshootingParameters, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "networkWatcherName": autorest.Encode("path", networkWatcherName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/queryTroubleshootResult", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// GetTroubleshootingResultSender sends the GetTroubleshootingResult request. The method will close the +// http.Response Body if it receives an error. +func (client WatchersClient) GetTroubleshootingResultSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// GetTroubleshootingResultResponder handles the response to the GetTroubleshootingResult request. The method always +// closes the http.Response Body. +func (client WatchersClient) GetTroubleshootingResultResponder(resp *http.Response) (result TroubleshootingResult, 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 +} + +// GetVMSecurityRules gets the configured and effective security group rules on +// the specified VM. This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to +// cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. networkWatcherName is +// the name of the network watcher. parameters is parameters that define the VM +// to check security groups for. +func (client WatchersClient) GetVMSecurityRules(resourceGroupName string, networkWatcherName string, parameters SecurityGroupViewParameters, cancel <-chan struct{}) (<-chan SecurityGroupViewResult, <-chan error) { + resultChan := make(chan SecurityGroupViewResult, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TargetResourceID", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "network.WatchersClient", "GetVMSecurityRules") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result SecurityGroupViewResult + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.GetVMSecurityRulesPreparer(resourceGroupName, networkWatcherName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetVMSecurityRules", nil, "Failure preparing request") + return + } + + resp, err := client.GetVMSecurityRulesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetVMSecurityRules", resp, "Failure sending request") + return + } + + result, err = client.GetVMSecurityRulesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetVMSecurityRules", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// GetVMSecurityRulesPreparer prepares the GetVMSecurityRules request. +func (client WatchersClient) GetVMSecurityRulesPreparer(resourceGroupName string, networkWatcherName string, parameters SecurityGroupViewParameters, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "networkWatcherName": autorest.Encode("path", networkWatcherName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/securityGroupView", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// GetVMSecurityRulesSender sends the GetVMSecurityRules request. The method will close the +// http.Response Body if it receives an error. +func (client WatchersClient) GetVMSecurityRulesSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// GetVMSecurityRulesResponder handles the response to the GetVMSecurityRules request. The method always +// closes the http.Response Body. +func (client WatchersClient) GetVMSecurityRulesResponder(resp *http.Response) (result SecurityGroupViewResult, 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 +} + +// List gets all network watchers by resource group. +// +// resourceGroupName is the name of the resource group. +func (client WatchersClient) List(resourceGroupName string) (result WatcherListResult, err error) { + req, err := client.ListPreparer(resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.WatchersClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client WatchersClient) ListPreparer(resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client WatchersClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client WatchersClient) ListResponder(resp *http.Response) (result WatcherListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListAll gets all network watchers by subscription. +func (client WatchersClient) ListAll() (result WatcherListResult, err error) { + req, err := client.ListAllPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "ListAll", nil, "Failure preparing request") + return + } + + resp, err := client.ListAllSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.WatchersClient", "ListAll", resp, "Failure sending request") + return + } + + result, err = client.ListAllResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "ListAll", resp, "Failure responding to request") + } + + return +} + +// ListAllPreparer prepares the ListAll request. +func (client WatchersClient) ListAllPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/networkWatchers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListAllSender sends the ListAll request. The method will close the +// http.Response Body if it receives an error. +func (client WatchersClient) ListAllSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListAllResponder handles the response to the ListAll request. The method always +// closes the http.Response Body. +func (client WatchersClient) ListAllResponder(resp *http.Response) (result WatcherListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// SetFlowLogConfiguration configures flow log on a specified resource. This +// method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the network watcher resource group. +// networkWatcherName is the name of the network watcher resource. parameters +// is parameters that define the configuration of flow log. +func (client WatchersClient) SetFlowLogConfiguration(resourceGroupName string, networkWatcherName string, parameters FlowLogInformation, cancel <-chan struct{}) (<-chan FlowLogInformation, <-chan error) { + resultChan := make(chan FlowLogInformation, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TargetResourceID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.FlowLogProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.FlowLogProperties.StorageID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.FlowLogProperties.Enabled", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "network.WatchersClient", "SetFlowLogConfiguration") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result FlowLogInformation + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.SetFlowLogConfigurationPreparer(resourceGroupName, networkWatcherName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "SetFlowLogConfiguration", nil, "Failure preparing request") + return + } + + resp, err := client.SetFlowLogConfigurationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.WatchersClient", "SetFlowLogConfiguration", resp, "Failure sending request") + return + } + + result, err = client.SetFlowLogConfigurationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "SetFlowLogConfiguration", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// SetFlowLogConfigurationPreparer prepares the SetFlowLogConfiguration request. +func (client WatchersClient) SetFlowLogConfigurationPreparer(resourceGroupName string, networkWatcherName string, parameters FlowLogInformation, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "networkWatcherName": autorest.Encode("path", networkWatcherName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/configureFlowLog", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// SetFlowLogConfigurationSender sends the SetFlowLogConfiguration request. The method will close the +// http.Response Body if it receives an error. +func (client WatchersClient) SetFlowLogConfigurationSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// SetFlowLogConfigurationResponder handles the response to the SetFlowLogConfiguration request. The method always +// closes the http.Response Body. +func (client WatchersClient) SetFlowLogConfigurationResponder(resp *http.Response) (result FlowLogInformation, 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 +} + +// VerifyIPFlow verify IP flow from the specified VM to a location given the +// currently configured NSG rules. This method may poll for completion. Polling +// can be canceled by passing the cancel channel argument. The channel will be +// used to cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. networkWatcherName is +// the name of the network watcher. parameters is parameters that define the IP +// flow to be verified. +func (client WatchersClient) VerifyIPFlow(resourceGroupName string, networkWatcherName string, parameters VerificationIPFlowParameters, cancel <-chan struct{}) (<-chan VerificationIPFlowResult, <-chan error) { + resultChan := make(chan VerificationIPFlowResult, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TargetResourceID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.LocalPort", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.RemotePort", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.LocalIPAddress", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.RemoteIPAddress", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "network.WatchersClient", "VerifyIPFlow") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result VerificationIPFlowResult + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.VerifyIPFlowPreparer(resourceGroupName, networkWatcherName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "VerifyIPFlow", nil, "Failure preparing request") + return + } + + resp, err := client.VerifyIPFlowSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "network.WatchersClient", "VerifyIPFlow", resp, "Failure sending request") + return + } + + result, err = client.VerifyIPFlowResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.WatchersClient", "VerifyIPFlow", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// VerifyIPFlowPreparer prepares the VerifyIPFlow request. +func (client WatchersClient) VerifyIPFlowPreparer(resourceGroupName string, networkWatcherName string, parameters VerificationIPFlowParameters, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "networkWatcherName": autorest.Encode("path", networkWatcherName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/ipFlowVerify", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// VerifyIPFlowSender sends the VerifyIPFlow request. The method will close the +// http.Response Body if it receives an error. +func (client WatchersClient) VerifyIPFlowSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// VerifyIPFlowResponder handles the response to the VerifyIPFlow request. The method always +// closes the http.Response Body. +func (client WatchersClient) VerifyIPFlowResponder(resp *http.Response) (result VerificationIPFlowResult, 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/arm/redis/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/client.go old mode 100644 new mode 100755 index d547a53d8..a2fe3a6d6 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/client.go @@ -17,7 +17,7 @@ package redis // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -26,9 +26,6 @@ import ( ) const ( - // APIVersion is the version of the Redis - APIVersion = "2016-04-01" - // DefaultBaseURI is the default URI used for the service Redis DefaultBaseURI = "https://management.azure.com" ) @@ -37,7 +34,6 @@ const ( type ManagementClient struct { autorest.Client BaseURI string - APIVersion string SubscriptionID string } @@ -51,7 +47,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, - APIVersion: APIVersion, SubscriptionID: subscriptionID, } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/firewallrule.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/firewallrule.go new file mode 100755 index 000000000..b1db86584 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/firewallrule.go @@ -0,0 +1,254 @@ +package redis + +// 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// FirewallRuleClient is the rEST API for Azure Redis Cache Service. +type FirewallRuleClient struct { + ManagementClient +} + +// NewFirewallRuleClient creates an instance of the FirewallRuleClient client. +func NewFirewallRuleClient(subscriptionID string) FirewallRuleClient { + return NewFirewallRuleClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFirewallRuleClientWithBaseURI creates an instance of the +// FirewallRuleClient client. +func NewFirewallRuleClientWithBaseURI(baseURI string, subscriptionID string) FirewallRuleClient { + return FirewallRuleClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update a redis cache firewall rule +// +// resourceGroupName is the name of the resource group. cacheName is the name +// of the Redis cache. ruleName is the name of the firewall rule. parameters is +// parameters supplied to the create or update redis firewall rule operation. +func (client FirewallRuleClient) CreateOrUpdate(resourceGroupName string, cacheName string, ruleName string, parameters FirewallRule) (result FirewallRule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.FirewallRuleProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.FirewallRuleProperties.StartIP", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.FirewallRuleProperties.EndIP", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "redis.FirewallRuleClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, cacheName, ruleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.FirewallRuleClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redis.FirewallRuleClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.FirewallRuleClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client FirewallRuleClient) CreateOrUpdatePreparer(resourceGroupName string, cacheName string, ruleName string, parameters FirewallRule) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{cacheName}/firewallRules/{ruleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRuleClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client FirewallRuleClient) CreateOrUpdateResponder(resp *http.Response) (result FirewallRule, 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 deletes a single firewall rule in a specified redis cache. +// +// resourceGroupName is the name of the resource group. cacheName is the name +// of the Redis cache. ruleName is the name of the firewall rule. +func (client FirewallRuleClient) Delete(resourceGroupName string, cacheName string, ruleName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, cacheName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.FirewallRuleClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "redis.FirewallRuleClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.FirewallRuleClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client FirewallRuleClient) DeletePreparer(resourceGroupName string, cacheName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{cacheName}/firewallRules/{ruleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRuleClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client FirewallRuleClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a single firewall rule in a specified redis cache. +// +// resourceGroupName is the name of the resource group. cacheName is the name +// of the Redis cache. ruleName is the name of the firewall rule. +func (client FirewallRuleClient) Get(resourceGroupName string, cacheName string, ruleName string) (result FirewallRule, err error) { + req, err := client.GetPreparer(resourceGroupName, cacheName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.FirewallRuleClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redis.FirewallRuleClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.FirewallRuleClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client FirewallRuleClient) GetPreparer(resourceGroupName string, cacheName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{cacheName}/firewallRules/{ruleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRuleClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client FirewallRuleClient) GetResponder(resp *http.Response) (result FirewallRule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/firewallrules.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/firewallrules.go new file mode 100755 index 000000000..571d96bc7 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/firewallrules.go @@ -0,0 +1,132 @@ +package redis + +// 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// FirewallRulesClient is the rEST API for Azure Redis Cache Service. +type FirewallRulesClient struct { + ManagementClient +} + +// NewFirewallRulesClient creates an instance of the FirewallRulesClient +// client. +func NewFirewallRulesClient(subscriptionID string) FirewallRulesClient { + return NewFirewallRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFirewallRulesClientWithBaseURI creates an instance of the +// FirewallRulesClient client. +func NewFirewallRulesClientWithBaseURI(baseURI string, subscriptionID string) FirewallRulesClient { + return FirewallRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List gets all firewall rules in the specified redis cache. +// +// resourceGroupName is the name of the resource group. cacheName is the name +// of the Redis cache. +func (client FirewallRulesClient) List(resourceGroupName string, cacheName string) (result FirewallRuleListResult, err error) { + req, err := client.ListPreparer(resourceGroupName, cacheName) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client FirewallRulesClient) ListPreparer(resourceGroupName string, cacheName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{cacheName}/firewallRules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRulesClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) ListResponder(resp *http.Response) (result FirewallRuleListResult, 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 FirewallRulesClient) ListNextResults(lastResults FirewallRuleListResult) (result FirewallRuleListResult, err error) { + req, err := lastResults.FirewallRuleListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "List", 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, "redis.FirewallRulesClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.FirewallRulesClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/models.go old mode 100644 new mode 100755 index 85e003532..f4ef80cc5 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/models.go @@ -14,7 +14,7 @@ package redis // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -127,6 +127,49 @@ type ExportRDBParameters struct { Container *string `json:"container,omitempty"` } +// FirewallRule is a firewall rule on a redis cache has a name, and describes a +// contiguous range of IP addresses permitted to connect +type FirewallRule struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + *FirewallRuleProperties `json:"properties,omitempty"` +} + +// FirewallRuleListResult is the response of list firewall rules Redis +// operation. +type FirewallRuleListResult struct { + autorest.Response `json:"-"` + Value *[]FirewallRule `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// FirewallRuleListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client FirewallRuleListResult) FirewallRuleListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// FirewallRuleProperties is specifies a range of IP addresses permitted to +// connect to the cache +type FirewallRuleProperties struct { + StartIP *string `json:"startIP,omitempty"` + EndIP *string `json:"endIP,omitempty"` +} + +// ForceRebootResponse is response to force reboot for Redis cache. +type ForceRebootResponse struct { + autorest.Response `json:"-"` + Message *string `json:"Message,omitempty"` +} + // ImportRDBParameters is parameters for Redis import operation. type ImportRDBParameters struct { Format *string `json:"format,omitempty"` @@ -152,6 +195,41 @@ func (client ListResult) ListResultPreparer() (*http.Request, error) { autorest.WithBaseURL(to.String(client.NextLink))) } +// Operation is rEST API operation +type Operation struct { + Name *string `json:"name,omitempty"` + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay is the object that describes the operation. +type OperationDisplay struct { + Provider *string `json:"provider,omitempty"` + Operation *string `json:"operation,omitempty"` + Resource *string `json:"resource,omitempty"` + Description *string `json:"description,omitempty"` +} + +// OperationListResult is result of the request to list REST API operations. It +// contains a list of operations and a URL nextLink to get the next set of +// results. +type OperationListResult struct { + autorest.Response `json:"-"` + Value *[]Operation `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client OperationListResult) OperationListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + // PatchSchedule is response to put/get patch schedules for Redis cache. type PatchSchedule struct { autorest.Response `json:"-"` @@ -206,6 +284,7 @@ type ResourceProperties struct { HostName *string `json:"hostName,omitempty"` Port *int32 `json:"port,omitempty"` SslPort *int32 `json:"sslPort,omitempty"` + AccessKeys *AccessKeys `json:"accessKeys,omitempty"` } // ResourceType is a single Redis item in List or Get Operation. diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/operations.go new file mode 100755 index 000000000..f0e825dd1 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/operations.go @@ -0,0 +1,123 @@ +package redis + +// 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OperationsClient is the rEST API for Azure Redis Cache Service. +type OperationsClient struct { + ManagementClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient +// client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available REST API operations of the Microsoft.Cache +// provider. +func (client OperationsClient) List() (result OperationListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "redis.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redis.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer() (*http.Request, error) { + const APIVersion = "2016-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Cache/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, 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 OperationsClient) ListNextResults(lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.OperationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "redis.OperationsClient", "List", 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, "redis.OperationsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.OperationsClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/patchschedules.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/patchschedules.go old mode 100644 new mode 100755 index 1994aaf4c..44661ec9a --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/patchschedules.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/patchschedules.go @@ -14,16 +14,15 @@ package redis // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. import ( - "net/http" - "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/validation" + "net/http" ) // PatchSchedulesClient is the rEST API for Azure Redis Cache Service. @@ -54,19 +53,20 @@ func (client PatchSchedulesClient) CreateOrUpdate(resourceGroupName string, name {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.ScheduleEntries", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "parameters.ScheduleEntries.ScheduleEntries", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "redis.PatchSchedulesClient", "CreateOrUpdate") } req, err := client.CreateOrUpdatePreparer(resourceGroupName, name, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "redis.PatchSchedulesClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "redis.PatchSchedulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "redis.PatchSchedulesClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "redis.PatchSchedulesClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -85,8 +85,9 @@ func (client PatchSchedulesClient) CreateOrUpdatePreparer(resourceGroupName stri "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -111,7 +112,7 @@ func (client PatchSchedulesClient) CreateOrUpdateResponder(resp *http.Response) err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} @@ -126,13 +127,15 @@ func (client PatchSchedulesClient) CreateOrUpdateResponder(resp *http.Response) func (client PatchSchedulesClient) Delete(resourceGroupName string, name string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, name) if err != nil { - return result, autorest.NewErrorWithError(err, "redis.PatchSchedulesClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "redis.PatchSchedulesClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "redis.PatchSchedulesClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "redis.PatchSchedulesClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -151,8 +154,9 @@ func (client PatchSchedulesClient) DeletePreparer(resourceGroupName string, name "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -188,13 +192,15 @@ func (client PatchSchedulesClient) DeleteResponder(resp *http.Response) (result func (client PatchSchedulesClient) Get(resourceGroupName string, name string) (result PatchSchedule, err error) { req, err := client.GetPreparer(resourceGroupName, name) if err != nil { - return result, autorest.NewErrorWithError(err, "redis.PatchSchedulesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "redis.PatchSchedulesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "redis.PatchSchedulesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "redis.PatchSchedulesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -213,8 +219,9 @@ func (client PatchSchedulesClient) GetPreparer(resourceGroupName string, name st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -237,7 +244,7 @@ func (client PatchSchedulesClient) GetResponder(resp *http.Response) (result Pat err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), + azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/redisgroup.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/redisgroup.go old mode 100644 new mode 100755 index b41afccf5..af411bfaa --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/redisgroup.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/redisgroup.go @@ -14,7 +14,7 @@ package redis // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -48,33 +48,49 @@ func NewGroupClientWithBaseURI(baseURI string, subscriptionID string) GroupClien // resourceGroupName is the name of the resource group. name is the name of the // Redis cache. parameters is parameters supplied to the Create Redis // operation. -func (client GroupClient) Create(resourceGroupName string, name string, parameters CreateParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client GroupClient) Create(resourceGroupName string, name string, parameters CreateParameters, cancel <-chan struct{}) (<-chan ResourceType, <-chan error) { + resultChan := make(chan ResourceType, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.CreateProperties", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "parameters.CreateProperties.Sku", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "parameters.CreateProperties.Sku.Capacity", Name: validation.Null, Rule: true, Chain: nil}}}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "redis.GroupClient", "Create") + errChan <- validation.NewErrorWithValidationError(err, "redis.GroupClient", "Create") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreatePreparer(resourceGroupName, name, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "redis.GroupClient", "Create", nil, "Failure preparing request") - } + go func() { + var err error + var result ResourceType + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(resourceGroupName, name, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.GroupClient", "Create", nil, "Failure preparing request") + return + } - resp, err := client.CreateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "redis.GroupClient", "Create", resp, "Failure sending request") - } + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redis.GroupClient", "Create", resp, "Failure sending request") + return + } - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "redis.GroupClient", "Create", resp, "Failure responding to request") - } - - return + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.GroupClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreatePreparer prepares the Create request. @@ -85,8 +101,9 @@ func (client GroupClient) CreatePreparer(resourceGroupName string, name string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -109,13 +126,14 @@ func (client GroupClient) CreateSender(req *http.Request) (*http.Response, error // CreateResponder handles the response to the Create request. The method always // closes the http.Response Body. -func (client GroupClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client GroupClient) CreateResponder(resp *http.Response) (result ResourceType, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -125,24 +143,37 @@ func (client GroupClient) CreateResponder(resp *http.Response) (result autorest. // // resourceGroupName is the name of the resource group. name is the name of the // Redis cache. -func (client GroupClient) Delete(resourceGroupName string, name string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, name, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "redis.GroupClient", "Delete", nil, "Failure preparing request") - } +func (client GroupClient) Delete(resourceGroupName string, name string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, name, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.GroupClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "redis.GroupClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "redis.GroupClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "redis.GroupClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.GroupClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -153,8 +184,9 @@ func (client GroupClient) DeletePreparer(resourceGroupName string, name string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -192,31 +224,47 @@ func (client GroupClient) DeleteResponder(resp *http.Response) (result autorest. // // resourceGroupName is the name of the resource group. name is the name of the // Redis cache. parameters is parameters for Redis export operation. -func (client GroupClient) ExportData(resourceGroupName string, name string, parameters ExportRDBParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client GroupClient) ExportData(resourceGroupName string, name string, parameters ExportRDBParameters, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.Prefix", Name: validation.Null, Rule: true, Chain: nil}, {Target: "parameters.Container", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "redis.GroupClient", "ExportData") + errChan <- validation.NewErrorWithValidationError(err, "redis.GroupClient", "ExportData") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.ExportDataPreparer(resourceGroupName, name, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "redis.GroupClient", "ExportData", nil, "Failure preparing request") - } + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ExportDataPreparer(resourceGroupName, name, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.GroupClient", "ExportData", nil, "Failure preparing request") + return + } - resp, err := client.ExportDataSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "redis.GroupClient", "ExportData", resp, "Failure sending request") - } + resp, err := client.ExportDataSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "redis.GroupClient", "ExportData", resp, "Failure sending request") + return + } - result, err = client.ExportDataResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "redis.GroupClient", "ExportData", resp, "Failure responding to request") - } - - return + result, err = client.ExportDataResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.GroupClient", "ExportData", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // ExportDataPreparer prepares the ExportData request. @@ -227,8 +275,9 @@ func (client GroupClient) ExportDataPreparer(resourceGroupName string, name stri "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -255,7 +304,7 @@ func (client GroupClient) ExportDataResponder(resp *http.Response) (result autor err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK, http.StatusNoContent), autorest.ByClosing()) result.Response = resp return @@ -266,16 +315,18 @@ func (client GroupClient) ExportDataResponder(resp *http.Response) (result autor // // resourceGroupName is the name of the resource group. name is the name of the // Redis cache. parameters is specifies which Redis node(s) to reboot. -func (client GroupClient) ForceReboot(resourceGroupName string, name string, parameters RebootParameters) (result autorest.Response, err error) { +func (client GroupClient) ForceReboot(resourceGroupName string, name string, parameters RebootParameters) (result ForceRebootResponse, err error) { req, err := client.ForceRebootPreparer(resourceGroupName, name, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "redis.GroupClient", "ForceReboot", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "redis.GroupClient", "ForceReboot", nil, "Failure preparing request") + return } resp, err := client.ForceRebootSender(req) if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "redis.GroupClient", "ForceReboot", resp, "Failure sending request") + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redis.GroupClient", "ForceReboot", resp, "Failure sending request") + return } result, err = client.ForceRebootResponder(resp) @@ -294,8 +345,9 @@ func (client GroupClient) ForceRebootPreparer(resourceGroupName string, name str "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -316,13 +368,14 @@ func (client GroupClient) ForceRebootSender(req *http.Request) (*http.Response, // ForceRebootResponder handles the response to the ForceReboot request. The method always // closes the http.Response Body. -func (client GroupClient) ForceRebootResponder(resp *http.Response) (result autorest.Response, err error) { +func (client GroupClient) ForceRebootResponder(resp *http.Response) (result ForceRebootResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -333,13 +386,15 @@ func (client GroupClient) ForceRebootResponder(resp *http.Response) (result auto func (client GroupClient) Get(resourceGroupName string, name string) (result ResourceType, err error) { req, err := client.GetPreparer(resourceGroupName, name) if err != nil { - return result, autorest.NewErrorWithError(err, "redis.GroupClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "redis.GroupClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "redis.GroupClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "redis.GroupClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -358,8 +413,9 @@ func (client GroupClient) GetPreparer(resourceGroupName string, name string) (*h "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -396,30 +452,46 @@ func (client GroupClient) GetResponder(resp *http.Response) (result ResourceType // // resourceGroupName is the name of the resource group. name is the name of the // Redis cache. parameters is parameters for Redis import operation. -func (client GroupClient) ImportData(resourceGroupName string, name string, parameters ImportRDBParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client GroupClient) ImportData(resourceGroupName string, name string, parameters ImportRDBParameters, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.Files", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "redis.GroupClient", "ImportData") + errChan <- validation.NewErrorWithValidationError(err, "redis.GroupClient", "ImportData") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.ImportDataPreparer(resourceGroupName, name, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "redis.GroupClient", "ImportData", nil, "Failure preparing request") - } + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ImportDataPreparer(resourceGroupName, name, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.GroupClient", "ImportData", nil, "Failure preparing request") + return + } - resp, err := client.ImportDataSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "redis.GroupClient", "ImportData", resp, "Failure sending request") - } + resp, err := client.ImportDataSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "redis.GroupClient", "ImportData", resp, "Failure sending request") + return + } - result, err = client.ImportDataResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "redis.GroupClient", "ImportData", resp, "Failure responding to request") - } - - return + result, err = client.ImportDataResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redis.GroupClient", "ImportData", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // ImportDataPreparer prepares the ImportData request. @@ -430,8 +502,9 @@ func (client GroupClient) ImportDataPreparer(resourceGroupName string, name stri "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -458,7 +531,7 @@ func (client GroupClient) ImportDataResponder(resp *http.Response) (result autor err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK, http.StatusNoContent), autorest.ByClosing()) result.Response = resp return @@ -468,13 +541,15 @@ func (client GroupClient) ImportDataResponder(resp *http.Response) (result autor func (client GroupClient) List() (result ListResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "redis.GroupClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "redis.GroupClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "redis.GroupClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "redis.GroupClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -491,8 +566,9 @@ func (client GroupClient) ListPreparer() (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -552,13 +628,15 @@ func (client GroupClient) ListNextResults(lastResults ListResult) (result ListRe func (client GroupClient) ListByResourceGroup(resourceGroupName string) (result ListResult, err error) { req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "redis.GroupClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "redis.GroupClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "redis.GroupClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "redis.GroupClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -576,8 +654,9 @@ func (client GroupClient) ListByResourceGroupPreparer(resourceGroupName string) "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -639,13 +718,15 @@ func (client GroupClient) ListByResourceGroupNextResults(lastResults ListResult) func (client GroupClient) ListKeys(resourceGroupName string, name string) (result AccessKeys, err error) { req, err := client.ListKeysPreparer(resourceGroupName, name) if err != nil { - return result, autorest.NewErrorWithError(err, "redis.GroupClient", "ListKeys", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "redis.GroupClient", "ListKeys", nil, "Failure preparing request") + return } resp, err := client.ListKeysSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "redis.GroupClient", "ListKeys", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "redis.GroupClient", "ListKeys", resp, "Failure sending request") + return } result, err = client.ListKeysResponder(resp) @@ -664,8 +745,9 @@ func (client GroupClient) ListKeysPreparer(resourceGroupName string, name string "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -703,13 +785,15 @@ func (client GroupClient) ListKeysResponder(resp *http.Response) (result AccessK func (client GroupClient) RegenerateKey(resourceGroupName string, name string, parameters RegenerateKeyParameters) (result AccessKeys, err error) { req, err := client.RegenerateKeyPreparer(resourceGroupName, name, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "redis.GroupClient", "RegenerateKey", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "redis.GroupClient", "RegenerateKey", nil, "Failure preparing request") + return } resp, err := client.RegenerateKeySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "redis.GroupClient", "RegenerateKey", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "redis.GroupClient", "RegenerateKey", resp, "Failure sending request") + return } result, err = client.RegenerateKeyResponder(resp) @@ -728,8 +812,9 @@ func (client GroupClient) RegenerateKeyPreparer(resourceGroupName string, name s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -769,13 +854,15 @@ func (client GroupClient) RegenerateKeyResponder(resp *http.Response) (result Ac func (client GroupClient) Update(resourceGroupName string, name string, parameters UpdateParameters) (result ResourceType, err error) { req, err := client.UpdatePreparer(resourceGroupName, name, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "redis.GroupClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "redis.GroupClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "redis.GroupClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "redis.GroupClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -794,8 +881,9 @@ func (client GroupClient) UpdatePreparer(resourceGroupName string, name string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/version.go old mode 100644 new mode 100755 index 6f6645623..c5a6a48ad --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/version.go @@ -18,43 +18,12 @@ package redis // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -import ( - "bytes" - "fmt" - "strings" -) - -const ( - major = "8" - minor = "1" - patch = "0" - tag = "beta" - userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" -) - -// cached results of UserAgent and Version to prevent repeated operations. -var ( - userAgent string - version string -) - // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - if userAgent == "" { - userAgent = fmt.Sprintf(userAgentFormat, Version(), "redis", "2016-04-01") - } - return userAgent + return "Azure-SDK-For-Go/v10.0.2-beta arm-redis/2016-04-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - if version == "" { - versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) - if tag != "" { - versionBuilder.WriteRune('-') - versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) - } - version = string(versionBuilder.Bytes()) - } - return version + return "v10.0.2-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/client.go old mode 100644 new mode 100755 index d994e08b3..3e13c72f9 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/client.go @@ -27,9 +27,6 @@ import ( ) const ( - // APIVersion is the version of the Resources - APIVersion = "2016-09-01" - // DefaultBaseURI is the default URI used for the service Resources DefaultBaseURI = "https://management.azure.com" ) @@ -38,7 +35,6 @@ const ( type ManagementClient struct { autorest.Client BaseURI string - APIVersion string SubscriptionID string } @@ -52,7 +48,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, - APIVersion: APIVersion, SubscriptionID: subscriptionID, } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/deploymentoperations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/deploymentoperations.go old mode 100644 new mode 100755 index 58f470f3e..34d12aac6 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/deploymentoperations.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/deploymentoperations.go @@ -63,13 +63,15 @@ func (client DeploymentOperationsClient) Get(resourceGroupName string, deploymen req, err := client.GetPreparer(resourceGroupName, deploymentName, operationID) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.DeploymentOperationsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.DeploymentOperationsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.DeploymentOperationsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.DeploymentOperationsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -89,8 +91,9 @@ func (client DeploymentOperationsClient) GetPreparer(resourceGroupName string, d "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -140,13 +143,15 @@ func (client DeploymentOperationsClient) List(resourceGroupName string, deployme req, err := client.ListPreparer(resourceGroupName, deploymentName, top) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.DeploymentOperationsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.DeploymentOperationsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.DeploymentOperationsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.DeploymentOperationsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -165,8 +170,9 @@ func (client DeploymentOperationsClient) ListPreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if top != nil { queryParameters["$top"] = autorest.Encode("query", *top) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/deployments.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/deployments.go old mode 100644 new mode 100755 index bd1e702ca..7c3e19288 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/deployments.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/deployments.go @@ -64,13 +64,15 @@ func (client DeploymentsClient) Cancel(resourceGroupName string, deploymentName req, err := client.CancelPreparer(resourceGroupName, deploymentName) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Cancel", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Cancel", nil, "Failure preparing request") + return } resp, err := client.CancelSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Cancel", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Cancel", resp, "Failure sending request") + return } result, err = client.CancelResponder(resp) @@ -89,8 +91,9 @@ func (client DeploymentsClient) CancelPreparer(resourceGroupName string, deploym "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -139,13 +142,15 @@ func (client DeploymentsClient) CheckExistence(resourceGroupName string, deploym req, err := client.CheckExistencePreparer(resourceGroupName, deploymentName) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "CheckExistence", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "CheckExistence", nil, "Failure preparing request") + return } resp, err := client.CheckExistenceSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "CheckExistence", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "CheckExistence", resp, "Failure sending request") + return } result, err = client.CheckExistenceResponder(resp) @@ -164,8 +169,9 @@ func (client DeploymentsClient) CheckExistencePreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -203,7 +209,9 @@ func (client DeploymentsClient) CheckExistenceResponder(resp *http.Response) (re // to. The name is case insensitive. The resource group must already exist. // deploymentName is the name of the deployment. parameters is additional // parameters supplied to the operation. -func (client DeploymentsClient) CreateOrUpdate(resourceGroupName string, deploymentName string, parameters Deployment, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client DeploymentsClient) CreateOrUpdate(resourceGroupName string, deploymentName string, parameters Deployment, cancel <-chan struct{}) (<-chan DeploymentExtended, <-chan error) { + resultChan := make(chan DeploymentExtended, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -214,32 +222,46 @@ func (client DeploymentsClient) CreateOrUpdate(resourceGroupName string, deploym {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: false, + Constraints: []validation.Constraint{{Target: "parameters.Properties", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "parameters.Properties.TemplateLink", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.Properties.TemplateLink.URI", Name: validation.Null, Rule: true, Chain: nil}}}, {Target: "parameters.Properties.ParametersLink", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.Properties.ParametersLink.URI", Name: validation.Null, Rule: true, Chain: nil}}}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "resources.DeploymentsClient", "CreateOrUpdate") + errChan <- validation.NewErrorWithValidationError(err, "resources.DeploymentsClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, deploymentName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "CreateOrUpdate", nil, "Failure preparing request") - } + go func() { + var err error + var result DeploymentExtended + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, deploymentName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -250,8 +272,9 @@ func (client DeploymentsClient) CreateOrUpdatePreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -274,13 +297,14 @@ func (client DeploymentsClient) CreateOrUpdateSender(req *http.Request) (*http.R // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client DeploymentsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client DeploymentsClient) CreateOrUpdateResponder(resp *http.Response) (result DeploymentExtended, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -301,7 +325,9 @@ func (client DeploymentsClient) CreateOrUpdateResponder(resp *http.Response) (re // resourceGroupName is the name of the resource group with the deployment to // delete. The name is case insensitive. deploymentName is the name of the // deployment to delete. -func (client DeploymentsClient) Delete(resourceGroupName string, deploymentName string, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client DeploymentsClient) Delete(resourceGroupName string, deploymentName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -311,26 +337,40 @@ func (client DeploymentsClient) Delete(resourceGroupName string, 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 { - return result, validation.NewErrorWithValidationError(err, "resources.DeploymentsClient", "Delete") + errChan <- validation.NewErrorWithValidationError(err, "resources.DeploymentsClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.DeletePreparer(resourceGroupName, deploymentName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Delete", nil, "Failure preparing request") - } + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, deploymentName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -341,8 +381,9 @@ func (client DeploymentsClient) DeletePreparer(resourceGroupName string, deploym "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -393,13 +434,15 @@ func (client DeploymentsClient) ExportTemplate(resourceGroupName string, deploym req, err := client.ExportTemplatePreparer(resourceGroupName, deploymentName) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "ExportTemplate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "ExportTemplate", nil, "Failure preparing request") + return } resp, err := client.ExportTemplateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "ExportTemplate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "ExportTemplate", resp, "Failure sending request") + return } result, err = client.ExportTemplateResponder(resp) @@ -418,8 +461,9 @@ func (client DeploymentsClient) ExportTemplatePreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -468,13 +512,15 @@ func (client DeploymentsClient) Get(resourceGroupName string, deploymentName str req, err := client.GetPreparer(resourceGroupName, deploymentName) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -493,8 +539,9 @@ func (client DeploymentsClient) GetPreparer(resourceGroupName string, deployment "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -542,13 +589,15 @@ func (client DeploymentsClient) List(resourceGroupName string, filter string, to req, err := client.ListPreparer(resourceGroupName, filter, top) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -566,8 +615,9 @@ func (client DeploymentsClient) ListPreparer(resourceGroupName string, filter st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -644,7 +694,7 @@ func (client DeploymentsClient) Validate(resourceGroupName string, deploymentNam {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: false, + Constraints: []validation.Constraint{{Target: "parameters.Properties", Name: validation.Null, Rule: true, 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, @@ -655,13 +705,15 @@ func (client DeploymentsClient) Validate(resourceGroupName string, deploymentNam req, err := client.ValidatePreparer(resourceGroupName, deploymentName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Validate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Validate", nil, "Failure preparing request") + return } resp, err := client.ValidateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Validate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "Validate", resp, "Failure sending request") + return } result, err = client.ValidateResponder(resp) @@ -680,8 +732,9 @@ func (client DeploymentsClient) ValidatePreparer(resourceGroupName string, deplo "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/groups.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/groups.go old mode 100644 new mode 100755 index 084cfe21e..13244a9ea --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/groups.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/groups.go @@ -56,13 +56,15 @@ func (client GroupsClient) CheckExistence(resourceGroupName string) (result auto req, err := client.CheckExistencePreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "CheckExistence", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.GroupsClient", "CheckExistence", nil, "Failure preparing request") + return } resp, err := client.CheckExistenceSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "CheckExistence", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.GroupsClient", "CheckExistence", resp, "Failure sending request") + return } result, err = client.CheckExistenceResponder(resp) @@ -80,8 +82,9 @@ func (client GroupsClient) CheckExistencePreparer(resourceGroupName string) (*ht "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -127,13 +130,15 @@ func (client GroupsClient) CreateOrUpdate(resourceGroupName string, parameters G req, err := client.CreateOrUpdatePreparer(resourceGroupName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.GroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.GroupsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -151,8 +156,9 @@ func (client GroupsClient) CreateOrUpdatePreparer(resourceGroupName string, para "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -192,32 +198,48 @@ func (client GroupsClient) CreateOrUpdateResponder(resp *http.Response) (result // // resourceGroupName is the name of the resource group to delete. The name is // case insensitive. -func (client GroupsClient) Delete(resourceGroupName string, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client GroupsClient) Delete(resourceGroupName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) 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.NewErrorWithValidationError(err, "resources.GroupsClient", "Delete") + errChan <- validation.NewErrorWithValidationError(err, "resources.GroupsClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.DeletePreparer(resourceGroupName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "Delete", nil, "Failure preparing request") - } + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -227,8 +249,9 @@ func (client GroupsClient) DeletePreparer(resourceGroupName string, cancel <-cha "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -274,13 +297,15 @@ func (client GroupsClient) ExportTemplate(resourceGroupName string, parameters E req, err := client.ExportTemplatePreparer(resourceGroupName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "ExportTemplate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.GroupsClient", "ExportTemplate", nil, "Failure preparing request") + return } resp, err := client.ExportTemplateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "ExportTemplate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.GroupsClient", "ExportTemplate", resp, "Failure sending request") + return } result, err = client.ExportTemplateResponder(resp) @@ -298,8 +323,9 @@ func (client GroupsClient) ExportTemplatePreparer(resourceGroupName string, para "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -346,13 +372,15 @@ func (client GroupsClient) Get(resourceGroupName string) (result Group, err erro req, err := client.GetPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -370,8 +398,9 @@ func (client GroupsClient) GetPreparer(resourceGroupName string) (*http.Request, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -408,13 +437,15 @@ func (client GroupsClient) GetResponder(resp *http.Response) (result Group, err func (client GroupsClient) List(filter string, top *int32) (result GroupListResult, err error) { req, err := client.ListPreparer(filter, top) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.GroupsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.GroupsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -431,8 +462,9 @@ func (client GroupsClient) ListPreparer(filter string, top *int32) (*http.Reques "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -509,13 +541,15 @@ func (client GroupsClient) ListResources(resourceGroupName string, filter string req, err := client.ListResourcesPreparer(resourceGroupName, filter, expand, top) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "ListResources", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.GroupsClient", "ListResources", nil, "Failure preparing request") + return } resp, err := client.ListResourcesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "ListResources", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.GroupsClient", "ListResources", resp, "Failure sending request") + return } result, err = client.ListResourcesResponder(resp) @@ -533,8 +567,9 @@ func (client GroupsClient) ListResourcesPreparer(resourceGroupName string, filte "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -615,13 +650,15 @@ func (client GroupsClient) Patch(resourceGroupName string, parameters Group) (re req, err := client.PatchPreparer(resourceGroupName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "Patch", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Patch", nil, "Failure preparing request") + return } resp, err := client.PatchSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "Patch", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Patch", resp, "Failure sending request") + return } result, err = client.PatchResponder(resp) @@ -639,8 +676,9 @@ func (client GroupsClient) PatchPreparer(resourceGroupName string, parameters Gr "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/models.go old mode 100644 new mode 100755 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/providers.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/providers.go old mode 100644 new mode 100755 index 827e49dd5..7fd6dc158 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/providers.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/providers.go @@ -49,13 +49,15 @@ func NewProvidersClientWithBaseURI(baseURI string, subscriptionID string) Provid func (client ProvidersClient) Get(resourceProviderNamespace string, expand string) (result Provider, err error) { req, err := client.GetPreparer(resourceProviderNamespace, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.ProvidersClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.ProvidersClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.ProvidersClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.ProvidersClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -73,8 +75,9 @@ func (client ProvidersClient) GetPreparer(resourceProviderNamespace string, expa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(expand) > 0 { queryParameters["$expand"] = autorest.Encode("query", expand) @@ -117,13 +120,15 @@ func (client ProvidersClient) GetResponder(resp *http.Response) (result Provider func (client ProvidersClient) List(top *int32, expand string) (result ProviderListResult, err error) { req, err := client.ListPreparer(top, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.ProvidersClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.ProvidersClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.ProvidersClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.ProvidersClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -140,8 +145,9 @@ func (client ProvidersClient) ListPreparer(top *int32, expand string) (*http.Req "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if top != nil { queryParameters["$top"] = autorest.Encode("query", *top) @@ -208,13 +214,15 @@ func (client ProvidersClient) ListNextResults(lastResults ProviderListResult) (r func (client ProvidersClient) Register(resourceProviderNamespace string) (result Provider, err error) { req, err := client.RegisterPreparer(resourceProviderNamespace) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.ProvidersClient", "Register", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.ProvidersClient", "Register", nil, "Failure preparing request") + return } resp, err := client.RegisterSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.ProvidersClient", "Register", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.ProvidersClient", "Register", resp, "Failure sending request") + return } result, err = client.RegisterResponder(resp) @@ -232,8 +240,9 @@ func (client ProvidersClient) RegisterPreparer(resourceProviderNamespace string) "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -270,13 +279,15 @@ func (client ProvidersClient) RegisterResponder(resp *http.Response) (result Pro func (client ProvidersClient) Unregister(resourceProviderNamespace string) (result Provider, err error) { req, err := client.UnregisterPreparer(resourceProviderNamespace) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.ProvidersClient", "Unregister", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.ProvidersClient", "Unregister", nil, "Failure preparing request") + return } resp, err := client.UnregisterSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.ProvidersClient", "Unregister", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.ProvidersClient", "Unregister", resp, "Failure sending request") + return } result, err = client.UnregisterResponder(resp) @@ -294,8 +305,9 @@ func (client ProvidersClient) UnregisterPreparer(resourceProviderNamespace strin "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/resourcesgroup.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/resourcesgroup.go old mode 100644 new mode 100755 index 6b752cc81..a7179dda8 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/resourcesgroup.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/resourcesgroup.go @@ -59,13 +59,15 @@ func (client GroupClient) CheckExistence(resourceGroupName string, resourceProvi req, err := client.CheckExistencePreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.GroupClient", "CheckExistence", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.GroupClient", "CheckExistence", nil, "Failure preparing request") + return } resp, err := client.CheckExistenceSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "resources.GroupClient", "CheckExistence", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.GroupClient", "CheckExistence", resp, "Failure sending request") + return } result, err = client.CheckExistenceResponder(resp) @@ -87,8 +89,9 @@ func (client GroupClient) CheckExistencePreparer(resourceGroupName string, resou "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -125,13 +128,15 @@ func (client GroupClient) CheckExistenceResponder(resp *http.Response) (result a func (client GroupClient) CheckExistenceByID(resourceID string) (result autorest.Response, err error) { req, err := client.CheckExistenceByIDPreparer(resourceID) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.GroupClient", "CheckExistenceByID", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.GroupClient", "CheckExistenceByID", nil, "Failure preparing request") + return } resp, err := client.CheckExistenceByIDSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "resources.GroupClient", "CheckExistenceByID", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.GroupClient", "CheckExistenceByID", resp, "Failure sending request") + return } result, err = client.CheckExistenceByIDResponder(resp) @@ -148,8 +153,9 @@ func (client GroupClient) CheckExistenceByIDPreparer(resourceID string) (*http.R "resourceId": resourceID, } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -188,7 +194,9 @@ func (client GroupClient) CheckExistenceByIDResponder(resp *http.Response) (resu // resourceType is the resource type of the resource to create. resourceName is // the name of the resource to create. parameters is parameters for creating or // updating the resource. -func (client GroupClient) CreateOrUpdate(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, parameters GenericResource, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client GroupClient) CreateOrUpdate(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, parameters GenericResource, cancel <-chan struct{}) (<-chan GenericResource, <-chan error) { + resultChan := make(chan GenericResource, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -197,26 +205,40 @@ func (client GroupClient) CreateOrUpdate(resourceGroupName string, resourceProvi {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.NewErrorWithValidationError(err, "resources.GroupClient", "CreateOrUpdate") + errChan <- validation.NewErrorWithValidationError(err, "resources.GroupClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.GroupClient", "CreateOrUpdate", nil, "Failure preparing request") - } + go func() { + var err error + var result GenericResource + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "resources.GroupClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "resources.GroupClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "resources.GroupClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "resources.GroupClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -230,8 +252,9 @@ func (client GroupClient) CreateOrUpdatePreparer(resourceGroupName string, resou "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -254,13 +277,14 @@ func (client GroupClient) CreateOrUpdateSender(req *http.Request) (*http.Respons // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client GroupClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client GroupClient) CreateOrUpdateResponder(resp *http.Response) (result GenericResource, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -273,31 +297,47 @@ func (client GroupClient) CreateOrUpdateResponder(resp *http.Response) (result a // name and resource type. Use the format, // /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} // parameters is create or update resource parameters. -func (client GroupClient) CreateOrUpdateByID(resourceID string, parameters GenericResource, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client GroupClient) CreateOrUpdateByID(resourceID string, parameters GenericResource, cancel <-chan struct{}) (<-chan GenericResource, <-chan error) { + resultChan := make(chan GenericResource, 1) + errChan := make(chan error, 1) 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.NewErrorWithValidationError(err, "resources.GroupClient", "CreateOrUpdateByID") + errChan <- validation.NewErrorWithValidationError(err, "resources.GroupClient", "CreateOrUpdateByID") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdateByIDPreparer(resourceID, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.GroupClient", "CreateOrUpdateByID", nil, "Failure preparing request") - } + go func() { + var err error + var result GenericResource + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdateByIDPreparer(resourceID, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "resources.GroupClient", "CreateOrUpdateByID", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateByIDSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "resources.GroupClient", "CreateOrUpdateByID", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "resources.GroupClient", "CreateOrUpdateByID", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateByIDResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupClient", "CreateOrUpdateByID", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "resources.GroupClient", "CreateOrUpdateByID", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdateByIDPreparer prepares the CreateOrUpdateByID request. @@ -306,8 +346,9 @@ func (client GroupClient) CreateOrUpdateByIDPreparer(resourceID string, paramete "resourceId": resourceID, } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -330,13 +371,14 @@ func (client GroupClient) CreateOrUpdateByIDSender(req *http.Request) (*http.Res // CreateOrUpdateByIDResponder handles the response to the CreateOrUpdateByID request. The method always // closes the http.Response Body. -func (client GroupClient) CreateOrUpdateByIDResponder(resp *http.Response) (result autorest.Response, err error) { +func (client GroupClient) CreateOrUpdateByIDResponder(resp *http.Response) (result GenericResource, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -349,32 +391,48 @@ func (client GroupClient) CreateOrUpdateByIDResponder(resp *http.Response) (resu // is the namespace of the resource provider. parentResourcePath is the parent // resource identity. resourceType is the resource type. resourceName is the // name of the resource to delete. -func (client GroupClient) Delete(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client GroupClient) Delete(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) 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.NewErrorWithValidationError(err, "resources.GroupClient", "Delete") + errChan <- validation.NewErrorWithValidationError(err, "resources.GroupClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.DeletePreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.GroupClient", "Delete", nil, "Failure preparing request") - } + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "resources.GroupClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "resources.GroupClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "resources.GroupClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "resources.GroupClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -388,8 +446,9 @@ func (client GroupClient) DeletePreparer(resourceGroupName string, resourceProvi "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -427,24 +486,37 @@ func (client GroupClient) DeleteResponder(resp *http.Response) (result autorest. // resourceID is 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 GroupClient) DeleteByID(resourceID string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeleteByIDPreparer(resourceID, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.GroupClient", "DeleteByID", nil, "Failure preparing request") - } +func (client GroupClient) DeleteByID(resourceID string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeleteByIDPreparer(resourceID, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "resources.GroupClient", "DeleteByID", nil, "Failure preparing request") + return + } - resp, err := client.DeleteByIDSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "resources.GroupClient", "DeleteByID", resp, "Failure sending request") - } + resp, err := client.DeleteByIDSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "resources.GroupClient", "DeleteByID", resp, "Failure sending request") + return + } - result, err = client.DeleteByIDResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupClient", "DeleteByID", resp, "Failure responding to request") - } - - return + result, err = client.DeleteByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "resources.GroupClient", "DeleteByID", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeleteByIDPreparer prepares the DeleteByID request. @@ -453,8 +525,9 @@ func (client GroupClient) DeleteByIDPreparer(resourceID string, cancel <-chan st "resourceId": resourceID, } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -503,13 +576,15 @@ func (client GroupClient) Get(resourceGroupName string, resourceProviderNamespac req, err := client.GetPreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.GroupClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.GroupClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.GroupClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.GroupClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -531,8 +606,9 @@ func (client GroupClient) GetPreparer(resourceGroupName string, resourceProvider "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -570,13 +646,15 @@ func (client GroupClient) GetResponder(resp *http.Response) (result GenericResou func (client GroupClient) GetByID(resourceID string) (result GenericResource, err error) { req, err := client.GetByIDPreparer(resourceID) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.GroupClient", "GetByID", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.GroupClient", "GetByID", nil, "Failure preparing request") + return } resp, err := client.GetByIDSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.GroupClient", "GetByID", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.GroupClient", "GetByID", resp, "Failure sending request") + return } result, err = client.GetByIDResponder(resp) @@ -593,8 +671,9 @@ func (client GroupClient) GetByIDPreparer(resourceID string) (*http.Request, err "resourceId": resourceID, } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -632,13 +711,15 @@ func (client GroupClient) GetByIDResponder(resp *http.Response) (result GenericR func (client GroupClient) List(filter string, expand string, top *int32) (result ListResult, err error) { req, err := client.ListPreparer(filter, expand, top) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.GroupClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.GroupClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.GroupClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.GroupClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -655,8 +736,9 @@ func (client GroupClient) ListPreparer(filter string, expand string, top *int32) "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -729,32 +811,48 @@ func (client GroupClient) ListNextResults(lastResults ListResult) (result ListRe // // sourceResourceGroupName is the name of the resource group containing the // rsources to move. parameters is parameters for moving resources. -func (client GroupClient) MoveResources(sourceResourceGroupName string, parameters MoveInfo, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client GroupClient) MoveResources(sourceResourceGroupName string, parameters MoveInfo, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) 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.NewErrorWithValidationError(err, "resources.GroupClient", "MoveResources") + errChan <- validation.NewErrorWithValidationError(err, "resources.GroupClient", "MoveResources") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.MoveResourcesPreparer(sourceResourceGroupName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.GroupClient", "MoveResources", nil, "Failure preparing request") - } + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.MoveResourcesPreparer(sourceResourceGroupName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "resources.GroupClient", "MoveResources", nil, "Failure preparing request") + return + } - resp, err := client.MoveResourcesSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "resources.GroupClient", "MoveResources", resp, "Failure sending request") - } + resp, err := client.MoveResourcesSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "resources.GroupClient", "MoveResources", resp, "Failure sending request") + return + } - result, err = client.MoveResourcesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.GroupClient", "MoveResources", resp, "Failure responding to request") - } - - return + result, err = client.MoveResourcesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "resources.GroupClient", "MoveResources", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // MoveResourcesPreparer prepares the MoveResources request. @@ -764,8 +862,9 @@ func (client GroupClient) MoveResourcesPreparer(sourceResourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/tags.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/tags.go old mode 100644 new mode 100755 index d9be4a4b1..445fccf62 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/tags.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/tags.go @@ -48,13 +48,15 @@ func NewTagsClientWithBaseURI(baseURI string, subscriptionID string) TagsClient func (client TagsClient) CreateOrUpdate(tagName string) (result TagDetails, err error) { req, err := client.CreateOrUpdatePreparer(tagName) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.TagsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.TagsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.TagsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.TagsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -72,8 +74,9 @@ func (client TagsClient) CreateOrUpdatePreparer(tagName string) (*http.Request, "tagName": autorest.Encode("path", tagName), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -110,13 +113,15 @@ func (client TagsClient) CreateOrUpdateResponder(resp *http.Response) (result Ta func (client TagsClient) CreateOrUpdateValue(tagName string, tagValue string) (result TagValue, err error) { req, err := client.CreateOrUpdateValuePreparer(tagName, tagValue) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.TagsClient", "CreateOrUpdateValue", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.TagsClient", "CreateOrUpdateValue", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateValueSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.TagsClient", "CreateOrUpdateValue", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.TagsClient", "CreateOrUpdateValue", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateValueResponder(resp) @@ -135,8 +140,9 @@ func (client TagsClient) CreateOrUpdateValuePreparer(tagName string, tagValue st "tagValue": autorest.Encode("path", tagValue), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -173,13 +179,15 @@ func (client TagsClient) CreateOrUpdateValueResponder(resp *http.Response) (resu func (client TagsClient) Delete(tagName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(tagName) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.TagsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.TagsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "resources.TagsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.TagsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -197,8 +205,9 @@ func (client TagsClient) DeletePreparer(tagName string) (*http.Request, error) { "tagName": autorest.Encode("path", tagName), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -233,13 +242,15 @@ func (client TagsClient) DeleteResponder(resp *http.Response) (result autorest.R func (client TagsClient) DeleteValue(tagName string, tagValue string) (result autorest.Response, err error) { req, err := client.DeleteValuePreparer(tagName, tagValue) if err != nil { - return result, autorest.NewErrorWithError(err, "resources.TagsClient", "DeleteValue", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.TagsClient", "DeleteValue", nil, "Failure preparing request") + return } resp, err := client.DeleteValueSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "resources.TagsClient", "DeleteValue", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.TagsClient", "DeleteValue", resp, "Failure sending request") + return } result, err = client.DeleteValueResponder(resp) @@ -258,8 +269,9 @@ func (client TagsClient) DeleteValuePreparer(tagName string, tagValue string) (* "tagValue": autorest.Encode("path", tagValue), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -293,13 +305,15 @@ func (client TagsClient) DeleteValueResponder(resp *http.Response) (result autor func (client TagsClient) List() (result TagsListResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "resources.TagsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "resources.TagsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.TagsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "resources.TagsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -316,8 +330,9 @@ func (client TagsClient) ListPreparer() (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-09-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/version.go old mode 100644 new mode 100755 index 391e5ffb7..998788856 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/version.go @@ -18,43 +18,12 @@ package resources // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -import ( - "bytes" - "fmt" - "strings" -) - -const ( - major = "8" - minor = "1" - patch = "0" - tag = "beta" - userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" -) - -// cached results of UserAgent and Version to prevent repeated operations. -var ( - userAgent string - version string -) - // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - if userAgent == "" { - userAgent = fmt.Sprintf(userAgentFormat, Version(), "resources", "2016-09-01") - } - return userAgent + return "Azure-SDK-For-Go/v10.0.2-beta arm-resources/2016-09-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - if version == "" { - versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) - if tag != "" { - versionBuilder.WriteRune('-') - versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) - } - version = string(versionBuilder.Bytes()) - } - return version + return "v10.0.2-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/client.go old mode 100644 new mode 100755 index 6d90b5d03..4d99f6f11 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/client.go @@ -27,9 +27,6 @@ import ( ) const ( - // APIVersion is the version of the Scheduler - APIVersion = "2016-03-01" - // DefaultBaseURI is the default URI used for the service Scheduler DefaultBaseURI = "https://management.azure.com" ) @@ -38,7 +35,6 @@ const ( type ManagementClient struct { autorest.Client BaseURI string - APIVersion string SubscriptionID string } @@ -52,7 +48,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, - APIVersion: APIVersion, SubscriptionID: subscriptionID, } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/jobcollections.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/jobcollections.go old mode 100644 new mode 100755 index 636827469..9e192dad7 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/jobcollections.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/jobcollections.go @@ -50,13 +50,15 @@ func NewJobCollectionsClientWithBaseURI(baseURI string, subscriptionID string) J func (client JobCollectionsClient) CreateOrUpdate(resourceGroupName string, jobCollectionName string, jobCollection JobCollectionDefinition) (result JobCollectionDefinition, err error) { req, err := client.CreateOrUpdatePreparer(resourceGroupName, jobCollectionName, jobCollection) if err != nil { - return result, autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -75,8 +77,9 @@ func (client JobCollectionsClient) CreateOrUpdatePreparer(resourceGroupName stri "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -114,24 +117,37 @@ func (client JobCollectionsClient) CreateOrUpdateResponder(resp *http.Response) // // resourceGroupName is the resource group name. jobCollectionName is the job // collection name. -func (client JobCollectionsClient) Delete(resourceGroupName string, jobCollectionName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, jobCollectionName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Delete", nil, "Failure preparing request") - } +func (client JobCollectionsClient) Delete(resourceGroupName string, jobCollectionName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, jobCollectionName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Delete", nil, "Failure preparing request") + return + } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Delete", resp, "Failure sending request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Delete", resp, "Failure sending request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Delete", resp, "Failure responding to request") - } - - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -142,8 +158,9 @@ func (client JobCollectionsClient) DeletePreparer(resourceGroupName string, jobC "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -181,24 +198,37 @@ func (client JobCollectionsClient) DeleteResponder(resp *http.Response) (result // // resourceGroupName is the resource group name. jobCollectionName is the job // collection name. -func (client JobCollectionsClient) Disable(resourceGroupName string, jobCollectionName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DisablePreparer(resourceGroupName, jobCollectionName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Disable", nil, "Failure preparing request") - } +func (client JobCollectionsClient) Disable(resourceGroupName string, jobCollectionName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DisablePreparer(resourceGroupName, jobCollectionName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Disable", nil, "Failure preparing request") + return + } - resp, err := client.DisableSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Disable", resp, "Failure sending request") - } + resp, err := client.DisableSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Disable", resp, "Failure sending request") + return + } - result, err = client.DisableResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Disable", resp, "Failure responding to request") - } - - return + result, err = client.DisableResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Disable", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DisablePreparer prepares the Disable request. @@ -209,8 +239,9 @@ func (client JobCollectionsClient) DisablePreparer(resourceGroupName string, job "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -248,24 +279,37 @@ func (client JobCollectionsClient) DisableResponder(resp *http.Response) (result // // resourceGroupName is the resource group name. jobCollectionName is the job // collection name. -func (client JobCollectionsClient) Enable(resourceGroupName string, jobCollectionName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.EnablePreparer(resourceGroupName, jobCollectionName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Enable", nil, "Failure preparing request") - } +func (client JobCollectionsClient) Enable(resourceGroupName string, jobCollectionName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.EnablePreparer(resourceGroupName, jobCollectionName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Enable", nil, "Failure preparing request") + return + } - resp, err := client.EnableSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Enable", resp, "Failure sending request") - } + resp, err := client.EnableSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Enable", resp, "Failure sending request") + return + } - result, err = client.EnableResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Enable", resp, "Failure responding to request") - } - - return + result, err = client.EnableResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Enable", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // EnablePreparer prepares the Enable request. @@ -276,8 +320,9 @@ func (client JobCollectionsClient) EnablePreparer(resourceGroupName string, jobC "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -315,13 +360,15 @@ func (client JobCollectionsClient) EnableResponder(resp *http.Response) (result func (client JobCollectionsClient) Get(resourceGroupName string, jobCollectionName string) (result JobCollectionDefinition, err error) { req, err := client.GetPreparer(resourceGroupName, jobCollectionName) if err != nil { - return result, autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -340,8 +387,9 @@ func (client JobCollectionsClient) GetPreparer(resourceGroupName string, jobColl "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -377,13 +425,15 @@ func (client JobCollectionsClient) GetResponder(resp *http.Response) (result Job func (client JobCollectionsClient) ListByResourceGroup(resourceGroupName string) (result JobCollectionListResult, err error) { req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -401,8 +451,9 @@ func (client JobCollectionsClient) ListByResourceGroupPreparer(resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -460,13 +511,15 @@ func (client JobCollectionsClient) ListByResourceGroupNextResults(lastResults Jo func (client JobCollectionsClient) ListBySubscription() (result JobCollectionListResult, err error) { req, err := client.ListBySubscriptionPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "ListBySubscription", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "ListBySubscription", nil, "Failure preparing request") + return } resp, err := client.ListBySubscriptionSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "ListBySubscription", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "ListBySubscription", resp, "Failure sending request") + return } result, err = client.ListBySubscriptionResponder(resp) @@ -483,8 +536,9 @@ func (client JobCollectionsClient) ListBySubscriptionPreparer() (*http.Request, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -545,13 +599,15 @@ func (client JobCollectionsClient) ListBySubscriptionNextResults(lastResults Job func (client JobCollectionsClient) Patch(resourceGroupName string, jobCollectionName string, jobCollection JobCollectionDefinition) (result JobCollectionDefinition, err error) { req, err := client.PatchPreparer(resourceGroupName, jobCollectionName, jobCollection) if err != nil { - return result, autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Patch", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Patch", nil, "Failure preparing request") + return } resp, err := client.PatchSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Patch", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "scheduler.JobCollectionsClient", "Patch", resp, "Failure sending request") + return } result, err = client.PatchResponder(resp) @@ -570,8 +626,9 @@ func (client JobCollectionsClient) PatchPreparer(resourceGroupName string, jobCo "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/jobs.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/jobs.go old mode 100644 new mode 100755 index 318f50523..64eab66c5 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/jobs.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/jobs.go @@ -47,13 +47,15 @@ func NewJobsClientWithBaseURI(baseURI string, subscriptionID string) JobsClient func (client JobsClient) CreateOrUpdate(resourceGroupName string, jobCollectionName string, jobName string, job JobDefinition) (result JobDefinition, err error) { req, err := client.CreateOrUpdatePreparer(resourceGroupName, jobCollectionName, jobName, job) if err != nil { - return result, autorest.NewErrorWithError(err, "scheduler.JobsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "scheduler.JobsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "scheduler.JobsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "scheduler.JobsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -73,8 +75,9 @@ func (client JobsClient) CreateOrUpdatePreparer(resourceGroupName string, jobCol "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -113,13 +116,15 @@ func (client JobsClient) CreateOrUpdateResponder(resp *http.Response) (result Jo func (client JobsClient) Delete(resourceGroupName string, jobCollectionName string, jobName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, jobCollectionName, jobName) if err != nil { - return result, autorest.NewErrorWithError(err, "scheduler.JobsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "scheduler.JobsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "scheduler.JobsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "scheduler.JobsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -139,8 +144,9 @@ func (client JobsClient) DeletePreparer(resourceGroupName string, jobCollectionN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -176,13 +182,15 @@ func (client JobsClient) DeleteResponder(resp *http.Response) (result autorest.R func (client JobsClient) Get(resourceGroupName string, jobCollectionName string, jobName string) (result JobDefinition, err error) { req, err := client.GetPreparer(resourceGroupName, jobCollectionName, jobName) if err != nil { - return result, autorest.NewErrorWithError(err, "scheduler.JobsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "scheduler.JobsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "scheduler.JobsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "scheduler.JobsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -202,8 +210,9 @@ func (client JobsClient) GetPreparer(resourceGroupName string, jobCollectionName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -251,13 +260,15 @@ func (client JobsClient) List(resourceGroupName string, jobCollectionName string req, err := client.ListPreparer(resourceGroupName, jobCollectionName, top, skip, filter) if err != nil { - return result, autorest.NewErrorWithError(err, "scheduler.JobsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "scheduler.JobsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "scheduler.JobsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "scheduler.JobsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -276,8 +287,9 @@ func (client JobsClient) ListPreparer(resourceGroupName string, jobCollectionNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if top != nil { queryParameters["$top"] = autorest.Encode("query", *top) @@ -359,13 +371,15 @@ func (client JobsClient) ListJobHistory(resourceGroupName string, jobCollectionN req, err := client.ListJobHistoryPreparer(resourceGroupName, jobCollectionName, jobName, top, skip, filter) if err != nil { - return result, autorest.NewErrorWithError(err, "scheduler.JobsClient", "ListJobHistory", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "scheduler.JobsClient", "ListJobHistory", nil, "Failure preparing request") + return } resp, err := client.ListJobHistorySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "scheduler.JobsClient", "ListJobHistory", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "scheduler.JobsClient", "ListJobHistory", resp, "Failure sending request") + return } result, err = client.ListJobHistoryResponder(resp) @@ -385,8 +399,9 @@ func (client JobsClient) ListJobHistoryPreparer(resourceGroupName string, jobCol "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if top != nil { queryParameters["$top"] = autorest.Encode("query", *top) @@ -456,13 +471,15 @@ func (client JobsClient) ListJobHistoryNextResults(lastResults JobHistoryListRes func (client JobsClient) Patch(resourceGroupName string, jobCollectionName string, jobName string, job JobDefinition) (result JobDefinition, err error) { req, err := client.PatchPreparer(resourceGroupName, jobCollectionName, jobName, job) if err != nil { - return result, autorest.NewErrorWithError(err, "scheduler.JobsClient", "Patch", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "scheduler.JobsClient", "Patch", nil, "Failure preparing request") + return } resp, err := client.PatchSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "scheduler.JobsClient", "Patch", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "scheduler.JobsClient", "Patch", resp, "Failure sending request") + return } result, err = client.PatchResponder(resp) @@ -482,8 +499,9 @@ func (client JobsClient) PatchPreparer(resourceGroupName string, jobCollectionNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -522,13 +540,15 @@ func (client JobsClient) PatchResponder(resp *http.Response) (result JobDefiniti func (client JobsClient) Run(resourceGroupName string, jobCollectionName string, jobName string) (result autorest.Response, err error) { req, err := client.RunPreparer(resourceGroupName, jobCollectionName, jobName) if err != nil { - return result, autorest.NewErrorWithError(err, "scheduler.JobsClient", "Run", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "scheduler.JobsClient", "Run", nil, "Failure preparing request") + return } resp, err := client.RunSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "scheduler.JobsClient", "Run", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "scheduler.JobsClient", "Run", resp, "Failure sending request") + return } result, err = client.RunResponder(resp) @@ -548,8 +568,9 @@ func (client JobsClient) RunPreparer(resourceGroupName string, jobCollectionName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-03-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/models.go old mode 100644 new mode 100755 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/version.go old mode 100644 new mode 100755 index b56e86a67..9744571f6 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/version.go @@ -18,43 +18,12 @@ package scheduler // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -import ( - "bytes" - "fmt" - "strings" -) - -const ( - major = "8" - minor = "1" - patch = "0" - tag = "beta" - userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" -) - -// cached results of UserAgent and Version to prevent repeated operations. -var ( - userAgent string - version string -) - // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - if userAgent == "" { - userAgent = fmt.Sprintf(userAgentFormat, Version(), "scheduler", "2016-03-01") - } - return userAgent + return "Azure-SDK-For-Go/v10.0.2-beta arm-scheduler/2016-03-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - if version == "" { - versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) - if tag != "" { - versionBuilder.WriteRune('-') - versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) - } - version = string(versionBuilder.Bytes()) - } - return version + return "v10.0.2-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/client.go old mode 100644 new mode 100755 index ffd627270..446baff17 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/client.go @@ -18,7 +18,7 @@ package servicebus // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -27,9 +27,6 @@ import ( ) const ( - // APIVersion is the version of the Servicebus - APIVersion = "2015-08-01" - // DefaultBaseURI is the default URI used for the service Servicebus DefaultBaseURI = "https://management.azure.com" ) @@ -38,7 +35,6 @@ const ( type ManagementClient struct { autorest.Client BaseURI string - APIVersion string SubscriptionID string } @@ -52,7 +48,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, - APIVersion: APIVersion, SubscriptionID: subscriptionID, } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/models.go old mode 100644 new mode 100755 index fe0a17112..1cb4882ff --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/models.go @@ -14,7 +14,7 @@ package servicebus // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -166,6 +166,42 @@ const ( SkuTierStandard SkuTier = "Standard" ) +// UnavailableReason enumerates the values for unavailable reason. +type UnavailableReason string + +const ( + // InvalidName specifies the invalid name state for unavailable reason. + InvalidName UnavailableReason = "InvalidName" + // NameInLockdown specifies the name in lockdown state for unavailable + // reason. + NameInLockdown UnavailableReason = "NameInLockdown" + // NameInUse specifies the name in use state for unavailable reason. + NameInUse UnavailableReason = "NameInUse" + // None specifies the none state for unavailable reason. + None UnavailableReason = "None" + // SubscriptionIsDisabled specifies the subscription is disabled state for + // unavailable reason. + SubscriptionIsDisabled UnavailableReason = "SubscriptionIsDisabled" + // TooManyNamespaceInCurrentSubscription specifies the too many namespace + // in current subscription state for unavailable reason. + TooManyNamespaceInCurrentSubscription UnavailableReason = "TooManyNamespaceInCurrentSubscription" +) + +// CheckNameAvailability is description of a Check Name availability request +// properties. +type CheckNameAvailability struct { + Name *string `json:"name,omitempty"` +} + +// CheckNameAvailabilityResult is description of a Check Name availability +// request properties. +type CheckNameAvailabilityResult struct { + autorest.Response `json:"-"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason UnavailableReason `json:"reason,omitempty"` + Message *string `json:"message,omitempty"` +} + // MessageCountDetails is message Count Details. type MessageCountDetails struct { ActiveMessageCount *int64 `json:"activeMessageCount,omitempty"` @@ -219,13 +255,54 @@ type NamespaceResource struct { autorest.Response `json:"-"` ID *string `json:"id,omitempty"` Name *string `json:"name,omitempty"` - Type *string `json:"type,omitempty"` Location *string `json:"location,omitempty"` + Type *string `json:"type,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` Sku *Sku `json:"sku,omitempty"` *NamespaceProperties `json:"properties,omitempty"` } +// NamespaceUpdateParameters is parameters supplied to the Patch Namespace +// operation. +type NamespaceUpdateParameters struct { + Tags *map[string]*string `json:"tags,omitempty"` + Sku *Sku `json:"sku,omitempty"` +} + +// Operation is a ServiceBus REST API operation +type Operation struct { + Name *string `json:"name,omitempty"` + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay is the object that represents the operation. +type OperationDisplay struct { + Provider *string `json:"provider,omitempty"` + Resource *string `json:"resource,omitempty"` + Operation *string `json:"operation,omitempty"` +} + +// OperationListResult is result of the request to list ServiceBus operations. +// It contains a list of operations and a URL link to get the next set of +// results. +type OperationListResult struct { + autorest.Response `json:"-"` + Value *[]Operation `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client OperationListResult) OperationListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + // QueueCreateOrUpdateParameters is parameters supplied to the Create Or Update // Queue operation. type QueueCreateOrUpdateParameters struct { @@ -253,27 +330,27 @@ func (client QueueListResult) QueueListResultPreparer() (*http.Request, error) { autorest.WithBaseURL(to.String(client.NextLink))) } -// QueueProperties is +// QueueProperties is the Queue Properties definition. type QueueProperties struct { - LockDuration *string `json:"lockDuration ,omitempty"` + LockDuration *string `json:"lockDuration,omitempty"` AccessedAt *date.Time `json:"accessedAt,omitempty"` AutoDeleteOnIdle *string `json:"autoDeleteOnIdle,omitempty"` - EntityAvailabilityStatus EntityAvailabilityStatus `json:"entityAvailabilityStatus ,omitempty"` + EntityAvailabilityStatus EntityAvailabilityStatus `json:"entityAvailabilityStatus,omitempty"` CreatedAt *date.Time `json:"createdAt,omitempty"` DefaultMessageTimeToLive *string `json:"defaultMessageTimeToLive,omitempty"` - DuplicateDetectionHistoryTimeWindow *string `json:"duplicateDetectionHistoryTimeWindow ,omitempty"` + DuplicateDetectionHistoryTimeWindow *string `json:"duplicateDetectionHistoryTimeWindow,omitempty"` EnableBatchedOperations *bool `json:"enableBatchedOperations,omitempty"` DeadLetteringOnMessageExpiration *bool `json:"deadLetteringOnMessageExpiration,omitempty"` EnableExpress *bool `json:"enableExpress,omitempty"` EnablePartitioning *bool `json:"enablePartitioning,omitempty"` IsAnonymousAccessible *bool `json:"isAnonymousAccessible,omitempty"` - MaxDeliveryCount *int32 `json:"maxDeliveryCount ,omitempty"` + MaxDeliveryCount *int32 `json:"maxDeliveryCount,omitempty"` MaxSizeInMegabytes *int64 `json:"maxSizeInMegabytes,omitempty"` - MessageCount *int64 `json:"messageCount ,omitempty"` + MessageCount *int64 `json:"messageCount,omitempty"` CountDetails *MessageCountDetails `json:"countDetails,omitempty"` RequiresDuplicateDetection *bool `json:"requiresDuplicateDetection,omitempty"` RequiresSession *bool `json:"requiresSession,omitempty"` - SizeInBytes *int64 `json:"sizeInBytes ,omitempty"` + SizeInBytes *int64 `json:"sizeInBytes,omitempty"` Status EntityStatus `json:"status,omitempty"` SupportOrdering *bool `json:"supportOrdering,omitempty"` UpdatedAt *date.Time `json:"updatedAt,omitempty"` @@ -282,11 +359,10 @@ type QueueProperties struct { // QueueResource is description of queue Resource. type QueueResource struct { autorest.Response `json:"-"` - ID *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` - Tags *map[string]*string `json:"tags,omitempty"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Type *string `json:"type,omitempty"` *QueueProperties `json:"properties,omitempty"` } @@ -296,13 +372,12 @@ type RegenerateKeysParameters struct { Policykey Policykey `json:"Policykey,omitempty"` } -// Resource is +// Resource is the Resource definition for other than namespace. type Resource struct { - ID *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` - Tags *map[string]*string `json:"tags,omitempty"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Type *string `json:"type,omitempty"` } // ResourceListKeys is namespace/ServiceBus Connection String @@ -353,11 +428,10 @@ type SharedAccessAuthorizationRuleProperties struct { // authorization rule. type SharedAccessAuthorizationRuleResource struct { autorest.Response `json:"-"` - ID *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` - Tags *map[string]*string `json:"tags,omitempty"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Type *string `json:"type,omitempty"` *SharedAccessAuthorizationRuleProperties `json:"properties,omitempty"` } @@ -418,11 +492,10 @@ type SubscriptionProperties struct { // SubscriptionResource is description of subscription resource. type SubscriptionResource struct { autorest.Response `json:"-"` - ID *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` - Tags *map[string]*string `json:"tags,omitempty"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Type *string `json:"type,omitempty"` *SubscriptionProperties `json:"properties,omitempty"` } @@ -453,15 +526,15 @@ func (client TopicListResult) TopicListResultPreparer() (*http.Request, error) { autorest.WithBaseURL(to.String(client.NextLink))) } -// TopicProperties is +// TopicProperties is the Tpoic Properties definition. type TopicProperties struct { AccessedAt *date.Time `json:"accessedAt,omitempty"` AutoDeleteOnIdle *string `json:"autoDeleteOnIdle,omitempty"` - EntityAvailabilityStatus EntityAvailabilityStatus `json:"entityAvailabilityStatus ,omitempty"` + EntityAvailabilityStatus EntityAvailabilityStatus `json:"entityAvailabilityStatus,omitempty"` CreatedAt *date.Time `json:"createdAt,omitempty"` CountDetails *MessageCountDetails `json:"countDetails,omitempty"` DefaultMessageTimeToLive *string `json:"defaultMessageTimeToLive,omitempty"` - DuplicateDetectionHistoryTimeWindow *string `json:"duplicateDetectionHistoryTimeWindow ,omitempty"` + DuplicateDetectionHistoryTimeWindow *string `json:"duplicateDetectionHistoryTimeWindow,omitempty"` EnableBatchedOperations *bool `json:"enableBatchedOperations,omitempty"` EnableExpress *bool `json:"enableExpress,omitempty"` EnablePartitioning *bool `json:"enablePartitioning,omitempty"` @@ -481,10 +554,18 @@ type TopicProperties struct { // TopicResource is description of topic resource. type TopicResource struct { autorest.Response `json:"-"` - ID *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` - Tags *map[string]*string `json:"tags,omitempty"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Type *string `json:"type,omitempty"` *TopicProperties `json:"properties,omitempty"` } + +// TrackedResource is the Resource definition. +type TrackedResource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Type *string `json:"type,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/namespaces.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/namespaces.go old mode 100644 new mode 100755 index 2163c230d..efdf329f1 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/namespaces.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/namespaces.go @@ -14,7 +14,7 @@ package servicebus // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -41,39 +41,129 @@ func NewNamespacesClientWithBaseURI(baseURI string, subscriptionID string) Names return NamespacesClient{NewWithBaseURI(baseURI, subscriptionID)} } +// CheckNameAvailabilityMethod check the give namespace name availability. +// +// parameters is parameters to check availability of the given namespace name +func (client NamespacesClient) CheckNameAvailabilityMethod(parameters CheckNameAvailability) (result CheckNameAvailabilityResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.NamespacesClient", "CheckNameAvailabilityMethod") + } + + req, err := client.CheckNameAvailabilityMethodPreparer(parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CheckNameAvailabilityMethod", nil, "Failure preparing request") + return + } + + resp, err := client.CheckNameAvailabilityMethodSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CheckNameAvailabilityMethod", resp, "Failure sending request") + return + } + + result, err = client.CheckNameAvailabilityMethodResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CheckNameAvailabilityMethod", resp, "Failure responding to request") + } + + return +} + +// CheckNameAvailabilityMethodPreparer prepares the CheckNameAvailabilityMethod request. +func (client NamespacesClient) CheckNameAvailabilityMethodPreparer(parameters CheckNameAvailability) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CheckNameAvailabilityMethodSender sends the CheckNameAvailabilityMethod request. The method will close the +// http.Response Body if it receives an error. +func (client NamespacesClient) CheckNameAvailabilityMethodSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CheckNameAvailabilityMethodResponder handles the response to the CheckNameAvailabilityMethod request. The method always +// closes the http.Response Body. +func (client NamespacesClient) CheckNameAvailabilityMethodResponder(resp *http.Response) (result CheckNameAvailabilityResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // CreateOrUpdate creates or updates a service namespace. Once created, this // namespace's resource manifest is immutable. This operation is idempotent. // This method may poll for completion. Polling can be canceled by passing the // cancel channel argument. The channel will be used to cancel polling and any // outstanding HTTP requests. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. parameters is parameters supplied to create a namespace -// resource. -func (client NamespacesClient) CreateOrUpdate(resourceGroupName string, namespaceName string, parameters NamespaceCreateOrUpdateParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name. parameters is parameters +// supplied to create a namespace resource. +func (client NamespacesClient) CreateOrUpdate(resourceGroupName string, namespaceName string, parameters NamespaceCreateOrUpdateParameters, cancel <-chan struct{}) (<-chan NamespaceResource, <-chan error) { + resultChan := make(chan NamespaceResource, 1) + errChan := make(chan error, 1) 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}}}, {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "servicebus.NamespacesClient", "CreateOrUpdate") + errChan <- validation.NewErrorWithValidationError(err, "servicebus.NamespacesClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, namespaceName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CreateOrUpdate", nil, "Failure preparing request") - } + go func() { + var err error + var result NamespaceResource + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, namespaceName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -84,8 +174,9 @@ func (client NamespacesClient) CreateOrUpdatePreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -108,24 +199,35 @@ func (client NamespacesClient) CreateOrUpdateSender(req *http.Request) (*http.Re // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client NamespacesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client NamespacesClient) CreateOrUpdateResponder(resp *http.Response) (result NamespaceResource, err error) { err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } // CreateOrUpdateAuthorizationRule creates or updates an authorization rule for // a namespace. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. authorizationRuleName is namespace authorization rule name. -// parameters is the shared access authorization rule. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name authorizationRuleName is +// the authorizationrule name. parameters is the shared access authorization +// rule. func (client NamespacesClient) CreateOrUpdateAuthorizationRule(resourceGroupName string, namespaceName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters) (result SharedAccessAuthorizationRuleResource, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.SharedAccessAuthorizationRuleProperties", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.SharedAccessAuthorizationRuleProperties.Rights", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { @@ -134,13 +236,15 @@ func (client NamespacesClient) CreateOrUpdateAuthorizationRule(resourceGroupName req, err := client.CreateOrUpdateAuthorizationRulePreparer(resourceGroupName, namespaceName, authorizationRuleName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateAuthorizationRuleSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CreateOrUpdateAuthorizationRule", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CreateOrUpdateAuthorizationRule", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateAuthorizationRuleResponder(resp) @@ -160,8 +264,9 @@ func (client NamespacesClient) CreateOrUpdateAuthorizationRulePreparer(resourceG "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -199,26 +304,52 @@ func (client NamespacesClient) CreateOrUpdateAuthorizationRuleResponder(resp *ht // The channel will be used to cancel polling and any outstanding HTTP // requests. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. -func (client NamespacesClient) Delete(resourceGroupName string, namespaceName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, namespaceName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "Delete", nil, "Failure preparing request") +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name +func (client NamespacesClient) Delete(resourceGroupName string, namespaceName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "servicebus.NamespacesClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan } - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "Delete", resp, "Failure sending request") - } + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, namespaceName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "Delete", nil, "Failure preparing request") + return + } - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "Delete", resp, "Failure responding to request") - } + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "Delete", resp, "Failure sending request") + return + } - return + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -229,8 +360,9 @@ func (client NamespacesClient) DeletePreparer(resourceGroupName string, namespac "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -263,18 +395,34 @@ func (client NamespacesClient) DeleteResponder(resp *http.Response) (result auto // DeleteAuthorizationRule deletes a namespace authorization rule. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. authorizationRuleName is authorization rule name. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name authorizationRuleName is +// the authorizationrule name. func (client NamespacesClient) DeleteAuthorizationRule(resourceGroupName string, namespaceName string, authorizationRuleName 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.NamespacesClient", "DeleteAuthorizationRule") + } + req, err := client.DeleteAuthorizationRulePreparer(resourceGroupName, namespaceName, authorizationRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "DeleteAuthorizationRule", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "DeleteAuthorizationRule", nil, "Failure preparing request") + return } resp, err := client.DeleteAuthorizationRuleSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "DeleteAuthorizationRule", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "DeleteAuthorizationRule", resp, "Failure sending request") + return } result, err = client.DeleteAuthorizationRuleResponder(resp) @@ -294,8 +442,9 @@ func (client NamespacesClient) DeleteAuthorizationRulePreparer(resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -326,18 +475,30 @@ func (client NamespacesClient) DeleteAuthorizationRuleResponder(resp *http.Respo // Get gets a description for the specified namespace. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name func (client NamespacesClient) Get(resourceGroupName string, namespaceName string) (result NamespaceResource, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.NamespacesClient", "Get") + } + req, err := client.GetPreparer(resourceGroupName, namespaceName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -356,8 +517,9 @@ func (client NamespacesClient) GetPreparer(resourceGroupName string, namespaceNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -390,18 +552,34 @@ func (client NamespacesClient) GetResponder(resp *http.Response) (result Namespa // GetAuthorizationRule gets an authorization rule for a namespace by rule // name. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. authorizationRuleName is authorization rule name. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name authorizationRuleName is +// the authorizationrule name. func (client NamespacesClient) GetAuthorizationRule(resourceGroupName string, namespaceName string, authorizationRuleName string) (result SharedAccessAuthorizationRuleResource, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.NamespacesClient", "GetAuthorizationRule") + } + req, err := client.GetAuthorizationRulePreparer(resourceGroupName, namespaceName, authorizationRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "GetAuthorizationRule", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "GetAuthorizationRule", nil, "Failure preparing request") + return } resp, err := client.GetAuthorizationRuleSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "GetAuthorizationRule", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "GetAuthorizationRule", resp, "Failure sending request") + return } result, err = client.GetAuthorizationRuleResponder(resp) @@ -421,8 +599,9 @@ func (client NamespacesClient) GetAuthorizationRulePreparer(resourceGroupName st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -454,18 +633,30 @@ func (client NamespacesClient) GetAuthorizationRuleResponder(resp *http.Response // ListAuthorizationRules gets the authorization rules for a namespace. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name func (client NamespacesClient) ListAuthorizationRules(resourceGroupName string, namespaceName string) (result SharedAccessAuthorizationRuleListResult, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.NamespacesClient", "ListAuthorizationRules") + } + req, err := client.ListAuthorizationRulesPreparer(resourceGroupName, namespaceName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListAuthorizationRules", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListAuthorizationRules", nil, "Failure preparing request") + return } resp, err := client.ListAuthorizationRulesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListAuthorizationRules", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListAuthorizationRules", resp, "Failure sending request") + return } result, err = client.ListAuthorizationRulesResponder(resp) @@ -484,8 +675,9 @@ func (client NamespacesClient) ListAuthorizationRulesPreparer(resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -541,17 +733,27 @@ func (client NamespacesClient) ListAuthorizationRulesNextResults(lastResults Sha // ListByResourceGroup gets the available namespaces within a resource group. // -// resourceGroupName is the name of the resource group. +// resourceGroupName is name of the Resource group within the Azure +// subscription. func (client NamespacesClient) ListByResourceGroup(resourceGroupName string) (result NamespaceListResult, 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}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.NamespacesClient", "ListByResourceGroup") + } + req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -569,8 +771,9 @@ func (client NamespacesClient) ListByResourceGroupPreparer(resourceGroupName str "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -629,13 +832,15 @@ func (client NamespacesClient) ListByResourceGroupNextResults(lastResults Namesp func (client NamespacesClient) ListBySubscription() (result NamespaceListResult, err error) { req, err := client.ListBySubscriptionPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListBySubscription", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListBySubscription", nil, "Failure preparing request") + return } resp, err := client.ListBySubscriptionSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListBySubscription", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListBySubscription", resp, "Failure sending request") + return } result, err = client.ListBySubscriptionResponder(resp) @@ -652,8 +857,9 @@ func (client NamespacesClient) ListBySubscriptionPreparer() (*http.Request, erro "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -710,18 +916,34 @@ func (client NamespacesClient) ListBySubscriptionNextResults(lastResults Namespa // ListKeys gets the primary and secondary connection strings for the // namespace. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. authorizationRuleName is the authorization rule name. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name authorizationRuleName is +// the authorizationrule name. func (client NamespacesClient) ListKeys(resourceGroupName string, namespaceName string, authorizationRuleName string) (result ResourceListKeys, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.NamespacesClient", "ListKeys") + } + req, err := client.ListKeysPreparer(resourceGroupName, namespaceName, authorizationRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListKeys", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListKeys", nil, "Failure preparing request") + return } resp, err := client.ListKeysSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListKeys", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListKeys", resp, "Failure sending request") + return } result, err = client.ListKeysResponder(resp) @@ -741,8 +963,9 @@ func (client NamespacesClient) ListKeysPreparer(resourceGroupName string, namesp "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -775,19 +998,35 @@ func (client NamespacesClient) ListKeysResponder(resp *http.Response) (result Re // RegenerateKeys regenerates the primary or secondary connection strings for // the namespace. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. authorizationRuleName is the authorization rule name. -// parameters is parameters supplied to regenerate the authorization rule. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name authorizationRuleName is +// the authorizationrule name. parameters is parameters supplied to regenerate +// the authorization rule. func (client NamespacesClient) RegenerateKeys(resourceGroupName string, namespaceName string, authorizationRuleName string, parameters RegenerateKeysParameters) (result ResourceListKeys, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.NamespacesClient", "RegenerateKeys") + } + req, err := client.RegenerateKeysPreparer(resourceGroupName, namespaceName, authorizationRuleName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "RegenerateKeys", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "RegenerateKeys", nil, "Failure preparing request") + return } resp, err := client.RegenerateKeysSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "RegenerateKeys", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "RegenerateKeys", resp, "Failure sending request") + return } result, err = client.RegenerateKeysResponder(resp) @@ -807,8 +1046,9 @@ func (client NamespacesClient) RegenerateKeysPreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -839,3 +1079,83 @@ func (client NamespacesClient) RegenerateKeysResponder(resp *http.Response) (res result.Response = autorest.Response{Response: resp} return } + +// Update updates a service namespace. Once created, this namespace's resource +// manifest is immutable. This operation is idempotent. +// +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name parameters is parameters +// supplied to update a namespace resource. +func (client NamespacesClient) Update(resourceGroupName string, namespaceName string, parameters NamespaceUpdateParameters) (result NamespaceResource, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.NamespacesClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, namespaceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client NamespacesClient) UpdatePreparer(resourceGroupName string, namespaceName string, parameters NamespaceUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "namespaceName": autorest.Encode("path", namespaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client NamespacesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client NamespacesClient) UpdateResponder(resp *http.Response) (result NamespaceResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusCreated, 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/arm/servicebus/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/operations.go new file mode 100755 index 000000000..3f7b127e5 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/operations.go @@ -0,0 +1,122 @@ +package servicebus + +// 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OperationsClient is the azure Service Bus client +type OperationsClient struct { + ManagementClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient +// client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available ServiceBus REST API operations. +func (client OperationsClient) List() (result OperationListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "servicebus.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicebus.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicebus.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer() (*http.Request, error) { + const APIVersion = "2015-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.ServiceBus/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, 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 OperationsClient) ListNextResults(lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.OperationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "servicebus.OperationsClient", "List", 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, "servicebus.OperationsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicebus.OperationsClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/queues.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/queues.go old mode 100644 new mode 100755 index 854eea482..9d52011dd --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/queues.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/queues.go @@ -14,7 +14,7 @@ package servicebus // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -43,11 +43,21 @@ func NewQueuesClientWithBaseURI(baseURI string, subscriptionID string) QueuesCli // CreateOrUpdate creates or updates a Service Bus queue. This operation is // idempotent. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. queueName is the queue name. parameters is parameters -// supplied to create or update a queue resource. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name queueName is the queue +// name. parameters is parameters supplied to create or update a queue +// resource. func (client QueuesClient) CreateOrUpdate(resourceGroupName string, namespaceName string, queueName string, parameters QueueCreateOrUpdateParameters) (result QueueResource, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: queueName, + Constraints: []validation.Constraint{{Target: "queueName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "queueName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "servicebus.QueuesClient", "CreateOrUpdate") @@ -55,13 +65,15 @@ func (client QueuesClient) CreateOrUpdate(resourceGroupName string, namespaceNam req, err := client.CreateOrUpdatePreparer(resourceGroupName, namespaceName, queueName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -81,8 +93,9 @@ func (client QueuesClient) CreateOrUpdatePreparer(resourceGroupName string, name "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -116,11 +129,24 @@ func (client QueuesClient) CreateOrUpdateResponder(resp *http.Response) (result // CreateOrUpdateAuthorizationRule creates an authorization rule for a queue. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. queueName is the queue name. authorizationRuleName is -// authorization rule name. parameters is the shared access authorization rule. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name queueName is the queue +// name. authorizationRuleName is the authorizationrule name. parameters is the +// shared access authorization rule. func (client QueuesClient) CreateOrUpdateAuthorizationRule(resourceGroupName string, namespaceName string, queueName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters) (result SharedAccessAuthorizationRuleResource, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: queueName, + Constraints: []validation.Constraint{{Target: "queueName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "queueName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.SharedAccessAuthorizationRuleProperties", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.SharedAccessAuthorizationRuleProperties.Rights", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { @@ -129,13 +155,15 @@ func (client QueuesClient) CreateOrUpdateAuthorizationRule(resourceGroupName str req, err := client.CreateOrUpdateAuthorizationRulePreparer(resourceGroupName, namespaceName, queueName, authorizationRuleName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateAuthorizationRuleSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "CreateOrUpdateAuthorizationRule", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "CreateOrUpdateAuthorizationRule", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateAuthorizationRuleResponder(resp) @@ -156,8 +184,9 @@ func (client QueuesClient) CreateOrUpdateAuthorizationRulePreparer(resourceGroup "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -191,18 +220,34 @@ func (client QueuesClient) CreateOrUpdateAuthorizationRuleResponder(resp *http.R // Delete deletes a queue from the specified namespace in a resource group. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. queueName is the name of the queue to be deleted. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name queueName is the queue +// name. func (client QueuesClient) Delete(resourceGroupName string, namespaceName string, queueName 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: queueName, + Constraints: []validation.Constraint{{Target: "queueName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "queueName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.QueuesClient", "Delete") + } + req, err := client.DeletePreparer(resourceGroupName, namespaceName, queueName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -222,8 +267,9 @@ func (client QueuesClient) DeletePreparer(resourceGroupName string, namespaceNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -254,19 +300,37 @@ func (client QueuesClient) DeleteResponder(resp *http.Response) (result autorest // DeleteAuthorizationRule deletes a queue authorization rule. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. queueName is the queue name. authorizationRuleName is -// authorization rule name. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name queueName is the queue +// name. authorizationRuleName is the authorizationrule name. func (client QueuesClient) DeleteAuthorizationRule(resourceGroupName string, namespaceName string, queueName string, authorizationRuleName 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: queueName, + Constraints: []validation.Constraint{{Target: "queueName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "queueName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.QueuesClient", "DeleteAuthorizationRule") + } + req, err := client.DeleteAuthorizationRulePreparer(resourceGroupName, namespaceName, queueName, authorizationRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "DeleteAuthorizationRule", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "DeleteAuthorizationRule", nil, "Failure preparing request") + return } resp, err := client.DeleteAuthorizationRuleSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "DeleteAuthorizationRule", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "DeleteAuthorizationRule", resp, "Failure sending request") + return } result, err = client.DeleteAuthorizationRuleResponder(resp) @@ -287,8 +351,9 @@ func (client QueuesClient) DeleteAuthorizationRulePreparer(resourceGroupName str "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -319,18 +384,34 @@ func (client QueuesClient) DeleteAuthorizationRuleResponder(resp *http.Response) // Get returns a description for the specified queue. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. queueName is the queue name. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name queueName is the queue +// name. func (client QueuesClient) Get(resourceGroupName string, namespaceName string, queueName string) (result QueueResource, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: queueName, + Constraints: []validation.Constraint{{Target: "queueName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "queueName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.QueuesClient", "Get") + } + req, err := client.GetPreparer(resourceGroupName, namespaceName, queueName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -350,8 +431,9 @@ func (client QueuesClient) GetPreparer(resourceGroupName string, namespaceName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -383,19 +465,37 @@ func (client QueuesClient) GetResponder(resp *http.Response) (result QueueResour // GetAuthorizationRule gets an authorization rule for a queue by rule name. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. queueName is the queue name. authorizationRuleName is -// authorization rule name. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name queueName is the queue +// name. authorizationRuleName is the authorizationrule name. func (client QueuesClient) GetAuthorizationRule(resourceGroupName string, namespaceName string, queueName string, authorizationRuleName string) (result SharedAccessAuthorizationRuleResource, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: queueName, + Constraints: []validation.Constraint{{Target: "queueName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "queueName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.QueuesClient", "GetAuthorizationRule") + } + req, err := client.GetAuthorizationRulePreparer(resourceGroupName, namespaceName, queueName, authorizationRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "GetAuthorizationRule", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "GetAuthorizationRule", nil, "Failure preparing request") + return } resp, err := client.GetAuthorizationRuleSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "GetAuthorizationRule", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "GetAuthorizationRule", resp, "Failure sending request") + return } result, err = client.GetAuthorizationRuleResponder(resp) @@ -416,8 +516,9 @@ func (client QueuesClient) GetAuthorizationRulePreparer(resourceGroupName string "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -449,18 +550,30 @@ func (client QueuesClient) GetAuthorizationRuleResponder(resp *http.Response) (r // ListAll gets the queues within a namespace. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name func (client QueuesClient) ListAll(resourceGroupName string, namespaceName string) (result QueueListResult, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.QueuesClient", "ListAll") + } + req, err := client.ListAllPreparer(resourceGroupName, namespaceName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "ListAll", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "ListAll", nil, "Failure preparing request") + return } resp, err := client.ListAllSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "ListAll", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "ListAll", resp, "Failure sending request") + return } result, err = client.ListAllResponder(resp) @@ -479,8 +592,9 @@ func (client QueuesClient) ListAllPreparer(resourceGroupName string, namespaceNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -536,18 +650,34 @@ func (client QueuesClient) ListAllNextResults(lastResults QueueListResult) (resu // ListAuthorizationRules gets all authorization rules for a queue. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name queueName is the queue name. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name queueName is the queue +// name. func (client QueuesClient) ListAuthorizationRules(resourceGroupName string, namespaceName string, queueName string) (result SharedAccessAuthorizationRuleListResult, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: queueName, + Constraints: []validation.Constraint{{Target: "queueName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "queueName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.QueuesClient", "ListAuthorizationRules") + } + req, err := client.ListAuthorizationRulesPreparer(resourceGroupName, namespaceName, queueName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "ListAuthorizationRules", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "ListAuthorizationRules", nil, "Failure preparing request") + return } resp, err := client.ListAuthorizationRulesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "ListAuthorizationRules", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "ListAuthorizationRules", resp, "Failure sending request") + return } result, err = client.ListAuthorizationRulesResponder(resp) @@ -567,8 +697,9 @@ func (client QueuesClient) ListAuthorizationRulesPreparer(resourceGroupName stri "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -624,19 +755,37 @@ func (client QueuesClient) ListAuthorizationRulesNextResults(lastResults SharedA // ListKeys primary and secondary connection strings to the queue. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. queueName is the queue name. authorizationRuleName is the -// authorization rule name. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name queueName is the queue +// name. authorizationRuleName is the authorizationrule name. func (client QueuesClient) ListKeys(resourceGroupName string, namespaceName string, queueName string, authorizationRuleName string) (result ResourceListKeys, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: queueName, + Constraints: []validation.Constraint{{Target: "queueName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "queueName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.QueuesClient", "ListKeys") + } + req, err := client.ListKeysPreparer(resourceGroupName, namespaceName, queueName, authorizationRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "ListKeys", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "ListKeys", nil, "Failure preparing request") + return } resp, err := client.ListKeysSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "ListKeys", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "ListKeys", resp, "Failure sending request") + return } result, err = client.ListKeysResponder(resp) @@ -657,8 +806,9 @@ func (client QueuesClient) ListKeysPreparer(resourceGroupName string, namespaceN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -691,20 +841,38 @@ func (client QueuesClient) ListKeysResponder(resp *http.Response) (result Resour // RegenerateKeys regenerates the primary or secondary connection strings to // the queue. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. queueName is the queue name. authorizationRuleName is the -// authorization rule name. parameters is parameters supplied to regenerate the -// authorization rule. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name queueName is the queue +// name. authorizationRuleName is the authorizationrule name. parameters is +// parameters supplied to regenerate the authorization rule. func (client QueuesClient) RegenerateKeys(resourceGroupName string, namespaceName string, queueName string, authorizationRuleName string, parameters RegenerateKeysParameters) (result ResourceListKeys, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: queueName, + Constraints: []validation.Constraint{{Target: "queueName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "queueName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.QueuesClient", "RegenerateKeys") + } + req, err := client.RegenerateKeysPreparer(resourceGroupName, namespaceName, queueName, authorizationRuleName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "RegenerateKeys", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "RegenerateKeys", nil, "Failure preparing request") + return } resp, err := client.RegenerateKeysSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "RegenerateKeys", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "RegenerateKeys", resp, "Failure sending request") + return } result, err = client.RegenerateKeysResponder(resp) @@ -725,8 +893,9 @@ func (client QueuesClient) RegenerateKeysPreparer(resourceGroupName string, name "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/subscriptions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/subscriptions.go old mode 100644 new mode 100755 index 47c798f99..83799ec0b --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/subscriptions.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/subscriptions.go @@ -14,7 +14,7 @@ package servicebus // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -44,12 +44,24 @@ func NewSubscriptionsClientWithBaseURI(baseURI string, subscriptionID string) Su // CreateOrUpdate creates a topic subscription. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. topicName is the topic name. subscriptionName is the -// subscription name. parameters is parameters supplied to create a -// subscription resource. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name topicName is the topic +// name. subscriptionName is the subscription name. parameters is parameters +// supplied to create a subscription resource. func (client SubscriptionsClient) CreateOrUpdate(resourceGroupName string, namespaceName string, topicName string, subscriptionName string, parameters SubscriptionCreateOrUpdateParameters) (result SubscriptionResource, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: topicName, + Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: subscriptionName, + Constraints: []validation.Constraint{{Target: "subscriptionName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "subscriptionName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "servicebus.SubscriptionsClient", "CreateOrUpdate") @@ -57,13 +69,15 @@ func (client SubscriptionsClient) CreateOrUpdate(resourceGroupName string, names req, err := client.CreateOrUpdatePreparer(resourceGroupName, namespaceName, topicName, subscriptionName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -84,8 +98,9 @@ func (client SubscriptionsClient) CreateOrUpdatePreparer(resourceGroupName strin "topicName": autorest.Encode("path", topicName), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -119,19 +134,37 @@ func (client SubscriptionsClient) CreateOrUpdateResponder(resp *http.Response) ( // Delete deletes a subscription from the specified topic. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. topicName is the topic name. subscriptionName is the -// subscription name. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name topicName is the topic +// name. subscriptionName is the subscription name. func (client SubscriptionsClient) Delete(resourceGroupName string, namespaceName string, topicName string, subscriptionName 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: topicName, + Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: subscriptionName, + Constraints: []validation.Constraint{{Target: "subscriptionName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "subscriptionName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.SubscriptionsClient", "Delete") + } + req, err := client.DeletePreparer(resourceGroupName, namespaceName, topicName, subscriptionName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -152,8 +185,9 @@ func (client SubscriptionsClient) DeletePreparer(resourceGroupName string, names "topicName": autorest.Encode("path", topicName), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -184,19 +218,37 @@ func (client SubscriptionsClient) DeleteResponder(resp *http.Response) (result a // Get returns a subscription description for the specified topic. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. topicName is the topic name. subscriptionName is the -// subscription name. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name topicName is the topic +// name. subscriptionName is the subscription name. func (client SubscriptionsClient) Get(resourceGroupName string, namespaceName string, topicName string, subscriptionName string) (result SubscriptionResource, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: topicName, + Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: subscriptionName, + Constraints: []validation.Constraint{{Target: "subscriptionName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "subscriptionName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.SubscriptionsClient", "Get") + } + req, err := client.GetPreparer(resourceGroupName, namespaceName, topicName, subscriptionName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -217,8 +269,9 @@ func (client SubscriptionsClient) GetPreparer(resourceGroupName string, namespac "topicName": autorest.Encode("path", topicName), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -248,20 +301,36 @@ func (client SubscriptionsClient) GetResponder(resp *http.Response) (result Subs return } -// ListAll lsit all the subscriptions under a specified topic. +// ListAll list all the subscriptions under a specified topic. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. topicName is the topic name. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name topicName is the topic +// name. func (client SubscriptionsClient) ListAll(resourceGroupName string, namespaceName string, topicName string) (result SubscriptionListResult, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: topicName, + Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.SubscriptionsClient", "ListAll") + } + req, err := client.ListAllPreparer(resourceGroupName, namespaceName, topicName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "ListAll", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "ListAll", nil, "Failure preparing request") + return } resp, err := client.ListAllSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "ListAll", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "ListAll", resp, "Failure sending request") + return } result, err = client.ListAllResponder(resp) @@ -281,8 +350,9 @@ func (client SubscriptionsClient) ListAllPreparer(resourceGroupName string, name "topicName": autorest.Encode("path", topicName), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/topics.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/topics.go old mode 100644 new mode 100755 index 5123a1a45..02938927e --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/topics.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/topics.go @@ -14,7 +14,7 @@ package servicebus // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -42,11 +42,20 @@ func NewTopicsClientWithBaseURI(baseURI string, subscriptionID string) TopicsCli // CreateOrUpdate creates a topic in the specified namespace. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. topicName is the topic name. parameters is parameters -// supplied to create a topic resource. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name topicName is the topic +// name. parameters is parameters supplied to create a topic resource. func (client TopicsClient) CreateOrUpdate(resourceGroupName string, namespaceName string, topicName string, parameters TopicCreateOrUpdateParameters) (result TopicResource, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: topicName, + Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "servicebus.TopicsClient", "CreateOrUpdate") @@ -54,13 +63,15 @@ func (client TopicsClient) CreateOrUpdate(resourceGroupName string, namespaceNam req, err := client.CreateOrUpdatePreparer(resourceGroupName, namespaceName, topicName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -80,8 +91,9 @@ func (client TopicsClient) CreateOrUpdatePreparer(resourceGroupName string, name "topicName": autorest.Encode("path", topicName), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -116,11 +128,24 @@ func (client TopicsClient) CreateOrUpdateResponder(resp *http.Response) (result // CreateOrUpdateAuthorizationRule creates an authorizatio rule for the // specified topic. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. topicName is the topic name. authorizationRuleName is -// authorization rule name. parameters is the shared access authorization rule. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name topicName is the topic +// name. authorizationRuleName is the authorizationrule name. parameters is the +// shared access authorization rule. func (client TopicsClient) CreateOrUpdateAuthorizationRule(resourceGroupName string, namespaceName string, topicName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters) (result SharedAccessAuthorizationRuleResource, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: topicName, + Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.SharedAccessAuthorizationRuleProperties", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.SharedAccessAuthorizationRuleProperties.Rights", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { @@ -129,13 +154,15 @@ func (client TopicsClient) CreateOrUpdateAuthorizationRule(resourceGroupName str req, err := client.CreateOrUpdateAuthorizationRulePreparer(resourceGroupName, namespaceName, topicName, authorizationRuleName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateAuthorizationRuleSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "CreateOrUpdateAuthorizationRule", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "CreateOrUpdateAuthorizationRule", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateAuthorizationRuleResponder(resp) @@ -156,8 +183,9 @@ func (client TopicsClient) CreateOrUpdateAuthorizationRulePreparer(resourceGroup "topicName": autorest.Encode("path", topicName), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -191,18 +219,34 @@ func (client TopicsClient) CreateOrUpdateAuthorizationRuleResponder(resp *http.R // Delete deletes a topic from the specified namespace and resource group. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. topicName is the name of the topic to delete. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name topicName is the topic +// name. func (client TopicsClient) Delete(resourceGroupName string, namespaceName string, topicName 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: topicName, + Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.TopicsClient", "Delete") + } + req, err := client.DeletePreparer(resourceGroupName, namespaceName, topicName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -222,8 +266,9 @@ func (client TopicsClient) DeletePreparer(resourceGroupName string, namespaceNam "topicName": autorest.Encode("path", topicName), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -254,19 +299,37 @@ func (client TopicsClient) DeleteResponder(resp *http.Response) (result autorest // DeleteAuthorizationRule deletes a topic authorization rule. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. topicName is the topic name. authorizationRuleName is -// authorization rule name. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name topicName is the topic +// name. authorizationRuleName is the authorizationrule name. func (client TopicsClient) DeleteAuthorizationRule(resourceGroupName string, namespaceName string, topicName string, authorizationRuleName 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: topicName, + Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.TopicsClient", "DeleteAuthorizationRule") + } + req, err := client.DeleteAuthorizationRulePreparer(resourceGroupName, namespaceName, topicName, authorizationRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "DeleteAuthorizationRule", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "DeleteAuthorizationRule", nil, "Failure preparing request") + return } resp, err := client.DeleteAuthorizationRuleSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "DeleteAuthorizationRule", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "DeleteAuthorizationRule", resp, "Failure sending request") + return } result, err = client.DeleteAuthorizationRuleResponder(resp) @@ -287,8 +350,9 @@ func (client TopicsClient) DeleteAuthorizationRulePreparer(resourceGroupName str "topicName": autorest.Encode("path", topicName), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -319,18 +383,34 @@ func (client TopicsClient) DeleteAuthorizationRuleResponder(resp *http.Response) // Get returns a description for the specified topic. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. topicName is the topic name. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name topicName is the topic +// name. func (client TopicsClient) Get(resourceGroupName string, namespaceName string, topicName string) (result TopicResource, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: topicName, + Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.TopicsClient", "Get") + } + req, err := client.GetPreparer(resourceGroupName, namespaceName, topicName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -350,8 +430,9 @@ func (client TopicsClient) GetPreparer(resourceGroupName string, namespaceName s "topicName": autorest.Encode("path", topicName), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -383,19 +464,37 @@ func (client TopicsClient) GetResponder(resp *http.Response) (result TopicResour // GetAuthorizationRule returns the specified authorization rule. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. topicName is the topic name. authorizationRuleName is -// authorization rule name. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name topicName is the topic +// name. authorizationRuleName is the authorizationrule name. func (client TopicsClient) GetAuthorizationRule(resourceGroupName string, namespaceName string, topicName string, authorizationRuleName string) (result SharedAccessAuthorizationRuleResource, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: topicName, + Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.TopicsClient", "GetAuthorizationRule") + } + req, err := client.GetAuthorizationRulePreparer(resourceGroupName, namespaceName, topicName, authorizationRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "GetAuthorizationRule", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "GetAuthorizationRule", nil, "Failure preparing request") + return } resp, err := client.GetAuthorizationRuleSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "GetAuthorizationRule", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "GetAuthorizationRule", resp, "Failure sending request") + return } result, err = client.GetAuthorizationRuleResponder(resp) @@ -416,8 +515,9 @@ func (client TopicsClient) GetAuthorizationRulePreparer(resourceGroupName string "topicName": autorest.Encode("path", topicName), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -449,18 +549,30 @@ func (client TopicsClient) GetAuthorizationRuleResponder(resp *http.Response) (r // ListAll gets all the topics in a namespace. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name func (client TopicsClient) ListAll(resourceGroupName string, namespaceName string) (result TopicListResult, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.TopicsClient", "ListAll") + } + req, err := client.ListAllPreparer(resourceGroupName, namespaceName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "ListAll", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "ListAll", nil, "Failure preparing request") + return } resp, err := client.ListAllSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "ListAll", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "ListAll", resp, "Failure sending request") + return } result, err = client.ListAllResponder(resp) @@ -479,8 +591,9 @@ func (client TopicsClient) ListAllPreparer(resourceGroupName string, namespaceNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -536,18 +649,34 @@ func (client TopicsClient) ListAllNextResults(lastResults TopicListResult) (resu // ListAuthorizationRules gets authorization rules for a topic. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. topicName is the topic name. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name topicName is the topic +// name. func (client TopicsClient) ListAuthorizationRules(resourceGroupName string, namespaceName string, topicName string) (result SharedAccessAuthorizationRuleListResult, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: topicName, + Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.TopicsClient", "ListAuthorizationRules") + } + req, err := client.ListAuthorizationRulesPreparer(resourceGroupName, namespaceName, topicName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "ListAuthorizationRules", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "ListAuthorizationRules", nil, "Failure preparing request") + return } resp, err := client.ListAuthorizationRulesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "ListAuthorizationRules", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "ListAuthorizationRules", resp, "Failure sending request") + return } result, err = client.ListAuthorizationRulesResponder(resp) @@ -567,8 +696,9 @@ func (client TopicsClient) ListAuthorizationRulesPreparer(resourceGroupName stri "topicName": autorest.Encode("path", topicName), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -624,19 +754,37 @@ func (client TopicsClient) ListAuthorizationRulesNextResults(lastResults SharedA // ListKeys gets the primary and secondary connection strings for the topic. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. topicName is the topic name. authorizationRuleName is the -// authorization rule name. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name topicName is the topic +// name. authorizationRuleName is the authorizationrule name. func (client TopicsClient) ListKeys(resourceGroupName string, namespaceName string, topicName string, authorizationRuleName string) (result ResourceListKeys, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: topicName, + Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.TopicsClient", "ListKeys") + } + req, err := client.ListKeysPreparer(resourceGroupName, namespaceName, topicName, authorizationRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "ListKeys", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "ListKeys", nil, "Failure preparing request") + return } resp, err := client.ListKeysSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "ListKeys", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "ListKeys", resp, "Failure sending request") + return } result, err = client.ListKeysResponder(resp) @@ -657,8 +805,9 @@ func (client TopicsClient) ListKeysPreparer(resourceGroupName string, namespaceN "topicName": autorest.Encode("path", topicName), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -691,20 +840,38 @@ func (client TopicsClient) ListKeysResponder(resp *http.Response) (result Resour // RegenerateKeys regenerates primary or secondary connection strings for the // topic. // -// resourceGroupName is the name of the resource group. namespaceName is the -// namespace name. topicName is the topic name. authorizationRuleName is the -// authorization rule name. parameters is parameters supplied to regenerate the -// authorization rule. +// resourceGroupName is name of the Resource group within the Azure +// subscription. namespaceName is the namespace name topicName is the topic +// name. authorizationRuleName is the authorizationrule name. parameters is +// parameters supplied to regenerate the authorization rule. func (client TopicsClient) RegenerateKeys(resourceGroupName string, namespaceName string, topicName string, authorizationRuleName string, parameters RegenerateKeysParameters) (result ResourceListKeys, 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}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: topicName, + Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: authorizationRuleName, + Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "servicebus.TopicsClient", "RegenerateKeys") + } + req, err := client.RegenerateKeysPreparer(resourceGroupName, namespaceName, topicName, authorizationRuleName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "RegenerateKeys", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "RegenerateKeys", nil, "Failure preparing request") + return } resp, err := client.RegenerateKeysSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "RegenerateKeys", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "RegenerateKeys", resp, "Failure sending request") + return } result, err = client.RegenerateKeysResponder(resp) @@ -725,8 +892,9 @@ func (client TopicsClient) RegenerateKeysPreparer(resourceGroupName string, name "topicName": autorest.Encode("path", topicName), } + const APIVersion = "2015-08-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/version.go old mode 100644 new mode 100755 index 6bb9a10d9..163910ee4 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/version.go @@ -18,43 +18,12 @@ package servicebus // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -import ( - "bytes" - "fmt" - "strings" -) - -const ( - major = "8" - minor = "1" - patch = "0" - tag = "beta" - userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" -) - -// cached results of UserAgent and Version to prevent repeated operations. -var ( - userAgent string - version string -) - // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - if userAgent == "" { - userAgent = fmt.Sprintf(userAgentFormat, Version(), "servicebus", "2015-08-01") - } - return userAgent + return "Azure-SDK-For-Go/v10.0.2-beta arm-servicebus/2015-08-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - if version == "" { - versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) - if tag != "" { - versionBuilder.WriteRune('-') - versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) - } - version = string(versionBuilder.Bytes()) - } - return version + return "v10.0.2-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/capabilities.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/capabilities.go new file mode 100755 index 000000000..ec8aca224 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/capabilities.go @@ -0,0 +1,108 @@ +package sql + +// 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// CapabilitiesClient is the the Azure SQL Database management API provides a +// RESTful set of web services that interact with Azure SQL Database services +// to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type CapabilitiesClient struct { + ManagementClient +} + +// NewCapabilitiesClient creates an instance of the CapabilitiesClient client. +func NewCapabilitiesClient(subscriptionID string) CapabilitiesClient { + return NewCapabilitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCapabilitiesClientWithBaseURI creates an instance of the +// CapabilitiesClient client. +func NewCapabilitiesClientWithBaseURI(baseURI string, subscriptionID string) CapabilitiesClient { + return CapabilitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByLocation gets the capabilities available for the specified location. +// +// locationID is the location id whose capabilities are retrieved. +func (client CapabilitiesClient) ListByLocation(locationID string) (result LocationCapabilities, err error) { + req, err := client.ListByLocationPreparer(locationID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.CapabilitiesClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.CapabilitiesClient", "ListByLocation", resp, "Failure sending request") + return + } + + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.CapabilitiesClient", "ListByLocation", resp, "Failure responding to request") + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client CapabilitiesClient) ListByLocationPreparer(locationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationId": autorest.Encode("path", locationID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationId}/capabilities", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByLocationSender sends the ListByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client CapabilitiesClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client CapabilitiesClient) ListByLocationResponder(resp *http.Response) (result LocationCapabilities, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/client.go old mode 100644 new mode 100755 index 916cd5043..dbc1dfaa2 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/client.go @@ -1,8 +1,8 @@ -// Package sql implements the Azure ARM Sql service API version 2014-04-01. +// Package sql implements the Azure ARM Sql service API version . // -// Provides create, read, update and delete functionality for Azure SQL -// resources including servers, databases, elastic pools, recommendations, -// operations, and usage metrics. +// The Azure SQL Database management API provides a RESTful set of web services +// that interact with Azure SQL Database services to manage your databases. The +// API enables you to create, retrieve, update, and delete databases. package sql // Copyright (c) Microsoft and contributors. All rights reserved. @@ -19,7 +19,7 @@ package sql // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -28,9 +28,6 @@ import ( ) const ( - // APIVersion is the version of the Sql - APIVersion = "2014-04-01" - // DefaultBaseURI is the default URI used for the service Sql DefaultBaseURI = "https://management.azure.com" ) @@ -39,7 +36,6 @@ const ( type ManagementClient struct { autorest.Client BaseURI string - APIVersion string SubscriptionID string } @@ -53,7 +49,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, - APIVersion: APIVersion, SubscriptionID: subscriptionID, } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/databases.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/databases.go old mode 100644 new mode 100755 index 70a13d619..c0d36034f --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/databases.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/databases.go @@ -14,19 +14,21 @@ package sql // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" "net/http" ) -// DatabasesClient is the provides create, read, update and delete -// functionality for Azure SQL resources including servers, databases, -// elastic pools, recommendations, operations, and usage metrics. +// DatabasesClient is the the Azure SQL Database management API provides a +// RESTful set of web services that interact with Azure SQL Database services +// to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. type DatabasesClient struct { ManagementClient } @@ -42,39 +44,149 @@ func NewDatabasesClientWithBaseURI(baseURI string, subscriptionID string) Databa return DatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} } -// CreateOrUpdate creates a new Azure SQL database or updates an existing -// Azure SQL database. Location is a required property in the request body, -// and it must be the same as the location of the SQL server. This method may +// CreateImportOperation creates an import operation that imports a bacpac into +// an existing database. The existing database must be empty. This method may // poll for completion. Polling can be canceled by passing the cancel channel // argument. The channel will be used to cancel polling and any outstanding // HTTP requests. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. databaseName -// is the name of the Azure SQL database to be operated on (updated or -// created). parameters is the required parameters for creating or updating a -// database. -func (client DatabasesClient) CreateOrUpdate(resourceGroupName string, serverName string, databaseName string, parameters Database, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateOrUpdatePreparer(resourceGroupName, serverName, databaseName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdate", nil, "Failure preparing request") +// the portal. serverName is the name of the server. databaseName is the name +// of the database to import into parameters is the required parameters for +// importing a Bacpac into a database. +func (client DatabasesClient) CreateImportOperation(resourceGroupName string, serverName string, databaseName string, parameters ImportExtensionRequest, cancel <-chan struct{}) (<-chan ImportExportResponse, <-chan error) { + resultChan := make(chan ImportExportResponse, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ImportExtensionProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ImportExtensionProperties.OperationMode", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "sql.DatabasesClient", "CreateImportOperation") + close(errChan) + close(resultChan) + return resultChan, errChan } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdate", resp, "Failure sending request") + go func() { + var err error + var result ImportExportResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateImportOperationPreparer(resourceGroupName, serverName, databaseName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateImportOperation", nil, "Failure preparing request") + return + } + + resp, err := client.CreateImportOperationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateImportOperation", resp, "Failure sending request") + return + } + + result, err = client.CreateImportOperationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateImportOperation", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateImportOperationPreparer prepares the CreateImportOperation request. +func (client DatabasesClient) CreateImportOperationPreparer(resourceGroupName string, serverName string, databaseName string, parameters ImportExtensionRequest, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdate", resp, "Failure responding to request") + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, } + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions/import", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateImportOperationSender sends the CreateImportOperation request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) CreateImportOperationSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateImportOperationResponder handles the response to the CreateImportOperation request. The method always +// closes the http.Response Body. +func (client DatabasesClient) CreateImportOperationResponder(resp *http.Response) (result ImportExportResponse, 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 } +// CreateOrUpdate creates a new database or updates an existing database. +// Location is a required property in the request body, and it must be the same +// as the location of the SQL server. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel +// will be used to cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. serverName is the name of the server. databaseName is the name +// of the database to be operated on (updated or created). parameters is the +// required parameters for creating or updating a database. +func (client DatabasesClient) CreateOrUpdate(resourceGroupName string, serverName string, databaseName string, parameters Database, cancel <-chan struct{}) (<-chan Database, <-chan error) { + resultChan := make(chan Database, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result Database + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, serverName, databaseName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client DatabasesClient) CreateOrUpdatePreparer(resourceGroupName string, serverName string, databaseName string, parameters Database, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ @@ -84,8 +196,9 @@ func (client DatabasesClient) CreateOrUpdatePreparer(resourceGroupName string, s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -108,35 +221,184 @@ func (client DatabasesClient) CreateOrUpdateSender(req *http.Request) (*http.Res // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client DatabasesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client DatabasesClient) CreateOrUpdateResponder(resp *http.Response) (result Database, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } -// CreateOrUpdateTransparentDataEncryptionConfiguration creates or updates an -// Azure SQL Database Transparent Data Encryption Operation. +// CreateOrUpdateBlobAuditingPolicy creates or updates a database's blob +// auditing policy. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. databaseName -// is the name of the Azure SQL database for which setting the Transparent -// Data Encryption applies. parameters is the required parameters for -// creating or updating transparent data encryption. +// the portal. serverName is the name of the server. databaseName is the name +// of the database for which database blob audit policy will be defined. +// parameters is the database blob auditing policy. +func (client DatabasesClient) CreateOrUpdateBlobAuditingPolicy(resourceGroupName string, serverName string, databaseName string, parameters DatabaseBlobAuditingPolicy) (result DatabaseBlobAuditingPolicy, err error) { + req, err := client.CreateOrUpdateBlobAuditingPolicyPreparer(resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdateBlobAuditingPolicy", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateBlobAuditingPolicySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdateBlobAuditingPolicy", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateBlobAuditingPolicyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdateBlobAuditingPolicy", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdateBlobAuditingPolicyPreparer prepares the CreateOrUpdateBlobAuditingPolicy request. +func (client DatabasesClient) CreateOrUpdateBlobAuditingPolicyPreparer(resourceGroupName string, serverName string, databaseName string, parameters DatabaseBlobAuditingPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings/default", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateBlobAuditingPolicySender sends the CreateOrUpdateBlobAuditingPolicy request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) CreateOrUpdateBlobAuditingPolicySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateBlobAuditingPolicyResponder handles the response to the CreateOrUpdateBlobAuditingPolicy request. The method always +// closes the http.Response Body. +func (client DatabasesClient) CreateOrUpdateBlobAuditingPolicyResponder(resp *http.Response) (result DatabaseBlobAuditingPolicy, 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 +} + +// CreateOrUpdateThreatDetectionPolicy creates or updates a database's threat +// detection policy. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. serverName is the name of the server. databaseName is the name +// of the database for which database Threat Detection policy is defined. +// parameters is the database Threat Detection policy. +func (client DatabasesClient) CreateOrUpdateThreatDetectionPolicy(resourceGroupName string, serverName string, databaseName string, parameters DatabaseSecurityAlertPolicy) (result DatabaseSecurityAlertPolicy, err error) { + req, err := client.CreateOrUpdateThreatDetectionPolicyPreparer(resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdateThreatDetectionPolicy", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateThreatDetectionPolicySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdateThreatDetectionPolicy", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateThreatDetectionPolicyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdateThreatDetectionPolicy", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdateThreatDetectionPolicyPreparer prepares the CreateOrUpdateThreatDetectionPolicy request. +func (client DatabasesClient) CreateOrUpdateThreatDetectionPolicyPreparer(resourceGroupName string, serverName string, databaseName string, parameters DatabaseSecurityAlertPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies/default", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateThreatDetectionPolicySender sends the CreateOrUpdateThreatDetectionPolicy request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) CreateOrUpdateThreatDetectionPolicySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateThreatDetectionPolicyResponder handles the response to the CreateOrUpdateThreatDetectionPolicy request. The method always +// closes the http.Response Body. +func (client DatabasesClient) CreateOrUpdateThreatDetectionPolicyResponder(resp *http.Response) (result DatabaseSecurityAlertPolicy, 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 +} + +// CreateOrUpdateTransparentDataEncryptionConfiguration creates or updates a +// database's transparent data encryption configuration. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. serverName is the name of the server. databaseName is the name +// of the database for which setting the transparent data encryption applies. +// parameters is the required parameters for creating or updating transparent +// data encryption. func (client DatabasesClient) CreateOrUpdateTransparentDataEncryptionConfiguration(resourceGroupName string, serverName string, databaseName string, parameters TransparentDataEncryption) (result TransparentDataEncryption, err error) { req, err := client.CreateOrUpdateTransparentDataEncryptionConfigurationPreparer(resourceGroupName, serverName, databaseName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdateTransparentDataEncryptionConfiguration", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdateTransparentDataEncryptionConfiguration", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateTransparentDataEncryptionConfigurationSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdateTransparentDataEncryptionConfiguration", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdateTransparentDataEncryptionConfiguration", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateTransparentDataEncryptionConfigurationResponder(resp) @@ -156,8 +418,9 @@ func (client DatabasesClient) CreateOrUpdateTransparentDataEncryptionConfigurati "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -189,22 +452,24 @@ func (client DatabasesClient) CreateOrUpdateTransparentDataEncryptionConfigurati return } -// Delete deletes an Azure SQL database. +// Delete deletes a database. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. databaseName -// is the name of the Azure SQL database to be deleted. +// the portal. serverName is the name of the server. databaseName is the name +// of the database to be deleted. func (client DatabasesClient) Delete(resourceGroupName string, serverName string, databaseName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, serverName, databaseName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -224,8 +489,9 @@ func (client DatabasesClient) DeletePreparer(resourceGroupName string, serverNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -254,24 +520,370 @@ func (client DatabasesClient) DeleteResponder(resp *http.Response) (result autor return } -// Get gets information about an Azure SQL database. +// DeleteReplicationLink deletes a database replication link. Cannot be done +// during failover. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. databaseName -// is the name of the Azure SQL database to be retrieved. expand is the comma -// separated list of child objects to expand in the response. Possible -// properties: serviceTierAdvisors, upgradeHint, transparentDataEncryption. +// the portal. serverName is the name of the server. databaseName is the name +// of the database that has the replication link to be dropped. linkID is the +// ID of the replication link to be deleted. +func (client DatabasesClient) DeleteReplicationLink(resourceGroupName string, serverName string, databaseName string, linkID string) (result autorest.Response, err error) { + req, err := client.DeleteReplicationLinkPreparer(resourceGroupName, serverName, databaseName, linkID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "DeleteReplicationLink", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteReplicationLinkSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "DeleteReplicationLink", resp, "Failure sending request") + return + } + + result, err = client.DeleteReplicationLinkResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "DeleteReplicationLink", resp, "Failure responding to request") + } + + return +} + +// DeleteReplicationLinkPreparer prepares the DeleteReplicationLink request. +func (client DatabasesClient) DeleteReplicationLinkPreparer(resourceGroupName string, serverName string, databaseName string, linkID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "linkId": autorest.Encode("path", linkID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteReplicationLinkSender sends the DeleteReplicationLink request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) DeleteReplicationLinkSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteReplicationLinkResponder handles the response to the DeleteReplicationLink request. The method always +// closes the http.Response Body. +func (client DatabasesClient) DeleteReplicationLinkResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Export exports a database to a bacpac. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel +// will be used to cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. serverName is the name of the server. databaseName is the name +// of the database to be exported. parameters is the required parameters for +// exporting a database. +func (client DatabasesClient) Export(resourceGroupName string, serverName string, databaseName string, parameters ExportRequest, cancel <-chan struct{}) (<-chan ImportExportResponse, <-chan error) { + resultChan := make(chan ImportExportResponse, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.StorageKey", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.StorageURI", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AdministratorLogin", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AdministratorLoginPassword", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "sql.DatabasesClient", "Export") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result ImportExportResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ExportPreparer(resourceGroupName, serverName, databaseName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Export", nil, "Failure preparing request") + return + } + + resp, err := client.ExportSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Export", resp, "Failure sending request") + return + } + + result, err = client.ExportResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Export", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ExportPreparer prepares the Export request. +func (client DatabasesClient) ExportPreparer(resourceGroupName string, serverName string, databaseName string, parameters ExportRequest, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/export", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ExportSender sends the Export request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ExportSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ExportResponder handles the response to the Export request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ExportResponder(resp *http.Response) (result ImportExportResponse, 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 +} + +// FailoverReplicationLink sets which replica database is primary by failing +// over from the current primary replica database. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. serverName is the name of the server. databaseName is the name +// of the database that has the replication link to be failed over. linkID is +// the ID of the replication link to be failed over. +func (client DatabasesClient) FailoverReplicationLink(resourceGroupName string, serverName string, databaseName string, linkID string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.FailoverReplicationLinkPreparer(resourceGroupName, serverName, databaseName, linkID, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "FailoverReplicationLink", nil, "Failure preparing request") + return + } + + resp, err := client.FailoverReplicationLinkSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "FailoverReplicationLink", resp, "Failure sending request") + return + } + + result, err = client.FailoverReplicationLinkResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "FailoverReplicationLink", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// FailoverReplicationLinkPreparer prepares the FailoverReplicationLink request. +func (client DatabasesClient) FailoverReplicationLinkPreparer(resourceGroupName string, serverName string, databaseName string, linkID string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "linkId": autorest.Encode("path", linkID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/failover", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// FailoverReplicationLinkSender sends the FailoverReplicationLink request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) FailoverReplicationLinkSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// FailoverReplicationLinkResponder handles the response to the FailoverReplicationLink request. The method always +// closes the http.Response Body. +func (client DatabasesClient) FailoverReplicationLinkResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// FailoverReplicationLinkAllowDataLoss sets which replica database is primary +// by failing over from the current primary replica database. This operation +// might result in data loss. This method may poll for completion. Polling can +// be canceled by passing the cancel channel argument. The channel will be used +// to cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. serverName is the name of the server. databaseName is the name +// of the database that has the replication link to be failed over. linkID is +// the ID of the replication link to be failed over. +func (client DatabasesClient) FailoverReplicationLinkAllowDataLoss(resourceGroupName string, serverName string, databaseName string, linkID string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.FailoverReplicationLinkAllowDataLossPreparer(resourceGroupName, serverName, databaseName, linkID, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "FailoverReplicationLinkAllowDataLoss", nil, "Failure preparing request") + return + } + + resp, err := client.FailoverReplicationLinkAllowDataLossSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "FailoverReplicationLinkAllowDataLoss", resp, "Failure sending request") + return + } + + result, err = client.FailoverReplicationLinkAllowDataLossResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "FailoverReplicationLinkAllowDataLoss", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// FailoverReplicationLinkAllowDataLossPreparer prepares the FailoverReplicationLinkAllowDataLoss request. +func (client DatabasesClient) FailoverReplicationLinkAllowDataLossPreparer(resourceGroupName string, serverName string, databaseName string, linkID string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "linkId": autorest.Encode("path", linkID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/forceFailoverAllowDataLoss", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// FailoverReplicationLinkAllowDataLossSender sends the FailoverReplicationLinkAllowDataLoss request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) FailoverReplicationLinkAllowDataLossSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// FailoverReplicationLinkAllowDataLossResponder handles the response to the FailoverReplicationLinkAllowDataLoss request. The method always +// closes the http.Response Body. +func (client DatabasesClient) FailoverReplicationLinkAllowDataLossResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a database. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. serverName is the name of the server. databaseName is the name +// of the database to be retrieved. expand is a comma separated list of child +// objects to expand in the response. Possible properties: serviceTierAdvisors, +// transparentDataEncryption. func (client DatabasesClient) Get(resourceGroupName string, serverName string, databaseName string, expand string) (result Database, err error) { req, err := client.GetPreparer(resourceGroupName, serverName, databaseName, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -291,8 +903,9 @@ func (client DatabasesClient) GetPreparer(resourceGroupName string, serverName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(expand) > 0 { queryParameters["$expand"] = autorest.Encode("query", expand) @@ -325,23 +938,164 @@ func (client DatabasesClient) GetResponder(resp *http.Response) (result Database return } -// GetServiceTierAdvisor gets information about a service tier advisor. +// GetBlobAuditingPolicy gets a database's blob auditing policy. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. databaseName -// is the name of database. serviceTierAdvisorName is the name of service -// tier advisor. +// the portal. serverName is the name of the server. databaseName is the name +// of the database for which database blob audit policy is defined. +func (client DatabasesClient) GetBlobAuditingPolicy(resourceGroupName string, serverName string, databaseName string) (result DatabaseBlobAuditingPolicy, err error) { + req, err := client.GetBlobAuditingPolicyPreparer(resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetBlobAuditingPolicy", nil, "Failure preparing request") + return + } + + resp, err := client.GetBlobAuditingPolicySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetBlobAuditingPolicy", resp, "Failure sending request") + return + } + + result, err = client.GetBlobAuditingPolicyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetBlobAuditingPolicy", resp, "Failure responding to request") + } + + return +} + +// GetBlobAuditingPolicyPreparer prepares the GetBlobAuditingPolicy request. +func (client DatabasesClient) GetBlobAuditingPolicyPreparer(resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetBlobAuditingPolicySender sends the GetBlobAuditingPolicy request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) GetBlobAuditingPolicySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetBlobAuditingPolicyResponder handles the response to the GetBlobAuditingPolicy request. The method always +// closes the http.Response Body. +func (client DatabasesClient) GetBlobAuditingPolicyResponder(resp *http.Response) (result DatabaseBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetReplicationLink gets a database replication link. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. serverName is the name of the server. databaseName is the name +// of the database to get the link for. linkID is the replication link ID to be +// retrieved. +func (client DatabasesClient) GetReplicationLink(resourceGroupName string, serverName string, databaseName string, linkID string) (result ReplicationLink, err error) { + req, err := client.GetReplicationLinkPreparer(resourceGroupName, serverName, databaseName, linkID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetReplicationLink", nil, "Failure preparing request") + return + } + + resp, err := client.GetReplicationLinkSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetReplicationLink", resp, "Failure sending request") + return + } + + result, err = client.GetReplicationLinkResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetReplicationLink", resp, "Failure responding to request") + } + + return +} + +// GetReplicationLinkPreparer prepares the GetReplicationLink request. +func (client DatabasesClient) GetReplicationLinkPreparer(resourceGroupName string, serverName string, databaseName string, linkID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "linkId": autorest.Encode("path", linkID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetReplicationLinkSender sends the GetReplicationLink request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) GetReplicationLinkSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetReplicationLinkResponder handles the response to the GetReplicationLink request. The method always +// closes the http.Response Body. +func (client DatabasesClient) GetReplicationLinkResponder(resp *http.Response) (result ReplicationLink, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetServiceTierAdvisor gets a service tier advisor. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. serverName is the name of the server. databaseName is the name +// of database. serviceTierAdvisorName is the name of service tier advisor. func (client DatabasesClient) GetServiceTierAdvisor(resourceGroupName string, serverName string, databaseName string, serviceTierAdvisorName string) (result ServiceTierAdvisor, err error) { req, err := client.GetServiceTierAdvisorPreparer(resourceGroupName, serverName, databaseName, serviceTierAdvisorName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetServiceTierAdvisor", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetServiceTierAdvisor", nil, "Failure preparing request") + return } resp, err := client.GetServiceTierAdvisorSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetServiceTierAdvisor", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetServiceTierAdvisor", resp, "Failure sending request") + return } result, err = client.GetServiceTierAdvisorResponder(resp) @@ -362,8 +1116,9 @@ func (client DatabasesClient) GetServiceTierAdvisorPreparer(resourceGroupName st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -393,24 +1148,94 @@ func (client DatabasesClient) GetServiceTierAdvisorResponder(resp *http.Response return } -// GetTransparentDataEncryptionConfiguration gets an Azure SQL Database -// Transparent Data Encryption Response. +// GetThreatDetectionPolicy gets a database's threat detection policy. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. databaseName -// is the name of the Azure SQL database for which the Transparent Data -// Encryption applies. +// the portal. serverName is the name of the server. databaseName is the name +// of the database for which database Threat Detection policy is defined. +func (client DatabasesClient) GetThreatDetectionPolicy(resourceGroupName string, serverName string, databaseName string) (result DatabaseSecurityAlertPolicy, err error) { + req, err := client.GetThreatDetectionPolicyPreparer(resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetThreatDetectionPolicy", nil, "Failure preparing request") + return + } + + resp, err := client.GetThreatDetectionPolicySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetThreatDetectionPolicy", resp, "Failure sending request") + return + } + + result, err = client.GetThreatDetectionPolicyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetThreatDetectionPolicy", resp, "Failure responding to request") + } + + return +} + +// GetThreatDetectionPolicyPreparer prepares the GetThreatDetectionPolicy request. +func (client DatabasesClient) GetThreatDetectionPolicyPreparer(resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetThreatDetectionPolicySender sends the GetThreatDetectionPolicy request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) GetThreatDetectionPolicySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetThreatDetectionPolicyResponder handles the response to the GetThreatDetectionPolicy request. The method always +// closes the http.Response Body. +func (client DatabasesClient) GetThreatDetectionPolicyResponder(resp *http.Response) (result DatabaseSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetTransparentDataEncryptionConfiguration gets a database's transparent data +// encryption configuration. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. serverName is the name of the server. databaseName is the name +// of the database for which the transparent data encryption applies. func (client DatabasesClient) GetTransparentDataEncryptionConfiguration(resourceGroupName string, serverName string, databaseName string) (result TransparentDataEncryption, err error) { req, err := client.GetTransparentDataEncryptionConfigurationPreparer(resourceGroupName, serverName, databaseName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetTransparentDataEncryptionConfiguration", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetTransparentDataEncryptionConfiguration", nil, "Failure preparing request") + return } resp, err := client.GetTransparentDataEncryptionConfigurationSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetTransparentDataEncryptionConfiguration", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetTransparentDataEncryptionConfiguration", resp, "Failure sending request") + return } result, err = client.GetTransparentDataEncryptionConfigurationResponder(resp) @@ -430,8 +1255,9 @@ func (client DatabasesClient) GetTransparentDataEncryptionConfigurationPreparer( "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -461,21 +1287,122 @@ func (client DatabasesClient) GetTransparentDataEncryptionConfigurationResponder return } -// ListByServer returns information about an Azure SQL database. +// Import imports a bacpac into a new database. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. -func (client DatabasesClient) ListByServer(resourceGroupName string, serverName string) (result DatabaseListResult, err error) { - req, err := client.ListByServerPreparer(resourceGroupName, serverName) +// the portal. serverName is the name of the server. parameters is the required +// parameters for importing a Bacpac into a database. +func (client DatabasesClient) Import(resourceGroupName string, serverName string, parameters ImportRequest, cancel <-chan struct{}) (<-chan ImportExportResponse, <-chan error) { + resultChan := make(chan ImportExportResponse, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DatabaseName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.MaxSizeBytes", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "sql.DatabasesClient", "Import") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result ImportExportResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ImportPreparer(resourceGroupName, serverName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Import", nil, "Failure preparing request") + return + } + + resp, err := client.ImportSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Import", resp, "Failure sending request") + return + } + + result, err = client.ImportResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Import", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ImportPreparer prepares the Import request. +func (client DatabasesClient) ImportPreparer(resourceGroupName string, serverName string, parameters ImportRequest, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/import", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ImportSender sends the Import request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ImportSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ImportResponder handles the response to the Import request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ImportResponder(resp *http.Response) (result ImportExportResponse, 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 +} + +// ListByServer returns a list of databases in a server. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. serverName is the name of the server. expand is a comma +// separated list of child objects to expand in the response. Possible +// properties: serviceTierAdvisors, transparentDataEncryption. filter is an +// OData filter expression that describes a subset of databases to return. +func (client DatabasesClient) ListByServer(resourceGroupName string, serverName string, expand string, filter string) (result DatabaseListResult, err error) { + req, err := client.ListByServerPreparer(resourceGroupName, serverName, expand, filter) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByServer", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByServer", nil, "Failure preparing request") + return } resp, err := client.ListByServerSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByServer", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByServer", resp, "Failure sending request") + return } result, err = client.ListByServerResponder(resp) @@ -487,15 +1414,22 @@ func (client DatabasesClient) ListByServer(resourceGroupName string, serverName } // ListByServerPreparer prepares the ListByServer request. -func (client DatabasesClient) ListByServerPreparer(resourceGroupName string, serverName string) (*http.Request, error) { +func (client DatabasesClient) ListByServerPreparer(resourceGroupName string, serverName string, expand string, filter string) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "serverName": autorest.Encode("path", serverName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) } preparer := autorest.CreatePreparer( @@ -525,23 +1459,93 @@ func (client DatabasesClient) ListByServerResponder(resp *http.Response) (result return } -// ListRestorePoints returns a list of Azure SQL database restore points. +// ListReplicationLinks lists a database's replication links. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. databaseName -// is the name of the Azure SQL database from which to retrieve available -// restore points. +// the portal. serverName is the name of the server. databaseName is the name +// of the database to retrieve links for. +func (client DatabasesClient) ListReplicationLinks(resourceGroupName string, serverName string, databaseName string) (result ReplicationLinkListResult, err error) { + req, err := client.ListReplicationLinksPreparer(resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListReplicationLinks", nil, "Failure preparing request") + return + } + + resp, err := client.ListReplicationLinksSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListReplicationLinks", resp, "Failure sending request") + return + } + + result, err = client.ListReplicationLinksResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListReplicationLinks", resp, "Failure responding to request") + } + + return +} + +// ListReplicationLinksPreparer prepares the ListReplicationLinks request. +func (client DatabasesClient) ListReplicationLinksPreparer(resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListReplicationLinksSender sends the ListReplicationLinks request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ListReplicationLinksSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListReplicationLinksResponder handles the response to the ListReplicationLinks request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListReplicationLinksResponder(resp *http.Response) (result ReplicationLinkListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListRestorePoints returns a list of database restore points. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. serverName is the name of the server. databaseName is the name +// of the database from which to retrieve available restore points. func (client DatabasesClient) ListRestorePoints(resourceGroupName string, serverName string, databaseName string) (result RestorePointListResult, err error) { req, err := client.ListRestorePointsPreparer(resourceGroupName, serverName, databaseName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListRestorePoints", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListRestorePoints", nil, "Failure preparing request") + return } resp, err := client.ListRestorePointsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListRestorePoints", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListRestorePoints", resp, "Failure sending request") + return } result, err = client.ListRestorePointsResponder(resp) @@ -561,8 +1565,9 @@ func (client DatabasesClient) ListRestorePointsPreparer(resourceGroupName string "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -592,23 +1597,25 @@ func (client DatabasesClient) ListRestorePointsResponder(resp *http.Response) (r return } -// ListServiceTierAdvisors returns information about service tier advisors for -// specified database. +// ListServiceTierAdvisors returns service tier advisors for specified +// database. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. databaseName -// is the name of database. +// the portal. serverName is the name of the server. databaseName is the name +// of database. func (client DatabasesClient) ListServiceTierAdvisors(resourceGroupName string, serverName string, databaseName string) (result ServiceTierAdvisorListResult, err error) { req, err := client.ListServiceTierAdvisorsPreparer(resourceGroupName, serverName, databaseName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListServiceTierAdvisors", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListServiceTierAdvisors", nil, "Failure preparing request") + return } resp, err := client.ListServiceTierAdvisorsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListServiceTierAdvisors", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListServiceTierAdvisors", resp, "Failure sending request") + return } result, err = client.ListServiceTierAdvisorsResponder(resp) @@ -628,8 +1635,9 @@ func (client DatabasesClient) ListServiceTierAdvisorsPreparer(resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -659,24 +1667,25 @@ func (client DatabasesClient) ListServiceTierAdvisorsResponder(resp *http.Respon return } -// ListTransparentDataEncryptionActivity returns an Azure SQL Database -// Transparent Data Encryption Activity Response. +// ListTransparentDataEncryptionActivity returns a database's transparent data +// encryption operation result. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. databaseName -// is the name of the Azure SQL database for which the Transparent Data -// Encryption applies. +// the portal. serverName is the name of the server. databaseName is the name +// of the database for which the transparent data encryption applies. func (client DatabasesClient) ListTransparentDataEncryptionActivity(resourceGroupName string, serverName string, databaseName string) (result TransparentDataEncryptionActivityListResult, err error) { req, err := client.ListTransparentDataEncryptionActivityPreparer(resourceGroupName, serverName, databaseName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListTransparentDataEncryptionActivity", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListTransparentDataEncryptionActivity", nil, "Failure preparing request") + return } resp, err := client.ListTransparentDataEncryptionActivitySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListTransparentDataEncryptionActivity", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListTransparentDataEncryptionActivity", resp, "Failure sending request") + return } result, err = client.ListTransparentDataEncryptionActivityResponder(resp) @@ -696,8 +1705,9 @@ func (client DatabasesClient) ListTransparentDataEncryptionActivityPreparer(reso "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -727,22 +1737,24 @@ func (client DatabasesClient) ListTransparentDataEncryptionActivityResponder(res return } -// ListUsages returns information about Azure SQL database usages. +// ListUsages returns database usages. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. databaseName -// is the name of the Azure SQL database. +// the portal. serverName is the name of the server. databaseName is the name +// of the database. func (client DatabasesClient) ListUsages(resourceGroupName string, serverName string, databaseName string) (result DatabaseMetricListResult, err error) { req, err := client.ListUsagesPreparer(resourceGroupName, serverName, databaseName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListUsages", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListUsages", nil, "Failure preparing request") + return } resp, err := client.ListUsagesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListUsages", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListUsages", resp, "Failure sending request") + return } result, err = client.ListUsagesResponder(resp) @@ -762,8 +1774,9 @@ func (client DatabasesClient) ListUsagesPreparer(resourceGroupName string, serve "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -793,37 +1806,49 @@ func (client DatabasesClient) ListUsagesResponder(resp *http.Response) (result D return } -// PauseDataWarehouse pause an Azure SQL Data Warehouse database. This method -// may poll for completion. Polling can be canceled by passing the cancel -// channel argument. The channel will be used to cancel polling and any -// outstanding HTTP requests. +// Pause pauses a data warehouse. This method may poll for completion. Polling +// can be canceled by passing the cancel channel argument. The channel will be +// used to cancel polling and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. databaseName -// is the name of the Azure SQL Data Warehouse database to pause. -func (client DatabasesClient) PauseDataWarehouse(resourceGroupName string, serverName string, databaseName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.PauseDataWarehousePreparer(resourceGroupName, serverName, databaseName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "PauseDataWarehouse", nil, "Failure preparing request") - } +// the portal. serverName is the name of the server. databaseName is the name +// of the data warehouse to pause. +func (client DatabasesClient) Pause(resourceGroupName string, serverName string, databaseName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.PausePreparer(resourceGroupName, serverName, databaseName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Pause", nil, "Failure preparing request") + return + } - resp, err := client.PauseDataWarehouseSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "PauseDataWarehouse", resp, "Failure sending request") - } + resp, err := client.PauseSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Pause", resp, "Failure sending request") + return + } - result, err = client.PauseDataWarehouseResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "PauseDataWarehouse", resp, "Failure responding to request") - } - - return + result, err = client.PauseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Pause", resp, "Failure responding to request") + } + }() + return resultChan, errChan } -// PauseDataWarehousePreparer prepares the PauseDataWarehouse request. -func (client DatabasesClient) PauseDataWarehousePreparer(resourceGroupName string, serverName string, databaseName string, cancel <-chan struct{}) (*http.Request, error) { +// PausePreparer prepares the Pause request. +func (client DatabasesClient) PausePreparer(resourceGroupName string, serverName string, databaseName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "databaseName": autorest.Encode("path", databaseName), "resourceGroupName": autorest.Encode("path", resourceGroupName), @@ -831,8 +1856,9 @@ func (client DatabasesClient) PauseDataWarehousePreparer(resourceGroupName strin "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -843,17 +1869,17 @@ func (client DatabasesClient) PauseDataWarehousePreparer(resourceGroupName strin return preparer.Prepare(&http.Request{Cancel: cancel}) } -// PauseDataWarehouseSender sends the PauseDataWarehouse request. The method will close the +// PauseSender sends the Pause request. The method will close the // http.Response Body if it receives an error. -func (client DatabasesClient) PauseDataWarehouseSender(req *http.Request) (*http.Response, error) { +func (client DatabasesClient) PauseSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req, azure.DoPollForAsynchronous(client.PollingDelay)) } -// PauseDataWarehouseResponder handles the response to the PauseDataWarehouse request. The method always +// PauseResponder handles the response to the Pause request. The method always // closes the http.Response Body. -func (client DatabasesClient) PauseDataWarehouseResponder(resp *http.Response) (result autorest.Response, err error) { +func (client DatabasesClient) PauseResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -863,37 +1889,49 @@ func (client DatabasesClient) PauseDataWarehouseResponder(resp *http.Response) ( return } -// ResumeDataWarehouse resume an Azure SQL Data Warehouse database. This -// method may poll for completion. Polling can be canceled by passing the -// cancel channel argument. The channel will be used to cancel polling and -// any outstanding HTTP requests. +// Resume resumes a data warehouse. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel +// will be used to cancel polling and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. databaseName -// is the name of the Azure SQL Data Warehouse database to resume. -func (client DatabasesClient) ResumeDataWarehouse(resourceGroupName string, serverName string, databaseName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.ResumeDataWarehousePreparer(resourceGroupName, serverName, databaseName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "ResumeDataWarehouse", nil, "Failure preparing request") - } +// the portal. serverName is the name of the server. databaseName is the name +// of the data warehouse to resume. +func (client DatabasesClient) Resume(resourceGroupName string, serverName string, databaseName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ResumePreparer(resourceGroupName, serverName, databaseName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Resume", nil, "Failure preparing request") + return + } - resp, err := client.ResumeDataWarehouseSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "ResumeDataWarehouse", resp, "Failure sending request") - } + resp, err := client.ResumeSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Resume", resp, "Failure sending request") + return + } - result, err = client.ResumeDataWarehouseResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ResumeDataWarehouse", resp, "Failure responding to request") - } - - return + result, err = client.ResumeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Resume", resp, "Failure responding to request") + } + }() + return resultChan, errChan } -// ResumeDataWarehousePreparer prepares the ResumeDataWarehouse request. -func (client DatabasesClient) ResumeDataWarehousePreparer(resourceGroupName string, serverName string, databaseName string, cancel <-chan struct{}) (*http.Request, error) { +// ResumePreparer prepares the Resume request. +func (client DatabasesClient) ResumePreparer(resourceGroupName string, serverName string, databaseName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "databaseName": autorest.Encode("path", databaseName), "resourceGroupName": autorest.Encode("path", resourceGroupName), @@ -901,8 +1939,9 @@ func (client DatabasesClient) ResumeDataWarehousePreparer(resourceGroupName stri "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -913,17 +1952,17 @@ func (client DatabasesClient) ResumeDataWarehousePreparer(resourceGroupName stri return preparer.Prepare(&http.Request{Cancel: cancel}) } -// ResumeDataWarehouseSender sends the ResumeDataWarehouse request. The method will close the +// ResumeSender sends the Resume request. The method will close the // http.Response Body if it receives an error. -func (client DatabasesClient) ResumeDataWarehouseSender(req *http.Request) (*http.Response, error) { +func (client DatabasesClient) ResumeSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req, azure.DoPollForAsynchronous(client.PollingDelay)) } -// ResumeDataWarehouseResponder handles the response to the ResumeDataWarehouse request. The method always +// ResumeResponder handles the response to the Resume request. The method always // closes the http.Response Body. -func (client DatabasesClient) ResumeDataWarehouseResponder(resp *http.Response) (result autorest.Response, err error) { +func (client DatabasesClient) ResumeResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/elasticpools.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/elasticpools.go old mode 100644 new mode 100755 index e68d6674a..e195ada6b --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/elasticpools.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/elasticpools.go @@ -14,7 +14,7 @@ package sql // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -24,9 +24,10 @@ import ( "net/http" ) -// ElasticPoolsClient is the provides create, read, update and delete -// functionality for Azure SQL resources including servers, databases, -// elastic pools, recommendations, operations, and usage metrics. +// ElasticPoolsClient is the the Azure SQL Database management API provides a +// RESTful set of web services that interact with Azure SQL Database services +// to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. type ElasticPoolsClient struct { ManagementClient } @@ -42,35 +43,47 @@ func NewElasticPoolsClientWithBaseURI(baseURI string, subscriptionID string) Ela return ElasticPoolsClient{NewWithBaseURI(baseURI, subscriptionID)} } -// CreateOrUpdate creates a new Azure SQL elastic pool or updates an existing -// Azure SQL elastic pool. This method may poll for completion. Polling can -// be canceled by passing the cancel channel argument. The channel will be -// used to cancel polling and any outstanding HTTP requests. +// CreateOrUpdate creates a new elastic pool or updates an existing elastic +// pool. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. -// elasticPoolName is the name of the Azure SQL Elastic Pool to be operated -// on (Updated or created). parameters is the required parameters for -// creating or updating an Elastic Pool. -func (client ElasticPoolsClient) CreateOrUpdate(resourceGroupName string, serverName string, elasticPoolName string, parameters ElasticPool, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateOrUpdatePreparer(resourceGroupName, serverName, elasticPoolName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "CreateOrUpdate", nil, "Failure preparing request") - } +// the portal. serverName is the name of the server. elasticPoolName is the +// name of the elastic pool to be operated on (updated or created). parameters +// is the required parameters for creating or updating an elastic pool. +func (client ElasticPoolsClient) CreateOrUpdate(resourceGroupName string, serverName string, elasticPoolName string, parameters ElasticPool, cancel <-chan struct{}) (<-chan ElasticPool, <-chan error) { + resultChan := make(chan ElasticPool, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ElasticPool + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, serverName, elasticPoolName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "CreateOrUpdate", resp, "Failure sending request") - } + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -82,8 +95,9 @@ func (client ElasticPoolsClient) CreateOrUpdatePreparer(resourceGroupName string "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -106,32 +120,35 @@ func (client ElasticPoolsClient) CreateOrUpdateSender(req *http.Request) (*http. // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client ElasticPoolsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ElasticPoolsClient) CreateOrUpdateResponder(resp *http.Response) (result ElasticPool, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } -// Delete deletes the Azure SQL elastic pool. +// Delete deletes the elastic pool. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. -// elasticPoolName is the name of the Azure SQL Elastic Pool to be deleted. +// the portal. serverName is the name of the server. elasticPoolName is the +// name of the elastic pool to be deleted. func (client ElasticPoolsClient) Delete(resourceGroupName string, serverName string, elasticPoolName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, serverName, elasticPoolName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -151,8 +168,9 @@ func (client ElasticPoolsClient) DeletePreparer(resourceGroupName string, server "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -181,22 +199,24 @@ func (client ElasticPoolsClient) DeleteResponder(resp *http.Response) (result au return } -// Get gets information about an Azure SQL elastic pool. +// Get gets an elastic pool. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. -// elasticPoolName is the name of the Azure SQL Elastic Pool to be retrieved. +// the portal. serverName is the name of the server. elasticPoolName is the +// name of the elastic pool to be retrieved. func (client ElasticPoolsClient) Get(resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPool, err error) { req, err := client.GetPreparer(resourceGroupName, serverName, elasticPoolName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -216,8 +236,9 @@ func (client ElasticPoolsClient) GetPreparer(resourceGroupName string, serverNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -247,24 +268,25 @@ func (client ElasticPoolsClient) GetResponder(resp *http.Response) (result Elast return } -// GetDatabase gets information about an Azure SQL database inside of an Azure -// SQL elastic pool. +// GetDatabase gets a database inside of an elastic pool. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. -// elasticPoolName is the name of the Azure SQL Elastic Pool to be retrieved. -// databaseName is the name of the Azure SQL database to be retrieved. +// the portal. serverName is the name of the server. elasticPoolName is the +// name of the elastic pool to be retrieved. databaseName is the name of the +// database to be retrieved. func (client ElasticPoolsClient) GetDatabase(resourceGroupName string, serverName string, elasticPoolName string, databaseName string) (result Database, err error) { req, err := client.GetDatabasePreparer(resourceGroupName, serverName, elasticPoolName, databaseName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "GetDatabase", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "GetDatabase", nil, "Failure preparing request") + return } resp, err := client.GetDatabaseSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "GetDatabase", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "GetDatabase", resp, "Failure sending request") + return } result, err = client.GetDatabaseResponder(resp) @@ -285,8 +307,9 @@ func (client ElasticPoolsClient) GetDatabasePreparer(resourceGroupName string, s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -316,23 +339,24 @@ func (client ElasticPoolsClient) GetDatabaseResponder(resp *http.Response) (resu return } -// ListActivity returns information about Azure SQL elastic pool activities. +// ListActivity returns elastic pool activities. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. -// elasticPoolName is the name of the Azure SQL Elastic Pool for which to get -// the current activity. +// the portal. serverName is the name of the server. elasticPoolName is the +// name of the elastic pool for which to get the current activity. func (client ElasticPoolsClient) ListActivity(resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolActivityListResult, err error) { req, err := client.ListActivityPreparer(resourceGroupName, serverName, elasticPoolName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListActivity", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListActivity", nil, "Failure preparing request") + return } resp, err := client.ListActivitySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListActivity", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListActivity", resp, "Failure sending request") + return } result, err = client.ListActivityResponder(resp) @@ -352,8 +376,9 @@ func (client ElasticPoolsClient) ListActivityPreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -383,21 +408,23 @@ func (client ElasticPoolsClient) ListActivityResponder(resp *http.Response) (res return } -// ListByServer returns information about Azure SQL elastic pools. +// ListByServer returns a list of elastic pools in a server. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. +// the portal. serverName is the name of the server. func (client ElasticPoolsClient) ListByServer(resourceGroupName string, serverName string) (result ElasticPoolListResult, err error) { req, err := client.ListByServerPreparer(resourceGroupName, serverName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListByServer", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListByServer", nil, "Failure preparing request") + return } resp, err := client.ListByServerSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListByServer", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListByServer", resp, "Failure sending request") + return } result, err = client.ListByServerResponder(resp) @@ -416,8 +443,9 @@ func (client ElasticPoolsClient) ListByServerPreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -447,23 +475,25 @@ func (client ElasticPoolsClient) ListByServerResponder(resp *http.Response) (res return } -// ListDatabaseActivity returns information about activity on Azure SQL -// databases inside of an Azure SQL elastic pool. +// ListDatabaseActivity returns activity on databases inside of an elastic +// pool. // -// elasticPoolName is the name of the Azure SQL Elastic Pool. // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. -func (client ElasticPoolsClient) ListDatabaseActivity(elasticPoolName string, resourceGroupName string, serverName string) (result ElasticPoolDatabaseActivityListResult, err error) { - req, err := client.ListDatabaseActivityPreparer(elasticPoolName, resourceGroupName, serverName) +// the portal. serverName is the name of the server. elasticPoolName is the +// name of the elastic pool. +func (client ElasticPoolsClient) ListDatabaseActivity(resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolDatabaseActivityListResult, err error) { + req, err := client.ListDatabaseActivityPreparer(resourceGroupName, serverName, elasticPoolName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListDatabaseActivity", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListDatabaseActivity", nil, "Failure preparing request") + return } resp, err := client.ListDatabaseActivitySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListDatabaseActivity", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListDatabaseActivity", resp, "Failure sending request") + return } result, err = client.ListDatabaseActivityResponder(resp) @@ -475,7 +505,7 @@ func (client ElasticPoolsClient) ListDatabaseActivity(elasticPoolName string, re } // ListDatabaseActivityPreparer prepares the ListDatabaseActivity request. -func (client ElasticPoolsClient) ListDatabaseActivityPreparer(elasticPoolName string, resourceGroupName string, serverName string) (*http.Request, error) { +func (client ElasticPoolsClient) ListDatabaseActivityPreparer(resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "elasticPoolName": autorest.Encode("path", elasticPoolName), "resourceGroupName": autorest.Encode("path", resourceGroupName), @@ -483,8 +513,9 @@ func (client ElasticPoolsClient) ListDatabaseActivityPreparer(elasticPoolName st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -514,23 +545,24 @@ func (client ElasticPoolsClient) ListDatabaseActivityResponder(resp *http.Respon return } -// ListDatabases returns information about an Azure SQL database inside of an -// Azure SQL elastic pool. +// ListDatabases returns a list of databases in an elastic pool. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. -// elasticPoolName is the name of the Azure SQL Elastic Pool to be retrieved. +// the portal. serverName is the name of the server. elasticPoolName is the +// name of the elastic pool to be retrieved. func (client ElasticPoolsClient) ListDatabases(resourceGroupName string, serverName string, elasticPoolName string) (result DatabaseListResult, err error) { req, err := client.ListDatabasesPreparer(resourceGroupName, serverName, elasticPoolName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListDatabases", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListDatabases", nil, "Failure preparing request") + return } resp, err := client.ListDatabasesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListDatabases", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListDatabases", resp, "Failure sending request") + return } result, err = client.ListDatabasesResponder(resp) @@ -550,8 +582,9 @@ func (client ElasticPoolsClient) ListDatabasesPreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/firewallrules.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/firewallrules.go new file mode 100755 index 000000000..e4f3fa4c0 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/firewallrules.go @@ -0,0 +1,331 @@ +package sql + +// 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// FirewallRulesClient is the the Azure SQL Database management API provides a +// RESTful set of web services that interact with Azure SQL Database services +// to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type FirewallRulesClient struct { + ManagementClient +} + +// NewFirewallRulesClient creates an instance of the FirewallRulesClient +// client. +func NewFirewallRulesClient(subscriptionID string) FirewallRulesClient { + return NewFirewallRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFirewallRulesClientWithBaseURI creates an instance of the +// FirewallRulesClient client. +func NewFirewallRulesClientWithBaseURI(baseURI string, subscriptionID string) FirewallRulesClient { + return FirewallRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a firewall rule. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. serverName is the name of the server. firewallRuleName is the +// name of the firewall rule. parameters is the required parameters for +// creating or updating a firewall rule. +func (client FirewallRulesClient) CreateOrUpdate(resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule) (result FirewallRule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.FirewallRuleProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.FirewallRuleProperties.StartIPAddress", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.FirewallRuleProperties.EndIPAddress", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "sql.FirewallRulesClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, serverName, firewallRuleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client FirewallRulesClient) CreateOrUpdatePreparer(resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) CreateOrUpdateResponder(resp *http.Response) (result FirewallRule, 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 deletes a firewall rule. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. serverName is the name of the server. firewallRuleName is the +// name of the firewall rule. +func (client FirewallRulesClient) Delete(resourceGroupName string, serverName string, firewallRuleName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, serverName, firewallRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client FirewallRulesClient) DeletePreparer(resourceGroupName string, serverName string, firewallRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRulesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a firewall rule. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. serverName is the name of the server. firewallRuleName is the +// name of the firewall rule. +func (client FirewallRulesClient) Get(resourceGroupName string, serverName string, firewallRuleName string) (result FirewallRule, err error) { + req, err := client.GetPreparer(resourceGroupName, serverName, firewallRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client FirewallRulesClient) GetPreparer(resourceGroupName string, serverName string, firewallRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) GetResponder(resp *http.Response) (result FirewallRule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer returns a list of firewall rules. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. serverName is the name of the server. +func (client FirewallRulesClient) ListByServer(resourceGroupName string, serverName string) (result FirewallRuleListResult, err error) { + req, err := client.ListByServerPreparer(resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "ListByServer", resp, "Failure responding to request") + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client FirewallRulesClient) ListByServerPreparer(resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRulesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) ListByServerResponder(resp *http.Response) (result FirewallRuleListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/models.go old mode 100644 new mode 100755 index 497d7defb..6f42dca75 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/models.go @@ -14,7 +14,7 @@ package sql // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -24,6 +24,45 @@ import ( "github.com/satori/uuid" ) +// AuthenticationType enumerates the values for authentication type. +type AuthenticationType string + +const ( + // ADPassword specifies the ad password state for authentication type. + ADPassword AuthenticationType = "ADPassword" + // SQL specifies the sql state for authentication type. + SQL AuthenticationType = "SQL" +) + +// BlobAuditingPolicyState enumerates the values for blob auditing policy +// state. +type BlobAuditingPolicyState string + +const ( + // Disabled specifies the disabled state for blob auditing policy state. + Disabled BlobAuditingPolicyState = "Disabled" + // Enabled specifies the enabled state for blob auditing policy state. + Enabled BlobAuditingPolicyState = "Enabled" +) + +// CapabilityStatus enumerates the values for capability status. +type CapabilityStatus string + +const ( + // CapabilityStatusAvailable specifies the capability status available + // state for capability status. + CapabilityStatusAvailable CapabilityStatus = "Available" + // CapabilityStatusDefault specifies the capability status default state + // for capability status. + CapabilityStatusDefault CapabilityStatus = "Default" + // CapabilityStatusDisabled specifies the capability status disabled state + // for capability status. + CapabilityStatusDisabled CapabilityStatus = "Disabled" + // CapabilityStatusVisible specifies the capability status visible state + // for capability status. + CapabilityStatusVisible CapabilityStatus = "Visible" +) + // CreateMode enumerates the values for create mode. type CreateMode string @@ -44,112 +83,190 @@ const ( Recovery CreateMode = "Recovery" // Restore specifies the restore state for create mode. Restore CreateMode = "Restore" + // RestoreLongTermRetentionBackup specifies the restore long term retention + // backup state for create mode. + RestoreLongTermRetentionBackup CreateMode = "RestoreLongTermRetentionBackup" ) -// DatabaseEditions enumerates the values for database editions. -type DatabaseEditions string +// DatabaseEdition enumerates the values for database edition. +type DatabaseEdition string const ( - // Basic specifies the basic state for database editions. - Basic DatabaseEditions = "Basic" - // Business specifies the business state for database editions. - Business DatabaseEditions = "Business" - // DataWarehouse specifies the data warehouse state for database editions. - DataWarehouse DatabaseEditions = "DataWarehouse" - // Free specifies the free state for database editions. - Free DatabaseEditions = "Free" - // Premium specifies the premium state for database editions. - Premium DatabaseEditions = "Premium" - // Standard specifies the standard state for database editions. - Standard DatabaseEditions = "Standard" - // Stretch specifies the stretch state for database editions. - Stretch DatabaseEditions = "Stretch" - // Web specifies the web state for database editions. - Web DatabaseEditions = "Web" + // Basic specifies the basic state for database edition. + Basic DatabaseEdition = "Basic" + // Business specifies the business state for database edition. + Business DatabaseEdition = "Business" + // DataWarehouse specifies the data warehouse state for database edition. + DataWarehouse DatabaseEdition = "DataWarehouse" + // Free specifies the free state for database edition. + Free DatabaseEdition = "Free" + // Premium specifies the premium state for database edition. + Premium DatabaseEdition = "Premium" + // Standard specifies the standard state for database edition. + Standard DatabaseEdition = "Standard" + // Stretch specifies the stretch state for database edition. + Stretch DatabaseEdition = "Stretch" + // System specifies the system state for database edition. + System DatabaseEdition = "System" + // System2 specifies the system 2 state for database edition. + System2 DatabaseEdition = "System2" + // Web specifies the web state for database edition. + Web DatabaseEdition = "Web" ) -// ElasticPoolEditions enumerates the values for elastic pool editions. -type ElasticPoolEditions string +// ElasticPoolEdition enumerates the values for elastic pool edition. +type ElasticPoolEdition string const ( - // ElasticPoolEditionsBasic specifies the elastic pool editions basic - // state for elastic pool editions. - ElasticPoolEditionsBasic ElasticPoolEditions = "Basic" - // ElasticPoolEditionsPremium specifies the elastic pool editions premium - // state for elastic pool editions. - ElasticPoolEditionsPremium ElasticPoolEditions = "Premium" - // ElasticPoolEditionsStandard specifies the elastic pool editions - // standard state for elastic pool editions. - ElasticPoolEditionsStandard ElasticPoolEditions = "Standard" + // ElasticPoolEditionBasic specifies the elastic pool edition basic state + // for elastic pool edition. + ElasticPoolEditionBasic ElasticPoolEdition = "Basic" + // ElasticPoolEditionPremium specifies the elastic pool edition premium + // state for elastic pool edition. + ElasticPoolEditionPremium ElasticPoolEdition = "Premium" + // ElasticPoolEditionStandard specifies the elastic pool edition standard + // state for elastic pool edition. + ElasticPoolEditionStandard ElasticPoolEdition = "Standard" ) // ElasticPoolState enumerates the values for elastic pool state. type ElasticPoolState string const ( - // Creating specifies the creating state for elastic pool state. - Creating ElasticPoolState = "Creating" - // Disabled specifies the disabled state for elastic pool state. - Disabled ElasticPoolState = "Disabled" - // Ready specifies the ready state for elastic pool state. - Ready ElasticPoolState = "Ready" + // ElasticPoolStateCreating specifies the elastic pool state creating state + // for elastic pool state. + ElasticPoolStateCreating ElasticPoolState = "Creating" + // ElasticPoolStateDisabled specifies the elastic pool state disabled state + // for elastic pool state. + ElasticPoolStateDisabled ElasticPoolState = "Disabled" + // ElasticPoolStateReady specifies the elastic pool state ready state for + // elastic pool state. + ElasticPoolStateReady ElasticPoolState = "Ready" ) -// RecommendedIndexActions enumerates the values for recommended index actions. -type RecommendedIndexActions string +// MaxSizeUnits enumerates the values for max size units. +type MaxSizeUnits string const ( - // Create specifies the create state for recommended index actions. - Create RecommendedIndexActions = "Create" - // Drop specifies the drop state for recommended index actions. - Drop RecommendedIndexActions = "Drop" - // Rebuild specifies the rebuild state for recommended index actions. - Rebuild RecommendedIndexActions = "Rebuild" + // Gigabytes specifies the gigabytes state for max size units. + Gigabytes MaxSizeUnits = "Gigabytes" + // Megabytes specifies the megabytes state for max size units. + Megabytes MaxSizeUnits = "Megabytes" + // Petabytes specifies the petabytes state for max size units. + Petabytes MaxSizeUnits = "Petabytes" + // Terabytes specifies the terabytes state for max size units. + Terabytes MaxSizeUnits = "Terabytes" ) -// RecommendedIndexStates enumerates the values for recommended index states. -type RecommendedIndexStates string +// PerformanceLevelUnit enumerates the values for performance level unit. +type PerformanceLevelUnit string const ( - // Active specifies the active state for recommended index states. - Active RecommendedIndexStates = "Active" - // Blocked specifies the blocked state for recommended index states. - Blocked RecommendedIndexStates = "Blocked" - // Executing specifies the executing state for recommended index states. - Executing RecommendedIndexStates = "Executing" - // Expired specifies the expired state for recommended index states. - Expired RecommendedIndexStates = "Expired" - // Ignored specifies the ignored state for recommended index states. - Ignored RecommendedIndexStates = "Ignored" - // Pending specifies the pending state for recommended index states. - Pending RecommendedIndexStates = "Pending" + // DTU specifies the dtu state for performance level unit. + DTU PerformanceLevelUnit = "DTU" +) + +// ReadScale enumerates the values for read scale. +type ReadScale string + +const ( + // ReadScaleDisabled specifies the read scale disabled state for read + // scale. + ReadScaleDisabled ReadScale = "Disabled" + // ReadScaleEnabled specifies the read scale enabled state for read scale. + ReadScaleEnabled ReadScale = "Enabled" +) + +// RecommendedIndexAction enumerates the values for recommended index action. +type RecommendedIndexAction string + +const ( + // Create specifies the create state for recommended index action. + Create RecommendedIndexAction = "Create" + // Drop specifies the drop state for recommended index action. + Drop RecommendedIndexAction = "Drop" + // Rebuild specifies the rebuild state for recommended index action. + Rebuild RecommendedIndexAction = "Rebuild" +) + +// RecommendedIndexState enumerates the values for recommended index state. +type RecommendedIndexState string + +const ( + // Active specifies the active state for recommended index state. + Active RecommendedIndexState = "Active" + // Blocked specifies the blocked state for recommended index state. + Blocked RecommendedIndexState = "Blocked" + // Executing specifies the executing state for recommended index state. + Executing RecommendedIndexState = "Executing" + // Expired specifies the expired state for recommended index state. + Expired RecommendedIndexState = "Expired" + // Ignored specifies the ignored state for recommended index state. + Ignored RecommendedIndexState = "Ignored" + // Pending specifies the pending state for recommended index state. + Pending RecommendedIndexState = "Pending" // PendingRevert specifies the pending revert state for recommended index - // states. - PendingRevert RecommendedIndexStates = "Pending Revert" - // Reverted specifies the reverted state for recommended index states. - Reverted RecommendedIndexStates = "Reverted" - // Reverting specifies the reverting state for recommended index states. - Reverting RecommendedIndexStates = "Reverting" - // Success specifies the success state for recommended index states. - Success RecommendedIndexStates = "Success" - // Verifying specifies the verifying state for recommended index states. - Verifying RecommendedIndexStates = "Verifying" + // state. + PendingRevert RecommendedIndexState = "Pending Revert" + // Reverted specifies the reverted state for recommended index state. + Reverted RecommendedIndexState = "Reverted" + // Reverting specifies the reverting state for recommended index state. + Reverting RecommendedIndexState = "Reverting" + // Success specifies the success state for recommended index state. + Success RecommendedIndexState = "Success" + // Verifying specifies the verifying state for recommended index state. + Verifying RecommendedIndexState = "Verifying" ) -// RecommendedIndexTypes enumerates the values for recommended index types. -type RecommendedIndexTypes string +// RecommendedIndexType enumerates the values for recommended index type. +type RecommendedIndexType string const ( - // CLUSTERED specifies the clustered state for recommended index types. - CLUSTERED RecommendedIndexTypes = "CLUSTERED" + // CLUSTERED specifies the clustered state for recommended index type. + CLUSTERED RecommendedIndexType = "CLUSTERED" // CLUSTEREDCOLUMNSTORE specifies the clusteredcolumnstore state for - // recommended index types. - CLUSTEREDCOLUMNSTORE RecommendedIndexTypes = "CLUSTERED COLUMNSTORE" - // COLUMNSTORE specifies the columnstore state for recommended index types. - COLUMNSTORE RecommendedIndexTypes = "COLUMNSTORE" + // recommended index type. + CLUSTEREDCOLUMNSTORE RecommendedIndexType = "CLUSTERED COLUMNSTORE" + // COLUMNSTORE specifies the columnstore state for recommended index type. + COLUMNSTORE RecommendedIndexType = "COLUMNSTORE" // NONCLUSTERED specifies the nonclustered state for recommended index - // types. - NONCLUSTERED RecommendedIndexTypes = "NONCLUSTERED" + // type. + NONCLUSTERED RecommendedIndexType = "NONCLUSTERED" +) + +// ReplicationRole enumerates the values for replication role. +type ReplicationRole string + +const ( + // ReplicationRoleCopy specifies the replication role copy state for + // replication role. + ReplicationRoleCopy ReplicationRole = "Copy" + // ReplicationRoleNonReadableSecondary specifies the replication role non + // readable secondary state for replication role. + ReplicationRoleNonReadableSecondary ReplicationRole = "NonReadableSecondary" + // ReplicationRolePrimary specifies the replication role primary state for + // replication role. + ReplicationRolePrimary ReplicationRole = "Primary" + // ReplicationRoleSecondary specifies the replication role secondary state + // for replication role. + ReplicationRoleSecondary ReplicationRole = "Secondary" + // ReplicationRoleSource specifies the replication role source state for + // replication role. + ReplicationRoleSource ReplicationRole = "Source" +) + +// ReplicationState enumerates the values for replication state. +type ReplicationState string + +const ( + // CATCHUP specifies the catchup state for replication state. + CATCHUP ReplicationState = "CATCH_UP" + // PENDING specifies the pending state for replication state. + PENDING ReplicationState = "PENDING" + // SEEDING specifies the seeding state for replication state. + SEEDING ReplicationState = "SEEDING" + // SUSPENDED specifies the suspended state for replication state. + SUSPENDED ReplicationState = "SUSPENDED" ) // RestorePointTypes enumerates the values for restore point types. @@ -162,12 +279,78 @@ const ( DISCRETE RestorePointTypes = "DISCRETE" ) +// SampleName enumerates the values for sample name. +type SampleName string + +const ( + // AdventureWorksLT specifies the adventure works lt state for sample name. + AdventureWorksLT SampleName = "AdventureWorksLT" +) + +// SecurityAlertPolicyEmailAccountAdmins enumerates the values for security +// alert policy email account admins. +type SecurityAlertPolicyEmailAccountAdmins string + +const ( + // SecurityAlertPolicyEmailAccountAdminsDisabled specifies the security + // alert policy email account admins disabled state for security alert + // policy email account admins. + SecurityAlertPolicyEmailAccountAdminsDisabled SecurityAlertPolicyEmailAccountAdmins = "Disabled" + // SecurityAlertPolicyEmailAccountAdminsEnabled specifies the security + // alert policy email account admins enabled state for security alert + // policy email account admins. + SecurityAlertPolicyEmailAccountAdminsEnabled SecurityAlertPolicyEmailAccountAdmins = "Enabled" +) + +// SecurityAlertPolicyState enumerates the values for security alert policy +// state. +type SecurityAlertPolicyState string + +const ( + // SecurityAlertPolicyStateDisabled specifies the security alert policy + // state disabled state for security alert policy state. + SecurityAlertPolicyStateDisabled SecurityAlertPolicyState = "Disabled" + // SecurityAlertPolicyStateEnabled specifies the security alert policy + // state enabled state for security alert policy state. + SecurityAlertPolicyStateEnabled SecurityAlertPolicyState = "Enabled" + // SecurityAlertPolicyStateNew specifies the security alert policy state + // new state for security alert policy state. + SecurityAlertPolicyStateNew SecurityAlertPolicyState = "New" +) + +// SecurityAlertPolicyUseServerDefault enumerates the values for security alert +// policy use server default. +type SecurityAlertPolicyUseServerDefault string + +const ( + // SecurityAlertPolicyUseServerDefaultDisabled specifies the security alert + // policy use server default disabled state for security alert policy use + // server default. + SecurityAlertPolicyUseServerDefaultDisabled SecurityAlertPolicyUseServerDefault = "Disabled" + // SecurityAlertPolicyUseServerDefaultEnabled specifies the security alert + // policy use server default enabled state for security alert policy use + // server default. + SecurityAlertPolicyUseServerDefaultEnabled SecurityAlertPolicyUseServerDefault = "Enabled" +) + +// ServerState enumerates the values for server state. +type ServerState string + +const ( + // ServerStateDisabled specifies the server state disabled state for server + // state. + ServerStateDisabled ServerState = "Disabled" + // ServerStateReady specifies the server state ready state for server + // state. + ServerStateReady ServerState = "Ready" +) + // ServerVersion enumerates the values for server version. type ServerVersion string const ( - // OneTwoFullStopZero specifies the one two full stop zero state for - // server version. + // OneTwoFullStopZero specifies the one two full stop zero state for server + // version. OneTwoFullStopZero ServerVersion = "12.0" // TwoFullStopZero specifies the two full stop zero state for server // version. @@ -181,142 +364,134 @@ const ( // ServiceObjectiveNameBasic specifies the service objective name basic // state for service objective name. ServiceObjectiveNameBasic ServiceObjectiveName = "Basic" - // ServiceObjectiveNameP1 specifies the service objective name p1 state - // for service objective name. + // ServiceObjectiveNameElasticPool specifies the service objective name + // elastic pool state for service objective name. + ServiceObjectiveNameElasticPool ServiceObjectiveName = "ElasticPool" + // ServiceObjectiveNameP1 specifies the service objective name p1 state for + // service objective name. ServiceObjectiveNameP1 ServiceObjectiveName = "P1" - // ServiceObjectiveNameP2 specifies the service objective name p2 state + // ServiceObjectiveNameP11 specifies the service objective name p11 state // for service objective name. + ServiceObjectiveNameP11 ServiceObjectiveName = "P11" + // ServiceObjectiveNameP15 specifies the service objective name p15 state + // for service objective name. + ServiceObjectiveNameP15 ServiceObjectiveName = "P15" + // ServiceObjectiveNameP2 specifies the service objective name p2 state for + // service objective name. ServiceObjectiveNameP2 ServiceObjectiveName = "P2" - // ServiceObjectiveNameP3 specifies the service objective name p3 state - // for service objective name. + // ServiceObjectiveNameP3 specifies the service objective name p3 state for + // service objective name. ServiceObjectiveNameP3 ServiceObjectiveName = "P3" - // ServiceObjectiveNameS0 specifies the service objective name s0 state - // for service objective name. + // ServiceObjectiveNameP4 specifies the service objective name p4 state for + // service objective name. + ServiceObjectiveNameP4 ServiceObjectiveName = "P4" + // ServiceObjectiveNameP6 specifies the service objective name p6 state for + // service objective name. + ServiceObjectiveNameP6 ServiceObjectiveName = "P6" + // ServiceObjectiveNameS0 specifies the service objective name s0 state for + // service objective name. ServiceObjectiveNameS0 ServiceObjectiveName = "S0" - // ServiceObjectiveNameS1 specifies the service objective name s1 state - // for service objective name. + // ServiceObjectiveNameS1 specifies the service objective name s1 state for + // service objective name. ServiceObjectiveNameS1 ServiceObjectiveName = "S1" - // ServiceObjectiveNameS2 specifies the service objective name s2 state - // for service objective name. + // ServiceObjectiveNameS2 specifies the service objective name s2 state for + // service objective name. ServiceObjectiveNameS2 ServiceObjectiveName = "S2" - // ServiceObjectiveNameS3 specifies the service objective name s3 state - // for service objective name. + // ServiceObjectiveNameS3 specifies the service objective name s3 state for + // service objective name. ServiceObjectiveNameS3 ServiceObjectiveName = "S3" + // ServiceObjectiveNameSystem specifies the service objective name system + // state for service objective name. + ServiceObjectiveNameSystem ServiceObjectiveName = "System" + // ServiceObjectiveNameSystem2 specifies the service objective name system + // 2 state for service objective name. + ServiceObjectiveNameSystem2 ServiceObjectiveName = "System2" ) -// TableType enumerates the values for table type. -type TableType string +// StorageKeyType enumerates the values for storage key type. +type StorageKeyType string const ( - // BaseTable specifies the base table state for table type. - BaseTable TableType = "BaseTable" - // View specifies the view state for table type. - View TableType = "View" + // SharedAccessKey specifies the shared access key state for storage key + // type. + SharedAccessKey StorageKeyType = "SharedAccessKey" + // StorageAccessKey specifies the storage access key state for storage key + // type. + StorageAccessKey StorageKeyType = "StorageAccessKey" ) -// TargetDatabaseEditions enumerates the values for target database editions. -type TargetDatabaseEditions string - -const ( - // TargetDatabaseEditionsBasic specifies the target database editions - // basic state for target database editions. - TargetDatabaseEditionsBasic TargetDatabaseEditions = "Basic" - // TargetDatabaseEditionsDataWarehouse specifies the target database - // editions data warehouse state for target database editions. - TargetDatabaseEditionsDataWarehouse TargetDatabaseEditions = "DataWarehouse" - // TargetDatabaseEditionsFree specifies the target database editions free - // state for target database editions. - TargetDatabaseEditionsFree TargetDatabaseEditions = "Free" - // TargetDatabaseEditionsPremium specifies the target database editions - // premium state for target database editions. - TargetDatabaseEditionsPremium TargetDatabaseEditions = "Premium" - // TargetDatabaseEditionsStandard specifies the target database editions - // standard state for target database editions. - TargetDatabaseEditionsStandard TargetDatabaseEditions = "Standard" - // TargetDatabaseEditionsStretch specifies the target database editions - // stretch state for target database editions. - TargetDatabaseEditionsStretch TargetDatabaseEditions = "Stretch" -) - -// TargetElasticPoolEditions enumerates the values for target elastic pool -// editions. -type TargetElasticPoolEditions string - -const ( - // TargetElasticPoolEditionsBasic specifies the target elastic pool - // editions basic state for target elastic pool editions. - TargetElasticPoolEditionsBasic TargetElasticPoolEditions = "Basic" - // TargetElasticPoolEditionsPremium specifies the target elastic pool - // editions premium state for target elastic pool editions. - TargetElasticPoolEditionsPremium TargetElasticPoolEditions = "Premium" - // TargetElasticPoolEditionsStandard specifies the target elastic pool - // editions standard state for target elastic pool editions. - TargetElasticPoolEditionsStandard TargetElasticPoolEditions = "Standard" -) - -// TransparentDataEncryptionActivityStates enumerates the values for -// transparent data encryption activity states. -type TransparentDataEncryptionActivityStates string +// TransparentDataEncryptionActivityStatus enumerates the values for +// transparent data encryption activity status. +type TransparentDataEncryptionActivityStatus string const ( // Decrypting specifies the decrypting state for transparent data - // encryption activity states. - Decrypting TransparentDataEncryptionActivityStates = "Decrypting" + // encryption activity status. + Decrypting TransparentDataEncryptionActivityStatus = "Decrypting" // Encrypting specifies the encrypting state for transparent data - // encryption activity states. - Encrypting TransparentDataEncryptionActivityStates = "Encrypting" + // encryption activity status. + Encrypting TransparentDataEncryptionActivityStatus = "Encrypting" ) -// TransparentDataEncryptionStates enumerates the values for transparent data -// encryption states. -type TransparentDataEncryptionStates string +// TransparentDataEncryptionStatus enumerates the values for transparent data +// encryption status. +type TransparentDataEncryptionStatus string const ( - // TransparentDataEncryptionStatesDisabled specifies the transparent data - // encryption states disabled state for transparent data encryption - // states. - TransparentDataEncryptionStatesDisabled TransparentDataEncryptionStates = "Disabled" - // TransparentDataEncryptionStatesEnabled specifies the transparent data - // encryption states enabled state for transparent data encryption states. - TransparentDataEncryptionStatesEnabled TransparentDataEncryptionStates = "Enabled" + // TransparentDataEncryptionStatusDisabled specifies the transparent data + // encryption status disabled state for transparent data encryption status. + TransparentDataEncryptionStatusDisabled TransparentDataEncryptionStatus = "Disabled" + // TransparentDataEncryptionStatusEnabled specifies the transparent data + // encryption status enabled state for transparent data encryption status. + TransparentDataEncryptionStatusEnabled TransparentDataEncryptionStatus = "Enabled" ) -// Column is represents an Azure SQL Database table column. -type Column struct { - Name *string `json:"name,omitempty"` - ID *string `json:"id,omitempty"` - Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` - Tags *map[string]*string `json:"tags,omitempty"` - *ColumnProperties `json:"properties,omitempty"` -} - -// ColumnProperties is represents the properties of an Azure SQL Database -// table column. -type ColumnProperties struct { - ColumnType *string `json:"columnType,omitempty"` -} - -// Database is represents an Azure SQL Database. +// Database is represents a database. type Database struct { autorest.Response `json:"-"` - Name *string `json:"name,omitempty"` ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` + Location *string `json:"location,omitempty"` + Kind *string `json:"kind,omitempty"` *DatabaseProperties `json:"properties,omitempty"` } -// DatabaseListResult is represents the response to a List Azure SQL Database -// request. +// DatabaseBlobAuditingPolicy is contains information about a database Blob +// Auditing policy. +type DatabaseBlobAuditingPolicy struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Kind *string `json:"kind,omitempty"` + *DatabaseBlobAuditingPolicyProperties `json:"properties,omitempty"` +} + +// DatabaseBlobAuditingPolicyProperties is properties for a database Blob +// Auditing policy. +type DatabaseBlobAuditingPolicyProperties struct { + State BlobAuditingPolicyState `json:"state,omitempty"` + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + RetentionDays *int32 `json:"retentionDays,omitempty"` + AuditActionsAndGroups *[]string `json:"auditActionsAndGroups,omitempty"` + StorageAccountSubscriptionID *string `json:"storageAccountSubscriptionId,omitempty"` + IsStorageSecondaryKeyInUse *bool `json:"isStorageSecondaryKeyInUse,omitempty"` +} + +// DatabaseListResult is represents the response to a list database request. type DatabaseListResult struct { autorest.Response `json:"-"` Value *[]Database `json:"value,omitempty"` } -// DatabaseMetric is represents Azure SQL Database metrics. +// DatabaseMetric is represents database metrics. type DatabaseMetric struct { + Name *string `json:"name,omitempty"` + ID *string `json:"id,omitempty"` ResourceName *string `json:"resourceName,omitempty"` DisplayName *string `json:"displayName,omitempty"` CurrentValue *float64 `json:"currentValue,omitempty"` @@ -325,107 +500,145 @@ type DatabaseMetric struct { NextResetTime *date.Time `json:"nextResetTime,omitempty"` } -// DatabaseMetricListResult is represents the response to a List Azure SQL -// Database metrics request. +// DatabaseMetricListResult is represents the response to a list database +// metrics request. type DatabaseMetricListResult struct { autorest.Response `json:"-"` Value *[]DatabaseMetric `json:"value,omitempty"` } -// DatabaseProperties is represents the properties of an Azure SQL Database. +// DatabaseProperties is represents the properties of a database. type DatabaseProperties struct { - Collation *string `json:"collation,omitempty"` - CreationDate *date.Time `json:"creationDate,omitempty"` - ContainmentState *int64 `json:"containmentState,omitempty"` - CurrentServiceObjectiveID *uuid.UUID `json:"currentServiceObjectiveId,omitempty"` - DatabaseID *string `json:"databaseId,omitempty"` - EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` - CreateMode CreateMode `json:"createMode,omitempty"` - SourceDatabaseID *string `json:"sourceDatabaseId,omitempty"` - Edition DatabaseEditions `json:"edition,omitempty"` - MaxSizeBytes *string `json:"maxSizeBytes,omitempty"` - RequestedServiceObjectiveID *uuid.UUID `json:"requestedServiceObjectiveId,omitempty"` - RequestedServiceObjectiveName ServiceObjectiveName `json:"requestedServiceObjectiveName,omitempty"` - ServiceLevelObjective ServiceObjectiveName `json:"serviceLevelObjective,omitempty"` - Status *string `json:"status,omitempty"` - ElasticPoolName *string `json:"elasticPoolName,omitempty"` - DefaultSecondaryLocation *string `json:"defaultSecondaryLocation,omitempty"` - ServiceTierAdvisors *[]ServiceTierAdvisor `json:"serviceTierAdvisors,omitempty"` - UpgradeHint *UpgradeHint `json:"upgradeHint,omitempty"` - Schemas *[]Schema `json:"schemas,omitempty"` - TransparentDataEncryption *[]TransparentDataEncryption `json:"transparentDataEncryption,omitempty"` - RecommendedIndex *[]RecommendedIndex `json:"recommendedIndex,omitempty"` + Collation *string `json:"collation,omitempty"` + CreationDate *date.Time `json:"creationDate,omitempty"` + ContainmentState *int64 `json:"containmentState,omitempty"` + CurrentServiceObjectiveID *uuid.UUID `json:"currentServiceObjectiveId,omitempty"` + DatabaseID *uuid.UUID `json:"databaseId,omitempty"` + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` + CreateMode CreateMode `json:"createMode,omitempty"` + SourceDatabaseID *string `json:"sourceDatabaseId,omitempty"` + SourceDatabaseDeletionDate *date.Time `json:"sourceDatabaseDeletionDate,omitempty"` + RestorePointInTime *date.Time `json:"restorePointInTime,omitempty"` + RecoveryServicesRecoveryPointResourceID *string `json:"recoveryServicesRecoveryPointResourceId,omitempty"` + Edition DatabaseEdition `json:"edition,omitempty"` + MaxSizeBytes *string `json:"maxSizeBytes,omitempty"` + RequestedServiceObjectiveID *uuid.UUID `json:"requestedServiceObjectiveId,omitempty"` + RequestedServiceObjectiveName ServiceObjectiveName `json:"requestedServiceObjectiveName,omitempty"` + ServiceLevelObjective ServiceObjectiveName `json:"serviceLevelObjective,omitempty"` + Status *string `json:"status,omitempty"` + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + DefaultSecondaryLocation *string `json:"defaultSecondaryLocation,omitempty"` + ServiceTierAdvisors *[]ServiceTierAdvisor `json:"serviceTierAdvisors,omitempty"` + TransparentDataEncryption *[]TransparentDataEncryption `json:"transparentDataEncryption,omitempty"` + RecommendedIndex *[]RecommendedIndex `json:"recommendedIndex,omitempty"` + FailoverGroupID *uuid.UUID `json:"failoverGroupId,omitempty"` + ReadScale ReadScale `json:"readScale,omitempty"` + SampleName SampleName `json:"sampleName,omitempty"` } -// ElasticPool is represents an Azure SQL Database elastic pool. +// DatabaseSecurityAlertPolicy is contains information about a database Threat +// Detection policy. +type DatabaseSecurityAlertPolicy struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Kind *string `json:"kind,omitempty"` + *DatabaseSecurityAlertPolicyProperties `json:"properties,omitempty"` +} + +// DatabaseSecurityAlertPolicyProperties is properties for a database Threat +// Detection policy. +type DatabaseSecurityAlertPolicyProperties struct { + State SecurityAlertPolicyState `json:"state,omitempty"` + DisabledAlerts *string `json:"disabledAlerts,omitempty"` + EmailAddresses *string `json:"emailAddresses,omitempty"` + EmailAccountAdmins SecurityAlertPolicyEmailAccountAdmins `json:"emailAccountAdmins,omitempty"` + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + RetentionDays *int32 `json:"retentionDays,omitempty"` + UseServerDefault SecurityAlertPolicyUseServerDefault `json:"useServerDefault,omitempty"` +} + +// EditionCapability is the database edition capabilities. +type EditionCapability struct { + Name *string `json:"name,omitempty"` + Status CapabilityStatus `json:"status,omitempty"` + SupportedServiceLevelObjectives *[]ServiceObjectiveCapability `json:"supportedServiceLevelObjectives,omitempty"` +} + +// ElasticPool is represents a database elastic pool. type ElasticPool struct { autorest.Response `json:"-"` - Name *string `json:"name,omitempty"` ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` + Location *string `json:"location,omitempty"` *ElasticPoolProperties `json:"properties,omitempty"` + Kind *string `json:"kind,omitempty"` } -// ElasticPoolActivity is represents the activity on an Azure SQL Elastic Pool. +// ElasticPoolActivity is represents the activity on an elastic pool. type ElasticPoolActivity struct { - Name *string `json:"name,omitempty"` - ID *string `json:"id,omitempty"` - Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` - Tags *map[string]*string `json:"tags,omitempty"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` *ElasticPoolActivityProperties `json:"properties,omitempty"` } -// ElasticPoolActivityListResult is represents the response to a List Azure -// SQL Elastic Pool Activity request. +// ElasticPoolActivityListResult is represents the response to a list elastic +// pool activity request. type ElasticPoolActivityListResult struct { autorest.Response `json:"-"` Value *[]ElasticPoolActivity `json:"value,omitempty"` } -// ElasticPoolActivityProperties is represents the properties of an Azure SQL -// Elastic Pool. +// ElasticPoolActivityProperties is represents the properties of an elastic +// pool. type ElasticPoolActivityProperties struct { - EndTime *date.Time `json:"endTime,omitempty"` - ErrorCode *int32 `json:"errorCode,omitempty"` - ErrorMessage *string `json:"errorMessage,omitempty"` - ErrorSeverity *int32 `json:"errorSeverity,omitempty"` - Operation *string `json:"operation,omitempty"` - OperationID *string `json:"operationId,omitempty"` - PercentComplete *int32 `json:"percentComplete,omitempty"` - RequestedDatabaseDtuMax *int32 `json:"requestedDatabaseDtuMax,omitempty"` - RequestedDatabaseDtuMin *int32 `json:"requestedDatabaseDtuMin,omitempty"` - RequestedDtu *int32 `json:"requestedDtu,omitempty"` - RequestedElasticPoolName *string `json:"requestedElasticPoolName,omitempty"` - RequestedStorageLimitInGB *int64 `json:"requestedStorageLimitInGB,omitempty"` - ElasticPoolName *string `json:"elasticPoolName,omitempty"` - ServerName *string `json:"serverName,omitempty"` - StartTime *date.Time `json:"startTime,omitempty"` - State *string `json:"state,omitempty"` + EndTime *date.Time `json:"endTime,omitempty"` + ErrorCode *int32 `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + Operation *string `json:"operation,omitempty"` + OperationID *uuid.UUID `json:"operationId,omitempty"` + PercentComplete *int32 `json:"percentComplete,omitempty"` + RequestedDatabaseDtuMax *int32 `json:"requestedDatabaseDtuMax,omitempty"` + RequestedDatabaseDtuMin *int32 `json:"requestedDatabaseDtuMin,omitempty"` + RequestedDtu *int32 `json:"requestedDtu,omitempty"` + RequestedElasticPoolName *string `json:"requestedElasticPoolName,omitempty"` + RequestedStorageLimitInGB *int64 `json:"requestedStorageLimitInGB,omitempty"` + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + ServerName *string `json:"serverName,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` + State *string `json:"state,omitempty"` + RequestedStorageLimitInMB *int32 `json:"requestedStorageLimitInMB,omitempty"` + RequestedDatabaseDtuGuarantee *int32 `json:"requestedDatabaseDtuGuarantee,omitempty"` + RequestedDatabaseDtuCap *int32 `json:"requestedDatabaseDtuCap,omitempty"` + RequestedDtuGuarantee *int32 `json:"requestedDtuGuarantee,omitempty"` } -// ElasticPoolDatabaseActivity is represents the activity on an Azure SQL -// Elastic Pool. +// ElasticPoolDatabaseActivity is represents the activity on an elastic pool. type ElasticPoolDatabaseActivity struct { - Name *string `json:"name,omitempty"` - ID *string `json:"id,omitempty"` - Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` - Tags *map[string]*string `json:"tags,omitempty"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` *ElasticPoolDatabaseActivityProperties `json:"properties,omitempty"` } -// ElasticPoolDatabaseActivityListResult is represents the response to a List -// Azure SQL Elastic Pool Database Activity request. +// ElasticPoolDatabaseActivityListResult is represents the response to a list +// elastic pool database activity request. type ElasticPoolDatabaseActivityListResult struct { autorest.Response `json:"-"` Value *[]ElasticPoolDatabaseActivity `json:"value,omitempty"` } // ElasticPoolDatabaseActivityProperties is represents the properties of an -// Azure SQL Elastic Pool Database Activity. +// elastic pool database activity. type ElasticPoolDatabaseActivityProperties struct { DatabaseName *string `json:"databaseName,omitempty"` EndTime *date.Time `json:"endTime,omitempty"` @@ -433,7 +646,7 @@ type ElasticPoolDatabaseActivityProperties struct { ErrorMessage *string `json:"errorMessage,omitempty"` ErrorSeverity *int32 `json:"errorSeverity,omitempty"` Operation *string `json:"operation,omitempty"` - OperationID *string `json:"operationId,omitempty"` + OperationID *uuid.UUID `json:"operationId,omitempty"` PercentComplete *int32 `json:"percentComplete,omitempty"` RequestedElasticPoolName *string `json:"requestedElasticPoolName,omitempty"` CurrentElasticPoolName *string `json:"currentElasticPoolName,omitempty"` @@ -444,23 +657,174 @@ type ElasticPoolDatabaseActivityProperties struct { State *string `json:"state,omitempty"` } -// ElasticPoolListResult is represents the response to a List Azure SQL -// Elastic Pool request. +// ElasticPoolDtuCapability is the Elastic Pool DTU capability. +type ElasticPoolDtuCapability struct { + Limit *int64 `json:"limit,omitempty"` + MaxDatabaseCount *int64 `json:"maxDatabaseCount,omitempty"` + Status CapabilityStatus `json:"status,omitempty"` + SupportedMaxSizes *[]MaxSizeCapability `json:"supportedMaxSizes,omitempty"` + IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` + SupportedPerDatabaseMaxSizes *[]MaxSizeCapability `json:"supportedPerDatabaseMaxSizes,omitempty"` + SupportedPerDatabaseMaxDtus *[]ElasticPoolPerDatabaseMaxDtuCapability `json:"supportedPerDatabaseMaxDtus,omitempty"` +} + +// ElasticPoolEditionCapability is the elastic pool edition capabilities. +type ElasticPoolEditionCapability struct { + Name *string `json:"name,omitempty"` + Status CapabilityStatus `json:"status,omitempty"` + SupportedElasticPoolDtus *[]ElasticPoolDtuCapability `json:"supportedElasticPoolDtus,omitempty"` +} + +// ElasticPoolListResult is represents the response to a list elastic pool +// request. type ElasticPoolListResult struct { autorest.Response `json:"-"` Value *[]ElasticPool `json:"value,omitempty"` } -// ElasticPoolProperties is represents the properties of an Azure SQL Elastic -// Pool. +// ElasticPoolPerDatabaseMaxDtuCapability is the max per-database DTU +// capability. +type ElasticPoolPerDatabaseMaxDtuCapability struct { + Limit *int64 `json:"limit,omitempty"` + Status CapabilityStatus `json:"status,omitempty"` + SupportedPerDatabaseMinDtus *[]ElasticPoolPerDatabaseMinDtuCapability `json:"supportedPerDatabaseMinDtus,omitempty"` +} + +// ElasticPoolPerDatabaseMinDtuCapability is the minimum per-database DTU +// capability. +type ElasticPoolPerDatabaseMinDtuCapability struct { + Limit *int64 `json:"limit,omitempty"` + Status CapabilityStatus `json:"status,omitempty"` +} + +// ElasticPoolProperties is represents the properties of an elastic pool. type ElasticPoolProperties struct { - CreationDate *date.Time `json:"creationDate,omitempty"` - State ElasticPoolState `json:"state,omitempty"` - Edition ElasticPoolEditions `json:"edition,omitempty"` - Dtu *int32 `json:"dtu,omitempty"` - DatabaseDtuMax *int32 `json:"databaseDtuMax,omitempty"` - DatabaseDtuMin *int32 `json:"databaseDtuMin,omitempty"` - StorageMB *int32 `json:"storageMB,omitempty"` + CreationDate *date.Time `json:"creationDate,omitempty"` + State ElasticPoolState `json:"state,omitempty"` + Edition ElasticPoolEdition `json:"edition,omitempty"` + Dtu *int32 `json:"dtu,omitempty"` + DatabaseDtuMax *int32 `json:"databaseDtuMax,omitempty"` + DatabaseDtuMin *int32 `json:"databaseDtuMin,omitempty"` + StorageMB *int32 `json:"storageMB,omitempty"` +} + +// ExportRequest is export database parameters. +type ExportRequest struct { + StorageKeyType StorageKeyType `json:"storageKeyType,omitempty"` + StorageKey *string `json:"storageKey,omitempty"` + StorageURI *string `json:"storageUri,omitempty"` + AdministratorLogin *string `json:"administratorLogin,omitempty"` + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + AuthenticationType AuthenticationType `json:"authenticationType,omitempty"` +} + +// FirewallRule is represents a server firewall rule. +type FirewallRule struct { + autorest.Response `json:"-"` + Name *string `json:"name,omitempty"` + ID *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Type *string `json:"type,omitempty"` + *FirewallRuleProperties `json:"properties,omitempty"` +} + +// FirewallRuleListResult is represents the response to a List Firewall Rules +// request. +type FirewallRuleListResult struct { + autorest.Response `json:"-"` + Value *[]FirewallRule `json:"value,omitempty"` +} + +// FirewallRuleProperties is represents the properties of a server firewall +// rule. +type FirewallRuleProperties struct { + StartIPAddress *string `json:"startIpAddress,omitempty"` + EndIPAddress *string `json:"endIpAddress,omitempty"` +} + +// ImportExportResponse is response for Import/Export Get operation. +type ImportExportResponse struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + *ImportExportResponseProperties `json:"properties,omitempty"` +} + +// ImportExportResponseProperties is response for Import/Export Status +// operation. +type ImportExportResponseProperties struct { + RequestType *string `json:"requestType,omitempty"` + RequestID *uuid.UUID `json:"requestId,omitempty"` + ServerName *string `json:"serverName,omitempty"` + DatabaseName *string `json:"databaseName,omitempty"` + Status *string `json:"status,omitempty"` + LastModifiedTime *string `json:"lastModifiedTime,omitempty"` + QueuedTime *string `json:"queuedTime,omitempty"` + BlobURI *string `json:"blobUri,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// ImportExtensionProperties is represents the properties for an import +// operation +type ImportExtensionProperties struct { + StorageKeyType StorageKeyType `json:"storageKeyType,omitempty"` + StorageKey *string `json:"storageKey,omitempty"` + StorageURI *string `json:"storageUri,omitempty"` + AdministratorLogin *string `json:"administratorLogin,omitempty"` + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + AuthenticationType AuthenticationType `json:"authenticationType,omitempty"` + OperationMode *string `json:"operationMode,omitempty"` +} + +// ImportExtensionRequest is import database parameters. +type ImportExtensionRequest struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + *ImportExtensionProperties `json:"properties,omitempty"` +} + +// ImportRequest is import database parameters. +type ImportRequest struct { + StorageKeyType StorageKeyType `json:"storageKeyType,omitempty"` + StorageKey *string `json:"storageKey,omitempty"` + StorageURI *string `json:"storageUri,omitempty"` + AdministratorLogin *string `json:"administratorLogin,omitempty"` + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + AuthenticationType AuthenticationType `json:"authenticationType,omitempty"` + DatabaseName *string `json:"databaseName,omitempty"` + Edition DatabaseEdition `json:"edition,omitempty"` + ServiceObjectiveName ServiceObjectiveName `json:"serviceObjectiveName,omitempty"` + MaxSizeBytes *string `json:"maxSizeBytes,omitempty"` +} + +// LocationCapabilities is the capabilities for a location. +type LocationCapabilities struct { + autorest.Response `json:"-"` + Name *string `json:"name,omitempty"` + Status CapabilityStatus `json:"status,omitempty"` + SupportedServerVersions *[]ServerVersionCapability `json:"supportedServerVersions,omitempty"` +} + +// MaxSizeCapability is the maximum size limits for a database. +type MaxSizeCapability struct { + Limit *int64 `json:"limit,omitempty"` + Unit MaxSizeUnits `json:"unit,omitempty"` + Status CapabilityStatus `json:"status,omitempty"` +} + +// Operation is sQL REST API operation definition. +type Operation struct { + Name *string `json:"name,omitempty"` + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay is display metadata associated with the operation. +type OperationDisplay struct { + Provider *string `json:"provider,omitempty"` + Resource *string `json:"resource,omitempty"` + Operation *string `json:"operation,omitempty"` } // OperationImpact is represents impact of an operation, both in absolute and @@ -472,51 +836,62 @@ type OperationImpact struct { ChangeValueRelative *float64 `json:"changeValueRelative,omitempty"` } -// RecommendedDatabaseProperties is represents the properties of a recommended -// Azure SQL Database being upgraded. -type RecommendedDatabaseProperties struct { - Name *string `json:"Name,omitempty"` - TargetEdition TargetDatabaseEditions `json:"TargetEdition,omitempty"` - TargetServiceLevelObjective *string `json:"TargetServiceLevelObjective,omitempty"` +// OperationListResult is result of the request to list SQL operations. It +// contains a list of operations and a URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + Value *[]Operation `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` } -// RecommendedElasticPool is represents an Azure SQL Recommended Elastic Pool. +// PerformanceLevel is a possible performance level of a service objective +// capability. +type PerformanceLevel struct { + Unit PerformanceLevelUnit `json:"unit,omitempty"` + Value *int32 `json:"value,omitempty"` +} + +// ProxyResource is aRM proxy resource. +type ProxyResource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +// RecommendedElasticPool is represents a recommented elastic pool. type RecommendedElasticPool struct { autorest.Response `json:"-"` - Name *string `json:"name,omitempty"` - ID *string `json:"id,omitempty"` - Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` - Tags *map[string]*string `json:"tags,omitempty"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` *RecommendedElasticPoolProperties `json:"properties,omitempty"` } -// RecommendedElasticPoolListMetricsResult is represents the response to a -// List Azure SQL Recommended Elastic Pool metrics request. +// RecommendedElasticPoolListMetricsResult is represents the response to a list +// recommended elastic pool metrics request. type RecommendedElasticPoolListMetricsResult struct { autorest.Response `json:"-"` Value *[]RecommendedElasticPoolMetric `json:"value,omitempty"` } -// RecommendedElasticPoolListResult is represents the response to a List Azure -// SQL Recommended Elastic Pool request. +// RecommendedElasticPoolListResult is represents the response to a list +// recommended elastic pool request. type RecommendedElasticPoolListResult struct { autorest.Response `json:"-"` Value *[]RecommendedElasticPool `json:"value,omitempty"` } -// RecommendedElasticPoolMetric is represents Azure SQL recommended elastic -// pool metric. +// RecommendedElasticPoolMetric is represents recommended elastic pool metric. type RecommendedElasticPoolMetric struct { DateTime *date.Time `json:"dateTime,omitempty"` Dtu *float64 `json:"dtu,omitempty"` SizeGB *float64 `json:"sizeGB,omitempty"` } -// RecommendedElasticPoolProperties is represents the properties of an Azure -// SQL Recommended Elastic Pool. +// RecommendedElasticPoolProperties is represents the properties of a +// recommented elastic pool. type RecommendedElasticPoolProperties struct { - DatabaseEdition ElasticPoolEditions `json:"databaseEdition,omitempty"` + DatabaseEdition ElasticPoolEdition `json:"databaseEdition,omitempty"` Dtu *float64 `json:"dtu,omitempty"` DatabaseDtuMin *float64 `json:"databaseDtuMin,omitempty"` DatabaseDtuMax *float64 `json:"databaseDtuMax,omitempty"` @@ -529,103 +904,114 @@ type RecommendedElasticPoolProperties struct { Metrics *[]RecommendedElasticPoolMetric `json:"metrics,omitempty"` } -// RecommendedIndex is represents an Azure SQL Database recommended index. +// RecommendedIndex is represents a database recommended index. type RecommendedIndex struct { - Name *string `json:"name,omitempty"` - ID *string `json:"id,omitempty"` - Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` - Tags *map[string]*string `json:"tags,omitempty"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` *RecommendedIndexProperties `json:"properties,omitempty"` } -// RecommendedIndexProperties is represents the properties of an Azure SQL -// Database recommended index. +// RecommendedIndexProperties is represents the properties of a database +// recommended index. type RecommendedIndexProperties struct { - Action RecommendedIndexActions `json:"action,omitempty"` - State RecommendedIndexStates `json:"state,omitempty"` - Created *date.Time `json:"created,omitempty"` - LastModified *date.Time `json:"lastModified,omitempty"` - IndexType RecommendedIndexTypes `json:"indexType,omitempty"` - Schema *string `json:"schema,omitempty"` - Table *string `json:"table,omitempty"` - Columns *[]string `json:"columns,omitempty"` - IncludedColumns *[]string `json:"includedColumns,omitempty"` - IndexScript *string `json:"indexScript,omitempty"` - EstimatedImpact *[]OperationImpact `json:"estimatedImpact,omitempty"` - ReportedImpact *[]OperationImpact `json:"reportedImpact,omitempty"` + Action RecommendedIndexAction `json:"action,omitempty"` + State RecommendedIndexState `json:"state,omitempty"` + Created *date.Time `json:"created,omitempty"` + LastModified *date.Time `json:"lastModified,omitempty"` + IndexType RecommendedIndexType `json:"indexType,omitempty"` + Schema *string `json:"schema,omitempty"` + Table *string `json:"table,omitempty"` + Columns *[]string `json:"columns,omitempty"` + IncludedColumns *[]string `json:"includedColumns,omitempty"` + IndexScript *string `json:"indexScript,omitempty"` + EstimatedImpact *[]OperationImpact `json:"estimatedImpact,omitempty"` + ReportedImpact *[]OperationImpact `json:"reportedImpact,omitempty"` } -// Resource is resource properties +// ReplicationLink is represents a database replication link. +type ReplicationLink struct { + autorest.Response `json:"-"` + Name *string `json:"name,omitempty"` + ID *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Type *string `json:"type,omitempty"` + *ReplicationLinkProperties `json:"properties,omitempty"` +} + +// ReplicationLinkListResult is represents the response to a List database +// replication link request. +type ReplicationLinkListResult struct { + autorest.Response `json:"-"` + Value *[]ReplicationLink `json:"value,omitempty"` +} + +// ReplicationLinkProperties is represents the properties of a database +// replication link. +type ReplicationLinkProperties struct { + IsTerminationAllowed *bool `json:"isTerminationAllowed,omitempty"` + ReplicationMode *string `json:"replicationMode,omitempty"` + PartnerServer *string `json:"partnerServer,omitempty"` + PartnerDatabase *string `json:"partnerDatabase,omitempty"` + PartnerLocation *string `json:"partnerLocation,omitempty"` + Role ReplicationRole `json:"role,omitempty"` + PartnerRole ReplicationRole `json:"partnerRole,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` + PercentComplete *int32 `json:"percentComplete,omitempty"` + ReplicationState ReplicationState `json:"replicationState,omitempty"` +} + +// Resource is aRM resource. type Resource struct { - Name *string `json:"name,omitempty"` - ID *string `json:"id,omitempty"` - Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` - Tags *map[string]*string `json:"tags,omitempty"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` } -// RestorePoint is represents an Azure SQL Database restore point. +// RestorePoint is represents a database restore point. type RestorePoint struct { - Name *string `json:"name,omitempty"` - ID *string `json:"id,omitempty"` - Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` - Tags *map[string]*string `json:"tags,omitempty"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` *RestorePointProperties `json:"properties,omitempty"` } -// RestorePointListResult is represents the response to a List Azure SQL -// Database restore points request. +// RestorePointListResult is represents the response to a list database restore +// points request. type RestorePointListResult struct { autorest.Response `json:"-"` Value *[]RestorePoint `json:"value,omitempty"` } -// RestorePointProperties is represents the properties of an Azure SQL -// Database restore point. +// RestorePointProperties is represents the properties of a database restore +// point. type RestorePointProperties struct { RestorePointType RestorePointTypes `json:"restorePointType,omitempty"` RestorePointCreationDate *date.Time `json:"restorePointCreationDate,omitempty"` EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` } -// Schema is represents an Azure SQL Database schema. -type Schema struct { - Name *string `json:"name,omitempty"` - ID *string `json:"id,omitempty"` - Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` - Tags *map[string]*string `json:"tags,omitempty"` - *SchemaProperties `json:"properties,omitempty"` -} - -// SchemaProperties is represents the properties of an Azure SQL Database -// schema. -type SchemaProperties struct { - Tables *[]Table `json:"tables,omitempty"` -} - -// Server is represents an Azure SQL server. +// Server is represents a server. type Server struct { autorest.Response `json:"-"` - Name *string `json:"name,omitempty"` ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` + Location *string `json:"location,omitempty"` + Kind *string `json:"kind,omitempty"` *ServerProperties `json:"properties,omitempty"` } -// ServerListResult is represents the response to a Get Azure SQL server -// request. +// ServerListResult is represents the response to a get server request. type ServerListResult struct { autorest.Response `json:"-"` Value *[]Server `json:"value,omitempty"` } -// ServerMetric is represents Azure SQL server metrics. +// ServerMetric is represents server metrics. type ServerMetric struct { + Name *string `json:"name,omitempty"` ResourceName *string `json:"resourceName,omitempty"` DisplayName *string `json:"displayName,omitempty"` CurrentValue *float64 `json:"currentValue,omitempty"` @@ -634,22 +1020,33 @@ type ServerMetric struct { NextResetTime *date.Time `json:"nextResetTime,omitempty"` } -// ServerMetricListResult is represents the response to a List Azure SQL -// server metrics request. +// ServerMetricListResult is represents the response to a list server metrics +// request. type ServerMetricListResult struct { autorest.Response `json:"-"` Value *[]ServerMetric `json:"value,omitempty"` } -// ServerProperties is represents the properties of an Azure SQL server. +// ServerProperties is represents the properties of a server. type ServerProperties struct { FullyQualifiedDomainName *string `json:"fullyQualifiedDomainName,omitempty"` Version ServerVersion `json:"version,omitempty"` AdministratorLogin *string `json:"administratorLogin,omitempty"` AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + ExternalAdministratorSid *uuid.UUID `json:"externalAdministratorSid,omitempty"` + ExternalAdministratorLogin *string `json:"externalAdministratorLogin,omitempty"` + State ServerState `json:"state,omitempty"` } -// ServiceObjective is represents an Azure SQL Database Service Objective. +// ServerVersionCapability is the server capabilities. +type ServerVersionCapability struct { + Name *string `json:"name,omitempty"` + Status CapabilityStatus `json:"status,omitempty"` + SupportedEditions *[]EditionCapability `json:"supportedEditions,omitempty"` + SupportedElasticPoolEditions *[]ElasticPoolEditionCapability `json:"supportedElasticPoolEditions,omitempty"` +} + +// ServiceObjective is represents a database service objective. type ServiceObjective struct { autorest.Response `json:"-"` Name *string `json:"name,omitempty"` @@ -657,15 +1054,25 @@ type ServiceObjective struct { *ServiceObjectiveProperties `json:"properties,omitempty"` } -// ServiceObjectiveListResult is represents the response to a Get Azure SQL -// Database Service Objectives request. +// ServiceObjectiveCapability is the service objectives capability. +type ServiceObjectiveCapability struct { + Name *string `json:"name,omitempty"` + Status CapabilityStatus `json:"status,omitempty"` + *PerformanceLevel `json:"performanceLevel,omitempty"` + ID *uuid.UUID `json:"id,omitempty"` + SupportedMaxSizes *[]MaxSizeCapability `json:"supportedMaxSizes,omitempty"` + IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` +} + +// ServiceObjectiveListResult is represents the response to a get database +// service objectives request. type ServiceObjectiveListResult struct { autorest.Response `json:"-"` Value *[]ServiceObjective `json:"value,omitempty"` } -// ServiceObjectiveProperties is represents the properties of an Azure SQL -// Database Service Objective. +// ServiceObjectiveProperties is represents the properties of a database +// service objective. type ServiceObjectiveProperties struct { ServiceObjectiveName *string `json:"serviceObjectiveName,omitempty"` IsDefault *bool `json:"isDefault,omitempty"` @@ -700,7 +1107,7 @@ type ServiceTierAdvisorProperties struct { MaxDtu *float64 `json:"maxDtu,omitempty"` MaxSizeInGB *float64 `json:"maxSizeInGB,omitempty"` ServiceLevelObjectiveUsageMetrics *[]SloUsageMetric `json:"serviceLevelObjectiveUsageMetrics,omitempty"` - CurrentServiceLevelObjective *uuid.UUID `json:"currentServiceLevelObjective,omitempty"` + CurrentServiceLevelObjective *string `json:"currentServiceLevelObjective,omitempty"` CurrentServiceLevelObjectiveID *uuid.UUID `json:"currentServiceLevelObjectiveId,omitempty"` UsageBasedRecommendationServiceLevelObjective *string `json:"usageBasedRecommendationServiceLevelObjective,omitempty"` UsageBasedRecommendationServiceLevelObjectiveID *uuid.UUID `json:"usageBasedRecommendationServiceLevelObjectiveId,omitempty"` @@ -715,11 +1122,6 @@ type ServiceTierAdvisorProperties struct { // SloUsageMetric is represents a Slo Usage Metric. type SloUsageMetric struct { - Name *string `json:"name,omitempty"` - ID *string `json:"id,omitempty"` - Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` - Tags *map[string]*string `json:"tags,omitempty"` ServiceLevelObjective ServiceObjectiveName `json:"serviceLevelObjective,omitempty"` ServiceLevelObjectiveID *uuid.UUID `json:"serviceLevelObjectiveId,omitempty"` InRangeTimeRatio *float64 `json:"inRangeTimeRatio,omitempty"` @@ -731,25 +1133,17 @@ type SubResource struct { ID *string `json:"id,omitempty"` } -// Table is represents an Azure SQL Database table. -type Table struct { - Name *string `json:"name,omitempty"` - ID *string `json:"id,omitempty"` - Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` - Tags *map[string]*string `json:"tags,omitempty"` - *TableProperties `json:"properties,omitempty"` +// TrackedResource is aRM tracked top level resource. +type TrackedResource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + Location *string `json:"location,omitempty"` } -// TableProperties is represents the properties of an Azure SQL Database table. -type TableProperties struct { - TableType TableType `json:"tableType,omitempty"` - Columns *[]Column `json:"columns,omitempty"` - RecommendedIndexes *[]RecommendedIndex `json:"recommendedIndexes,omitempty"` -} - -// TransparentDataEncryption is represents an Azure SQL Database Transparent -// Data Encryption . +// TransparentDataEncryption is represents a database transparent data +// encryption . type TransparentDataEncryption struct { autorest.Response `json:"-"` Name *string `json:"name,omitempty"` @@ -757,8 +1151,8 @@ type TransparentDataEncryption struct { *TransparentDataEncryptionProperties `json:"properties,omitempty"` } -// TransparentDataEncryptionActivity is represents an Azure SQL Database -// Transparent Data Encryption Scan. +// TransparentDataEncryptionActivity is represents a database transparent data +// encryption Scan. type TransparentDataEncryptionActivity struct { Name *string `json:"name,omitempty"` ID *string `json:"id,omitempty"` @@ -766,45 +1160,21 @@ type TransparentDataEncryptionActivity struct { } // TransparentDataEncryptionActivityListResult is represents the response to a -// List Azure SQL Database Transparent Data Encryption Activity request. +// list database transparent data encryption activity request. type TransparentDataEncryptionActivityListResult struct { autorest.Response `json:"-"` Value *[]TransparentDataEncryptionActivity `json:"value,omitempty"` } // TransparentDataEncryptionActivityProperties is represents the properties of -// an Azure SQL Database Transparent Data Encryption Scan. +// a database transparent data encryption Scan. type TransparentDataEncryptionActivityProperties struct { - Status TransparentDataEncryptionActivityStates `json:"status,omitempty"` + Status TransparentDataEncryptionActivityStatus `json:"status,omitempty"` PercentComplete *float64 `json:"percentComplete,omitempty"` } -// TransparentDataEncryptionProperties is represents the properties of an -// Azure SQL Database Transparent Data Encryption. +// TransparentDataEncryptionProperties is represents the properties of a +// database transparent data encryption. type TransparentDataEncryptionProperties struct { - Status TransparentDataEncryptionStates `json:"status,omitempty"` -} - -// UpgradeHint is represents a Upgrade Hint. -type UpgradeHint struct { - Name *string `json:"name,omitempty"` - ID *string `json:"id,omitempty"` - Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` - Tags *map[string]*string `json:"tags,omitempty"` - TargetServiceLevelObjective *string `json:"targetServiceLevelObjective,omitempty"` - TargetServiceLevelObjectiveID *uuid.UUID `json:"targetServiceLevelObjectiveId,omitempty"` -} - -// UpgradeRecommendedElasticPoolProperties is represents the properties of a -// Azure SQL Recommended Elastic Pool being upgraded. -type UpgradeRecommendedElasticPoolProperties struct { - Name *string `json:"Name,omitempty"` - Edition TargetElasticPoolEditions `json:"Edition,omitempty"` - Dtu *int32 `json:"Dtu,omitempty"` - StorageMb *int32 `json:"StorageMb,omitempty"` - DatabaseDtuMin *int32 `json:"DatabaseDtuMin,omitempty"` - DatabaseDtuMax *int32 `json:"DatabaseDtuMax,omitempty"` - DatabaseCollection *[]string `json:"DatabaseCollection,omitempty"` - IncludeAllDatabases *bool `json:"IncludeAllDatabases,omitempty"` + Status TransparentDataEncryptionStatus `json:"status,omitempty"` } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/operations.go new file mode 100755 index 000000000..510869b74 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/operations.go @@ -0,0 +1,101 @@ +package sql + +// 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OperationsClient is the the Azure SQL Database management API provides a +// RESTful set of web services that interact with Azure SQL Database services +// to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type OperationsClient struct { + ManagementClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient +// client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available SQL Rest API operations. +func (client OperationsClient) List() (result OperationListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer() (*http.Request, error) { + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Sql/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/recommendedelasticpools.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/recommendedelasticpools.go old mode 100644 new mode 100755 index 2dbe6611e..6beccb801 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/recommendedelasticpools.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/recommendedelasticpools.go @@ -14,7 +14,7 @@ package sql // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -24,9 +24,10 @@ import ( "net/http" ) -// RecommendedElasticPoolsClient is the provides create, read, update and -// delete functionality for Azure SQL resources including servers, databases, -// elastic pools, recommendations, operations, and usage metrics. +// RecommendedElasticPoolsClient is the the Azure SQL Database management API +// provides a RESTful set of web services that interact with Azure SQL Database +// services to manage your databases. The API enables you to create, retrieve, +// update, and delete databases. type RecommendedElasticPoolsClient struct { ManagementClient } @@ -43,23 +44,24 @@ func NewRecommendedElasticPoolsClientWithBaseURI(baseURI string, subscriptionID return RecommendedElasticPoolsClient{NewWithBaseURI(baseURI, subscriptionID)} } -// Get gets information about an Azure SQL Recommended Elastic Pool. +// Get gets a recommented elastic pool. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. -// recommendedElasticPoolName is the name of the Azure SQL Recommended -// Elastic Pool to be retrieved. +// the portal. serverName is the name of the server. recommendedElasticPoolName +// is the name of the recommended elastic pool to be retrieved. func (client RecommendedElasticPoolsClient) Get(resourceGroupName string, serverName string, recommendedElasticPoolName string) (result RecommendedElasticPool, err error) { req, err := client.GetPreparer(resourceGroupName, serverName, recommendedElasticPoolName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -79,8 +81,9 @@ func (client RecommendedElasticPoolsClient) GetPreparer(resourceGroupName string "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -110,25 +113,25 @@ func (client RecommendedElasticPoolsClient) GetResponder(resp *http.Response) (r return } -// GetDatabases gets information about an Azure SQL database inside of an -// Azure SQL Recommended Elastic Pool. +// GetDatabases gets a database inside of a recommented elastic pool. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. -// recommendedElasticPoolName is the name of the Azure SQL Elastic Pool to be -// retrieved. databaseName is the name of the Azure SQL database to be -// retrieved. +// the portal. serverName is the name of the server. recommendedElasticPoolName +// is the name of the elastic pool to be retrieved. databaseName is the name of +// the database to be retrieved. func (client RecommendedElasticPoolsClient) GetDatabases(resourceGroupName string, serverName string, recommendedElasticPoolName string, databaseName string) (result Database, err error) { req, err := client.GetDatabasesPreparer(resourceGroupName, serverName, recommendedElasticPoolName, databaseName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "GetDatabases", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "GetDatabases", nil, "Failure preparing request") + return } resp, err := client.GetDatabasesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "GetDatabases", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "GetDatabases", resp, "Failure sending request") + return } result, err = client.GetDatabasesResponder(resp) @@ -149,8 +152,9 @@ func (client RecommendedElasticPoolsClient) GetDatabasesPreparer(resourceGroupNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -180,41 +184,44 @@ func (client RecommendedElasticPoolsClient) GetDatabasesResponder(resp *http.Res return } -// List returns information about Azure SQL Recommended Elastic Pools. +// ListByServer returns recommended elastic pools. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. -func (client RecommendedElasticPoolsClient) List(resourceGroupName string, serverName string) (result RecommendedElasticPoolListResult, err error) { - req, err := client.ListPreparer(resourceGroupName, serverName) +// the portal. serverName is the name of the server. +func (client RecommendedElasticPoolsClient) ListByServer(resourceGroupName string, serverName string) (result RecommendedElasticPoolListResult, err error) { + req, err := client.ListByServerPreparer(resourceGroupName, serverName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "ListByServer", nil, "Failure preparing request") + return } - resp, err := client.ListSender(req) + resp, err := client.ListByServerSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "ListByServer", resp, "Failure sending request") + return } - result, err = client.ListResponder(resp) + result, err = client.ListByServerResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "List", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "ListByServer", resp, "Failure responding to request") } return } -// ListPreparer prepares the List request. -func (client RecommendedElasticPoolsClient) ListPreparer(resourceGroupName string, serverName string) (*http.Request, error) { +// ListByServerPreparer prepares the ListByServer request. +func (client RecommendedElasticPoolsClient) ListByServerPreparer(resourceGroupName string, serverName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "serverName": autorest.Encode("path", serverName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -225,15 +232,15 @@ func (client RecommendedElasticPoolsClient) ListPreparer(resourceGroupName strin return preparer.Prepare(&http.Request{}) } -// ListSender sends the List request. The method will close the +// ListByServerSender sends the ListByServer request. The method will close the // http.Response Body if it receives an error. -func (client RecommendedElasticPoolsClient) ListSender(req *http.Request) (*http.Response, error) { +func (client RecommendedElasticPoolsClient) ListByServerSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// ListResponder handles the response to the List request. The method always +// ListByServerResponder handles the response to the ListByServer request. The method always // closes the http.Response Body. -func (client RecommendedElasticPoolsClient) ListResponder(resp *http.Response) (result RecommendedElasticPoolListResult, err error) { +func (client RecommendedElasticPoolsClient) ListByServerResponder(resp *http.Response) (result RecommendedElasticPoolListResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -244,24 +251,24 @@ func (client RecommendedElasticPoolsClient) ListResponder(resp *http.Response) ( return } -// ListDatabases returns information about an Azure SQL database inside of an -// Azure SQL Recommended Elastic Pool. +// ListDatabases returns a list of databases inside a recommented elastic pool. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. -// recommendedElasticPoolName is the name of the Azure SQL Recommended -// Elastic Pool to be retrieved. +// the portal. serverName is the name of the server. recommendedElasticPoolName +// is the name of the recommended elastic pool to be retrieved. func (client RecommendedElasticPoolsClient) ListDatabases(resourceGroupName string, serverName string, recommendedElasticPoolName string) (result DatabaseListResult, err error) { req, err := client.ListDatabasesPreparer(resourceGroupName, serverName, recommendedElasticPoolName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "ListDatabases", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "ListDatabases", nil, "Failure preparing request") + return } resp, err := client.ListDatabasesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "ListDatabases", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "ListDatabases", resp, "Failure sending request") + return } result, err = client.ListDatabasesResponder(resp) @@ -281,8 +288,9 @@ func (client RecommendedElasticPoolsClient) ListDatabasesPreparer(resourceGroupN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -312,23 +320,24 @@ func (client RecommendedElasticPoolsClient) ListDatabasesResponder(resp *http.Re return } -// ListMetrics returns information about an recommended elastic pool metrics. +// ListMetrics returns a recommented elastic pool metrics. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. -// recommendedElasticPoolName is the name of the Azure SQL Recommended -// Elastic Pool to be retrieved. +// the portal. serverName is the name of the server. recommendedElasticPoolName +// is the name of the recommended elastic pool to be retrieved. func (client RecommendedElasticPoolsClient) ListMetrics(resourceGroupName string, serverName string, recommendedElasticPoolName string) (result RecommendedElasticPoolListMetricsResult, err error) { req, err := client.ListMetricsPreparer(resourceGroupName, serverName, recommendedElasticPoolName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "ListMetrics", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "ListMetrics", nil, "Failure preparing request") + return } resp, err := client.ListMetricsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "ListMetrics", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "ListMetrics", resp, "Failure sending request") + return } result, err = client.ListMetricsResponder(resp) @@ -348,8 +357,9 @@ func (client RecommendedElasticPoolsClient) ListMetricsPreparer(resourceGroupNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/servers.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/servers.go old mode 100644 new mode 100755 index 11e4a35e4..83290fa93 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/servers.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/servers.go @@ -14,7 +14,7 @@ package sql // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -24,9 +24,10 @@ import ( "net/http" ) -// ServersClient is the provides create, read, update and delete functionality -// for Azure SQL resources including servers, databases, elastic pools, -// recommendations, operations, and usage metrics. +// ServersClient is the the Azure SQL Database management API provides a +// RESTful set of web services that interact with Azure SQL Database services +// to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. type ServersClient struct { ManagementClient } @@ -41,22 +42,24 @@ func NewServersClientWithBaseURI(baseURI string, subscriptionID string) ServersC return ServersClient{NewWithBaseURI(baseURI, subscriptionID)} } -// CreateOrUpdate creates a new Azure SQL server. +// CreateOrUpdate creates or updates a new server. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. parameters is -// the required parameters for creating or updating a server. +// the portal. serverName is the name of the server. parameters is the required +// parameters for creating or updating a server. func (client ServersClient) CreateOrUpdate(resourceGroupName string, serverName string, parameters Server) (result Server, err error) { req, err := client.CreateOrUpdatePreparer(resourceGroupName, serverName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.ServersClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.ServersClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.ServersClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.ServersClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -75,8 +78,9 @@ func (client ServersClient) CreateOrUpdatePreparer(resourceGroupName string, ser "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -112,17 +116,19 @@ func (client ServersClient) CreateOrUpdateResponder(resp *http.Response) (result // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. +// the portal. serverName is the name of the server. func (client ServersClient) Delete(resourceGroupName string, serverName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, serverName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.ServersClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.ServersClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "sql.ServersClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.ServersClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -141,8 +147,9 @@ func (client ServersClient) DeletePreparer(resourceGroupName string, serverName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -171,41 +178,44 @@ func (client ServersClient) DeleteResponder(resp *http.Response) (result autores return } -// GetByResourceGroup gets information about an Azure SQL server. +// Get gets a server. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. -func (client ServersClient) GetByResourceGroup(resourceGroupName string, serverName string) (result Server, err error) { - req, err := client.GetByResourceGroupPreparer(resourceGroupName, serverName) +// the portal. serverName is the name of the server. +func (client ServersClient) Get(resourceGroupName string, serverName string) (result Server, err error) { + req, err := client.GetPreparer(resourceGroupName, serverName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.ServersClient", "GetByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.ServersClient", "Get", nil, "Failure preparing request") + return } - resp, err := client.GetByResourceGroupSender(req) + resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.ServersClient", "GetByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.ServersClient", "Get", resp, "Failure sending request") + return } - result, err = client.GetByResourceGroupResponder(resp) + result, err = client.GetResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ServersClient", "GetByResourceGroup", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.ServersClient", "Get", resp, "Failure responding to request") } return } -// GetByResourceGroupPreparer prepares the GetByResourceGroup request. -func (client ServersClient) GetByResourceGroupPreparer(resourceGroupName string, serverName string) (*http.Request, error) { +// GetPreparer prepares the Get request. +func (client ServersClient) GetPreparer(resourceGroupName string, serverName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "serverName": autorest.Encode("path", serverName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -216,15 +226,15 @@ func (client ServersClient) GetByResourceGroupPreparer(resourceGroupName string, return preparer.Prepare(&http.Request{}) } -// GetByResourceGroupSender sends the GetByResourceGroup request. The method will close the +// GetSender sends the Get request. The method will close the // http.Response Body if it receives an error. -func (client ServersClient) GetByResourceGroupSender(req *http.Request) (*http.Response, error) { +func (client ServersClient) GetSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// GetByResourceGroupResponder handles the response to the GetByResourceGroup request. The method always +// GetResponder handles the response to the Get request. The method always // closes the http.Response Body. -func (client ServersClient) GetByResourceGroupResponder(resp *http.Response) (result Server, err error) { +func (client ServersClient) GetResponder(resp *http.Response) (result Server, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -235,23 +245,24 @@ func (client ServersClient) GetByResourceGroupResponder(resp *http.Response) (re return } -// GetServiceObjective gets information about an Azure SQL database Service -// Objective. +// GetServiceObjective gets a database service objective. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. -// serviceObjectiveName is the name of the service objective to retrieve. +// the portal. serverName is the name of the server. serviceObjectiveName is +// the name of the service objective to retrieve. func (client ServersClient) GetServiceObjective(resourceGroupName string, serverName string, serviceObjectiveName string) (result ServiceObjective, err error) { req, err := client.GetServiceObjectivePreparer(resourceGroupName, serverName, serviceObjectiveName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.ServersClient", "GetServiceObjective", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.ServersClient", "GetServiceObjective", nil, "Failure preparing request") + return } resp, err := client.GetServiceObjectiveSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.ServersClient", "GetServiceObjective", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.ServersClient", "GetServiceObjective", resp, "Failure sending request") + return } result, err = client.GetServiceObjectiveResponder(resp) @@ -271,8 +282,9 @@ func (client ServersClient) GetServiceObjectivePreparer(resourceGroupName string "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -302,17 +314,19 @@ func (client ServersClient) GetServiceObjectiveResponder(resp *http.Response) (r return } -// List returns information about an Azure SQL server. +// List returns a list of servers. func (client ServersClient) List() (result ServerListResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "sql.ServersClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.ServersClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.ServersClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.ServersClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -329,8 +343,9 @@ func (client ServersClient) ListPreparer() (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -360,7 +375,7 @@ func (client ServersClient) ListResponder(resp *http.Response) (result ServerLis return } -// ListByResourceGroup returns information about an Azure SQL server. +// ListByResourceGroup returns a list of servers in a resource group. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or @@ -368,13 +383,15 @@ func (client ServersClient) ListResponder(resp *http.Response) (result ServerLis func (client ServersClient) ListByResourceGroup(resourceGroupName string) (result ServerListResult, err error) { req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.ServersClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.ServersClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.ServersClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.ServersClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -392,8 +409,9 @@ func (client ServersClient) ListByResourceGroupPreparer(resourceGroupName string "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -423,22 +441,23 @@ func (client ServersClient) ListByResourceGroupResponder(resp *http.Response) (r return } -// ListServiceObjectives returns information about Azure SQL database Service -// Objectives. +// ListServiceObjectives returns database service objectives. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. +// the portal. serverName is the name of the server. func (client ServersClient) ListServiceObjectives(resourceGroupName string, serverName string) (result ServiceObjectiveListResult, err error) { req, err := client.ListServiceObjectivesPreparer(resourceGroupName, serverName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.ServersClient", "ListServiceObjectives", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.ServersClient", "ListServiceObjectives", nil, "Failure preparing request") + return } resp, err := client.ListServiceObjectivesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.ServersClient", "ListServiceObjectives", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.ServersClient", "ListServiceObjectives", resp, "Failure sending request") + return } result, err = client.ListServiceObjectivesResponder(resp) @@ -457,8 +476,9 @@ func (client ServersClient) ListServiceObjectivesPreparer(resourceGroupName stri "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -488,21 +508,23 @@ func (client ServersClient) ListServiceObjectivesResponder(resp *http.Response) return } -// ListUsages returns information about Azure SQL server usage. +// ListUsages returns server usages. // // resourceGroupName is the name of the resource group that contains the // resource. You can obtain this value from the Azure Resource Manager API or -// the portal. serverName is the name of the Azure SQL server. +// the portal. serverName is the name of the server. func (client ServersClient) ListUsages(resourceGroupName string, serverName string) (result ServerMetricListResult, err error) { req, err := client.ListUsagesPreparer(resourceGroupName, serverName) if err != nil { - return result, autorest.NewErrorWithError(err, "sql.ServersClient", "ListUsages", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "sql.ServersClient", "ListUsages", nil, "Failure preparing request") + return } resp, err := client.ListUsagesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.ServersClient", "ListUsages", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "sql.ServersClient", "ListUsages", resp, "Failure sending request") + return } result, err = client.ListUsagesResponder(resp) @@ -521,8 +543,9 @@ func (client ServersClient) ListUsagesPreparer(resourceGroupName string, serverN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2014-04-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/version.go old mode 100644 new mode 100755 index 2fabb4531..37edb9716 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/version.go @@ -18,43 +18,12 @@ package sql // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -import ( - "bytes" - "fmt" - "strings" -) - -const ( - major = "8" - minor = "1" - patch = "0" - tag = "beta" - userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" -) - -// cached results of UserAgent and Version to prevent repeated operations. -var ( - userAgent string - version string -) - // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - if userAgent == "" { - userAgent = fmt.Sprintf(userAgentFormat, Version(), "sql", "2014-04-01") - } - return userAgent + return "Azure-SDK-For-Go/v10.0.2-beta arm-sql/" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - if version == "" { - versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) - if tag != "" { - versionBuilder.WriteRune('-') - versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) - } - version = string(versionBuilder.Bytes()) - } - return version + return "v10.0.2-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/accounts.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/accounts.go old mode 100644 new mode 100755 index 24e346465..f0606ac13 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/accounts.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/accounts.go @@ -14,7 +14,7 @@ package storage // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -25,7 +25,7 @@ import ( "net/http" ) -// AccountsClient is the the Storage Management Client. +// AccountsClient is the the Azure Storage Management API. type AccountsClient struct { ManagementClient } @@ -44,9 +44,9 @@ func NewAccountsClientWithBaseURI(baseURI string, subscriptionID string) Account // CheckNameAvailability checks that the storage account name is valid and is // not already in use. // -// accountName is the name of the storage account within the specified -// resource group. Storage account names must be between 3 and 24 characters -// in length and use numbers and lower-case letters only. +// accountName is the name of the storage account within the specified resource +// group. Storage account names must be between 3 and 24 characters in length +// and use numbers and lower-case letters only. func (client AccountsClient) CheckNameAvailability(accountName AccountCheckNameAvailabilityParameters) (result CheckNameAvailabilityResult, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: accountName, @@ -57,13 +57,15 @@ func (client AccountsClient) CheckNameAvailability(accountName AccountCheckNameA req, err := client.CheckNameAvailabilityPreparer(accountName) if err != nil { - return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "CheckNameAvailability", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "CheckNameAvailability", nil, "Failure preparing request") + return } resp, err := client.CheckNameAvailabilitySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "CheckNameAvailability", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "CheckNameAvailability", resp, "Failure sending request") + return } result, err = client.CheckNameAvailabilityResponder(resp) @@ -80,8 +82,9 @@ func (client AccountsClient) CheckNameAvailabilityPreparer(accountName AccountCh "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-12-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -114,21 +117,28 @@ func (client AccountsClient) CheckNameAvailabilityResponder(resp *http.Response) } // Create asynchronously creates a new storage account with the specified -// parameters. If an account is already created and a subsequent create -// request is issued with different properties, the account properties will -// be updated. If an account is already created and a subsequent create or -// update request is issued with the exact same set of properties, the -// request will succeed. This method may poll for completion. Polling can be -// canceled by passing the cancel channel argument. The channel will be used -// to cancel polling and any outstanding HTTP requests. +// parameters. If an account is already created and a subsequent create request +// is issued with different properties, the account properties will be updated. +// If an account is already created and a subsequent create or update request +// is issued with the exact same set of properties, the request will succeed. +// This method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. // // resourceGroupName is the name of the resource group within the user's -// subscription. accountName is the name of the storage account within the -// specified resource group. Storage account names must be between 3 and 24 -// characters in length and use numbers and lower-case letters only. -// parameters is the parameters to provide for the created account. -func (client AccountsClient) Create(resourceGroupName string, accountName string, parameters AccountCreateParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +// subscription. The name is case insensitive. accountName is the name of the +// storage account within the specified resource group. Storage account names +// must be between 3 and 24 characters in length and use numbers and lower-case +// letters only. parameters is the parameters to provide for the created +// account. +func (client AccountsClient) Create(resourceGroupName string, accountName string, parameters AccountCreateParameters, cancel <-chan struct{}) (<-chan Account, <-chan error) { + resultChan := make(chan Account, 1) + errChan := make(chan error, 1) 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: accountName, Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, @@ -141,26 +151,40 @@ func (client AccountsClient) Create(resourceGroupName string, accountName string {Target: "parameters.AccountPropertiesCreateParameters.Encryption", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.AccountPropertiesCreateParameters.Encryption.KeySource", Name: validation.Null, Rule: true, Chain: nil}}}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "storage.AccountsClient", "Create") + errChan <- validation.NewErrorWithValidationError(err, "storage.AccountsClient", "Create") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreatePreparer(resourceGroupName, accountName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "Create", nil, "Failure preparing request") - } + go func() { + var err error + var result Account + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(resourceGroupName, accountName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Create", nil, "Failure preparing request") + return + } - resp, err := client.CreateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "Create", resp, "Failure sending request") - } + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Create", resp, "Failure sending request") + return + } - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Create", resp, "Failure responding to request") - } - - return + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreatePreparer prepares the Create request. @@ -171,8 +195,9 @@ func (client AccountsClient) CreatePreparer(resourceGroupName string, accountNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-12-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -195,24 +220,30 @@ func (client AccountsClient) CreateSender(req *http.Request) (*http.Response, er // CreateResponder handles the response to the Create request. The method always // closes the http.Response Body. -func (client AccountsClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client AccountsClient) CreateResponder(resp *http.Response) (result Account, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } // Delete deletes a storage account in Microsoft Azure. // // resourceGroupName is the name of the resource group within the user's -// subscription. accountName is the name of the storage account within the -// specified resource group. Storage account names must be between 3 and 24 -// characters in length and use numbers and lower-case letters only. +// subscription. The name is case insensitive. accountName is the name of the +// storage account within the specified resource group. Storage account names +// must be between 3 and 24 characters in length and use numbers and lower-case +// letters only. func (client AccountsClient) Delete(resourceGroupName string, accountName 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: accountName, Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { @@ -221,13 +252,15 @@ func (client AccountsClient) Delete(resourceGroupName string, accountName string req, err := client.DeletePreparer(resourceGroupName, accountName) if err != nil { - return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -246,8 +279,9 @@ func (client AccountsClient) DeletePreparer(resourceGroupName string, accountNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-12-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -281,11 +315,16 @@ func (client AccountsClient) DeleteResponder(resp *http.Response) (result autore // The ListKeys operation should be used to retrieve storage keys. // // resourceGroupName is the name of the resource group within the user's -// subscription. accountName is the name of the storage account within the -// specified resource group. Storage account names must be between 3 and 24 -// characters in length and use numbers and lower-case letters only. +// subscription. The name is case insensitive. accountName is the name of the +// storage account within the specified resource group. Storage account names +// must be between 3 and 24 characters in length and use numbers and lower-case +// letters only. func (client AccountsClient) GetProperties(resourceGroupName string, accountName string) (result Account, 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: accountName, Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { @@ -294,13 +333,15 @@ func (client AccountsClient) GetProperties(resourceGroupName string, accountName req, err := client.GetPropertiesPreparer(resourceGroupName, accountName) if err != nil { - return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "GetProperties", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "GetProperties", nil, "Failure preparing request") + return } resp, err := client.GetPropertiesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "GetProperties", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "GetProperties", resp, "Failure sending request") + return } result, err = client.GetPropertiesResponder(resp) @@ -319,8 +360,9 @@ func (client AccountsClient) GetPropertiesPreparer(resourceGroupName string, acc "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-12-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -355,13 +397,15 @@ func (client AccountsClient) GetPropertiesResponder(resp *http.Response) (result func (client AccountsClient) List() (result AccountListResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -378,8 +422,9 @@ func (client AccountsClient) ListPreparer() (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-12-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -409,22 +454,117 @@ func (client AccountsClient) ListResponder(resp *http.Response) (result AccountL return } -// ListByResourceGroup lists all the storage accounts available under the -// given resource group. Note that storage keys are not returned; use the -// ListKeys operation for this. +// ListAccountSAS list SAS credentials of a storage account. // // resourceGroupName is the name of the resource group within the user's -// subscription. +// subscription. The name is case insensitive. accountName is the name of the +// storage account within the specified resource group. Storage account names +// must be between 3 and 24 characters in length and use numbers and lower-case +// letters only. parameters is the parameters to provide to list SAS +// credentials for the storage account. +func (client AccountsClient) ListAccountSAS(resourceGroupName string, accountName string, parameters AccountSasParameters) (result ListAccountSasResponse, 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: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.SharedAccessExpiryTime", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storage.AccountsClient", "ListAccountSAS") + } + + req, err := client.ListAccountSASPreparer(resourceGroupName, accountName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListAccountSAS", nil, "Failure preparing request") + return + } + + resp, err := client.ListAccountSASSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListAccountSAS", resp, "Failure sending request") + return + } + + result, err = client.ListAccountSASResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListAccountSAS", resp, "Failure responding to request") + } + + return +} + +// ListAccountSASPreparer prepares the ListAccountSAS request. +func (client AccountsClient) ListAccountSASPreparer(resourceGroupName string, accountName string, parameters AccountSasParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-12-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListAccountSASSender sends the ListAccountSAS request. The method will close the +// http.Response Body if it receives an error. +func (client AccountsClient) ListAccountSASSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListAccountSASResponder handles the response to the ListAccountSAS request. The method always +// closes the http.Response Body. +func (client AccountsClient) ListAccountSASResponder(resp *http.Response) (result ListAccountSasResponse, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup lists all the storage accounts available under the given +// resource group. Note that storage keys are not returned; use the ListKeys +// operation for this. +// +// resourceGroupName is the name of the resource group within the user's +// subscription. The name is case insensitive. func (client AccountsClient) ListByResourceGroup(resourceGroupName string) (result AccountListResult, 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.NewErrorWithValidationError(err, "storage.AccountsClient", "ListByResourceGroup") + } + req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -442,8 +582,9 @@ func (client AccountsClient) ListByResourceGroupPreparer(resourceGroupName strin "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-12-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -476,11 +617,16 @@ func (client AccountsClient) ListByResourceGroupResponder(resp *http.Response) ( // ListKeys lists the access keys for the specified storage account. // // resourceGroupName is the name of the resource group within the user's -// subscription. accountName is the name of the storage account within the -// specified resource group. Storage account names must be between 3 and 24 -// characters in length and use numbers and lower-case letters only. +// subscription. The name is case insensitive. accountName is the name of the +// storage account within the specified resource group. Storage account names +// must be between 3 and 24 characters in length and use numbers and lower-case +// letters only. func (client AccountsClient) ListKeys(resourceGroupName string, accountName string) (result AccountListKeysResult, 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: accountName, Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { @@ -489,13 +635,15 @@ func (client AccountsClient) ListKeys(resourceGroupName string, accountName stri req, err := client.ListKeysPreparer(resourceGroupName, accountName) if err != nil { - return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "ListKeys", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListKeys", nil, "Failure preparing request") + return } resp, err := client.ListKeysSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "ListKeys", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListKeys", resp, "Failure sending request") + return } result, err = client.ListKeysResponder(resp) @@ -514,8 +662,9 @@ func (client AccountsClient) ListKeysPreparer(resourceGroupName string, accountN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-12-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -545,17 +694,108 @@ func (client AccountsClient) ListKeysResponder(resp *http.Response) (result Acco return } +// ListServiceSAS list service SAS credentials of a specific resource. +// +// resourceGroupName is the name of the resource group within the user's +// subscription. The name is case insensitive. accountName is the name of the +// storage account within the specified resource group. Storage account names +// must be between 3 and 24 characters in length and use numbers and lower-case +// letters only. parameters is the parameters to provide to list service SAS +// credentials. +func (client AccountsClient) ListServiceSAS(resourceGroupName string, accountName string, parameters ServiceSasParameters) (result ListServiceSasResponse, 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: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.CanonicalizedResource", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Identifier", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Identifier", Name: validation.MaxLength, Rule: 64, Chain: nil}}}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storage.AccountsClient", "ListServiceSAS") + } + + req, err := client.ListServiceSASPreparer(resourceGroupName, accountName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListServiceSAS", nil, "Failure preparing request") + return + } + + resp, err := client.ListServiceSASSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListServiceSAS", resp, "Failure sending request") + return + } + + result, err = client.ListServiceSASResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListServiceSAS", resp, "Failure responding to request") + } + + return +} + +// ListServiceSASPreparer prepares the ListServiceSAS request. +func (client AccountsClient) ListServiceSASPreparer(resourceGroupName string, accountName string, parameters ServiceSasParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-12-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListServiceSASSender sends the ListServiceSAS request. The method will close the +// http.Response Body if it receives an error. +func (client AccountsClient) ListServiceSASSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListServiceSASResponder handles the response to the ListServiceSAS request. The method always +// closes the http.Response Body. +func (client AccountsClient) ListServiceSASResponder(resp *http.Response) (result ListServiceSasResponse, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // RegenerateKey regenerates one of the access keys for the specified storage // account. // // resourceGroupName is the name of the resource group within the user's -// subscription. accountName is the name of the storage account within the -// specified resource group. Storage account names must be between 3 and 24 -// characters in length and use numbers and lower-case letters only. -// regenerateKey is specifies name of the key which should be regenerated -- -// key1 or key2. +// subscription. The name is case insensitive. accountName is the name of the +// storage account within the specified resource group. Storage account names +// must be between 3 and 24 characters in length and use numbers and lower-case +// letters only. regenerateKey is specifies name of the key which should be +// regenerated -- key1 or key2. func (client AccountsClient) RegenerateKey(resourceGroupName string, accountName string, regenerateKey AccountRegenerateKeyParameters) (result AccountListKeysResult, 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: accountName, Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, @@ -566,13 +806,15 @@ func (client AccountsClient) RegenerateKey(resourceGroupName string, accountName req, err := client.RegenerateKeyPreparer(resourceGroupName, accountName, regenerateKey) if err != nil { - return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "RegenerateKey", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "RegenerateKey", nil, "Failure preparing request") + return } resp, err := client.RegenerateKeySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "RegenerateKey", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "RegenerateKey", resp, "Failure sending request") + return } result, err = client.RegenerateKeyResponder(resp) @@ -591,8 +833,9 @@ func (client AccountsClient) RegenerateKeyPreparer(resourceGroupName string, acc "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-12-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -626,22 +869,27 @@ func (client AccountsClient) RegenerateKeyResponder(resp *http.Response) (result // Update the update operation can be used to update the SKU, encryption, // access tier, or tags for a storage account. It can also be used to map the -// account to a custom domain. Only one custom domain is supported per -// storage account; the replacement/change of custom domain is not supported. -// In order to replace an old custom domain, the old value must be -// cleared/unregistered before a new value can be set. The update of multiple -// properties is supported. This call does not change the storage keys for -// the account. If you want to change the storage account keys, use the -// regenerate keys operation. The location and name of the storage account -// cannot be changed after creation. +// account to a custom domain. Only one custom domain is supported per storage +// account; the replacement/change of custom domain is not supported. In order +// to replace an old custom domain, the old value must be cleared/unregistered +// before a new value can be set. The update of multiple properties is +// supported. This call does not change the storage keys for the account. If +// you want to change the storage account keys, use the regenerate keys +// operation. The location and name of the storage account cannot be changed +// after creation. // // resourceGroupName is the name of the resource group within the user's -// subscription. accountName is the name of the storage account within the -// specified resource group. Storage account names must be between 3 and 24 -// characters in length and use numbers and lower-case letters only. -// parameters is the parameters to provide for the updated account. +// subscription. The name is case insensitive. accountName is the name of the +// storage account within the specified resource group. Storage account names +// must be between 3 and 24 characters in length and use numbers and lower-case +// letters only. parameters is the parameters to provide for the updated +// account. func (client AccountsClient) Update(resourceGroupName string, accountName string, parameters AccountUpdateParameters) (result Account, 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: accountName, Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { @@ -650,13 +898,15 @@ func (client AccountsClient) Update(resourceGroupName string, accountName string req, err := client.UpdatePreparer(resourceGroupName, accountName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -675,8 +925,9 @@ func (client AccountsClient) UpdatePreparer(resourceGroupName string, accountNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-12-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/client.go old mode 100644 new mode 100755 index 68708dbf2..a537bdd25 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/client.go @@ -1,7 +1,7 @@ // Package storage implements the Azure ARM Storage service API version -// 2016-01-01. +// 2016-12-01. // -// The Storage Management Client. +// The Azure Storage Management API. package storage // Copyright (c) Microsoft and contributors. All rights reserved. @@ -18,7 +18,7 @@ package storage // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -27,9 +27,6 @@ import ( ) const ( - // APIVersion is the version of the Storage - APIVersion = "2016-01-01" - // DefaultBaseURI is the default URI used for the service Storage DefaultBaseURI = "https://management.azure.com" ) @@ -38,7 +35,6 @@ const ( type ManagementClient struct { autorest.Client BaseURI string - APIVersion string SubscriptionID string } @@ -52,7 +48,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, - APIVersion: APIVersion, SubscriptionID: subscriptionID, } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/models.go old mode 100644 new mode 100755 index bff65ec6e..2e2030184 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/models.go @@ -14,7 +14,7 @@ package storage // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -38,19 +38,29 @@ type AccountStatus string const ( // Available specifies the available state for account status. - Available AccountStatus = "Available" + Available AccountStatus = "available" // Unavailable specifies the unavailable state for account status. - Unavailable AccountStatus = "Unavailable" + Unavailable AccountStatus = "unavailable" +) + +// HTTPProtocol enumerates the values for http protocol. +type HTTPProtocol string + +const ( + // HTTPS specifies the https state for http protocol. + HTTPS HTTPProtocol = "https" + // Httpshttp specifies the httpshttp state for http protocol. + Httpshttp HTTPProtocol = "https,http" ) // KeyPermission enumerates the values for key permission. type KeyPermission string const ( - // FULL specifies the full state for key permission. - FULL KeyPermission = "FULL" - // READ specifies the read state for key permission. - READ KeyPermission = "READ" + // Full specifies the full state for key permission. + Full KeyPermission = "Full" + // Read specifies the read state for key permission. + Read KeyPermission = "Read" ) // Kind enumerates the values for kind. @@ -63,6 +73,50 @@ const ( Storage Kind = "Storage" ) +// Permissions enumerates the values for permissions. +type Permissions string + +const ( + // A specifies the a state for permissions. + A Permissions = "a" + // C specifies the c state for permissions. + C Permissions = "c" + // D specifies the d state for permissions. + D Permissions = "d" + // L specifies the l state for permissions. + L Permissions = "l" + // P specifies the p state for permissions. + P Permissions = "p" + // R specifies the r state for permissions. + R Permissions = "r" + // U specifies the u state for permissions. + U Permissions = "u" + // W specifies the w state for permissions. + W Permissions = "w" +) + +// Permissions1 enumerates the values for permissions 1. +type Permissions1 string + +const ( + // Permissions1A specifies the permissions 1a state for permissions 1. + Permissions1A Permissions1 = "a" + // Permissions1C specifies the permissions 1c state for permissions 1. + Permissions1C Permissions1 = "c" + // Permissions1D specifies the permissions 1d state for permissions 1. + Permissions1D Permissions1 = "d" + // Permissions1L specifies the permissions 1l state for permissions 1. + Permissions1L Permissions1 = "l" + // Permissions1P specifies the permissions 1p state for permissions 1. + Permissions1P Permissions1 = "p" + // Permissions1R specifies the permissions 1r state for permissions 1. + Permissions1R Permissions1 = "r" + // Permissions1U specifies the permissions 1u state for permissions 1. + Permissions1U Permissions1 = "u" + // Permissions1W specifies the permissions 1w state for permissions 1. + Permissions1W Permissions1 = "w" +) + // ProvisioningState enumerates the values for provisioning state. type ProvisioningState string @@ -85,6 +139,46 @@ const ( AlreadyExists Reason = "AlreadyExists" ) +// ResourceEnum enumerates the values for resource enum. +type ResourceEnum string + +const ( + // ResourceEnumB specifies the resource enum b state for resource enum. + ResourceEnumB ResourceEnum = "b" + // ResourceEnumC specifies the resource enum c state for resource enum. + ResourceEnumC ResourceEnum = "c" + // ResourceEnumF specifies the resource enum f state for resource enum. + ResourceEnumF ResourceEnum = "f" + // ResourceEnumS specifies the resource enum s state for resource enum. + ResourceEnumS ResourceEnum = "s" +) + +// ResourceTypes enumerates the values for resource types. +type ResourceTypes string + +const ( + // ResourceTypesC specifies the resource types c state for resource types. + ResourceTypesC ResourceTypes = "c" + // ResourceTypesO specifies the resource types o state for resource types. + ResourceTypesO ResourceTypes = "o" + // ResourceTypesS specifies the resource types s state for resource types. + ResourceTypesS ResourceTypes = "s" +) + +// Services enumerates the values for services. +type Services string + +const ( + // B specifies the b state for services. + B Services = "b" + // F specifies the f state for services. + F Services = "f" + // Q specifies the q state for services. + Q Services = "q" + // T specifies the t state for services. + T Services = "t" +) + // SkuName enumerates the values for sku name. type SkuName string @@ -142,7 +236,8 @@ type Account struct { *AccountProperties `json:"properties,omitempty"` } -// AccountCheckNameAvailabilityParameters is +// AccountCheckNameAvailabilityParameters is the parameters used to check the +// availabity of the storage account name. type AccountCheckNameAvailabilityParameters struct { Name *string `json:"name,omitempty"` Type *string `json:"type,omitempty"` @@ -177,43 +272,62 @@ type AccountListResult struct { Value *[]Account `json:"value,omitempty"` } -// AccountProperties is +// AccountProperties is properties of the storage account. type AccountProperties struct { - ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` - PrimaryEndpoints *Endpoints `json:"primaryEndpoints,omitempty"` - PrimaryLocation *string `json:"primaryLocation,omitempty"` - StatusOfPrimary AccountStatus `json:"statusOfPrimary,omitempty"` - LastGeoFailoverTime *date.Time `json:"lastGeoFailoverTime,omitempty"` - SecondaryLocation *string `json:"secondaryLocation,omitempty"` - StatusOfSecondary AccountStatus `json:"statusOfSecondary,omitempty"` - CreationTime *date.Time `json:"creationTime,omitempty"` - CustomDomain *CustomDomain `json:"customDomain,omitempty"` - SecondaryEndpoints *Endpoints `json:"secondaryEndpoints,omitempty"` - Encryption *Encryption `json:"encryption,omitempty"` - AccessTier AccessTier `json:"accessTier,omitempty"` + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + PrimaryEndpoints *Endpoints `json:"primaryEndpoints,omitempty"` + PrimaryLocation *string `json:"primaryLocation,omitempty"` + StatusOfPrimary AccountStatus `json:"statusOfPrimary,omitempty"` + LastGeoFailoverTime *date.Time `json:"lastGeoFailoverTime,omitempty"` + SecondaryLocation *string `json:"secondaryLocation,omitempty"` + StatusOfSecondary AccountStatus `json:"statusOfSecondary,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + CustomDomain *CustomDomain `json:"customDomain,omitempty"` + SecondaryEndpoints *Endpoints `json:"secondaryEndpoints,omitempty"` + Encryption *Encryption `json:"encryption,omitempty"` + AccessTier AccessTier `json:"accessTier,omitempty"` + EnableHTTPSTrafficOnly *bool `json:"supportsHttpsTrafficOnly,omitempty"` } -// AccountPropertiesCreateParameters is +// AccountPropertiesCreateParameters is the parameters used to create the +// storage account. type AccountPropertiesCreateParameters struct { - CustomDomain *CustomDomain `json:"customDomain,omitempty"` - Encryption *Encryption `json:"encryption,omitempty"` - AccessTier AccessTier `json:"accessTier,omitempty"` + CustomDomain *CustomDomain `json:"customDomain,omitempty"` + Encryption *Encryption `json:"encryption,omitempty"` + AccessTier AccessTier `json:"accessTier,omitempty"` + EnableHTTPSTrafficOnly *bool `json:"supportsHttpsTrafficOnly,omitempty"` } -// AccountPropertiesUpdateParameters is +// AccountPropertiesUpdateParameters is the parameters used when updating a +// storage account. type AccountPropertiesUpdateParameters struct { - CustomDomain *CustomDomain `json:"customDomain,omitempty"` - Encryption *Encryption `json:"encryption,omitempty"` - AccessTier AccessTier `json:"accessTier,omitempty"` + CustomDomain *CustomDomain `json:"customDomain,omitempty"` + Encryption *Encryption `json:"encryption,omitempty"` + AccessTier AccessTier `json:"accessTier,omitempty"` + EnableHTTPSTrafficOnly *bool `json:"supportsHttpsTrafficOnly,omitempty"` } -// AccountRegenerateKeyParameters is +// AccountRegenerateKeyParameters is the parameters used to regenerate the +// storage account key. type AccountRegenerateKeyParameters struct { KeyName *string `json:"keyName,omitempty"` } -// AccountUpdateParameters is the parameters that can be provided when -// updating the storage account properties. +// AccountSasParameters is the parameters to list SAS credentials of a storage +// account. +type AccountSasParameters struct { + Services Services `json:"signedServices,omitempty"` + ResourceTypes ResourceTypes `json:"signedResourceTypes,omitempty"` + Permissions Permissions `json:"signedPermission,omitempty"` + IPAddressOrRange *string `json:"signedIp,omitempty"` + Protocols HTTPProtocol `json:"signedProtocol,omitempty"` + SharedAccessStartTime *date.Time `json:"signedStart,omitempty"` + SharedAccessExpiryTime *date.Time `json:"signedExpiry,omitempty"` + KeyToSign *string `json:"keyToSign,omitempty"` +} + +// AccountUpdateParameters is the parameters that can be provided when updating +// the storage account properties. type AccountUpdateParameters struct { Sku *Sku `json:"sku,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` @@ -228,8 +342,8 @@ type CheckNameAvailabilityResult struct { Message *string `json:"message,omitempty"` } -// CustomDomain is the custom domain assigned to this storage account. This -// can be set via Update. +// CustomDomain is the custom domain assigned to this storage account. This can +// be set via Update. type CustomDomain struct { Name *string `json:"name,omitempty"` UseSubDomain *bool `json:"useSubDomain,omitempty"` @@ -250,11 +364,14 @@ type EncryptionService struct { // EncryptionServices is a list of services that support encryption. type EncryptionServices struct { - Blob *EncryptionService `json:"blob,omitempty"` + Blob *EncryptionService `json:"blob,omitempty"` + File *EncryptionService `json:"file,omitempty"` + Table *EncryptionService `json:"table,omitempty"` + Queue *EncryptionService `json:"queue,omitempty"` } -// Endpoints is the URIs that are used to perform a retrieval of a public -// blob, queue, or table object. +// Endpoints is the URIs that are used to perform a retrieval of a public blob, +// queue, or table object. type Endpoints struct { Blob *string `json:"blob,omitempty"` Queue *string `json:"queue,omitempty"` @@ -262,7 +379,20 @@ type Endpoints struct { File *string `json:"file,omitempty"` } -// Resource is +// ListAccountSasResponse is the List SAS credentials operation response. +type ListAccountSasResponse struct { + autorest.Response `json:"-"` + AccountSasToken *string `json:"accountSasToken,omitempty"` +} + +// ListServiceSasResponse is the List service SAS credentials operation +// response. +type ListServiceSasResponse struct { + autorest.Response `json:"-"` + ServiceSasToken *string `json:"serviceSasToken,omitempty"` +} + +// Resource is describes a storage resource. type Resource struct { ID *string `json:"id,omitempty"` Name *string `json:"name,omitempty"` @@ -271,6 +401,29 @@ type Resource struct { Tags *map[string]*string `json:"tags,omitempty"` } +// ServiceSasParameters is the parameters to list service SAS credentials of a +// speicific resource. +type ServiceSasParameters struct { + CanonicalizedResource *string `json:"canonicalizedResource,omitempty"` + Resource Resource `json:"signedResource,omitempty"` + Permissions Permissions `json:"signedPermission,omitempty"` + IPAddressOrRange *string `json:"signedIp,omitempty"` + Protocols HTTPProtocol `json:"signedProtocol,omitempty"` + SharedAccessStartTime *date.Time `json:"signedStart,omitempty"` + SharedAccessExpiryTime *date.Time `json:"signedExpiry,omitempty"` + Identifier *string `json:"signedIdentifier,omitempty"` + PartitionKeyStart *string `json:"startPk,omitempty"` + PartitionKeyEnd *string `json:"endPk,omitempty"` + RowKeyStart *string `json:"startRk,omitempty"` + RowKeyEnd *string `json:"endRk,omitempty"` + KeyToSign *string `json:"keyToSign,omitempty"` + CacheControl *string `json:"rscc,omitempty"` + ContentDisposition *string `json:"rscd,omitempty"` + ContentEncoding *string `json:"rsce,omitempty"` + ContentLanguage *string `json:"rscl,omitempty"` + ContentType *string `json:"rsct,omitempty"` +} + // Sku is the SKU of the storage account. type Sku struct { Name SkuName `json:"name,omitempty"` diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/usageoperations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/usage.go old mode 100644 new mode 100755 similarity index 60% rename from vendor/github.com/Azure/azure-sdk-for-go/arm/storage/usageoperations.go rename to vendor/github.com/Azure/azure-sdk-for-go/arm/storage/usage.go index 866efc9c3..b12a6d315 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/usageoperations.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/usage.go @@ -14,7 +14,7 @@ package storage // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -24,53 +24,54 @@ import ( "net/http" ) -// UsageOperationsClient is the the Storage Management Client. -type UsageOperationsClient struct { +// UsageClient is the the Azure Storage Management API. +type UsageClient struct { ManagementClient } -// NewUsageOperationsClient creates an instance of the UsageOperationsClient -// client. -func NewUsageOperationsClient(subscriptionID string) UsageOperationsClient { - return NewUsageOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +// NewUsageClient creates an instance of the UsageClient client. +func NewUsageClient(subscriptionID string) UsageClient { + return NewUsageClientWithBaseURI(DefaultBaseURI, subscriptionID) } -// NewUsageOperationsClientWithBaseURI creates an instance of the -// UsageOperationsClient client. -func NewUsageOperationsClientWithBaseURI(baseURI string, subscriptionID string) UsageOperationsClient { - return UsageOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +// NewUsageClientWithBaseURI creates an instance of the UsageClient client. +func NewUsageClientWithBaseURI(baseURI string, subscriptionID string) UsageClient { + return UsageClient{NewWithBaseURI(baseURI, subscriptionID)} } // List gets the current usage count and the limit for the resources under the // subscription. -func (client UsageOperationsClient) List() (result UsageListResult, err error) { +func (client UsageClient) List() (result UsageListResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "storage.UsageOperationsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "storage.UsageClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "storage.UsageOperationsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "storage.UsageClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "storage.UsageOperationsClient", "List", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "storage.UsageClient", "List", resp, "Failure responding to request") } return } // ListPreparer prepares the List request. -func (client UsageOperationsClient) ListPreparer() (*http.Request, error) { +func (client UsageClient) ListPreparer() (*http.Request, error) { pathParameters := map[string]interface{}{ "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-12-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -83,13 +84,13 @@ func (client UsageOperationsClient) ListPreparer() (*http.Request, error) { // ListSender sends the List request. The method will close the // http.Response Body if it receives an error. -func (client UsageOperationsClient) ListSender(req *http.Request) (*http.Response, error) { +func (client UsageClient) ListSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } // ListResponder handles the response to the List request. The method always // closes the http.Response Body. -func (client UsageOperationsClient) ListResponder(resp *http.Response) (result UsageListResult, err error) { +func (client UsageClient) ListResponder(resp *http.Response) (result UsageListResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/version.go old mode 100644 new mode 100755 index 3cfedcdab..ac97c159f --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/version.go @@ -18,43 +18,12 @@ package storage // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -import ( - "bytes" - "fmt" - "strings" -) - -const ( - major = "8" - minor = "1" - patch = "0" - tag = "beta" - userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" -) - -// cached results of UserAgent and Version to prevent repeated operations. -var ( - userAgent string - version string -) - // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - if userAgent == "" { - userAgent = fmt.Sprintf(userAgentFormat, Version(), "storage", "2016-01-01") - } - return userAgent + return "Azure-SDK-For-Go/v10.0.2-beta arm-storage/2016-12-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - if version == "" { - versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) - if tag != "" { - versionBuilder.WriteRune('-') - versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) - } - version = string(versionBuilder.Bytes()) - } - return version + return "v10.0.2-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/client.go old mode 100644 new mode 100755 index 6e481cbf0..332f0addc --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/client.go @@ -27,9 +27,6 @@ import ( ) const ( - // APIVersion is the version of the Trafficmanager - APIVersion = "2015-11-01" - // DefaultBaseURI is the default URI used for the service Trafficmanager DefaultBaseURI = "https://management.azure.com" ) @@ -38,7 +35,6 @@ const ( type ManagementClient struct { autorest.Client BaseURI string - APIVersion string SubscriptionID string } @@ -52,7 +48,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, - APIVersion: APIVersion, SubscriptionID: subscriptionID, } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/endpoints.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/endpoints.go old mode 100644 new mode 100755 index 6a496e85c..cb88fa57c --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/endpoints.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/endpoints.go @@ -52,13 +52,15 @@ func NewEndpointsClientWithBaseURI(baseURI string, subscriptionID string) Endpoi func (client EndpointsClient) CreateOrUpdate(resourceGroupName string, profileName string, endpointType string, endpointName string, parameters Endpoint) (result Endpoint, err error) { req, err := client.CreateOrUpdatePreparer(resourceGroupName, profileName, endpointType, endpointName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -79,8 +81,9 @@ func (client EndpointsClient) CreateOrUpdatePreparer(resourceGroupName string, p "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-11-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -122,13 +125,15 @@ func (client EndpointsClient) CreateOrUpdateResponder(resp *http.Response) (resu func (client EndpointsClient) Delete(resourceGroupName string, profileName string, endpointType string, endpointName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, profileName, endpointType, endpointName) if err != nil { - return result, autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -149,8 +154,9 @@ func (client EndpointsClient) DeletePreparer(resourceGroupName string, profileNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-11-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -188,13 +194,15 @@ func (client EndpointsClient) DeleteResponder(resp *http.Response) (result autor func (client EndpointsClient) Get(resourceGroupName string, profileName string, endpointType string, endpointName string) (result Endpoint, err error) { req, err := client.GetPreparer(resourceGroupName, profileName, endpointType, endpointName) if err != nil { - return result, autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -215,8 +223,9 @@ func (client EndpointsClient) GetPreparer(resourceGroupName string, profileName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-11-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -257,13 +266,15 @@ func (client EndpointsClient) GetResponder(resp *http.Response) (result Endpoint func (client EndpointsClient) Update(resourceGroupName string, profileName string, endpointType string, endpointName string, parameters Endpoint) (result Endpoint, err error) { req, err := client.UpdatePreparer(resourceGroupName, profileName, endpointType, endpointName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -284,8 +295,9 @@ func (client EndpointsClient) UpdatePreparer(resourceGroupName string, profileNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-11-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/models.go old mode 100644 new mode 100755 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/profiles.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/profiles.go old mode 100644 new mode 100755 index 8550c9369..b1e2859d9 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/profiles.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/profiles.go @@ -49,13 +49,15 @@ func NewProfilesClientWithBaseURI(baseURI string, subscriptionID string) Profile func (client ProfilesClient) CheckTrafficManagerRelativeDNSNameAvailability(parameters CheckTrafficManagerRelativeDNSNameAvailabilityParameters) (result NameAvailability, err error) { req, err := client.CheckTrafficManagerRelativeDNSNameAvailabilityPreparer(parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "CheckTrafficManagerRelativeDNSNameAvailability", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "CheckTrafficManagerRelativeDNSNameAvailability", nil, "Failure preparing request") + return } resp, err := client.CheckTrafficManagerRelativeDNSNameAvailabilitySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "CheckTrafficManagerRelativeDNSNameAvailability", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "CheckTrafficManagerRelativeDNSNameAvailability", resp, "Failure sending request") + return } result, err = client.CheckTrafficManagerRelativeDNSNameAvailabilityResponder(resp) @@ -72,8 +74,9 @@ func (client ProfilesClient) CheckTrafficManagerRelativeDNSNameAvailabilityPrepa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-11-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -114,13 +117,15 @@ func (client ProfilesClient) CheckTrafficManagerRelativeDNSNameAvailabilityRespo func (client ProfilesClient) CreateOrUpdate(resourceGroupName string, profileName string, parameters Profile) (result Profile, err error) { req, err := client.CreateOrUpdatePreparer(resourceGroupName, profileName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -139,8 +144,9 @@ func (client ProfilesClient) CreateOrUpdatePreparer(resourceGroupName string, pr "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-11-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -180,13 +186,15 @@ func (client ProfilesClient) CreateOrUpdateResponder(resp *http.Response) (resul func (client ProfilesClient) Delete(resourceGroupName string, profileName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, profileName) if err != nil { - return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -205,8 +213,9 @@ func (client ProfilesClient) DeletePreparer(resourceGroupName string, profileNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-11-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -242,13 +251,15 @@ func (client ProfilesClient) DeleteResponder(resp *http.Response) (result autore func (client ProfilesClient) Get(resourceGroupName string, profileName string) (result Profile, err error) { req, err := client.GetPreparer(resourceGroupName, profileName) if err != nil { - return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -267,8 +278,9 @@ func (client ProfilesClient) GetPreparer(resourceGroupName string, profileName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-11-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -302,13 +314,15 @@ func (client ProfilesClient) GetResponder(resp *http.Response) (result Profile, func (client ProfilesClient) ListAll() (result ProfileListResult, err error) { req, err := client.ListAllPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "ListAll", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "ListAll", nil, "Failure preparing request") + return } resp, err := client.ListAllSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "ListAll", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "ListAll", resp, "Failure sending request") + return } result, err = client.ListAllResponder(resp) @@ -325,8 +339,9 @@ func (client ProfilesClient) ListAllPreparer() (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-11-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -364,13 +379,15 @@ func (client ProfilesClient) ListAllResponder(resp *http.Response) (result Profi func (client ProfilesClient) ListAllInResourceGroup(resourceGroupName string) (result ProfileListResult, err error) { req, err := client.ListAllInResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "ListAllInResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "ListAllInResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListAllInResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "ListAllInResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "ListAllInResourceGroup", resp, "Failure sending request") + return } result, err = client.ListAllInResourceGroupResponder(resp) @@ -388,8 +405,9 @@ func (client ProfilesClient) ListAllInResourceGroupPreparer(resourceGroupName st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-11-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -428,13 +446,15 @@ func (client ProfilesClient) ListAllInResourceGroupResponder(resp *http.Response func (client ProfilesClient) Update(resourceGroupName string, profileName string, parameters Profile) (result Profile, err error) { req, err := client.UpdatePreparer(resourceGroupName, profileName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -453,8 +473,9 @@ func (client ProfilesClient) UpdatePreparer(resourceGroupName string, profileNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-11-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/version.go old mode 100644 new mode 100755 index 5987777ce..eeb14d3fc --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/version.go @@ -18,43 +18,12 @@ package trafficmanager // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -import ( - "bytes" - "fmt" - "strings" -) - -const ( - major = "8" - minor = "1" - patch = "0" - tag = "beta" - userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" -) - -// cached results of UserAgent and Version to prevent repeated operations. -var ( - userAgent string - version string -) - // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - if userAgent == "" { - userAgent = fmt.Sprintf(userAgentFormat, Version(), "trafficmanager", "2015-11-01") - } - return userAgent + return "Azure-SDK-For-Go/v10.0.2-beta arm-trafficmanager/2015-11-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - if version == "" { - versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) - if tag != "" { - versionBuilder.WriteRune('-') - versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) - } - version = string(versionBuilder.Bytes()) - } - return version + return "v10.0.2-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/management/README.md b/vendor/github.com/Azure/azure-sdk-for-go/management/README.md index 0a3cf82e2..7a1abb35a 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/management/README.md +++ b/vendor/github.com/Azure/azure-sdk-for-go/management/README.md @@ -8,12 +8,3 @@ The client currently supports authentication to the Service Management API with certificates or Azure `.publishSettings` file. You can download the `.publishSettings` file for your subscriptions [here](https://manage.windowsazure.com/publishsettings). - -### Example: Creating a Linux Virtual Machine - -Complete source code for this example can be found in [example.go](/management/examples/example.go).To try this example, [download your .publishSettings](https://manage.windowsazure.com/publishsettings) and add its path in the first line of the main function. Run the example with commands: - -``` -$ cd management/examples -$ go run example.go -``` \ No newline at end of file diff --git a/vendor/github.com/Azure/azure-sdk-for-go/management/client.go b/vendor/github.com/Azure/azure-sdk-for-go/management/client.go index 67da834ff..155674a68 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/management/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/management/client.go @@ -4,14 +4,19 @@ package management import ( "errors" + "fmt" + "runtime" "time" ) +var ( + DefaultUserAgent = userAgent() +) + const ( DefaultAzureManagementURL = "https://management.core.windows.net" DefaultOperationPollInterval = time.Second * 30 DefaultAPIVersion = "2014-10-01" - DefaultUserAgent = "azure-sdk-for-go" errPublishSettingsConfiguration = "PublishSettingsFilePath is set. Consequently ManagementCertificatePath and SubscriptionId must not be set." errManagementCertificateConfiguration = "Both ManagementCertificatePath and SubscriptionId should be set, and PublishSettingsFilePath must not be set." @@ -136,3 +141,12 @@ func makeClient(subscriptionID string, managementCert []byte, config ClientConfi config: config, }, nil } + +func userAgent() string { + return fmt.Sprintf("Go/%s (%s-%s) Azure-SDK-For-Go/%s asm/%s", + runtime.Version(), + runtime.GOARCH, + runtime.GOOS, + sdkVersion, + DefaultAPIVersion) +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/management/version.go b/vendor/github.com/Azure/azure-sdk-for-go/management/version.go new file mode 100644 index 000000000..a1035e189 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/management/version.go @@ -0,0 +1,5 @@ +package management + +var ( + sdkVersion = "10.0.2-beta" +) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/README.md b/vendor/github.com/Azure/azure-sdk-for-go/storage/README.md deleted file mode 100644 index 0ab099848..000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/storage/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Azure Storage SDK for Go - -The `github.com/Azure/azure-sdk-for-go/storage` package is used to perform operations in Azure Storage Service. To manage your storage accounts (Azure Resource Manager / ARM), use the [github.com/Azure/azure-sdk-for-go/arm/storage](../arm/storage) package. For your classic storage accounts (Azure Service Management / ASM), use [github.com/Azure/azure-sdk-for-go/management/storageservice](../management/storageservice) package. - -This package includes support for [Azure Storage Emulator](https://azure.microsoft.com/documentation/articles/storage-use-emulator/) \ No newline at end of file diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/appendblob.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/appendblob.go new file mode 100644 index 000000000..3292cb556 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/appendblob.go @@ -0,0 +1,70 @@ +package storage + +import ( + "bytes" + "fmt" + "net/http" + "net/url" + "time" +) + +// PutAppendBlob initializes an empty append blob with specified name. An +// append blob must be created using this method before appending blocks. +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Put-Blob +func (b *Blob) PutAppendBlob(options *PutBlobOptions) error { + params := url.Values{} + headers := b.Container.bsc.client.getStandardHeaders() + headers["x-ms-blob-type"] = string(BlobTypeAppend) + headers = mergeHeaders(headers, headersFromStruct(b.Properties)) + headers = b.Container.bsc.client.addMetadataToHeaders(headers, b.Metadata) + + if options != nil { + params = addTimeout(params, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := b.Container.bsc.client.getEndpoint(blobServiceName, b.buildPath(), params) + + resp, err := b.Container.bsc.client.exec(http.MethodPut, uri, headers, nil, b.Container.bsc.auth) + if err != nil { + return err + } + readAndCloseBody(resp.body) + return checkRespCode(resp.statusCode, []int{http.StatusCreated}) +} + +// AppendBlockOptions includes the options for an append block operation +type AppendBlockOptions struct { + Timeout uint + LeaseID string `header:"x-ms-lease-id"` + MaxSize *uint `header:"x-ms-blob-condition-maxsize"` + AppendPosition *uint `header:"x-ms-blob-condition-appendpos"` + IfModifiedSince *time.Time `header:"If-Modified-Since"` + IfUnmodifiedSince *time.Time `header:"If-Unmodified-Since"` + IfMatch string `header:"If-Match"` + IfNoneMatch string `header:"If-None-Match"` + RequestID string `header:"x-ms-client-request-id"` +} + +// AppendBlock appends a block to an append blob. +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Append-Block +func (b *Blob) AppendBlock(chunk []byte, options *AppendBlockOptions) error { + params := url.Values{"comp": {"appendblock"}} + headers := b.Container.bsc.client.getStandardHeaders() + headers["x-ms-blob-type"] = string(BlobTypeAppend) + headers["Content-Length"] = fmt.Sprintf("%v", len(chunk)) + + if options != nil { + params = addTimeout(params, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := b.Container.bsc.client.getEndpoint(blobServiceName, b.buildPath(), params) + + resp, err := b.Container.bsc.client.exec(http.MethodPut, uri, headers, bytes.NewReader(chunk), b.Container.bsc.auth) + if err != nil { + return err + } + readAndCloseBody(resp.body) + return checkRespCode(resp.statusCode, []int{http.StatusCreated}) +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/authorization.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/authorization.go index 89a0d0b3c..608bf3133 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/storage/authorization.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/authorization.go @@ -20,20 +20,24 @@ const ( sharedKeyLiteForTable authentication = "sharedKeyLiteTable" // headers - headerAuthorization = "Authorization" - headerContentLength = "Content-Length" - headerDate = "Date" - headerXmsDate = "x-ms-date" - headerXmsVersion = "x-ms-version" - headerContentEncoding = "Content-Encoding" - headerContentLanguage = "Content-Language" - headerContentType = "Content-Type" - headerContentMD5 = "Content-MD5" - headerIfModifiedSince = "If-Modified-Since" - headerIfMatch = "If-Match" - headerIfNoneMatch = "If-None-Match" - headerIfUnmodifiedSince = "If-Unmodified-Since" - headerRange = "Range" + headerAcceptCharset = "Accept-Charset" + headerAuthorization = "Authorization" + headerContentLength = "Content-Length" + headerDate = "Date" + headerXmsDate = "x-ms-date" + headerXmsVersion = "x-ms-version" + headerContentEncoding = "Content-Encoding" + headerContentLanguage = "Content-Language" + headerContentType = "Content-Type" + headerContentMD5 = "Content-MD5" + headerIfModifiedSince = "If-Modified-Since" + headerIfMatch = "If-Match" + headerIfNoneMatch = "If-None-Match" + headerIfUnmodifiedSince = "If-Unmodified-Since" + headerRange = "Range" + headerDataServiceVersion = "DataServiceVersion" + headerMaxDataServiceVersion = "MaxDataServiceVersion" + headerContentTransferEncoding = "Content-Transfer-Encoding" ) func (c *Client) addAuthorizationHeader(verb, url string, headers map[string]string, auth authentication) (map[string]string, error) { diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/blob.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/blob.go index e33de1031..dd9eb386c 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/storage/blob.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/blob.go @@ -1,7 +1,6 @@ package storage import ( - "bytes" "encoding/xml" "errors" "fmt" @@ -13,52 +12,28 @@ import ( "time" ) -// BlobStorageClient contains operations for Microsoft Azure Blob Storage -// Service. -type BlobStorageClient struct { - client Client - auth authentication -} - -// A Container is an entry in ContainerListResponse. -type Container struct { - Name string `xml:"Name"` - Properties ContainerProperties `xml:"Properties"` - // TODO (ahmetalpbalkan) Metadata -} - -// ContainerProperties contains various properties of a container returned from -// various endpoints like ListContainers. -type ContainerProperties struct { - LastModified string `xml:"Last-Modified"` - Etag string `xml:"Etag"` - LeaseStatus string `xml:"LeaseStatus"` - LeaseState string `xml:"LeaseState"` - LeaseDuration string `xml:"LeaseDuration"` - // TODO (ahmetalpbalkan) remaining fields -} - -// ContainerListResponse contains the response fields from -// ListContainers call. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd179352.aspx -type ContainerListResponse struct { - XMLName xml.Name `xml:"EnumerationResults"` - Xmlns string `xml:"xmlns,attr"` - Prefix string `xml:"Prefix"` - Marker string `xml:"Marker"` - NextMarker string `xml:"NextMarker"` - MaxResults int64 `xml:"MaxResults"` - Containers []Container `xml:"Containers>Container"` -} - // A Blob is an entry in BlobListResponse. type Blob struct { + Container *Container Name string `xml:"Name"` + Snapshot time.Time `xml:"Snapshot"` Properties BlobProperties `xml:"Properties"` Metadata BlobMetadata `xml:"Metadata"` } +// PutBlobOptions includes the options any put blob operation +// (page, block, append) +type PutBlobOptions struct { + Timeout uint + LeaseID string `header:"x-ms-lease-id"` + Origin string `header:"Origin"` + IfModifiedSince *time.Time `header:"If-Modified-Since"` + IfUnmodifiedSince *time.Time `header:"If-Unmodified-Since"` + IfMatch string `header:"If-Match"` + IfNoneMatch string `header:"If-None-Match"` + RequestID string `header:"x-ms-client-request-id"` +} + // BlobMetadata is a set of custom name/value pairs. // // See https://msdn.microsoft.com/en-us/library/azure/dd179404.aspx @@ -106,129 +81,28 @@ func (bm BlobMetadata) MarshalXML(enc *xml.Encoder, start xml.StartElement) erro // BlobProperties contains various properties of a blob // returned in various endpoints like ListBlobs or GetBlobProperties. type BlobProperties struct { - LastModified string `xml:"Last-Modified"` - Etag string `xml:"Etag"` - ContentMD5 string `xml:"Content-MD5"` - ContentLength int64 `xml:"Content-Length"` - ContentType string `xml:"Content-Type"` - ContentEncoding string `xml:"Content-Encoding"` - CacheControl string `xml:"Cache-Control"` - ContentLanguage string `xml:"Cache-Language"` - BlobType BlobType `xml:"x-ms-blob-blob-type"` - SequenceNumber int64 `xml:"x-ms-blob-sequence-number"` - CopyID string `xml:"CopyId"` - CopyStatus string `xml:"CopyStatus"` - CopySource string `xml:"CopySource"` - CopyProgress string `xml:"CopyProgress"` - CopyCompletionTime string `xml:"CopyCompletionTime"` - CopyStatusDescription string `xml:"CopyStatusDescription"` - LeaseStatus string `xml:"LeaseStatus"` - LeaseState string `xml:"LeaseState"` -} - -// BlobHeaders contains various properties of a blob and is an entry -// in SetBlobProperties -type BlobHeaders struct { - ContentMD5 string `header:"x-ms-blob-content-md5"` - ContentLanguage string `header:"x-ms-blob-content-language"` - ContentEncoding string `header:"x-ms-blob-content-encoding"` - ContentType string `header:"x-ms-blob-content-type"` - CacheControl string `header:"x-ms-blob-cache-control"` -} - -// BlobListResponse contains the response fields from ListBlobs call. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd135734.aspx -type BlobListResponse struct { - XMLName xml.Name `xml:"EnumerationResults"` - Xmlns string `xml:"xmlns,attr"` - Prefix string `xml:"Prefix"` - Marker string `xml:"Marker"` - NextMarker string `xml:"NextMarker"` - MaxResults int64 `xml:"MaxResults"` - Blobs []Blob `xml:"Blobs>Blob"` - - // BlobPrefix is used to traverse blobs as if it were a file system. - // It is returned if ListBlobsParameters.Delimiter is specified. - // The list here can be thought of as "folders" that may contain - // other folders or blobs. - BlobPrefixes []string `xml:"Blobs>BlobPrefix>Name"` - - // Delimiter is used to traverse blobs as if it were a file system. - // It is returned if ListBlobsParameters.Delimiter is specified. - Delimiter string `xml:"Delimiter"` -} - -// ListContainersParameters defines the set of customizable parameters to make a -// List Containers call. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd179352.aspx -type ListContainersParameters struct { - Prefix string - Marker string - Include string - MaxResults uint - Timeout uint -} - -func (p ListContainersParameters) getParameters() url.Values { - out := url.Values{} - - if p.Prefix != "" { - out.Set("prefix", p.Prefix) - } - if p.Marker != "" { - out.Set("marker", p.Marker) - } - if p.Include != "" { - out.Set("include", p.Include) - } - if p.MaxResults != 0 { - out.Set("maxresults", fmt.Sprintf("%v", p.MaxResults)) - } - if p.Timeout != 0 { - out.Set("timeout", fmt.Sprintf("%v", p.Timeout)) - } - - return out -} - -// ListBlobsParameters defines the set of customizable -// parameters to make a List Blobs call. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd135734.aspx -type ListBlobsParameters struct { - Prefix string - Delimiter string - Marker string - Include string - MaxResults uint - Timeout uint -} - -func (p ListBlobsParameters) getParameters() url.Values { - out := url.Values{} - - if p.Prefix != "" { - out.Set("prefix", p.Prefix) - } - if p.Delimiter != "" { - out.Set("delimiter", p.Delimiter) - } - if p.Marker != "" { - out.Set("marker", p.Marker) - } - if p.Include != "" { - out.Set("include", p.Include) - } - if p.MaxResults != 0 { - out.Set("maxresults", fmt.Sprintf("%v", p.MaxResults)) - } - if p.Timeout != 0 { - out.Set("timeout", fmt.Sprintf("%v", p.Timeout)) - } - - return out + LastModified TimeRFC1123 `xml:"Last-Modified"` + Etag string `xml:"Etag"` + ContentMD5 string `xml:"Content-MD5" header:"x-ms-blob-content-md5"` + ContentLength int64 `xml:"Content-Length"` + ContentType string `xml:"Content-Type" header:"x-ms-blob-content-type"` + ContentEncoding string `xml:"Content-Encoding" header:"x-ms-blob-content-encoding"` + CacheControl string `xml:"Cache-Control" header:"x-ms-blob-cache-control"` + ContentLanguage string `xml:"Cache-Language" header:"x-ms-blob-content-language"` + ContentDisposition string `xml:"Content-Disposition" header:"x-ms-blob-content-disposition"` + BlobType BlobType `xml:"x-ms-blob-blob-type"` + SequenceNumber int64 `xml:"x-ms-blob-sequence-number"` + CopyID string `xml:"CopyId"` + CopyStatus string `xml:"CopyStatus"` + CopySource string `xml:"CopySource"` + CopyProgress string `xml:"CopyProgress"` + CopyCompletionTime TimeRFC1123 `xml:"CopyCompletionTime"` + CopyStatusDescription string `xml:"CopyStatusDescription"` + LeaseStatus string `xml:"LeaseStatus"` + LeaseState string `xml:"LeaseState"` + LeaseDuration string `xml:"LeaseDuration"` + ServerEncrypted bool `xml:"ServerEncrypted"` + IncrementalCopy bool `xml:"IncrementalCopy"` } // BlobType defines the type of the Azure Blob. @@ -241,387 +115,18 @@ const ( BlobTypeAppend BlobType = "AppendBlob" ) -// PageWriteType defines the type updates that are going to be -// done on the page blob. -type PageWriteType string - -// Types of operations on page blobs -const ( - PageWriteTypeUpdate PageWriteType = "update" - PageWriteTypeClear PageWriteType = "clear" -) - -const ( - blobCopyStatusPending = "pending" - blobCopyStatusSuccess = "success" - blobCopyStatusAborted = "aborted" - blobCopyStatusFailed = "failed" -) - -// lease constants. -const ( - leaseHeaderPrefix = "x-ms-lease-" - headerLeaseID = "x-ms-lease-id" - leaseAction = "x-ms-lease-action" - leaseBreakPeriod = "x-ms-lease-break-period" - leaseDuration = "x-ms-lease-duration" - leaseProposedID = "x-ms-proposed-lease-id" - leaseTime = "x-ms-lease-time" - - acquireLease = "acquire" - renewLease = "renew" - changeLease = "change" - releaseLease = "release" - breakLease = "break" -) - -// BlockListType is used to filter out types of blocks in a Get Blocks List call -// for a block blob. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd179400.aspx for all -// block types. -type BlockListType string - -// Filters for listing blocks in block blobs -const ( - BlockListTypeAll BlockListType = "all" - BlockListTypeCommitted BlockListType = "committed" - BlockListTypeUncommitted BlockListType = "uncommitted" -) - -// ContainerAccessType defines the access level to the container from a public -// request. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd179468.aspx and "x-ms- -// blob-public-access" header. -type ContainerAccessType string - -// Access options for containers -const ( - ContainerAccessTypePrivate ContainerAccessType = "" - ContainerAccessTypeBlob ContainerAccessType = "blob" - ContainerAccessTypeContainer ContainerAccessType = "container" -) - -// ContainerAccessPolicyDetails are used for SETTING container policies -type ContainerAccessPolicyDetails struct { - ID string - StartTime time.Time - ExpiryTime time.Time - CanRead bool - CanWrite bool - CanDelete bool +func (b *Blob) buildPath() string { + return b.Container.buildPath() + "/" + b.Name } -// ContainerPermissions is used when setting permissions and Access Policies for containers. -type ContainerPermissions struct { - AccessType ContainerAccessType - AccessPolicies []ContainerAccessPolicyDetails -} - -// ContainerAccessHeader references header used when setting/getting container ACL -const ( - ContainerAccessHeader string = "x-ms-blob-public-access" -) - -// Maximum sizes (per REST API) for various concepts -const ( - MaxBlobBlockSize = 4 * 1024 * 1024 - MaxBlobPageSize = 4 * 1024 * 1024 -) - -// BlockStatus defines states a block for a block blob can -// be in. -type BlockStatus string - -// List of statuses that can be used to refer to a block in a block list -const ( - BlockStatusUncommitted BlockStatus = "Uncommitted" - BlockStatusCommitted BlockStatus = "Committed" - BlockStatusLatest BlockStatus = "Latest" -) - -// Block is used to create Block entities for Put Block List -// call. -type Block struct { - ID string - Status BlockStatus -} - -// BlockListResponse contains the response fields from Get Block List call. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd179400.aspx -type BlockListResponse struct { - XMLName xml.Name `xml:"BlockList"` - CommittedBlocks []BlockResponse `xml:"CommittedBlocks>Block"` - UncommittedBlocks []BlockResponse `xml:"UncommittedBlocks>Block"` -} - -// BlockResponse contains the block information returned -// in the GetBlockListCall. -type BlockResponse struct { - Name string `xml:"Name"` - Size int64 `xml:"Size"` -} - -// GetPageRangesResponse contains the response fields from -// Get Page Ranges call. -// -// See https://msdn.microsoft.com/en-us/library/azure/ee691973.aspx -type GetPageRangesResponse struct { - XMLName xml.Name `xml:"PageList"` - PageList []PageRange `xml:"PageRange"` -} - -// PageRange contains information about a page of a page blob from -// Get Pages Range call. -// -// See https://msdn.microsoft.com/en-us/library/azure/ee691973.aspx -type PageRange struct { - Start int64 `xml:"Start"` - End int64 `xml:"End"` -} - -var ( - errBlobCopyAborted = errors.New("storage: blob copy is aborted") - errBlobCopyIDMismatch = errors.New("storage: blob copy id is a mismatch") -) - -// ListContainers returns the list of containers in a storage account along with -// pagination token and other response details. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd179352.aspx -func (b BlobStorageClient) ListContainers(params ListContainersParameters) (ContainerListResponse, error) { - q := mergeParams(params.getParameters(), url.Values{"comp": {"list"}}) - uri := b.client.getEndpoint(blobServiceName, "", q) - headers := b.client.getStandardHeaders() - - var out ContainerListResponse - resp, err := b.client.exec(http.MethodGet, uri, headers, nil, b.auth) - if err != nil { - return out, err - } - defer resp.body.Close() - - err = xmlUnmarshal(resp.body, &out) - return out, err -} - -// CreateContainer creates a blob container within the storage account -// with given name and access level. Returns error if container already exists. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd179468.aspx -func (b BlobStorageClient) CreateContainer(name string, access ContainerAccessType) error { - resp, err := b.createContainer(name, access) - if err != nil { - return err - } - defer resp.body.Close() - return checkRespCode(resp.statusCode, []int{http.StatusCreated}) -} - -// CreateContainerIfNotExists creates a blob container if it does not exist. Returns -// true if container is newly created or false if container already exists. -func (b BlobStorageClient) CreateContainerIfNotExists(name string, access ContainerAccessType) (bool, error) { - resp, err := b.createContainer(name, access) - if resp != nil { - defer resp.body.Close() - if resp.statusCode == http.StatusCreated || resp.statusCode == http.StatusConflict { - return resp.statusCode == http.StatusCreated, nil - } - } - return false, err -} - -func (b BlobStorageClient) createContainer(name string, access ContainerAccessType) (*storageResponse, error) { - uri := b.client.getEndpoint(blobServiceName, pathForContainer(name), url.Values{"restype": {"container"}}) - - headers := b.client.getStandardHeaders() - if access != "" { - headers[ContainerAccessHeader] = string(access) - } - return b.client.exec(http.MethodPut, uri, headers, nil, b.auth) -} - -// ContainerExists returns true if a container with given name exists -// on the storage account, otherwise returns false. -func (b BlobStorageClient) ContainerExists(name string) (bool, error) { - uri := b.client.getEndpoint(blobServiceName, pathForContainer(name), url.Values{"restype": {"container"}}) - headers := b.client.getStandardHeaders() - - resp, err := b.client.exec(http.MethodHead, uri, headers, nil, b.auth) - if resp != nil { - defer resp.body.Close() - if resp.statusCode == http.StatusOK || resp.statusCode == http.StatusNotFound { - return resp.statusCode == http.StatusOK, nil - } - } - return false, err -} - -// SetContainerPermissions sets up container permissions as per https://msdn.microsoft.com/en-us/library/azure/dd179391.aspx -func (b BlobStorageClient) SetContainerPermissions(container string, containerPermissions ContainerPermissions, timeout int, leaseID string) (err error) { - params := url.Values{ - "restype": {"container"}, - "comp": {"acl"}, - } - - if timeout > 0 { - params.Add("timeout", strconv.Itoa(timeout)) - } - - uri := b.client.getEndpoint(blobServiceName, pathForContainer(container), params) - headers := b.client.getStandardHeaders() - if containerPermissions.AccessType != "" { - headers[ContainerAccessHeader] = string(containerPermissions.AccessType) - } - - if leaseID != "" { - headers[headerLeaseID] = leaseID - } - - body, length, err := generateContainerACLpayload(containerPermissions.AccessPolicies) - headers["Content-Length"] = strconv.Itoa(length) - resp, err := b.client.exec(http.MethodPut, uri, headers, body, b.auth) - - if err != nil { - return err - } - - if resp != nil { - defer resp.body.Close() - - if resp.statusCode != http.StatusOK { - return errors.New("Unable to set permissions") - } - } - return nil -} - -// GetContainerPermissions gets the container permissions as per https://msdn.microsoft.com/en-us/library/azure/dd179469.aspx -// If timeout is 0 then it will not be passed to Azure -// leaseID will only be passed to Azure if populated -// Returns permissionResponse which is combined permissions and AccessPolicy -func (b BlobStorageClient) GetContainerPermissions(container string, timeout int, leaseID string) (*ContainerPermissions, error) { - params := url.Values{"restype": {"container"}, - "comp": {"acl"}} - - if timeout > 0 { - params.Add("timeout", strconv.Itoa(timeout)) - } - - uri := b.client.getEndpoint(blobServiceName, pathForContainer(container), params) - headers := b.client.getStandardHeaders() - - if leaseID != "" { - headers[headerLeaseID] = leaseID - } - - resp, err := b.client.exec(http.MethodGet, uri, headers, nil, b.auth) - if err != nil { - return nil, err - } - defer resp.body.Close() - - var out AccessPolicy - err = xmlUnmarshal(resp.body, &out.SignedIdentifiersList) - if err != nil { - return nil, err - } - - permissionResponse := updateContainerAccessPolicy(out, &resp.headers) - return &permissionResponse, nil -} - -func updateContainerAccessPolicy(ap AccessPolicy, headers *http.Header) ContainerPermissions { - // containerAccess. Blob, Container, empty - containerAccess := headers.Get(http.CanonicalHeaderKey(ContainerAccessHeader)) - - var cp ContainerPermissions - cp.AccessType = ContainerAccessType(containerAccess) - for _, policy := range ap.SignedIdentifiersList.SignedIdentifiers { - capd := ContainerAccessPolicyDetails{ - ID: policy.ID, - StartTime: policy.AccessPolicy.StartTime, - ExpiryTime: policy.AccessPolicy.ExpiryTime, - } - capd.CanRead = updatePermissions(policy.AccessPolicy.Permission, "r") - capd.CanWrite = updatePermissions(policy.AccessPolicy.Permission, "w") - capd.CanDelete = updatePermissions(policy.AccessPolicy.Permission, "d") - - cp.AccessPolicies = append(cp.AccessPolicies, capd) - } - - return cp -} - -// DeleteContainer deletes the container with given name on the storage -// account. If the container does not exist returns error. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd179408.aspx -func (b BlobStorageClient) DeleteContainer(name string) error { - resp, err := b.deleteContainer(name) - if err != nil { - return err - } - defer resp.body.Close() - return checkRespCode(resp.statusCode, []int{http.StatusAccepted}) -} - -// DeleteContainerIfExists deletes the container with given name on the storage -// account if it exists. Returns true if container is deleted with this call, or -// false if the container did not exist at the time of the Delete Container -// operation. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd179408.aspx -func (b BlobStorageClient) DeleteContainerIfExists(name string) (bool, error) { - resp, err := b.deleteContainer(name) - if resp != nil { - defer resp.body.Close() - if resp.statusCode == http.StatusAccepted || resp.statusCode == http.StatusNotFound { - return resp.statusCode == http.StatusAccepted, nil - } - } - return false, err -} - -func (b BlobStorageClient) deleteContainer(name string) (*storageResponse, error) { - uri := b.client.getEndpoint(blobServiceName, pathForContainer(name), url.Values{"restype": {"container"}}) - - headers := b.client.getStandardHeaders() - return b.client.exec(http.MethodDelete, uri, headers, nil, b.auth) -} - -// ListBlobs returns an object that contains list of blobs in the container, -// pagination token and other information in the response of List Blobs call. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd135734.aspx -func (b BlobStorageClient) ListBlobs(container string, params ListBlobsParameters) (BlobListResponse, error) { - q := mergeParams(params.getParameters(), url.Values{ - "restype": {"container"}, - "comp": {"list"}}) - uri := b.client.getEndpoint(blobServiceName, pathForContainer(container), q) - headers := b.client.getStandardHeaders() - - var out BlobListResponse - resp, err := b.client.exec(http.MethodGet, uri, headers, nil, b.auth) - if err != nil { - return out, err - } - defer resp.body.Close() - - err = xmlUnmarshal(resp.body, &out) - return out, err -} - -// BlobExists returns true if a blob with given name exists on the specified +// Exists returns true if a blob with given name exists on the specified // container of the storage account. -func (b BlobStorageClient) BlobExists(container, name string) (bool, error) { - uri := b.client.getEndpoint(blobServiceName, pathForBlob(container, name), url.Values{}) - headers := b.client.getStandardHeaders() - resp, err := b.client.exec(http.MethodHead, uri, headers, nil, b.auth) +func (b *Blob) Exists() (bool, error) { + uri := b.Container.bsc.client.getEndpoint(blobServiceName, b.buildPath(), nil) + headers := b.Container.bsc.client.getStandardHeaders() + resp, err := b.Container.bsc.client.exec(http.MethodHead, uri, headers, nil, b.Container.bsc.auth) if resp != nil { - defer resp.body.Close() + defer readAndCloseBody(resp.body) if resp.statusCode == http.StatusOK || resp.statusCode == http.StatusNotFound { return resp.statusCode == http.StatusOK, nil } @@ -629,23 +134,57 @@ func (b BlobStorageClient) BlobExists(container, name string) (bool, error) { return false, err } -// GetBlobURL gets the canonical URL to the blob with the specified name in the -// specified container. This method does not create a publicly accessible URL if -// the blob or container is private and this method does not check if the blob -// exists. -func (b BlobStorageClient) GetBlobURL(container, name string) string { +// GetURL gets the canonical URL to the blob with the specified name in the +// specified container. If name is not specified, the canonical URL for the entire +// container is obtained. +// This method does not create a publicly accessible URL if the blob or container +// is private and this method does not check if the blob exists. +func (b *Blob) GetURL() string { + container := b.Container.Name if container == "" { container = "$root" } - return b.client.getEndpoint(blobServiceName, pathForBlob(container, name), url.Values{}) + return b.Container.bsc.client.getEndpoint(blobServiceName, pathForResource(container, b.Name), nil) } -// GetBlob returns a stream to read the blob. Caller must call Close() the -// reader to close on the underlying connection. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd179440.aspx -func (b BlobStorageClient) GetBlob(container, name string) (io.ReadCloser, error) { - resp, err := b.getBlobRange(container, name, "", nil) +// GetBlobRangeOptions includes the options for a get blob range operation +type GetBlobRangeOptions struct { + Range *BlobRange + GetRangeContentMD5 bool + *GetBlobOptions +} + +// GetBlobOptions includes the options for a get blob operation +type GetBlobOptions struct { + Timeout uint + Snapshot *time.Time + LeaseID string `header:"x-ms-lease-id"` + Origin string `header:"Origin"` + IfModifiedSince *time.Time `header:"If-Modified-Since"` + IfUnmodifiedSince *time.Time `header:"If-Unmodified-Since"` + IfMatch string `header:"If-Match"` + IfNoneMatch string `header:"If-None-Match"` + RequestID string `header:"x-ms-client-request-id"` +} + +// BlobRange represents the bytes range to be get +type BlobRange struct { + Start uint64 + End uint64 +} + +func (br BlobRange) String() string { + return fmt.Sprintf("bytes=%d-%d", br.Start, br.End) +} + +// Get returns a stream to read the blob. Caller must call both Read and Close() +// to correctly close the underlying connection. +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Get-Blob +func (b *Blob) Get(options *GetBlobOptions) (io.ReadCloser, error) { + rangeOptions := GetBlobRangeOptions{ + GetBlobOptions: options, + } + resp, err := b.getRange(&rangeOptions) if err != nil { return nil, err } @@ -653,15 +192,19 @@ func (b BlobStorageClient) GetBlob(container, name string) (io.ReadCloser, error if err := checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { return nil, err } + if err := b.writePropoerties(resp.headers); err != nil { + return resp.body, err + } return resp.body, nil } -// GetBlobRange reads the specified range of a blob to a stream. The bytesRange +// GetRange reads the specified range of a blob to a stream. The bytesRange // string must be in a format like "0-", "10-100" as defined in HTTP 1.1 spec. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd179440.aspx -func (b BlobStorageClient) GetBlobRange(container, name, bytesRange string, extraHeaders map[string]string) (io.ReadCloser, error) { - resp, err := b.getBlobRange(container, name, bytesRange, extraHeaders) +// Caller must call both Read and Close()// to correctly close the underlying +// connection. +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Get-Blob +func (b *Blob) GetRange(options *GetBlobRangeOptions) (io.ReadCloser, error) { + resp, err := b.getRange(options) if err != nil { return nil, err } @@ -669,66 +212,65 @@ func (b BlobStorageClient) GetBlobRange(container, name, bytesRange string, extr if err := checkRespCode(resp.statusCode, []int{http.StatusPartialContent}); err != nil { return nil, err } + if err := b.writePropoerties(resp.headers); err != nil { + return resp.body, err + } return resp.body, nil } -func (b BlobStorageClient) getBlobRange(container, name, bytesRange string, extraHeaders map[string]string) (*storageResponse, error) { - uri := b.client.getEndpoint(blobServiceName, pathForBlob(container, name), url.Values{}) +func (b *Blob) getRange(options *GetBlobRangeOptions) (*storageResponse, error) { + params := url.Values{} + headers := b.Container.bsc.client.getStandardHeaders() - extraHeaders = b.client.protectUserAgent(extraHeaders) - headers := b.client.getStandardHeaders() - if bytesRange != "" { - headers["Range"] = fmt.Sprintf("bytes=%s", bytesRange) + if options != nil { + if options.Range != nil { + headers["Range"] = options.Range.String() + headers["x-ms-range-get-content-md5"] = fmt.Sprintf("%v", options.GetRangeContentMD5) + } + if options.GetBlobOptions != nil { + headers = mergeHeaders(headers, headersFromStruct(*options.GetBlobOptions)) + params = addTimeout(params, options.Timeout) + params = addSnapshot(params, options.Snapshot) + } } + uri := b.Container.bsc.client.getEndpoint(blobServiceName, b.buildPath(), params) - for k, v := range extraHeaders { - headers[k] = v - } - - resp, err := b.client.exec(http.MethodGet, uri, headers, nil, b.auth) + resp, err := b.Container.bsc.client.exec(http.MethodGet, uri, headers, nil, b.Container.bsc.auth) if err != nil { return nil, err } return resp, err } -// leasePut is common PUT code for the various acquire/release/break etc functions. -func (b BlobStorageClient) leaseCommonPut(container string, name string, headers map[string]string, expectedStatus int) (http.Header, error) { - params := url.Values{"comp": {"lease"}} - uri := b.client.getEndpoint(blobServiceName, pathForBlob(container, name), params) - - resp, err := b.client.exec(http.MethodPut, uri, headers, nil, b.auth) - if err != nil { - return nil, err - } - defer resp.body.Close() - - if err := checkRespCode(resp.statusCode, []int{expectedStatus}); err != nil { - return nil, err - } - - return resp.headers, nil +// SnapshotOptions includes the options for a snapshot blob operation +type SnapshotOptions struct { + Timeout uint + LeaseID string `header:"x-ms-lease-id"` + IfModifiedSince *time.Time `header:"If-Modified-Since"` + IfUnmodifiedSince *time.Time `header:"If-Unmodified-Since"` + IfMatch string `header:"If-Match"` + IfNoneMatch string `header:"If-None-Match"` + RequestID string `header:"x-ms-client-request-id"` } -// SnapshotBlob creates a snapshot for a blob as per https://msdn.microsoft.com/en-us/library/azure/ee691971.aspx -func (b BlobStorageClient) SnapshotBlob(container string, name string, timeout int, extraHeaders map[string]string) (snapshotTimestamp *time.Time, err error) { - extraHeaders = b.client.protectUserAgent(extraHeaders) - headers := b.client.getStandardHeaders() +// CreateSnapshot creates a snapshot for a blob +// See https://msdn.microsoft.com/en-us/library/azure/ee691971.aspx +func (b *Blob) CreateSnapshot(options *SnapshotOptions) (snapshotTimestamp *time.Time, err error) { params := url.Values{"comp": {"snapshot"}} + headers := b.Container.bsc.client.getStandardHeaders() + headers = b.Container.bsc.client.addMetadataToHeaders(headers, b.Metadata) - if timeout > 0 { - params.Add("timeout", strconv.Itoa(timeout)) + if options != nil { + params = addTimeout(params, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) } + uri := b.Container.bsc.client.getEndpoint(blobServiceName, b.buildPath(), params) - for k, v := range extraHeaders { - headers[k] = v - } - - uri := b.client.getEndpoint(blobServiceName, pathForBlob(container, name), params) - resp, err := b.client.exec(http.MethodPut, uri, headers, nil, b.auth) - if err != nil { + resp, err := b.Container.bsc.client.exec(http.MethodPut, uri, headers, nil, b.Container.bsc.auth) + if err != nil || resp == nil { return nil, err } + defer readAndCloseBody(resp.body) if err := checkRespCode(resp.statusCode, []int{http.StatusCreated}); err != nil { return nil, err @@ -740,212 +282,178 @@ func (b BlobStorageClient) SnapshotBlob(container string, name string, timeout i if err != nil { return nil, err } - return &snapshotTimestamp, nil } return nil, errors.New("Snapshot not created") } -// AcquireLease creates a lease for a blob as per https://msdn.microsoft.com/en-us/library/azure/ee691972.aspx -// returns leaseID acquired -func (b BlobStorageClient) AcquireLease(container string, name string, leaseTimeInSeconds int, proposedLeaseID string) (returnedLeaseID string, err error) { - headers := b.client.getStandardHeaders() - headers[leaseAction] = acquireLease - - if leaseTimeInSeconds > 0 { - headers[leaseDuration] = strconv.Itoa(leaseTimeInSeconds) - } - - if proposedLeaseID != "" { - headers[leaseProposedID] = proposedLeaseID - } - - respHeaders, err := b.leaseCommonPut(container, name, headers, http.StatusCreated) - if err != nil { - return "", err - } - - returnedLeaseID = respHeaders.Get(http.CanonicalHeaderKey(headerLeaseID)) - - if returnedLeaseID != "" { - return returnedLeaseID, nil - } - - return "", errors.New("LeaseID not returned") +// GetBlobPropertiesOptions includes the options for a get blob properties operation +type GetBlobPropertiesOptions struct { + Timeout uint + Snapshot *time.Time + LeaseID string `header:"x-ms-lease-id"` + IfModifiedSince *time.Time `header:"If-Modified-Since"` + IfUnmodifiedSince *time.Time `header:"If-Unmodified-Since"` + IfMatch string `header:"If-Match"` + IfNoneMatch string `header:"If-None-Match"` + RequestID string `header:"x-ms-client-request-id"` } -// BreakLease breaks the lease for a blob as per https://msdn.microsoft.com/en-us/library/azure/ee691972.aspx -// Returns the timeout remaining in the lease in seconds -func (b BlobStorageClient) BreakLease(container string, name string) (breakTimeout int, err error) { - headers := b.client.getStandardHeaders() - headers[leaseAction] = breakLease - return b.breakLeaseCommon(container, name, headers) -} +// GetProperties provides various information about the specified blob. +// See https://msdn.microsoft.com/en-us/library/azure/dd179394.aspx +func (b *Blob) GetProperties(options *GetBlobPropertiesOptions) error { + params := url.Values{} + headers := b.Container.bsc.client.getStandardHeaders() -// BreakLeaseWithBreakPeriod breaks the lease for a blob as per https://msdn.microsoft.com/en-us/library/azure/ee691972.aspx -// breakPeriodInSeconds is used to determine how long until new lease can be created. -// Returns the timeout remaining in the lease in seconds -func (b BlobStorageClient) BreakLeaseWithBreakPeriod(container string, name string, breakPeriodInSeconds int) (breakTimeout int, err error) { - headers := b.client.getStandardHeaders() - headers[leaseAction] = breakLease - headers[leaseBreakPeriod] = strconv.Itoa(breakPeriodInSeconds) - return b.breakLeaseCommon(container, name, headers) -} - -// breakLeaseCommon is common code for both version of BreakLease (with and without break period) -func (b BlobStorageClient) breakLeaseCommon(container string, name string, headers map[string]string) (breakTimeout int, err error) { - - respHeaders, err := b.leaseCommonPut(container, name, headers, http.StatusAccepted) - if err != nil { - return 0, err + if options != nil { + params = addTimeout(params, options.Timeout) + params = addSnapshot(params, options.Snapshot) + headers = mergeHeaders(headers, headersFromStruct(*options)) } + uri := b.Container.bsc.client.getEndpoint(blobServiceName, b.buildPath(), params) - breakTimeoutStr := respHeaders.Get(http.CanonicalHeaderKey(leaseTime)) - if breakTimeoutStr != "" { - breakTimeout, err = strconv.Atoi(breakTimeoutStr) - if err != nil { - return 0, err - } - } - - return breakTimeout, nil -} - -// ChangeLease changes a lease ID for a blob as per https://msdn.microsoft.com/en-us/library/azure/ee691972.aspx -// Returns the new LeaseID acquired -func (b BlobStorageClient) ChangeLease(container string, name string, currentLeaseID string, proposedLeaseID string) (newLeaseID string, err error) { - headers := b.client.getStandardHeaders() - headers[leaseAction] = changeLease - headers[headerLeaseID] = currentLeaseID - headers[leaseProposedID] = proposedLeaseID - - respHeaders, err := b.leaseCommonPut(container, name, headers, http.StatusOK) - if err != nil { - return "", err - } - - newLeaseID = respHeaders.Get(http.CanonicalHeaderKey(headerLeaseID)) - if newLeaseID != "" { - return newLeaseID, nil - } - - return "", errors.New("LeaseID not returned") -} - -// ReleaseLease releases the lease for a blob as per https://msdn.microsoft.com/en-us/library/azure/ee691972.aspx -func (b BlobStorageClient) ReleaseLease(container string, name string, currentLeaseID string) error { - headers := b.client.getStandardHeaders() - headers[leaseAction] = releaseLease - headers[headerLeaseID] = currentLeaseID - - _, err := b.leaseCommonPut(container, name, headers, http.StatusOK) + resp, err := b.Container.bsc.client.exec(http.MethodHead, uri, headers, nil, b.Container.bsc.auth) if err != nil { return err } - - return nil -} - -// RenewLease renews the lease for a blob as per https://msdn.microsoft.com/en-us/library/azure/ee691972.aspx -func (b BlobStorageClient) RenewLease(container string, name string, currentLeaseID string) error { - headers := b.client.getStandardHeaders() - headers[leaseAction] = renewLease - headers[headerLeaseID] = currentLeaseID - - _, err := b.leaseCommonPut(container, name, headers, http.StatusOK) - if err != nil { - return err - } - - return nil -} - -// GetBlobProperties provides various information about the specified -// blob. See https://msdn.microsoft.com/en-us/library/azure/dd179394.aspx -func (b BlobStorageClient) GetBlobProperties(container, name string) (*BlobProperties, error) { - uri := b.client.getEndpoint(blobServiceName, pathForBlob(container, name), url.Values{}) - - headers := b.client.getStandardHeaders() - resp, err := b.client.exec(http.MethodHead, uri, headers, nil, b.auth) - if err != nil { - return nil, err - } - defer resp.body.Close() + defer readAndCloseBody(resp.body) if err = checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { - return nil, err + return err } + return b.writePropoerties(resp.headers) +} + +func (b *Blob) writePropoerties(h http.Header) error { + var err error var contentLength int64 - contentLengthStr := resp.headers.Get("Content-Length") + contentLengthStr := h.Get("Content-Length") if contentLengthStr != "" { contentLength, err = strconv.ParseInt(contentLengthStr, 0, 64) if err != nil { - return nil, err + return err } } var sequenceNum int64 - sequenceNumStr := resp.headers.Get("x-ms-blob-sequence-number") + sequenceNumStr := h.Get("x-ms-blob-sequence-number") if sequenceNumStr != "" { sequenceNum, err = strconv.ParseInt(sequenceNumStr, 0, 64) if err != nil { - return nil, err + return err } } - return &BlobProperties{ - LastModified: resp.headers.Get("Last-Modified"), - Etag: resp.headers.Get("Etag"), - ContentMD5: resp.headers.Get("Content-MD5"), + lastModified, err := getTimeFromHeaders(h, "Last-Modified") + if err != nil { + return err + } + + copyCompletionTime, err := getTimeFromHeaders(h, "x-ms-copy-completion-time") + if err != nil { + return err + } + + b.Properties = BlobProperties{ + LastModified: TimeRFC1123(*lastModified), + Etag: h.Get("Etag"), + ContentMD5: h.Get("Content-MD5"), ContentLength: contentLength, - ContentEncoding: resp.headers.Get("Content-Encoding"), - ContentType: resp.headers.Get("Content-Type"), - CacheControl: resp.headers.Get("Cache-Control"), - ContentLanguage: resp.headers.Get("Content-Language"), + ContentEncoding: h.Get("Content-Encoding"), + ContentType: h.Get("Content-Type"), + ContentDisposition: h.Get("Content-Disposition"), + CacheControl: h.Get("Cache-Control"), + ContentLanguage: h.Get("Content-Language"), SequenceNumber: sequenceNum, - CopyCompletionTime: resp.headers.Get("x-ms-copy-completion-time"), - CopyStatusDescription: resp.headers.Get("x-ms-copy-status-description"), - CopyID: resp.headers.Get("x-ms-copy-id"), - CopyProgress: resp.headers.Get("x-ms-copy-progress"), - CopySource: resp.headers.Get("x-ms-copy-source"), - CopyStatus: resp.headers.Get("x-ms-copy-status"), - BlobType: BlobType(resp.headers.Get("x-ms-blob-type")), - LeaseStatus: resp.headers.Get("x-ms-lease-status"), - LeaseState: resp.headers.Get("x-ms-lease-state"), - }, nil + CopyCompletionTime: TimeRFC1123(*copyCompletionTime), + CopyStatusDescription: h.Get("x-ms-copy-status-description"), + CopyID: h.Get("x-ms-copy-id"), + CopyProgress: h.Get("x-ms-copy-progress"), + CopySource: h.Get("x-ms-copy-source"), + CopyStatus: h.Get("x-ms-copy-status"), + BlobType: BlobType(h.Get("x-ms-blob-type")), + LeaseStatus: h.Get("x-ms-lease-status"), + LeaseState: h.Get("x-ms-lease-state"), + } + b.writeMetadata(h) + return nil } -// SetBlobProperties replaces the BlobHeaders for the specified blob. +// SetBlobPropertiesOptions contains various properties of a blob and is an entry +// in SetProperties +type SetBlobPropertiesOptions struct { + Timeout uint + LeaseID string `header:"x-ms-lease-id"` + Origin string `header:"Origin"` + IfModifiedSince *time.Time `header:"If-Modified-Since"` + IfUnmodifiedSince *time.Time `header:"If-Unmodified-Since"` + IfMatch string `header:"If-Match"` + IfNoneMatch string `header:"If-None-Match"` + SequenceNumberAction *SequenceNumberAction + RequestID string `header:"x-ms-client-request-id"` +} + +// SequenceNumberAction defines how the blob's sequence number should be modified +type SequenceNumberAction string + +// Options for sequence number action +const ( + SequenceNumberActionMax SequenceNumberAction = "max" + SequenceNumberActionUpdate SequenceNumberAction = "update" + SequenceNumberActionIncrement SequenceNumberAction = "increment" +) + +// SetProperties replaces the BlobHeaders for the specified blob. // // Some keys may be converted to Camel-Case before sending. All keys // are returned in lower case by GetBlobProperties. HTTP header names // are case-insensitive so case munging should not matter to other // applications either. // -// See https://msdn.microsoft.com/en-us/library/azure/ee691966.aspx -func (b BlobStorageClient) SetBlobProperties(container, name string, blobHeaders BlobHeaders) error { +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Set-Blob-Properties +func (b *Blob) SetProperties(options *SetBlobPropertiesOptions) error { params := url.Values{"comp": {"properties"}} - uri := b.client.getEndpoint(blobServiceName, pathForBlob(container, name), params) - headers := b.client.getStandardHeaders() + headers := b.Container.bsc.client.getStandardHeaders() + headers = mergeHeaders(headers, headersFromStruct(b.Properties)) - extraHeaders := headersFromStruct(blobHeaders) + if options != nil { + params = addTimeout(params, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := b.Container.bsc.client.getEndpoint(blobServiceName, b.buildPath(), params) - for k, v := range extraHeaders { - headers[k] = v + if b.Properties.BlobType == BlobTypePage { + headers = addToHeaders(headers, "x-ms-blob-content-length", fmt.Sprintf("byte %v", b.Properties.ContentLength)) + if options != nil || options.SequenceNumberAction != nil { + headers = addToHeaders(headers, "x-ms-sequence-number-action", string(*options.SequenceNumberAction)) + if *options.SequenceNumberAction != SequenceNumberActionIncrement { + headers = addToHeaders(headers, "x-ms-blob-sequence-number", fmt.Sprintf("%v", b.Properties.SequenceNumber)) + } + } } - resp, err := b.client.exec(http.MethodPut, uri, headers, nil, b.auth) + resp, err := b.Container.bsc.client.exec(http.MethodPut, uri, headers, nil, b.Container.bsc.auth) if err != nil { return err } - defer resp.body.Close() - + readAndCloseBody(resp.body) return checkRespCode(resp.statusCode, []int{http.StatusOK}) } -// SetBlobMetadata replaces the metadata for the specified blob. +// SetBlobMetadataOptions includes the options for a set blob metadata operation +type SetBlobMetadataOptions struct { + Timeout uint + LeaseID string `header:"x-ms-lease-id"` + IfModifiedSince *time.Time `header:"If-Modified-Since"` + IfUnmodifiedSince *time.Time `header:"If-Unmodified-Since"` + IfMatch string `header:"If-Match"` + IfNoneMatch string `header:"If-None-Match"` + RequestID string `header:"x-ms-client-request-id"` +} + +// SetMetadata replaces the metadata for the specified blob. // // Some keys may be converted to Camel-Case before sending. All keys // are returned in lower case by GetBlobMetadata. HTTP header names @@ -953,52 +461,71 @@ func (b BlobStorageClient) SetBlobProperties(container, name string, blobHeaders // applications either. // // See https://msdn.microsoft.com/en-us/library/azure/dd179414.aspx -func (b BlobStorageClient) SetBlobMetadata(container, name string, metadata map[string]string, extraHeaders map[string]string) error { +func (b *Blob) SetMetadata(options *SetBlobMetadataOptions) error { params := url.Values{"comp": {"metadata"}} - uri := b.client.getEndpoint(blobServiceName, pathForBlob(container, name), params) - metadata = b.client.protectUserAgent(metadata) - extraHeaders = b.client.protectUserAgent(extraHeaders) - headers := b.client.getStandardHeaders() - for k, v := range metadata { - headers[userDefinedMetadataHeaderPrefix+k] = v - } + headers := b.Container.bsc.client.getStandardHeaders() + headers = b.Container.bsc.client.addMetadataToHeaders(headers, b.Metadata) - for k, v := range extraHeaders { - headers[k] = v + if options != nil { + params = addTimeout(params, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) } + uri := b.Container.bsc.client.getEndpoint(blobServiceName, b.buildPath(), params) - resp, err := b.client.exec(http.MethodPut, uri, headers, nil, b.auth) + resp, err := b.Container.bsc.client.exec(http.MethodPut, uri, headers, nil, b.Container.bsc.auth) if err != nil { return err } - defer resp.body.Close() - + readAndCloseBody(resp.body) return checkRespCode(resp.statusCode, []int{http.StatusOK}) } -// GetBlobMetadata returns all user-defined metadata for the specified blob. +// GetBlobMetadataOptions includes the options for a get blob metadata operation +type GetBlobMetadataOptions struct { + Timeout uint + Snapshot *time.Time + LeaseID string `header:"x-ms-lease-id"` + IfModifiedSince *time.Time `header:"If-Modified-Since"` + IfUnmodifiedSince *time.Time `header:"If-Unmodified-Since"` + IfMatch string `header:"If-Match"` + IfNoneMatch string `header:"If-None-Match"` + RequestID string `header:"x-ms-client-request-id"` +} + +// GetMetadata returns all user-defined metadata for the specified blob. // // All metadata keys will be returned in lower case. (HTTP header // names are case-insensitive.) // // See https://msdn.microsoft.com/en-us/library/azure/dd179414.aspx -func (b BlobStorageClient) GetBlobMetadata(container, name string) (map[string]string, error) { +func (b *Blob) GetMetadata(options *GetBlobMetadataOptions) error { params := url.Values{"comp": {"metadata"}} - uri := b.client.getEndpoint(blobServiceName, pathForBlob(container, name), params) - headers := b.client.getStandardHeaders() + headers := b.Container.bsc.client.getStandardHeaders() - resp, err := b.client.exec(http.MethodGet, uri, headers, nil, b.auth) - if err != nil { - return nil, err + if options != nil { + params = addTimeout(params, options.Timeout) + params = addSnapshot(params, options.Snapshot) + headers = mergeHeaders(headers, headersFromStruct(*options)) } - defer resp.body.Close() + uri := b.Container.bsc.client.getEndpoint(blobServiceName, b.buildPath(), params) + + resp, err := b.Container.bsc.client.exec(http.MethodGet, uri, headers, nil, b.Container.bsc.auth) + if err != nil { + return err + } + defer readAndCloseBody(resp.body) if err := checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { - return nil, err + return err } + b.writeMetadata(resp.headers) + return nil +} + +func (b *Blob) writeMetadata(h http.Header) { metadata := make(map[string]string) - for k, v := range resp.headers { + for k, v := range h { // Can't trust CanonicalHeaderKey() to munge case // reliably. "_" is allowed in identifiers: // https://msdn.microsoft.com/en-us/library/azure/dd179414.aspx @@ -1007,383 +534,53 @@ func (b BlobStorageClient) GetBlobMetadata(container, name string) (map[string]s // ...but "_" is considered invalid by // CanonicalMIMEHeaderKey in // https://golang.org/src/net/textproto/reader.go?s=14615:14659#L542 - // so k can be "X-Ms-Meta-Foo" or "x-ms-meta-foo_bar". + // so k can be "X-Ms-Meta-Lol" or "x-ms-meta-lol_rofl". k = strings.ToLower(k) if len(v) == 0 || !strings.HasPrefix(k, strings.ToLower(userDefinedMetadataHeaderPrefix)) { continue } - // metadata["foo"] = content of the last X-Ms-Meta-Foo header + // metadata["lol"] = content of the last X-Ms-Meta-Lol header k = k[len(userDefinedMetadataHeaderPrefix):] metadata[k] = v[len(v)-1] } - return metadata, nil + + b.Metadata = BlobMetadata(metadata) } -// CreateBlockBlob initializes an empty block blob with no blocks. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd179451.aspx -func (b BlobStorageClient) CreateBlockBlob(container, name string) error { - return b.CreateBlockBlobFromReader(container, name, 0, nil, nil) +// DeleteBlobOptions includes the options for a delete blob operation +type DeleteBlobOptions struct { + Timeout uint + Snapshot *time.Time + LeaseID string `header:"x-ms-lease-id"` + DeleteSnapshots *bool + IfModifiedSince *time.Time `header:"If-Modified-Since"` + IfUnmodifiedSince *time.Time `header:"If-Unmodified-Since"` + IfMatch string `header:"If-Match"` + IfNoneMatch string `header:"If-None-Match"` + RequestID string `header:"x-ms-client-request-id"` } -// CreateBlockBlobFromReader initializes a block blob using data from -// reader. Size must be the number of bytes read from reader. To -// create an empty blob, use size==0 and reader==nil. -// -// The API rejects requests with size > 64 MiB (but this limit is not -// checked by the SDK). To write a larger blob, use CreateBlockBlob, -// PutBlock, and PutBlockList. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd179451.aspx -func (b BlobStorageClient) CreateBlockBlobFromReader(container, name string, size uint64, blob io.Reader, extraHeaders map[string]string) error { - path := fmt.Sprintf("%s/%s", container, name) - uri := b.client.getEndpoint(blobServiceName, path, url.Values{}) - extraHeaders = b.client.protectUserAgent(extraHeaders) - headers := b.client.getStandardHeaders() - headers["x-ms-blob-type"] = string(BlobTypeBlock) - headers["Content-Length"] = fmt.Sprintf("%d", size) - - for k, v := range extraHeaders { - headers[k] = v - } - - resp, err := b.client.exec(http.MethodPut, uri, headers, blob, b.auth) - if err != nil { - return err - } - defer resp.body.Close() - return checkRespCode(resp.statusCode, []int{http.StatusCreated}) -} - -// PutBlock saves the given data chunk to the specified block blob with -// given ID. -// -// The API rejects chunks larger than 4 MiB (but this limit is not -// checked by the SDK). -// -// See https://msdn.microsoft.com/en-us/library/azure/dd135726.aspx -func (b BlobStorageClient) PutBlock(container, name, blockID string, chunk []byte) error { - return b.PutBlockWithLength(container, name, blockID, uint64(len(chunk)), bytes.NewReader(chunk), nil) -} - -// PutBlockWithLength saves the given data stream of exactly specified size to -// the block blob with given ID. It is an alternative to PutBlocks where data -// comes as stream but the length is known in advance. -// -// The API rejects requests with size > 4 MiB (but this limit is not -// checked by the SDK). -// -// See https://msdn.microsoft.com/en-us/library/azure/dd135726.aspx -func (b BlobStorageClient) PutBlockWithLength(container, name, blockID string, size uint64, blob io.Reader, extraHeaders map[string]string) error { - uri := b.client.getEndpoint(blobServiceName, pathForBlob(container, name), url.Values{"comp": {"block"}, "blockid": {blockID}}) - extraHeaders = b.client.protectUserAgent(extraHeaders) - headers := b.client.getStandardHeaders() - headers["x-ms-blob-type"] = string(BlobTypeBlock) - headers["Content-Length"] = fmt.Sprintf("%v", size) - - for k, v := range extraHeaders { - headers[k] = v - } - - resp, err := b.client.exec(http.MethodPut, uri, headers, blob, b.auth) - if err != nil { - return err - } - - defer resp.body.Close() - return checkRespCode(resp.statusCode, []int{http.StatusCreated}) -} - -// PutBlockList saves list of blocks to the specified block blob. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd179467.aspx -func (b BlobStorageClient) PutBlockList(container, name string, blocks []Block) error { - blockListXML := prepareBlockListRequest(blocks) - - uri := b.client.getEndpoint(blobServiceName, pathForBlob(container, name), url.Values{"comp": {"blocklist"}}) - headers := b.client.getStandardHeaders() - headers["Content-Length"] = fmt.Sprintf("%v", len(blockListXML)) - - resp, err := b.client.exec(http.MethodPut, uri, headers, strings.NewReader(blockListXML), b.auth) - if err != nil { - return err - } - defer resp.body.Close() - return checkRespCode(resp.statusCode, []int{http.StatusCreated}) -} - -// GetBlockList retrieves list of blocks in the specified block blob. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd179400.aspx -func (b BlobStorageClient) GetBlockList(container, name string, blockType BlockListType) (BlockListResponse, error) { - params := url.Values{"comp": {"blocklist"}, "blocklisttype": {string(blockType)}} - uri := b.client.getEndpoint(blobServiceName, pathForBlob(container, name), params) - headers := b.client.getStandardHeaders() - - var out BlockListResponse - resp, err := b.client.exec(http.MethodGet, uri, headers, nil, b.auth) - if err != nil { - return out, err - } - defer resp.body.Close() - - err = xmlUnmarshal(resp.body, &out) - return out, err -} - -// PutPageBlob initializes an empty page blob with specified name and maximum -// size in bytes (size must be aligned to a 512-byte boundary). A page blob must -// be created using this method before writing pages. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd179451.aspx -func (b BlobStorageClient) PutPageBlob(container, name string, size int64, extraHeaders map[string]string) error { - path := fmt.Sprintf("%s/%s", container, name) - uri := b.client.getEndpoint(blobServiceName, path, url.Values{}) - extraHeaders = b.client.protectUserAgent(extraHeaders) - headers := b.client.getStandardHeaders() - headers["x-ms-blob-type"] = string(BlobTypePage) - headers["x-ms-blob-content-length"] = fmt.Sprintf("%v", size) - - for k, v := range extraHeaders { - headers[k] = v - } - - resp, err := b.client.exec(http.MethodPut, uri, headers, nil, b.auth) - if err != nil { - return err - } - defer resp.body.Close() - - return checkRespCode(resp.statusCode, []int{http.StatusCreated}) -} - -// PutPage writes a range of pages to a page blob or clears the given range. -// In case of 'clear' writes, given chunk is discarded. Ranges must be aligned -// with 512-byte boundaries and chunk must be of size multiplies by 512. -// -// See https://msdn.microsoft.com/en-us/library/ee691975.aspx -func (b BlobStorageClient) PutPage(container, name string, startByte, endByte int64, writeType PageWriteType, chunk []byte, extraHeaders map[string]string) error { - path := fmt.Sprintf("%s/%s", container, name) - uri := b.client.getEndpoint(blobServiceName, path, url.Values{"comp": {"page"}}) - extraHeaders = b.client.protectUserAgent(extraHeaders) - headers := b.client.getStandardHeaders() - headers["x-ms-blob-type"] = string(BlobTypePage) - headers["x-ms-page-write"] = string(writeType) - headers["x-ms-range"] = fmt.Sprintf("bytes=%v-%v", startByte, endByte) - for k, v := range extraHeaders { - headers[k] = v - } - var contentLength int64 - var data io.Reader - if writeType == PageWriteTypeClear { - contentLength = 0 - data = bytes.NewReader([]byte{}) - } else { - contentLength = int64(len(chunk)) - data = bytes.NewReader(chunk) - } - headers["Content-Length"] = fmt.Sprintf("%v", contentLength) - - resp, err := b.client.exec(http.MethodPut, uri, headers, data, b.auth) - if err != nil { - return err - } - defer resp.body.Close() - - return checkRespCode(resp.statusCode, []int{http.StatusCreated}) -} - -// GetPageRanges returns the list of valid page ranges for a page blob. -// -// See https://msdn.microsoft.com/en-us/library/azure/ee691973.aspx -func (b BlobStorageClient) GetPageRanges(container, name string) (GetPageRangesResponse, error) { - path := fmt.Sprintf("%s/%s", container, name) - uri := b.client.getEndpoint(blobServiceName, path, url.Values{"comp": {"pagelist"}}) - headers := b.client.getStandardHeaders() - - var out GetPageRangesResponse - resp, err := b.client.exec(http.MethodGet, uri, headers, nil, b.auth) - if err != nil { - return out, err - } - defer resp.body.Close() - - if err = checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { - return out, err - } - err = xmlUnmarshal(resp.body, &out) - return out, err -} - -// PutAppendBlob initializes an empty append blob with specified name. An -// append blob must be created using this method before appending blocks. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd179451.aspx -func (b BlobStorageClient) PutAppendBlob(container, name string, extraHeaders map[string]string) error { - path := fmt.Sprintf("%s/%s", container, name) - uri := b.client.getEndpoint(blobServiceName, path, url.Values{}) - extraHeaders = b.client.protectUserAgent(extraHeaders) - headers := b.client.getStandardHeaders() - headers["x-ms-blob-type"] = string(BlobTypeAppend) - - for k, v := range extraHeaders { - headers[k] = v - } - - resp, err := b.client.exec(http.MethodPut, uri, headers, nil, b.auth) - if err != nil { - return err - } - defer resp.body.Close() - - return checkRespCode(resp.statusCode, []int{http.StatusCreated}) -} - -// AppendBlock appends a block to an append blob. -// -// See https://msdn.microsoft.com/en-us/library/azure/mt427365.aspx -func (b BlobStorageClient) AppendBlock(container, name string, chunk []byte, extraHeaders map[string]string) error { - path := fmt.Sprintf("%s/%s", container, name) - uri := b.client.getEndpoint(blobServiceName, path, url.Values{"comp": {"appendblock"}}) - extraHeaders = b.client.protectUserAgent(extraHeaders) - headers := b.client.getStandardHeaders() - headers["x-ms-blob-type"] = string(BlobTypeAppend) - headers["Content-Length"] = fmt.Sprintf("%v", len(chunk)) - - for k, v := range extraHeaders { - headers[k] = v - } - - resp, err := b.client.exec(http.MethodPut, uri, headers, bytes.NewReader(chunk), b.auth) - if err != nil { - return err - } - defer resp.body.Close() - - return checkRespCode(resp.statusCode, []int{http.StatusCreated}) -} - -// CopyBlob starts a blob copy operation and waits for the operation to -// complete. sourceBlob parameter must be a canonical URL to the blob (can be -// obtained using GetBlobURL method.) There is no SLA on blob copy and therefore -// this helper method works faster on smaller files. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd894037.aspx -func (b BlobStorageClient) CopyBlob(container, name, sourceBlob string) error { - copyID, err := b.StartBlobCopy(container, name, sourceBlob) - if err != nil { - return err - } - - return b.WaitForBlobCopy(container, name, copyID) -} - -// StartBlobCopy starts a blob copy operation. -// sourceBlob parameter must be a canonical URL to the blob (can be -// obtained using GetBlobURL method.) -// -// See https://msdn.microsoft.com/en-us/library/azure/dd894037.aspx -func (b BlobStorageClient) StartBlobCopy(container, name, sourceBlob string) (string, error) { - uri := b.client.getEndpoint(blobServiceName, pathForBlob(container, name), url.Values{}) - - headers := b.client.getStandardHeaders() - headers["x-ms-copy-source"] = sourceBlob - - resp, err := b.client.exec(http.MethodPut, uri, headers, nil, b.auth) - if err != nil { - return "", err - } - defer resp.body.Close() - - if err := checkRespCode(resp.statusCode, []int{http.StatusAccepted, http.StatusCreated}); err != nil { - return "", err - } - - copyID := resp.headers.Get("x-ms-copy-id") - if copyID == "" { - return "", errors.New("Got empty copy id header") - } - return copyID, nil -} - -// AbortBlobCopy aborts a BlobCopy which has already been triggered by the StartBlobCopy function. -// copyID is generated from StartBlobCopy function. -// currentLeaseID is required IF the destination blob has an active lease on it. -// As defined in https://msdn.microsoft.com/en-us/library/azure/jj159098.aspx -func (b BlobStorageClient) AbortBlobCopy(container, name, copyID, currentLeaseID string, timeout int) error { - params := url.Values{"comp": {"copy"}, "copyid": {copyID}} - if timeout > 0 { - params.Add("timeout", strconv.Itoa(timeout)) - } - - uri := b.client.getEndpoint(blobServiceName, pathForBlob(container, name), params) - headers := b.client.getStandardHeaders() - headers["x-ms-copy-action"] = "abort" - - if currentLeaseID != "" { - headers[headerLeaseID] = currentLeaseID - } - - resp, err := b.client.exec(http.MethodPut, uri, headers, nil, b.auth) - if err != nil { - return err - } - defer resp.body.Close() - - if err := checkRespCode(resp.statusCode, []int{http.StatusNoContent}); err != nil { - return err - } - - return nil -} - -// WaitForBlobCopy loops until a BlobCopy operation is completed (or fails with error) -func (b BlobStorageClient) WaitForBlobCopy(container, name, copyID string) error { - for { - props, err := b.GetBlobProperties(container, name) - if err != nil { - return err - } - - if props.CopyID != copyID { - return errBlobCopyIDMismatch - } - - switch props.CopyStatus { - case blobCopyStatusSuccess: - return nil - case blobCopyStatusPending: - continue - case blobCopyStatusAborted: - return errBlobCopyAborted - case blobCopyStatusFailed: - return fmt.Errorf("storage: blob copy failed. Id=%s Description=%s", props.CopyID, props.CopyStatusDescription) - default: - return fmt.Errorf("storage: unhandled blob copy status: '%s'", props.CopyStatus) - } - } -} - -// DeleteBlob deletes the given blob from the specified container. +// Delete deletes the given blob from the specified container. // If the blob does not exists at the time of the Delete Blob operation, it -// returns error. See https://msdn.microsoft.com/en-us/library/azure/dd179413.aspx -func (b BlobStorageClient) DeleteBlob(container, name string, extraHeaders map[string]string) error { - resp, err := b.deleteBlob(container, name, extraHeaders) +// returns error. +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Delete-Blob +func (b *Blob) Delete(options *DeleteBlobOptions) error { + resp, err := b.delete(options) if err != nil { return err } - defer resp.body.Close() + readAndCloseBody(resp.body) return checkRespCode(resp.statusCode, []int{http.StatusAccepted}) } -// DeleteBlobIfExists deletes the given blob from the specified container If the +// DeleteIfExists deletes the given blob from the specified container If the // blob is deleted with this call, returns true. Otherwise returns false. // -// See https://msdn.microsoft.com/en-us/library/azure/dd179413.aspx -func (b BlobStorageClient) DeleteBlobIfExists(container, name string, extraHeaders map[string]string) (bool, error) { - resp, err := b.deleteBlob(container, name, extraHeaders) +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Delete-Blob +func (b *Blob) DeleteIfExists(options *DeleteBlobOptions) (bool, error) { + resp, err := b.delete(options) if resp != nil { - defer resp.body.Close() + defer readAndCloseBody(resp.body) if resp.statusCode == http.StatusAccepted || resp.statusCode == http.StatusNotFound { return resp.statusCode == http.StatusAccepted, nil } @@ -1391,149 +588,30 @@ func (b BlobStorageClient) DeleteBlobIfExists(container, name string, extraHeade return false, err } -func (b BlobStorageClient) deleteBlob(container, name string, extraHeaders map[string]string) (*storageResponse, error) { - uri := b.client.getEndpoint(blobServiceName, pathForBlob(container, name), url.Values{}) - extraHeaders = b.client.protectUserAgent(extraHeaders) - headers := b.client.getStandardHeaders() - for k, v := range extraHeaders { - headers[k] = v - } +func (b *Blob) delete(options *DeleteBlobOptions) (*storageResponse, error) { + params := url.Values{} + headers := b.Container.bsc.client.getStandardHeaders() - return b.client.exec(http.MethodDelete, uri, headers, nil, b.auth) -} - -// helper method to construct the path to a container given its name -func pathForContainer(name string) string { - return fmt.Sprintf("/%s", name) -} - -// helper method to construct the path to a blob given its container and blob -// name -func pathForBlob(container, name string) string { - return fmt.Sprintf("/%s/%s", container, name) -} - -// GetBlobSASURIWithSignedIPAndProtocol creates an URL to the specified blob which contains the Shared -// Access Signature with specified permissions and expiration time. Also includes signedIPRange and allowed protocols. -// If old API version is used but no signedIP is passed (ie empty string) then this should still work. -// We only populate the signedIP when it non-empty. -// -// See https://msdn.microsoft.com/en-us/library/azure/ee395415.aspx -func (b BlobStorageClient) GetBlobSASURIWithSignedIPAndProtocol(container, name string, expiry time.Time, permissions string, signedIPRange string, HTTPSOnly bool) (string, error) { - var ( - signedPermissions = permissions - blobURL = b.GetBlobURL(container, name) - ) - canonicalizedResource, err := b.client.buildCanonicalizedResource(blobURL, b.auth) - if err != nil { - return "", err - } - - // "The canonicalizedresouce portion of the string is a canonical path to the signed resource. - // It must include the service name (blob, table, queue or file) for version 2015-02-21 or - // later, the storage account name, and the resource name, and must be URL-decoded. - // -- https://msdn.microsoft.com/en-us/library/azure/dn140255.aspx - - // We need to replace + with %2b first to avoid being treated as a space (which is correct for query strings, but not the path component). - canonicalizedResource = strings.Replace(canonicalizedResource, "+", "%2b", -1) - canonicalizedResource, err = url.QueryUnescape(canonicalizedResource) - if err != nil { - return "", err - } - - signedExpiry := expiry.UTC().Format(time.RFC3339) - signedResource := "b" - - protocols := "https,http" - if HTTPSOnly { - protocols = "https" - } - stringToSign, err := blobSASStringToSign(b.client.apiVersion, canonicalizedResource, signedExpiry, signedPermissions, signedIPRange, protocols) - if err != nil { - return "", err - } - - sig := b.client.computeHmac256(stringToSign) - sasParams := url.Values{ - "sv": {b.client.apiVersion}, - "se": {signedExpiry}, - "sr": {signedResource}, - "sp": {signedPermissions}, - "sig": {sig}, - } - - if b.client.apiVersion >= "2015-04-05" { - sasParams.Add("spr", protocols) - if signedIPRange != "" { - sasParams.Add("sip", signedIPRange) + if options != nil { + params = addTimeout(params, options.Timeout) + params = addSnapshot(params, options.Snapshot) + headers = mergeHeaders(headers, headersFromStruct(*options)) + if options.DeleteSnapshots != nil { + if *options.DeleteSnapshots { + headers["x-ms-delete-snapshots"] = "include" + } else { + headers["x-ms-delete-snapshots"] = "only" + } } } - - sasURL, err := url.Parse(blobURL) - if err != nil { - return "", err - } - sasURL.RawQuery = sasParams.Encode() - return sasURL.String(), nil + uri := b.Container.bsc.client.getEndpoint(blobServiceName, b.buildPath(), params) + return b.Container.bsc.client.exec(http.MethodDelete, uri, headers, nil, b.Container.bsc.auth) } -// GetBlobSASURI creates an URL to the specified blob which contains the Shared -// Access Signature with specified permissions and expiration time. -// -// See https://msdn.microsoft.com/en-us/library/azure/ee395415.aspx -func (b BlobStorageClient) GetBlobSASURI(container, name string, expiry time.Time, permissions string) (string, error) { - url, err := b.GetBlobSASURIWithSignedIPAndProtocol(container, name, expiry, permissions, "", false) - return url, err -} - -func blobSASStringToSign(signedVersion, canonicalizedResource, signedExpiry, signedPermissions string, signedIP string, protocols string) (string, error) { - var signedStart, signedIdentifier, rscc, rscd, rsce, rscl, rsct string - - if signedVersion >= "2015-02-21" { - canonicalizedResource = "/blob" + canonicalizedResource - } - - // https://msdn.microsoft.com/en-us/library/azure/dn140255.aspx#Anchor_12 - if signedVersion >= "2015-04-05" { - return fmt.Sprintf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s", signedPermissions, signedStart, signedExpiry, canonicalizedResource, signedIdentifier, signedIP, protocols, signedVersion, rscc, rscd, rsce, rscl, rsct), nil - } - - // reference: http://msdn.microsoft.com/en-us/library/azure/dn140255.aspx - if signedVersion >= "2013-08-15" { - return fmt.Sprintf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s", signedPermissions, signedStart, signedExpiry, canonicalizedResource, signedIdentifier, signedVersion, rscc, rscd, rsce, rscl, rsct), nil - } - - return "", errors.New("storage: not implemented SAS for versions earlier than 2013-08-15") -} - -func generateContainerACLpayload(policies []ContainerAccessPolicyDetails) (io.Reader, int, error) { - sil := SignedIdentifiers{ - SignedIdentifiers: []SignedIdentifier{}, - } - for _, capd := range policies { - permission := capd.generateContainerPermissions() - signedIdentifier := convertAccessPolicyToXMLStructs(capd.ID, capd.StartTime, capd.ExpiryTime, permission) - sil.SignedIdentifiers = append(sil.SignedIdentifiers, signedIdentifier) - } - return xmlMarshal(sil) -} - -func (capd *ContainerAccessPolicyDetails) generateContainerPermissions() (permissions string) { - // generate the permissions string (rwd). - // still want the end user API to have bool flags. - permissions = "" - - if capd.CanRead { - permissions += "r" - } - - if capd.CanWrite { - permissions += "w" - } - - if capd.CanDelete { - permissions += "d" - } - - return permissions +// helper method to construct the path to either a blob or container +func pathForResource(container, name string) string { + if name != "" { + return fmt.Sprintf("/%s/%s", container, name) + } + return fmt.Sprintf("/%s", container) } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/blobsasuri.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/blobsasuri.go new file mode 100644 index 000000000..43173d3a4 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/blobsasuri.go @@ -0,0 +1,106 @@ +package storage + +import ( + "errors" + "fmt" + "net/url" + "strings" + "time" +) + +// GetSASURIWithSignedIPAndProtocol creates an URL to the specified blob which contains the Shared +// Access Signature with specified permissions and expiration time. Also includes signedIPRange and allowed protocols. +// If old API version is used but no signedIP is passed (ie empty string) then this should still work. +// We only populate the signedIP when it non-empty. +// +// See https://msdn.microsoft.com/en-us/library/azure/ee395415.aspx +func (b *Blob) GetSASURIWithSignedIPAndProtocol(expiry time.Time, permissions string, signedIPRange string, HTTPSOnly bool) (string, error) { + var ( + signedPermissions = permissions + blobURL = b.GetURL() + ) + canonicalizedResource, err := b.Container.bsc.client.buildCanonicalizedResource(blobURL, b.Container.bsc.auth) + if err != nil { + return "", err + } + + // "The canonicalizedresouce portion of the string is a canonical path to the signed resource. + // It must include the service name (blob, table, queue or file) for version 2015-02-21 or + // later, the storage account name, and the resource name, and must be URL-decoded. + // -- https://msdn.microsoft.com/en-us/library/azure/dn140255.aspx + + // We need to replace + with %2b first to avoid being treated as a space (which is correct for query strings, but not the path component). + canonicalizedResource = strings.Replace(canonicalizedResource, "+", "%2b", -1) + canonicalizedResource, err = url.QueryUnescape(canonicalizedResource) + if err != nil { + return "", err + } + + signedExpiry := expiry.UTC().Format(time.RFC3339) + + //If blob name is missing, resource is a container + signedResource := "c" + if len(b.Name) > 0 { + signedResource = "b" + } + + protocols := "https,http" + if HTTPSOnly { + protocols = "https" + } + stringToSign, err := blobSASStringToSign(b.Container.bsc.client.apiVersion, canonicalizedResource, signedExpiry, signedPermissions, signedIPRange, protocols) + if err != nil { + return "", err + } + + sig := b.Container.bsc.client.computeHmac256(stringToSign) + sasParams := url.Values{ + "sv": {b.Container.bsc.client.apiVersion}, + "se": {signedExpiry}, + "sr": {signedResource}, + "sp": {signedPermissions}, + "sig": {sig}, + } + + if b.Container.bsc.client.apiVersion >= "2015-04-05" { + sasParams.Add("spr", protocols) + if signedIPRange != "" { + sasParams.Add("sip", signedIPRange) + } + } + + sasURL, err := url.Parse(blobURL) + if err != nil { + return "", err + } + sasURL.RawQuery = sasParams.Encode() + return sasURL.String(), nil +} + +// GetSASURI creates an URL to the specified blob which contains the Shared +// Access Signature with specified permissions and expiration time. +// +// See https://msdn.microsoft.com/en-us/library/azure/ee395415.aspx +func (b *Blob) GetSASURI(expiry time.Time, permissions string) (string, error) { + return b.GetSASURIWithSignedIPAndProtocol(expiry, permissions, "", false) +} + +func blobSASStringToSign(signedVersion, canonicalizedResource, signedExpiry, signedPermissions string, signedIP string, protocols string) (string, error) { + var signedStart, signedIdentifier, rscc, rscd, rsce, rscl, rsct string + + if signedVersion >= "2015-02-21" { + canonicalizedResource = "/blob" + canonicalizedResource + } + + // https://msdn.microsoft.com/en-us/library/azure/dn140255.aspx#Anchor_12 + if signedVersion >= "2015-04-05" { + return fmt.Sprintf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s", signedPermissions, signedStart, signedExpiry, canonicalizedResource, signedIdentifier, signedIP, protocols, signedVersion, rscc, rscd, rsce, rscl, rsct), nil + } + + // reference: http://msdn.microsoft.com/en-us/library/azure/dn140255.aspx + if signedVersion >= "2013-08-15" { + return fmt.Sprintf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s", signedPermissions, signedStart, signedExpiry, canonicalizedResource, signedIdentifier, signedVersion, rscc, rscd, rsce, rscl, rsct), nil + } + + return "", errors.New("storage: not implemented SAS for versions earlier than 2013-08-15") +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/blobserviceclient.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/blobserviceclient.go new file mode 100644 index 000000000..450b20f96 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/blobserviceclient.go @@ -0,0 +1,95 @@ +package storage + +import ( + "net/http" + "net/url" + "strconv" +) + +// BlobStorageClient contains operations for Microsoft Azure Blob Storage +// Service. +type BlobStorageClient struct { + client Client + auth authentication +} + +// GetServiceProperties gets the properties of your storage account's blob service. +// See: https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-blob-service-properties +func (b *BlobStorageClient) GetServiceProperties() (*ServiceProperties, error) { + return b.client.getServiceProperties(blobServiceName, b.auth) +} + +// SetServiceProperties sets the properties of your storage account's blob service. +// See: https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/set-blob-service-properties +func (b *BlobStorageClient) SetServiceProperties(props ServiceProperties) error { + return b.client.setServiceProperties(props, blobServiceName, b.auth) +} + +// ListContainersParameters defines the set of customizable parameters to make a +// List Containers call. +// +// See https://msdn.microsoft.com/en-us/library/azure/dd179352.aspx +type ListContainersParameters struct { + Prefix string + Marker string + Include string + MaxResults uint + Timeout uint +} + +// GetContainerReference returns a Container object for the specified container name. +func (b *BlobStorageClient) GetContainerReference(name string) *Container { + return &Container{ + bsc: b, + Name: name, + } +} + +// ListContainers returns the list of containers in a storage account along with +// pagination token and other response details. +// +// See https://msdn.microsoft.com/en-us/library/azure/dd179352.aspx +func (b BlobStorageClient) ListContainers(params ListContainersParameters) (*ContainerListResponse, error) { + q := mergeParams(params.getParameters(), url.Values{"comp": {"list"}}) + uri := b.client.getEndpoint(blobServiceName, "", q) + headers := b.client.getStandardHeaders() + + var out ContainerListResponse + resp, err := b.client.exec(http.MethodGet, uri, headers, nil, b.auth) + if err != nil { + return nil, err + } + defer resp.body.Close() + err = xmlUnmarshal(resp.body, &out) + if err != nil { + return nil, err + } + + // assign our client to the newly created Container objects + for i := range out.Containers { + out.Containers[i].bsc = &b + } + return &out, err +} + +func (p ListContainersParameters) getParameters() url.Values { + out := url.Values{} + + if p.Prefix != "" { + out.Set("prefix", p.Prefix) + } + if p.Marker != "" { + out.Set("marker", p.Marker) + } + if p.Include != "" { + out.Set("include", p.Include) + } + if p.MaxResults != 0 { + out.Set("maxresults", strconv.FormatUint(uint64(p.MaxResults), 10)) + } + if p.Timeout != 0 { + out.Set("timeout", strconv.FormatUint(uint64(p.Timeout), 10)) + } + + return out +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/blockblob.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/blockblob.go new file mode 100644 index 000000000..09b13cc18 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/blockblob.go @@ -0,0 +1,225 @@ +package storage + +import ( + "bytes" + "encoding/xml" + "fmt" + "io" + "net/http" + "net/url" + "strings" + "time" +) + +// BlockListType is used to filter out types of blocks in a Get Blocks List call +// for a block blob. +// +// See https://msdn.microsoft.com/en-us/library/azure/dd179400.aspx for all +// block types. +type BlockListType string + +// Filters for listing blocks in block blobs +const ( + BlockListTypeAll BlockListType = "all" + BlockListTypeCommitted BlockListType = "committed" + BlockListTypeUncommitted BlockListType = "uncommitted" +) + +// Maximum sizes (per REST API) for various concepts +const ( + MaxBlobBlockSize = 100 * 1024 * 1024 + MaxBlobPageSize = 4 * 1024 * 1024 +) + +// BlockStatus defines states a block for a block blob can +// be in. +type BlockStatus string + +// List of statuses that can be used to refer to a block in a block list +const ( + BlockStatusUncommitted BlockStatus = "Uncommitted" + BlockStatusCommitted BlockStatus = "Committed" + BlockStatusLatest BlockStatus = "Latest" +) + +// Block is used to create Block entities for Put Block List +// call. +type Block struct { + ID string + Status BlockStatus +} + +// BlockListResponse contains the response fields from Get Block List call. +// +// See https://msdn.microsoft.com/en-us/library/azure/dd179400.aspx +type BlockListResponse struct { + XMLName xml.Name `xml:"BlockList"` + CommittedBlocks []BlockResponse `xml:"CommittedBlocks>Block"` + UncommittedBlocks []BlockResponse `xml:"UncommittedBlocks>Block"` +} + +// BlockResponse contains the block information returned +// in the GetBlockListCall. +type BlockResponse struct { + Name string `xml:"Name"` + Size int64 `xml:"Size"` +} + +// CreateBlockBlob initializes an empty block blob with no blocks. +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Put-Blob +func (b *Blob) CreateBlockBlob(options *PutBlobOptions) error { + return b.CreateBlockBlobFromReader(nil, options) +} + +// CreateBlockBlobFromReader initializes a block blob using data from +// reader. Size must be the number of bytes read from reader. To +// create an empty blob, use size==0 and reader==nil. +// +// The API rejects requests with size > 256 MiB (but this limit is not +// checked by the SDK). To write a larger blob, use CreateBlockBlob, +// PutBlock, and PutBlockList. +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Put-Blob +func (b *Blob) CreateBlockBlobFromReader(blob io.Reader, options *PutBlobOptions) error { + params := url.Values{} + headers := b.Container.bsc.client.getStandardHeaders() + headers["x-ms-blob-type"] = string(BlobTypeBlock) + headers["Content-Length"] = fmt.Sprintf("%d", b.Properties.ContentLength) + headers = mergeHeaders(headers, headersFromStruct(b.Properties)) + headers = b.Container.bsc.client.addMetadataToHeaders(headers, b.Metadata) + + if options != nil { + params = addTimeout(params, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := b.Container.bsc.client.getEndpoint(blobServiceName, b.buildPath(), params) + + resp, err := b.Container.bsc.client.exec(http.MethodPut, uri, headers, blob, b.Container.bsc.auth) + if err != nil { + return err + } + readAndCloseBody(resp.body) + return checkRespCode(resp.statusCode, []int{http.StatusCreated}) +} + +// PutBlockOptions includes the options for a put block operation +type PutBlockOptions struct { + Timeout uint + LeaseID string `header:"x-ms-lease-id"` + ContentMD5 string `header:"Content-MD5"` + RequestID string `header:"x-ms-client-request-id"` +} + +// PutBlock saves the given data chunk to the specified block blob with +// given ID. +// +// The API rejects chunks larger than 100 MiB (but this limit is not +// checked by the SDK). +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Put-Block +func (b *Blob) PutBlock(blockID string, chunk []byte, options *PutBlockOptions) error { + return b.PutBlockWithLength(blockID, uint64(len(chunk)), bytes.NewReader(chunk), options) +} + +// PutBlockWithLength saves the given data stream of exactly specified size to +// the block blob with given ID. It is an alternative to PutBlocks where data +// comes as stream but the length is known in advance. +// +// The API rejects requests with size > 100 MiB (but this limit is not +// checked by the SDK). +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Put-Block +func (b *Blob) PutBlockWithLength(blockID string, size uint64, blob io.Reader, options *PutBlockOptions) error { + query := url.Values{ + "comp": {"block"}, + "blockid": {blockID}, + } + headers := b.Container.bsc.client.getStandardHeaders() + headers["Content-Length"] = fmt.Sprintf("%v", size) + + if options != nil { + query = addTimeout(query, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := b.Container.bsc.client.getEndpoint(blobServiceName, b.buildPath(), query) + + resp, err := b.Container.bsc.client.exec(http.MethodPut, uri, headers, blob, b.Container.bsc.auth) + if err != nil { + return err + } + readAndCloseBody(resp.body) + return checkRespCode(resp.statusCode, []int{http.StatusCreated}) +} + +// PutBlockListOptions includes the options for a put block list operation +type PutBlockListOptions struct { + Timeout uint + LeaseID string `header:"x-ms-lease-id"` + IfModifiedSince *time.Time `header:"If-Modified-Since"` + IfUnmodifiedSince *time.Time `header:"If-Unmodified-Since"` + IfMatch string `header:"If-Match"` + IfNoneMatch string `header:"If-None-Match"` + RequestID string `header:"x-ms-client-request-id"` +} + +// PutBlockList saves list of blocks to the specified block blob. +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Put-Block-List +func (b *Blob) PutBlockList(blocks []Block, options *PutBlockListOptions) error { + params := url.Values{"comp": {"blocklist"}} + blockListXML := prepareBlockListRequest(blocks) + headers := b.Container.bsc.client.getStandardHeaders() + headers["Content-Length"] = fmt.Sprintf("%v", len(blockListXML)) + headers = mergeHeaders(headers, headersFromStruct(b.Properties)) + headers = b.Container.bsc.client.addMetadataToHeaders(headers, b.Metadata) + + if options != nil { + params = addTimeout(params, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := b.Container.bsc.client.getEndpoint(blobServiceName, b.buildPath(), params) + + resp, err := b.Container.bsc.client.exec(http.MethodPut, uri, headers, strings.NewReader(blockListXML), b.Container.bsc.auth) + if err != nil { + return err + } + readAndCloseBody(resp.body) + return checkRespCode(resp.statusCode, []int{http.StatusCreated}) +} + +// GetBlockListOptions includes the options for a get block list operation +type GetBlockListOptions struct { + Timeout uint + Snapshot *time.Time + LeaseID string `header:"x-ms-lease-id"` + RequestID string `header:"x-ms-client-request-id"` +} + +// GetBlockList retrieves list of blocks in the specified block blob. +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Get-Block-List +func (b *Blob) GetBlockList(blockType BlockListType, options *GetBlockListOptions) (BlockListResponse, error) { + params := url.Values{ + "comp": {"blocklist"}, + "blocklisttype": {string(blockType)}, + } + headers := b.Container.bsc.client.getStandardHeaders() + + if options != nil { + params = addTimeout(params, options.Timeout) + params = addSnapshot(params, options.Snapshot) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := b.Container.bsc.client.getEndpoint(blobServiceName, b.buildPath(), params) + + var out BlockListResponse + resp, err := b.Container.bsc.client.exec(http.MethodGet, uri, headers, nil, b.Container.bsc.auth) + if err != nil { + return out, err + } + defer resp.body.Close() + + err = xmlUnmarshal(resp.body, &out) + return out, err +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/client.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/client.go index 817f934c5..b4ac22d82 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/storage/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/client.go @@ -2,6 +2,7 @@ package storage import ( + "bufio" "bytes" "encoding/base64" "encoding/json" @@ -10,21 +11,28 @@ import ( "fmt" "io" "io/ioutil" + "mime" + "mime/multipart" "net/http" "net/url" + "regexp" "runtime" "strconv" "strings" + "time" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" ) const ( - // DefaultBaseURL is the domain name used for storage requests when a - // default client is created. + // DefaultBaseURL is the domain name used for storage requests in the + // public cloud when a default client is created. DefaultBaseURL = "core.windows.net" - // DefaultAPIVersion is the Azure Storage API version string used when a + // DefaultAPIVersion is the Azure Storage API version string used when a // basic client is created. - DefaultAPIVersion = "2015-02-21" + DefaultAPIVersion = "2016-05-31" defaultUseHTTPS = true @@ -44,15 +52,66 @@ const ( storageEmulatorQueue = "127.0.0.1:10001" userAgentHeader = "User-Agent" + + userDefinedMetadataHeaderPrefix = "x-ms-meta-" ) +var ( + validStorageAccount = regexp.MustCompile("^[0-9a-z]{3,24}$") +) + +// Sender sends a request +type Sender interface { + Send(*Client, *http.Request) (*http.Response, error) +} + +// DefaultSender is the default sender for the client. It implements +// an automatic retry strategy. +type DefaultSender struct { + RetryAttempts int + RetryDuration time.Duration + ValidStatusCodes []int + attempts int // used for testing +} + +// Send is the default retry strategy in the client +func (ds *DefaultSender) Send(c *Client, req *http.Request) (resp *http.Response, err error) { + b := []byte{} + if req.Body != nil { + b, err = ioutil.ReadAll(req.Body) + if err != nil { + return resp, err + } + } + + for attempts := 0; attempts < ds.RetryAttempts; attempts++ { + if len(b) > 0 { + req.Body = ioutil.NopCloser(bytes.NewBuffer(b)) + } + resp, err = c.HTTPClient.Do(req) + if err != nil || !autorest.ResponseHasStatusCode(resp, ds.ValidStatusCodes...) { + return resp, err + } + autorest.DelayForBackoff(ds.RetryDuration, attempts, req.Cancel) + ds.attempts = attempts + } + ds.attempts++ + return resp, err +} + // Client is the object that needs to be constructed to perform // operations on the storage account. type Client struct { // HTTPClient is the http.Client used to initiate API - // requests. If it is nil, http.DefaultClient is used. + // requests. http.DefaultClient is used when creating a + // client. HTTPClient *http.Client + // Sender is an interface that sends the request. Clients are + // created with a DefaultSender. The DefaultSender has an + // automatic retry strategy built in. The Sender can be customized. + Sender Sender + accountName string accountKey []byte useHTTPS bool @@ -85,6 +144,8 @@ type AzureStorageServiceError struct { Reason string `xml:"Reason"` StatusCode int RequestID string + Date string + APIVersion string } type odataErrorMessageMessage struct { @@ -131,7 +192,15 @@ func NewBasicClient(accountName, accountKey string) (Client, error) { return NewEmulatorClient() } return NewClient(accountName, accountKey, DefaultBaseURL, DefaultAPIVersion, defaultUseHTTPS) +} +// NewBasicClientOnSovereignCloud constructs a Client with given storage service name and +// key in the referenced cloud. +func NewBasicClientOnSovereignCloud(accountName, accountKey string, env azure.Environment) (Client, error) { + if accountName == StorageEmulatorAccountName { + return NewEmulatorClient() + } + return NewClient(accountName, accountKey, env.StorageEndpointSuffix, DefaultAPIVersion, defaultUseHTTPS) } //NewEmulatorClient contructs a Client intended to only work with Azure @@ -145,8 +214,8 @@ func NewEmulatorClient() (Client, error) { // storage endpoint than Azure Public Cloud. func NewClient(accountName, accountKey, blobServiceBaseURL, apiVersion string, useHTTPS bool) (Client, error) { var c Client - if accountName == "" { - return c, fmt.Errorf("azure: account name required") + if !IsValidStorageAccount(accountName) { + return c, fmt.Errorf("azure: account name is not valid: it must be between 3 and 24 characters, and only may contain numbers and lowercase letters: %v", accountName) } else if accountKey == "" { return c, fmt.Errorf("azure: account key required") } else if blobServiceBaseURL == "" { @@ -159,19 +228,37 @@ func NewClient(accountName, accountKey, blobServiceBaseURL, apiVersion string, u } c = Client{ + HTTPClient: http.DefaultClient, accountName: accountName, accountKey: key, useHTTPS: useHTTPS, baseURL: blobServiceBaseURL, apiVersion: apiVersion, UseSharedKeyLite: false, + Sender: &DefaultSender{ + RetryAttempts: 5, + ValidStatusCodes: []int{ + http.StatusRequestTimeout, // 408 + http.StatusInternalServerError, // 500 + http.StatusBadGateway, // 502 + http.StatusServiceUnavailable, // 503 + http.StatusGatewayTimeout, // 504 + }, + RetryDuration: time.Second * 5, + }, } c.userAgent = c.getDefaultUserAgent() return c, nil } +// IsValidStorageAccount checks if the storage account name is valid. +// See https://docs.microsoft.com/en-us/azure/storage/storage-create-storage-account +func IsValidStorageAccount(account string) bool { + return validStorageAccount.MatchString(account) +} + func (c Client) getDefaultUserAgent() string { - return fmt.Sprintf("Go/%s (%s-%s) Azure-SDK-For-Go/%s storage-dataplane/%s", + return fmt.Sprintf("Go/%s (%s-%s) azure-storage-go/%s api-version/%s", runtime.Version(), runtime.GOARCH, runtime.GOOS, @@ -200,7 +287,7 @@ func (c *Client) protectUserAgent(extraheaders map[string]string) map[string]str return extraheaders } -func (c Client) getBaseURL(service string) string { +func (c Client) getBaseURL(service string) *url.URL { scheme := "http" if c.useHTTPS { scheme = "https" @@ -219,18 +306,14 @@ func (c Client) getBaseURL(service string) string { host = fmt.Sprintf("%s.%s.%s", c.accountName, service, c.baseURL) } - u := &url.URL{ + return &url.URL{ Scheme: scheme, - Host: host} - return u.String() + Host: host, + } } func (c Client) getEndpoint(service, path string, params url.Values) string { - u, err := url.Parse(c.getBaseURL(service)) - if err != nil { - // really should not be happening - panic(err) - } + u := c.getBaseURL(service) // API doesn't accept path segments not starting with '/' if !strings.HasPrefix(path, "/") { @@ -335,11 +418,7 @@ func (c Client) exec(verb, url string, headers map[string]string, body io.Reader req.Header.Add(k, v) } - httpClient := c.HTTPClient - if httpClient == nil { - httpClient = http.DefaultClient - } - resp, err := httpClient.Do(req) + resp, err := c.Sender.Send(&c, req) if err != nil { return nil, err } @@ -347,18 +426,18 @@ func (c Client) exec(verb, url string, headers map[string]string, body io.Reader statusCode := resp.StatusCode if statusCode >= 400 && statusCode <= 505 { var respBody []byte - respBody, err = readResponseBody(resp) + respBody, err = readAndCloseBody(resp.Body) if err != nil { return nil, err } - requestID := resp.Header.Get("x-ms-request-id") + requestID, date, version := getDebugHeaders(resp.Header) if len(respBody) == 0 { // no error in response body, might happen in HEAD requests - err = serviceErrFromStatusCode(resp.StatusCode, resp.Status, requestID) + err = serviceErrFromStatusCode(resp.StatusCode, resp.Status, requestID, date, version) } else { // response contains storage service error object, unmarshal - storageErr, errIn := serviceErrFromXML(respBody, resp.StatusCode, requestID) + storageErr, errIn := serviceErrFromXML(respBody, resp.StatusCode, requestID, date, version) if err != nil { // error unmarshaling the error response err = errIn } @@ -377,10 +456,10 @@ func (c Client) exec(verb, url string, headers map[string]string, body io.Reader body: resp.Body}, nil } -func (c Client) execInternalJSON(verb, url string, headers map[string]string, body io.Reader, auth authentication) (*odataResponse, error) { +func (c Client) execInternalJSONCommon(verb, url string, headers map[string]string, body io.Reader, auth authentication) (*odataResponse, *http.Request, *http.Response, error) { headers, err := c.addAuthorizationHeader(verb, url, headers, auth) if err != nil { - return nil, err + return nil, nil, nil, err } req, err := http.NewRequest(verb, url, body) @@ -388,14 +467,9 @@ func (c Client) execInternalJSON(verb, url string, headers map[string]string, bo req.Header.Add(k, v) } - httpClient := c.HTTPClient - if httpClient == nil { - httpClient = http.DefaultClient - } - - resp, err := httpClient.Do(req) + resp, err := c.Sender.Send(&c, req) if err != nil { - return nil, err + return nil, nil, nil, err } respToRet := &odataResponse{} @@ -406,55 +480,149 @@ func (c Client) execInternalJSON(verb, url string, headers map[string]string, bo statusCode := resp.StatusCode if statusCode >= 400 && statusCode <= 505 { var respBody []byte - respBody, err = readResponseBody(resp) + respBody, err = readAndCloseBody(resp.Body) if err != nil { - return nil, err + return nil, nil, nil, err } + requestID, date, version := getDebugHeaders(resp.Header) if len(respBody) == 0 { // no error in response body, might happen in HEAD requests - err = serviceErrFromStatusCode(resp.StatusCode, resp.Status, resp.Header.Get("x-ms-request-id")) - return respToRet, err + err = serviceErrFromStatusCode(resp.StatusCode, resp.Status, requestID, date, version) + return respToRet, req, resp, err } // try unmarshal as odata.error json err = json.Unmarshal(respBody, &respToRet.odata) - return respToRet, err + } + + return respToRet, req, resp, err +} + +func (c Client) execInternalJSON(verb, url string, headers map[string]string, body io.Reader, auth authentication) (*odataResponse, error) { + respToRet, _, _, err := c.execInternalJSONCommon(verb, url, headers, body, auth) + return respToRet, err +} + +func (c Client) execBatchOperationJSON(verb, url string, headers map[string]string, body io.Reader, auth authentication) (*odataResponse, error) { + // execute common query, get back generated request, response etc... for more processing. + respToRet, req, resp, err := c.execInternalJSONCommon(verb, url, headers, body, auth) + if err != nil { + return nil, err + } + + // return the OData in the case of executing batch commands. + // In this case we need to read the outer batch boundary and contents. + // Then we read the changeset information within the batch + var respBody []byte + respBody, err = readAndCloseBody(resp.Body) + if err != nil { + return nil, err + } + + // outer multipart body + _, batchHeader, err := mime.ParseMediaType(resp.Header["Content-Type"][0]) + if err != nil { + return nil, err + } + + // batch details. + batchBoundary := batchHeader["boundary"] + batchPartBuf, changesetBoundary, err := genBatchReader(batchBoundary, respBody) + if err != nil { + return nil, err + } + + // changeset details. + err = genChangesetReader(req, respToRet, batchPartBuf, changesetBoundary) + if err != nil { + return nil, err } return respToRet, nil } -func readResponseBody(resp *http.Response) ([]byte, error) { - defer resp.Body.Close() - out, err := ioutil.ReadAll(resp.Body) +func genChangesetReader(req *http.Request, respToRet *odataResponse, batchPartBuf io.Reader, changesetBoundary string) error { + changesetMultiReader := multipart.NewReader(batchPartBuf, changesetBoundary) + changesetPart, err := changesetMultiReader.NextPart() + if err != nil { + return err + } + + changesetPartBufioReader := bufio.NewReader(changesetPart) + changesetResp, err := http.ReadResponse(changesetPartBufioReader, req) + if err != nil { + return err + } + + if changesetResp.StatusCode != http.StatusNoContent { + changesetBody, err := readAndCloseBody(changesetResp.Body) + err = json.Unmarshal(changesetBody, &respToRet.odata) + if err != nil { + return err + } + respToRet.statusCode = changesetResp.StatusCode + } + + return nil +} + +func genBatchReader(batchBoundary string, respBody []byte) (io.Reader, string, error) { + respBodyString := string(respBody) + respBodyReader := strings.NewReader(respBodyString) + + // reading batchresponse + batchMultiReader := multipart.NewReader(respBodyReader, batchBoundary) + batchPart, err := batchMultiReader.NextPart() + if err != nil { + return nil, "", err + } + batchPartBufioReader := bufio.NewReader(batchPart) + + _, changesetHeader, err := mime.ParseMediaType(batchPart.Header.Get("Content-Type")) + if err != nil { + return nil, "", err + } + changesetBoundary := changesetHeader["boundary"] + return batchPartBufioReader, changesetBoundary, nil +} + +func readAndCloseBody(body io.ReadCloser) ([]byte, error) { + defer body.Close() + out, err := ioutil.ReadAll(body) if err == io.EOF { err = nil } return out, err } -func serviceErrFromXML(body []byte, statusCode int, requestID string) (AzureStorageServiceError, error) { - var storageErr AzureStorageServiceError +func serviceErrFromXML(body []byte, statusCode int, requestID, date, version string) (AzureStorageServiceError, error) { + storageErr := AzureStorageServiceError{ + StatusCode: statusCode, + RequestID: requestID, + Date: date, + APIVersion: version, + } if err := xml.Unmarshal(body, &storageErr); err != nil { + storageErr.Message = fmt.Sprintf("Response body could no be unmarshaled: %v. Body: %v.", err, string(body)) return storageErr, err } - storageErr.StatusCode = statusCode - storageErr.RequestID = requestID return storageErr, nil } -func serviceErrFromStatusCode(code int, status string, requestID string) AzureStorageServiceError { +func serviceErrFromStatusCode(code int, status string, requestID, date, version string) AzureStorageServiceError { return AzureStorageServiceError{ StatusCode: code, Code: status, RequestID: requestID, + Date: date, + APIVersion: version, Message: "no response body was available for error status code", } } func (e AzureStorageServiceError) Error() string { - return fmt.Sprintf("storage: service returned error: StatusCode=%d, ErrorCode=%s, ErrorMessage=%s, RequestId=%s, QueryParameterName=%s, QueryParameterValue=%s", - e.StatusCode, e.Code, e.Message, e.RequestID, e.QueryParameterName, e.QueryParameterValue) + return fmt.Sprintf("storage: service returned error: StatusCode=%d, ErrorCode=%s, ErrorMessage=%s, RequestInitiated=%s, RequestId=%s, API Version=%s, QueryParameterName=%s, QueryParameterValue=%s", + e.StatusCode, e.Code, e.Message, e.Date, e.RequestID, e.APIVersion, e.QueryParameterName, e.QueryParameterValue) } // checkRespCode returns UnexpectedStatusError if the given response code is not @@ -467,3 +635,18 @@ func checkRespCode(respCode int, allowed []int) error { } return UnexpectedStatusCodeError{allowed, respCode} } + +func (c Client) addMetadataToHeaders(h map[string]string, metadata map[string]string) map[string]string { + metadata = c.protectUserAgent(metadata) + for k, v := range metadata { + h[userDefinedMetadataHeaderPrefix+k] = v + } + return h +} + +func getDebugHeaders(h http.Header) (requestID, date, version string) { + requestID = h.Get("x-ms-request-id") + version = h.Get("x-ms-version") + date = h.Get("Date") + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/container.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/container.go new file mode 100644 index 000000000..b20dfcf35 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/container.go @@ -0,0 +1,450 @@ +package storage + +import ( + "encoding/xml" + "errors" + "fmt" + "io" + "net/http" + "net/url" + "strconv" + "strings" + "time" +) + +// Container represents an Azure container. +type Container struct { + bsc *BlobStorageClient + Name string `xml:"Name"` + Properties ContainerProperties `xml:"Properties"` + Metadata map[string]string +} + +func (c *Container) buildPath() string { + return fmt.Sprintf("/%s", c.Name) +} + +// ContainerProperties contains various properties of a container returned from +// various endpoints like ListContainers. +type ContainerProperties struct { + LastModified string `xml:"Last-Modified"` + Etag string `xml:"Etag"` + LeaseStatus string `xml:"LeaseStatus"` + LeaseState string `xml:"LeaseState"` + LeaseDuration string `xml:"LeaseDuration"` +} + +// ContainerListResponse contains the response fields from +// ListContainers call. +// +// See https://msdn.microsoft.com/en-us/library/azure/dd179352.aspx +type ContainerListResponse struct { + XMLName xml.Name `xml:"EnumerationResults"` + Xmlns string `xml:"xmlns,attr"` + Prefix string `xml:"Prefix"` + Marker string `xml:"Marker"` + NextMarker string `xml:"NextMarker"` + MaxResults int64 `xml:"MaxResults"` + Containers []Container `xml:"Containers>Container"` +} + +// BlobListResponse contains the response fields from ListBlobs call. +// +// See https://msdn.microsoft.com/en-us/library/azure/dd135734.aspx +type BlobListResponse struct { + XMLName xml.Name `xml:"EnumerationResults"` + Xmlns string `xml:"xmlns,attr"` + Prefix string `xml:"Prefix"` + Marker string `xml:"Marker"` + NextMarker string `xml:"NextMarker"` + MaxResults int64 `xml:"MaxResults"` + Blobs []Blob `xml:"Blobs>Blob"` + + // BlobPrefix is used to traverse blobs as if it were a file system. + // It is returned if ListBlobsParameters.Delimiter is specified. + // The list here can be thought of as "folders" that may contain + // other folders or blobs. + BlobPrefixes []string `xml:"Blobs>BlobPrefix>Name"` + + // Delimiter is used to traverse blobs as if it were a file system. + // It is returned if ListBlobsParameters.Delimiter is specified. + Delimiter string `xml:"Delimiter"` +} + +// IncludeBlobDataset has options to include in a list blobs operation +type IncludeBlobDataset struct { + Snapshots bool + Metadata bool + UncommittedBlobs bool + Copy bool +} + +// ListBlobsParameters defines the set of customizable +// parameters to make a List Blobs call. +// +// See https://msdn.microsoft.com/en-us/library/azure/dd135734.aspx +type ListBlobsParameters struct { + Prefix string + Delimiter string + Marker string + Include *IncludeBlobDataset + MaxResults uint + Timeout uint + RequestID string +} + +func (p ListBlobsParameters) getParameters() url.Values { + out := url.Values{} + + if p.Prefix != "" { + out.Set("prefix", p.Prefix) + } + if p.Delimiter != "" { + out.Set("delimiter", p.Delimiter) + } + if p.Marker != "" { + out.Set("marker", p.Marker) + } + if p.Include != nil { + include := []string{} + include = addString(include, p.Include.Snapshots, "snapshots") + include = addString(include, p.Include.Metadata, "metadata") + include = addString(include, p.Include.UncommittedBlobs, "uncommittedblobs") + include = addString(include, p.Include.Copy, "copy") + fullInclude := strings.Join(include, ",") + out.Set("include", fullInclude) + } + if p.MaxResults != 0 { + out.Set("maxresults", strconv.FormatUint(uint64(p.MaxResults), 10)) + } + if p.Timeout != 0 { + out.Set("timeout", strconv.FormatUint(uint64(p.Timeout), 10)) + } + + return out +} + +func addString(datasets []string, include bool, text string) []string { + if include { + datasets = append(datasets, text) + } + return datasets +} + +// ContainerAccessType defines the access level to the container from a public +// request. +// +// See https://msdn.microsoft.com/en-us/library/azure/dd179468.aspx and "x-ms- +// blob-public-access" header. +type ContainerAccessType string + +// Access options for containers +const ( + ContainerAccessTypePrivate ContainerAccessType = "" + ContainerAccessTypeBlob ContainerAccessType = "blob" + ContainerAccessTypeContainer ContainerAccessType = "container" +) + +// ContainerAccessPolicy represents each access policy in the container ACL. +type ContainerAccessPolicy struct { + ID string + StartTime time.Time + ExpiryTime time.Time + CanRead bool + CanWrite bool + CanDelete bool +} + +// ContainerPermissions represents the container ACLs. +type ContainerPermissions struct { + AccessType ContainerAccessType + AccessPolicies []ContainerAccessPolicy +} + +// ContainerAccessHeader references header used when setting/getting container ACL +const ( + ContainerAccessHeader string = "x-ms-blob-public-access" +) + +// GetBlobReference returns a Blob object for the specified blob name. +func (c *Container) GetBlobReference(name string) *Blob { + return &Blob{ + Container: c, + Name: name, + } +} + +// CreateContainerOptions includes the options for a create container operation +type CreateContainerOptions struct { + Timeout uint + Access ContainerAccessType `header:"x-ms-blob-public-access"` + RequestID string `header:"x-ms-client-request-id"` +} + +// Create creates a blob container within the storage account +// with given name and access level. Returns error if container already exists. +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Create-Container +func (c *Container) Create(options *CreateContainerOptions) error { + resp, err := c.create(options) + if err != nil { + return err + } + readAndCloseBody(resp.body) + return checkRespCode(resp.statusCode, []int{http.StatusCreated}) +} + +// CreateIfNotExists creates a blob container if it does not exist. Returns +// true if container is newly created or false if container already exists. +func (c *Container) CreateIfNotExists(options *CreateContainerOptions) (bool, error) { + resp, err := c.create(options) + if resp != nil { + defer readAndCloseBody(resp.body) + if resp.statusCode == http.StatusCreated || resp.statusCode == http.StatusConflict { + return resp.statusCode == http.StatusCreated, nil + } + } + return false, err +} + +func (c *Container) create(options *CreateContainerOptions) (*storageResponse, error) { + query := url.Values{"restype": {"container"}} + headers := c.bsc.client.getStandardHeaders() + headers = c.bsc.client.addMetadataToHeaders(headers, c.Metadata) + + if options != nil { + query = addTimeout(query, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := c.bsc.client.getEndpoint(blobServiceName, c.buildPath(), query) + + return c.bsc.client.exec(http.MethodPut, uri, headers, nil, c.bsc.auth) +} + +// Exists returns true if a container with given name exists +// on the storage account, otherwise returns false. +func (c *Container) Exists() (bool, error) { + uri := c.bsc.client.getEndpoint(blobServiceName, c.buildPath(), url.Values{"restype": {"container"}}) + headers := c.bsc.client.getStandardHeaders() + + resp, err := c.bsc.client.exec(http.MethodHead, uri, headers, nil, c.bsc.auth) + if resp != nil { + defer readAndCloseBody(resp.body) + if resp.statusCode == http.StatusOK || resp.statusCode == http.StatusNotFound { + return resp.statusCode == http.StatusOK, nil + } + } + return false, err +} + +// SetContainerPermissionOptions includes options for a set container permissions operation +type SetContainerPermissionOptions struct { + Timeout uint + LeaseID string `header:"x-ms-lease-id"` + IfModifiedSince *time.Time `header:"If-Modified-Since"` + IfUnmodifiedSince *time.Time `header:"If-Unmodified-Since"` + RequestID string `header:"x-ms-client-request-id"` +} + +// SetPermissions sets up container permissions +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Set-Container-ACL +func (c *Container) SetPermissions(permissions ContainerPermissions, options *SetContainerPermissionOptions) error { + body, length, err := generateContainerACLpayload(permissions.AccessPolicies) + if err != nil { + return err + } + params := url.Values{ + "restype": {"container"}, + "comp": {"acl"}, + } + headers := c.bsc.client.getStandardHeaders() + headers = addToHeaders(headers, ContainerAccessHeader, string(permissions.AccessType)) + headers["Content-Length"] = strconv.Itoa(length) + + if options != nil { + params = addTimeout(params, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := c.bsc.client.getEndpoint(blobServiceName, c.buildPath(), params) + + resp, err := c.bsc.client.exec(http.MethodPut, uri, headers, body, c.bsc.auth) + if err != nil { + return err + } + defer readAndCloseBody(resp.body) + + if err := checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { + return errors.New("Unable to set permissions") + } + + return nil +} + +// GetContainerPermissionOptions includes options for a get container permissions operation +type GetContainerPermissionOptions struct { + Timeout uint + LeaseID string `header:"x-ms-lease-id"` + RequestID string `header:"x-ms-client-request-id"` +} + +// GetPermissions gets the container permissions as per https://msdn.microsoft.com/en-us/library/azure/dd179469.aspx +// If timeout is 0 then it will not be passed to Azure +// leaseID will only be passed to Azure if populated +func (c *Container) GetPermissions(options *GetContainerPermissionOptions) (*ContainerPermissions, error) { + params := url.Values{ + "restype": {"container"}, + "comp": {"acl"}, + } + headers := c.bsc.client.getStandardHeaders() + + if options != nil { + params = addTimeout(params, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := c.bsc.client.getEndpoint(blobServiceName, c.buildPath(), params) + + resp, err := c.bsc.client.exec(http.MethodGet, uri, headers, nil, c.bsc.auth) + if err != nil { + return nil, err + } + defer resp.body.Close() + + var ap AccessPolicy + err = xmlUnmarshal(resp.body, &ap.SignedIdentifiersList) + if err != nil { + return nil, err + } + return buildAccessPolicy(ap, &resp.headers), nil +} + +func buildAccessPolicy(ap AccessPolicy, headers *http.Header) *ContainerPermissions { + // containerAccess. Blob, Container, empty + containerAccess := headers.Get(http.CanonicalHeaderKey(ContainerAccessHeader)) + permissions := ContainerPermissions{ + AccessType: ContainerAccessType(containerAccess), + AccessPolicies: []ContainerAccessPolicy{}, + } + + for _, policy := range ap.SignedIdentifiersList.SignedIdentifiers { + capd := ContainerAccessPolicy{ + ID: policy.ID, + StartTime: policy.AccessPolicy.StartTime, + ExpiryTime: policy.AccessPolicy.ExpiryTime, + } + capd.CanRead = updatePermissions(policy.AccessPolicy.Permission, "r") + capd.CanWrite = updatePermissions(policy.AccessPolicy.Permission, "w") + capd.CanDelete = updatePermissions(policy.AccessPolicy.Permission, "d") + + permissions.AccessPolicies = append(permissions.AccessPolicies, capd) + } + return &permissions +} + +// DeleteContainerOptions includes options for a delete container operation +type DeleteContainerOptions struct { + Timeout uint + LeaseID string `header:"x-ms-lease-id"` + IfModifiedSince *time.Time `header:"If-Modified-Since"` + IfUnmodifiedSince *time.Time `header:"If-Unmodified-Since"` + RequestID string `header:"x-ms-client-request-id"` +} + +// Delete deletes the container with given name on the storage +// account. If the container does not exist returns error. +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/delete-container +func (c *Container) Delete(options *DeleteContainerOptions) error { + resp, err := c.delete(options) + if err != nil { + return err + } + readAndCloseBody(resp.body) + return checkRespCode(resp.statusCode, []int{http.StatusAccepted}) +} + +// DeleteIfExists deletes the container with given name on the storage +// account if it exists. Returns true if container is deleted with this call, or +// false if the container did not exist at the time of the Delete Container +// operation. +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/delete-container +func (c *Container) DeleteIfExists(options *DeleteContainerOptions) (bool, error) { + resp, err := c.delete(options) + if resp != nil { + defer readAndCloseBody(resp.body) + if resp.statusCode == http.StatusAccepted || resp.statusCode == http.StatusNotFound { + return resp.statusCode == http.StatusAccepted, nil + } + } + return false, err +} + +func (c *Container) delete(options *DeleteContainerOptions) (*storageResponse, error) { + query := url.Values{"restype": {"container"}} + headers := c.bsc.client.getStandardHeaders() + + if options != nil { + query = addTimeout(query, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := c.bsc.client.getEndpoint(blobServiceName, c.buildPath(), query) + + return c.bsc.client.exec(http.MethodDelete, uri, headers, nil, c.bsc.auth) +} + +// ListBlobs returns an object that contains list of blobs in the container, +// pagination token and other information in the response of List Blobs call. +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/List-Blobs +func (c *Container) ListBlobs(params ListBlobsParameters) (BlobListResponse, error) { + q := mergeParams(params.getParameters(), url.Values{ + "restype": {"container"}, + "comp": {"list"}}, + ) + uri := c.bsc.client.getEndpoint(blobServiceName, c.buildPath(), q) + + headers := c.bsc.client.getStandardHeaders() + headers = addToHeaders(headers, "x-ms-client-request-id", params.RequestID) + + var out BlobListResponse + resp, err := c.bsc.client.exec(http.MethodGet, uri, headers, nil, c.bsc.auth) + if err != nil { + return out, err + } + defer resp.body.Close() + + err = xmlUnmarshal(resp.body, &out) + return out, err +} + +func generateContainerACLpayload(policies []ContainerAccessPolicy) (io.Reader, int, error) { + sil := SignedIdentifiers{ + SignedIdentifiers: []SignedIdentifier{}, + } + for _, capd := range policies { + permission := capd.generateContainerPermissions() + signedIdentifier := convertAccessPolicyToXMLStructs(capd.ID, capd.StartTime, capd.ExpiryTime, permission) + sil.SignedIdentifiers = append(sil.SignedIdentifiers, signedIdentifier) + } + return xmlMarshal(sil) +} + +func (capd *ContainerAccessPolicy) generateContainerPermissions() (permissions string) { + // generate the permissions string (rwd). + // still want the end user API to have bool flags. + permissions = "" + + if capd.CanRead { + permissions += "r" + } + + if capd.CanWrite { + permissions += "w" + } + + if capd.CanDelete { + permissions += "d" + } + + return permissions +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/copyblob.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/copyblob.go new file mode 100644 index 000000000..377a3c622 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/copyblob.go @@ -0,0 +1,223 @@ +package storage + +import ( + "errors" + "fmt" + "net/http" + "net/url" + "strings" + "time" +) + +const ( + blobCopyStatusPending = "pending" + blobCopyStatusSuccess = "success" + blobCopyStatusAborted = "aborted" + blobCopyStatusFailed = "failed" +) + +// CopyOptions includes the options for a copy blob operation +type CopyOptions struct { + Timeout uint + Source CopyOptionsConditions + Destiny CopyOptionsConditions + RequestID string +} + +// IncrementalCopyOptions includes the options for an incremental copy blob operation +type IncrementalCopyOptions struct { + Timeout uint + Destination IncrementalCopyOptionsConditions + RequestID string +} + +// CopyOptionsConditions includes some conditional options in a copy blob operation +type CopyOptionsConditions struct { + LeaseID string + IfModifiedSince *time.Time + IfUnmodifiedSince *time.Time + IfMatch string + IfNoneMatch string +} + +// IncrementalCopyOptionsConditions includes some conditional options in a copy blob operation +type IncrementalCopyOptionsConditions struct { + IfModifiedSince *time.Time + IfUnmodifiedSince *time.Time + IfMatch string + IfNoneMatch string +} + +// Copy starts a blob copy operation and waits for the operation to +// complete. sourceBlob parameter must be a canonical URL to the blob (can be +// obtained using GetBlobURL method.) There is no SLA on blob copy and therefore +// this helper method works faster on smaller files. +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Copy-Blob +func (b *Blob) Copy(sourceBlob string, options *CopyOptions) error { + copyID, err := b.StartCopy(sourceBlob, options) + if err != nil { + return err + } + + return b.WaitForCopy(copyID) +} + +// StartCopy starts a blob copy operation. +// sourceBlob parameter must be a canonical URL to the blob (can be +// obtained using GetBlobURL method.) +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Copy-Blob +func (b *Blob) StartCopy(sourceBlob string, options *CopyOptions) (string, error) { + params := url.Values{} + headers := b.Container.bsc.client.getStandardHeaders() + headers["x-ms-copy-source"] = sourceBlob + headers = b.Container.bsc.client.addMetadataToHeaders(headers, b.Metadata) + + if options != nil { + params = addTimeout(params, options.Timeout) + headers = addToHeaders(headers, "x-ms-client-request-id", options.RequestID) + // source + headers = addToHeaders(headers, "x-ms-source-lease-id", options.Source.LeaseID) + headers = addTimeToHeaders(headers, "x-ms-source-if-modified-since", options.Source.IfModifiedSince) + headers = addTimeToHeaders(headers, "x-ms-source-if-unmodified-since", options.Source.IfUnmodifiedSince) + headers = addToHeaders(headers, "x-ms-source-if-match", options.Source.IfMatch) + headers = addToHeaders(headers, "x-ms-source-if-none-match", options.Source.IfNoneMatch) + //destiny + headers = addToHeaders(headers, "x-ms-lease-id", options.Destiny.LeaseID) + headers = addTimeToHeaders(headers, "x-ms-if-modified-since", options.Destiny.IfModifiedSince) + headers = addTimeToHeaders(headers, "x-ms-if-unmodified-since", options.Destiny.IfUnmodifiedSince) + headers = addToHeaders(headers, "x-ms-if-match", options.Destiny.IfMatch) + headers = addToHeaders(headers, "x-ms-if-none-match", options.Destiny.IfNoneMatch) + } + uri := b.Container.bsc.client.getEndpoint(blobServiceName, b.buildPath(), params) + + resp, err := b.Container.bsc.client.exec(http.MethodPut, uri, headers, nil, b.Container.bsc.auth) + if err != nil { + return "", err + } + defer readAndCloseBody(resp.body) + + if err := checkRespCode(resp.statusCode, []int{http.StatusAccepted, http.StatusCreated}); err != nil { + return "", err + } + + copyID := resp.headers.Get("x-ms-copy-id") + if copyID == "" { + return "", errors.New("Got empty copy id header") + } + return copyID, nil +} + +// AbortCopyOptions includes the options for an abort blob operation +type AbortCopyOptions struct { + Timeout uint + LeaseID string `header:"x-ms-lease-id"` + RequestID string `header:"x-ms-client-request-id"` +} + +// AbortCopy aborts a BlobCopy which has already been triggered by the StartBlobCopy function. +// copyID is generated from StartBlobCopy function. +// currentLeaseID is required IF the destination blob has an active lease on it. +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Abort-Copy-Blob +func (b *Blob) AbortCopy(copyID string, options *AbortCopyOptions) error { + params := url.Values{ + "comp": {"copy"}, + "copyid": {copyID}, + } + headers := b.Container.bsc.client.getStandardHeaders() + headers["x-ms-copy-action"] = "abort" + + if options != nil { + params = addTimeout(params, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := b.Container.bsc.client.getEndpoint(blobServiceName, b.buildPath(), params) + + resp, err := b.Container.bsc.client.exec(http.MethodPut, uri, headers, nil, b.Container.bsc.auth) + if err != nil { + return err + } + readAndCloseBody(resp.body) + return checkRespCode(resp.statusCode, []int{http.StatusNoContent}) +} + +// WaitForCopy loops until a BlobCopy operation is completed (or fails with error) +func (b *Blob) WaitForCopy(copyID string) error { + for { + err := b.GetProperties(nil) + if err != nil { + return err + } + + if b.Properties.CopyID != copyID { + return errBlobCopyIDMismatch + } + + switch b.Properties.CopyStatus { + case blobCopyStatusSuccess: + return nil + case blobCopyStatusPending: + continue + case blobCopyStatusAborted: + return errBlobCopyAborted + case blobCopyStatusFailed: + return fmt.Errorf("storage: blob copy failed. Id=%s Description=%s", b.Properties.CopyID, b.Properties.CopyStatusDescription) + default: + return fmt.Errorf("storage: unhandled blob copy status: '%s'", b.Properties.CopyStatus) + } + } +} + +// IncrementalCopyBlob copies a snapshot of a source blob and copies to referring blob +// sourceBlob parameter must be a valid snapshot URL of the original blob. +// THe original blob mut be public, or use a Shared Access Signature. +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/incremental-copy-blob . +func (b *Blob) IncrementalCopyBlob(sourceBlobURL string, snapshotTime time.Time, options *IncrementalCopyOptions) (string, error) { + params := url.Values{"comp": {"incrementalcopy"}} + + // need formatting to 7 decimal places so it's friendly to Windows and *nix + snapshotTimeFormatted := snapshotTime.Format("2006-01-02T15:04:05.0000000Z") + u, err := url.Parse(sourceBlobURL) + if err != nil { + return "", err + } + query := u.Query() + query.Add("snapshot", snapshotTimeFormatted) + encodedQuery := query.Encode() + encodedQuery = strings.Replace(encodedQuery, "%3A", ":", -1) + u.RawQuery = encodedQuery + snapshotURL := u.String() + + headers := b.Container.bsc.client.getStandardHeaders() + headers["x-ms-copy-source"] = snapshotURL + + if options != nil { + addTimeout(params, options.Timeout) + headers = addToHeaders(headers, "x-ms-client-request-id", options.RequestID) + headers = addTimeToHeaders(headers, "x-ms-if-modified-since", options.Destination.IfModifiedSince) + headers = addTimeToHeaders(headers, "x-ms-if-unmodified-since", options.Destination.IfUnmodifiedSince) + headers = addToHeaders(headers, "x-ms-if-match", options.Destination.IfMatch) + headers = addToHeaders(headers, "x-ms-if-none-match", options.Destination.IfNoneMatch) + } + + // get URI of destination blob + uri := b.Container.bsc.client.getEndpoint(blobServiceName, b.buildPath(), params) + + resp, err := b.Container.bsc.client.exec(http.MethodPut, uri, headers, nil, b.Container.bsc.auth) + if err != nil { + return "", err + } + defer readAndCloseBody(resp.body) + + if err := checkRespCode(resp.statusCode, []int{http.StatusAccepted}); err != nil { + return "", err + } + + copyID := resp.headers.Get("x-ms-copy-id") + if copyID == "" { + return "", errors.New("Got empty copy id header") + } + return copyID, nil +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/directory.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/directory.go index d07e0af1c..29610329e 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/storage/directory.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/directory.go @@ -25,8 +25,9 @@ type DirectoryProperties struct { // ListDirsAndFilesParameters defines the set of customizable parameters to // make a List Files and Directories call. // -// See https://msdn.microsoft.com/en-us/library/azure/dn166980.aspx +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/List-Directories-and-Files type ListDirsAndFilesParameters struct { + Prefix string Marker string MaxResults uint Timeout uint @@ -35,7 +36,7 @@ type ListDirsAndFilesParameters struct { // DirsAndFilesListResponse contains the response fields from // a List Files and Directories call. // -// See https://msdn.microsoft.com/en-us/library/azure/dn166980.aspx +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/List-Directories-and-Files type DirsAndFilesListResponse struct { XMLName xml.Name `xml:"EnumerationResults"` Xmlns string `xml:"xmlns,attr"` @@ -60,14 +61,15 @@ func (d *Directory) buildPath() string { // Create this directory in the associated share. // If a directory with the same name already exists, the operation fails. // -// See https://msdn.microsoft.com/en-us/library/azure/dn166993.aspx -func (d *Directory) Create() error { +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Create-Directory +func (d *Directory) Create(options *FileRequestOptions) error { // if this is the root directory exit early if d.parent == nil { return nil } - headers, err := d.fsc.createResource(d.buildPath(), resourceDirectory, mergeMDIntoExtraHeaders(d.Metadata, nil)) + params := prepareOptions(options) + headers, err := d.fsc.createResource(d.buildPath(), resourceDirectory, params, mergeMDIntoExtraHeaders(d.Metadata, nil), []int{http.StatusCreated}) if err != nil { return err } @@ -80,23 +82,24 @@ func (d *Directory) Create() error { // directory does not exists. Returns true if the directory is newly created or // false if the directory already exists. // -// See https://msdn.microsoft.com/en-us/library/azure/dn166993.aspx -func (d *Directory) CreateIfNotExists() (bool, error) { +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Create-Directory +func (d *Directory) CreateIfNotExists(options *FileRequestOptions) (bool, error) { // if this is the root directory exit early if d.parent == nil { return false, nil } - resp, err := d.fsc.createResourceNoClose(d.buildPath(), resourceDirectory, nil) + params := prepareOptions(options) + resp, err := d.fsc.createResourceNoClose(d.buildPath(), resourceDirectory, params, nil) if resp != nil { - defer resp.body.Close() + defer readAndCloseBody(resp.body) if resp.statusCode == http.StatusCreated || resp.statusCode == http.StatusConflict { if resp.statusCode == http.StatusCreated { d.updateEtagAndLastModified(resp.headers) return true, nil } - return false, d.FetchAttributes() + return false, d.FetchAttributes(nil) } } @@ -106,18 +109,18 @@ func (d *Directory) CreateIfNotExists() (bool, error) { // Delete removes this directory. It must be empty in order to be deleted. // If the directory does not exist the operation fails. // -// See https://msdn.microsoft.com/en-us/library/azure/dn166969.aspx -func (d *Directory) Delete() error { - return d.fsc.deleteResource(d.buildPath(), resourceDirectory) +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Delete-Directory +func (d *Directory) Delete(options *FileRequestOptions) error { + return d.fsc.deleteResource(d.buildPath(), resourceDirectory, options) } // DeleteIfExists removes this directory if it exists. // -// See https://msdn.microsoft.com/en-us/library/azure/dn166969.aspx -func (d *Directory) DeleteIfExists() (bool, error) { - resp, err := d.fsc.deleteResourceNoClose(d.buildPath(), resourceDirectory) +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Delete-Directory +func (d *Directory) DeleteIfExists(options *FileRequestOptions) (bool, error) { + resp, err := d.fsc.deleteResourceNoClose(d.buildPath(), resourceDirectory, options) if resp != nil { - defer resp.body.Close() + defer readAndCloseBody(resp.body) if resp.statusCode == http.StatusAccepted || resp.statusCode == http.StatusNotFound { return resp.statusCode == http.StatusAccepted, nil } @@ -135,8 +138,10 @@ func (d *Directory) Exists() (bool, error) { } // FetchAttributes retrieves metadata for this directory. -func (d *Directory) FetchAttributes() error { - headers, err := d.fsc.getResourceHeaders(d.buildPath(), compNone, resourceDirectory, http.MethodHead) +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-directory-properties +func (d *Directory) FetchAttributes(options *FileRequestOptions) error { + params := prepareOptions(options) + headers, err := d.fsc.getResourceHeaders(d.buildPath(), compNone, resourceDirectory, params, http.MethodHead) if err != nil { return err } @@ -170,7 +175,7 @@ func (d *Directory) GetFileReference(name string) *File { // ListDirsAndFiles returns a list of files and directories under this directory. // It also contains a pagination token and other response details. // -// See https://msdn.microsoft.com/en-us/library/azure/dn166980.aspx +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/List-Directories-and-Files func (d *Directory) ListDirsAndFiles(params ListDirsAndFilesParameters) (*DirsAndFilesListResponse, error) { q := mergeParams(params.getParameters(), getURLInitValues(compList, resourceDirectory)) @@ -192,9 +197,9 @@ func (d *Directory) ListDirsAndFiles(params ListDirsAndFilesParameters) (*DirsAn // are case-insensitive so case munging should not matter to other // applications either. // -// See https://msdn.microsoft.com/en-us/library/azure/mt427370.aspx -func (d *Directory) SetMetadata() error { - headers, err := d.fsc.setResourceHeaders(d.buildPath(), compMetadata, resourceDirectory, mergeMDIntoExtraHeaders(d.Metadata, nil)) +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Set-Directory-Metadata +func (d *Directory) SetMetadata(options *FileRequestOptions) error { + headers, err := d.fsc.setResourceHeaders(d.buildPath(), compMetadata, resourceDirectory, mergeMDIntoExtraHeaders(d.Metadata, nil), options) if err != nil { return err } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/entity.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/entity.go new file mode 100644 index 000000000..13e947507 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/entity.go @@ -0,0 +1,439 @@ +package storage + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "io/ioutil" + "net/http" + "net/url" + "strconv" + "strings" + "time" + + "github.com/satori/uuid" +) + +// Annotating as secure for gas scanning +/* #nosec */ +const ( + partitionKeyNode = "PartitionKey" + rowKeyNode = "RowKey" + etagErrorTemplate = "Etag didn't match: %v" +) + +var ( + errEmptyPayload = errors.New("Empty payload is not a valid metadata level for this operation") + errNilPreviousResult = errors.New("The previous results page is nil") + errNilNextLink = errors.New("There are no more pages in this query results") +) + +// Entity represents an entity inside an Azure table. +type Entity struct { + Table *Table + PartitionKey string + RowKey string + TimeStamp time.Time + OdataMetadata string + OdataType string + OdataID string + OdataEtag string + OdataEditLink string + Properties map[string]interface{} +} + +// GetEntityReference returns an Entity object with the specified +// partition key and row key. +func (t *Table) GetEntityReference(partitionKey, rowKey string) *Entity { + return &Entity{ + PartitionKey: partitionKey, + RowKey: rowKey, + Table: t, + } +} + +// EntityOptions includes options for entity operations. +type EntityOptions struct { + Timeout uint + RequestID string `header:"x-ms-client-request-id"` +} + +// GetEntityOptions includes options for a get entity operation +type GetEntityOptions struct { + Select []string + RequestID string `header:"x-ms-client-request-id"` +} + +// Get gets the referenced entity. Which properties to get can be +// specified using the select option. +// See: +// https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/query-entities +// https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/querying-tables-and-entities +func (e *Entity) Get(timeout uint, ml MetadataLevel, options *GetEntityOptions) error { + if ml == EmptyPayload { + return errEmptyPayload + } + // RowKey and PartitionKey could be lost if not included in the query + // As those are the entity identifiers, it is best if they are not lost + rk := e.RowKey + pk := e.PartitionKey + + query := url.Values{ + "timeout": {strconv.FormatUint(uint64(timeout), 10)}, + } + headers := e.Table.tsc.client.getStandardHeaders() + headers[headerAccept] = string(ml) + + if options != nil { + if len(options.Select) > 0 { + query.Add("$select", strings.Join(options.Select, ",")) + } + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + + uri := e.Table.tsc.client.getEndpoint(tableServiceName, e.buildPath(), query) + resp, err := e.Table.tsc.client.exec(http.MethodGet, uri, headers, nil, e.Table.tsc.auth) + if err != nil { + return err + } + defer readAndCloseBody(resp.body) + + if err = checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { + return err + } + + respBody, err := ioutil.ReadAll(resp.body) + if err != nil { + return err + } + err = json.Unmarshal(respBody, e) + if err != nil { + return err + } + e.PartitionKey = pk + e.RowKey = rk + + return nil +} + +// Insert inserts the referenced entity in its table. +// The function fails if there is an entity with the same +// PartitionKey and RowKey in the table. +// ml determines the level of detail of metadata in the operation response, +// or no data at all. +// See: https://docs.microsoft.com/rest/api/storageservices/fileservices/insert-entity +func (e *Entity) Insert(ml MetadataLevel, options *EntityOptions) error { + query, headers := options.getParameters() + headers = mergeHeaders(headers, e.Table.tsc.client.getStandardHeaders()) + + body, err := json.Marshal(e) + if err != nil { + return err + } + headers = addBodyRelatedHeaders(headers, len(body)) + headers = addReturnContentHeaders(headers, ml) + + uri := e.Table.tsc.client.getEndpoint(tableServiceName, e.Table.buildPath(), query) + resp, err := e.Table.tsc.client.exec(http.MethodPost, uri, headers, bytes.NewReader(body), e.Table.tsc.auth) + if err != nil { + return err + } + defer resp.body.Close() + + data, err := ioutil.ReadAll(resp.body) + if err != nil { + return err + } + + if ml != EmptyPayload { + if err = checkRespCode(resp.statusCode, []int{http.StatusCreated}); err != nil { + return err + } + if err = e.UnmarshalJSON(data); err != nil { + return err + } + } else { + if err = checkRespCode(resp.statusCode, []int{http.StatusNoContent}); err != nil { + return err + } + } + + return nil +} + +// Update updates the contents of an entity. The function fails if there is no entity +// with the same PartitionKey and RowKey in the table or if the ETag is different +// than the one in Azure. +// See: https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/update-entity2 +func (e *Entity) Update(force bool, options *EntityOptions) error { + return e.updateMerge(force, http.MethodPut, options) +} + +// Merge merges the contents of entity specified with PartitionKey and RowKey +// with the content specified in Properties. +// The function fails if there is no entity with the same PartitionKey and +// RowKey in the table or if the ETag is different than the one in Azure. +// Read more: https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/merge-entity +func (e *Entity) Merge(force bool, options *EntityOptions) error { + return e.updateMerge(force, "MERGE", options) +} + +// Delete deletes the entity. +// The function fails if there is no entity with the same PartitionKey and +// RowKey in the table or if the ETag is different than the one in Azure. +// See: https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/delete-entity1 +func (e *Entity) Delete(force bool, options *EntityOptions) error { + query, headers := options.getParameters() + headers = mergeHeaders(headers, e.Table.tsc.client.getStandardHeaders()) + + headers = addIfMatchHeader(headers, force, e.OdataEtag) + headers = addReturnContentHeaders(headers, EmptyPayload) + + uri := e.Table.tsc.client.getEndpoint(tableServiceName, e.buildPath(), query) + resp, err := e.Table.tsc.client.exec(http.MethodDelete, uri, headers, nil, e.Table.tsc.auth) + if err != nil { + if resp.statusCode == http.StatusPreconditionFailed { + return fmt.Errorf(etagErrorTemplate, err) + } + return err + } + defer readAndCloseBody(resp.body) + + if err = checkRespCode(resp.statusCode, []int{http.StatusNoContent}); err != nil { + return err + } + + return e.updateTimestamp(resp.headers) +} + +// InsertOrReplace inserts an entity or replaces the existing one. +// Read more: https://docs.microsoft.com/rest/api/storageservices/fileservices/insert-or-replace-entity +func (e *Entity) InsertOrReplace(options *EntityOptions) error { + return e.insertOr(http.MethodPut, options) +} + +// InsertOrMerge inserts an entity or merges the existing one. +// Read more: https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/insert-or-merge-entity +func (e *Entity) InsertOrMerge(options *EntityOptions) error { + return e.insertOr("MERGE", options) +} + +func (e *Entity) buildPath() string { + return fmt.Sprintf("%s(PartitionKey='%s', RowKey='%s')", e.Table.buildPath(), e.PartitionKey, e.RowKey) +} + +// MarshalJSON is a custom marshaller for entity +func (e *Entity) MarshalJSON() ([]byte, error) { + completeMap := map[string]interface{}{} + completeMap[partitionKeyNode] = e.PartitionKey + completeMap[rowKeyNode] = e.RowKey + for k, v := range e.Properties { + typeKey := strings.Join([]string{k, OdataTypeSuffix}, "") + switch t := v.(type) { + case []byte: + completeMap[typeKey] = OdataBinary + completeMap[k] = string(t) + case time.Time: + completeMap[typeKey] = OdataDateTime + completeMap[k] = t.Format(time.RFC3339Nano) + case uuid.UUID: + completeMap[typeKey] = OdataGUID + completeMap[k] = t.String() + case int64: + completeMap[typeKey] = OdataInt64 + completeMap[k] = fmt.Sprintf("%v", v) + default: + completeMap[k] = v + } + if strings.HasSuffix(k, OdataTypeSuffix) { + if !(completeMap[k] == OdataBinary || + completeMap[k] == OdataDateTime || + completeMap[k] == OdataGUID || + completeMap[k] == OdataInt64) { + return nil, fmt.Errorf("Odata.type annotation %v value is not valid", k) + } + valueKey := strings.TrimSuffix(k, OdataTypeSuffix) + if _, ok := completeMap[valueKey]; !ok { + return nil, fmt.Errorf("Odata.type annotation %v defined without value defined", k) + } + } + } + return json.Marshal(completeMap) +} + +// UnmarshalJSON is a custom unmarshaller for entities +func (e *Entity) UnmarshalJSON(data []byte) error { + errorTemplate := "Deserializing error: %v" + + props := map[string]interface{}{} + err := json.Unmarshal(data, &props) + if err != nil { + return err + } + + // deselialize metadata + e.OdataMetadata = stringFromMap(props, "odata.metadata") + e.OdataType = stringFromMap(props, "odata.type") + e.OdataID = stringFromMap(props, "odata.id") + e.OdataEtag = stringFromMap(props, "odata.etag") + e.OdataEditLink = stringFromMap(props, "odata.editLink") + e.PartitionKey = stringFromMap(props, partitionKeyNode) + e.RowKey = stringFromMap(props, rowKeyNode) + + // deserialize timestamp + timeStamp, ok := props["Timestamp"] + if ok { + str, ok := timeStamp.(string) + if !ok { + return fmt.Errorf(errorTemplate, "Timestamp casting error") + } + t, err := time.Parse(time.RFC3339Nano, str) + if err != nil { + return fmt.Errorf(errorTemplate, err) + } + e.TimeStamp = t + } + delete(props, "Timestamp") + delete(props, "Timestamp@odata.type") + + // deserialize entity (user defined fields) + for k, v := range props { + if strings.HasSuffix(k, OdataTypeSuffix) { + valueKey := strings.TrimSuffix(k, OdataTypeSuffix) + str, ok := props[valueKey].(string) + if !ok { + return fmt.Errorf(errorTemplate, fmt.Sprintf("%v casting error", v)) + } + switch v { + case OdataBinary: + props[valueKey] = []byte(str) + case OdataDateTime: + t, err := time.Parse("2006-01-02T15:04:05Z", str) + if err != nil { + return fmt.Errorf(errorTemplate, err) + } + props[valueKey] = t + case OdataGUID: + props[valueKey] = uuid.FromStringOrNil(str) + case OdataInt64: + i, err := strconv.ParseInt(str, 10, 64) + if err != nil { + return fmt.Errorf(errorTemplate, err) + } + props[valueKey] = i + default: + return fmt.Errorf(errorTemplate, fmt.Sprintf("%v is not supported", v)) + } + delete(props, k) + } + } + + e.Properties = props + return nil +} + +func getAndDelete(props map[string]interface{}, key string) interface{} { + if value, ok := props[key]; ok { + delete(props, key) + return value + } + return nil +} + +func addIfMatchHeader(h map[string]string, force bool, etag string) map[string]string { + if force { + h[headerIfMatch] = "*" + } else { + h[headerIfMatch] = etag + } + return h +} + +// updates Etag and timestamp +func (e *Entity) updateEtagAndTimestamp(headers http.Header) error { + e.OdataEtag = headers.Get(headerEtag) + return e.updateTimestamp(headers) +} + +func (e *Entity) updateTimestamp(headers http.Header) error { + str := headers.Get(headerDate) + t, err := time.Parse(time.RFC1123, str) + if err != nil { + return fmt.Errorf("Update timestamp error: %v", err) + } + e.TimeStamp = t + return nil +} + +func (e *Entity) insertOr(verb string, options *EntityOptions) error { + query, headers := options.getParameters() + headers = mergeHeaders(headers, e.Table.tsc.client.getStandardHeaders()) + + body, err := json.Marshal(e) + if err != nil { + return err + } + headers = addBodyRelatedHeaders(headers, len(body)) + headers = addReturnContentHeaders(headers, EmptyPayload) + + uri := e.Table.tsc.client.getEndpoint(tableServiceName, e.buildPath(), query) + resp, err := e.Table.tsc.client.exec(verb, uri, headers, bytes.NewReader(body), e.Table.tsc.auth) + if err != nil { + return err + } + defer readAndCloseBody(resp.body) + + if err = checkRespCode(resp.statusCode, []int{http.StatusNoContent}); err != nil { + return err + } + + return e.updateEtagAndTimestamp(resp.headers) +} + +func (e *Entity) updateMerge(force bool, verb string, options *EntityOptions) error { + query, headers := options.getParameters() + headers = mergeHeaders(headers, e.Table.tsc.client.getStandardHeaders()) + + body, err := json.Marshal(e) + if err != nil { + return err + } + headers = addBodyRelatedHeaders(headers, len(body)) + headers = addIfMatchHeader(headers, force, e.OdataEtag) + headers = addReturnContentHeaders(headers, EmptyPayload) + + uri := e.Table.tsc.client.getEndpoint(tableServiceName, e.buildPath(), query) + resp, err := e.Table.tsc.client.exec(verb, uri, headers, bytes.NewReader(body), e.Table.tsc.auth) + if err != nil { + if resp.statusCode == http.StatusPreconditionFailed { + return fmt.Errorf(etagErrorTemplate, err) + } + return err + } + defer readAndCloseBody(resp.body) + + if err = checkRespCode(resp.statusCode, []int{http.StatusNoContent}); err != nil { + return err + } + + return e.updateEtagAndTimestamp(resp.headers) +} + +func stringFromMap(props map[string]interface{}, key string) string { + value := getAndDelete(props, key) + if value != nil { + return value.(string) + } + return "" +} + +func (options *EntityOptions) getParameters() (url.Values, map[string]string) { + query := url.Values{} + headers := map[string]string{} + if options != nil { + query = addTimeout(query, options.Timeout) + headers = headersFromStruct(*options) + } + return query, headers +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/file.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/file.go index 575f3f726..238ac6d6d 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/storage/file.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/file.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "io" + "io/ioutil" "net/http" "net/url" "strconv" @@ -14,12 +15,13 @@ const oneTB = uint64(1099511627776) // File represents a file on a share. type File struct { - fsc *FileServiceClient - Metadata map[string]string - Name string `xml:"Name"` - parent *Directory - Properties FileProperties `xml:"Properties"` - share *Share + fsc *FileServiceClient + Metadata map[string]string + Name string `xml:"Name"` + parent *Directory + Properties FileProperties `xml:"Properties"` + share *Share + FileCopyProperties FileCopyState } // FileProperties contains various properties of a file. @@ -30,7 +32,7 @@ type FileProperties struct { Etag string Language string `header:"x-ms-content-language"` LastModified string - Length uint64 `xml:"Content-Length"` + Length uint64 `xml:"Content-Length" header:"x-ms-content-length"` MD5 string `header:"x-ms-content-md5"` Type string `header:"x-ms-content-type"` } @@ -38,10 +40,10 @@ type FileProperties struct { // FileCopyState contains various properties of a file copy operation. type FileCopyState struct { CompletionTime string - ID string + ID string `header:"x-ms-copy-id"` Progress string Source string - Status string + Status string `header:"x-ms-copy-status"` StatusDesc string } @@ -51,9 +53,23 @@ type FileStream struct { ContentMD5 string } +// FileRequestOptions will be passed to misc file operations. +// Currently just Timeout (in seconds) but could expand. +type FileRequestOptions struct { + Timeout uint // timeout duration in seconds. +} + +func prepareOptions(options *FileRequestOptions) url.Values { + params := url.Values{} + if options != nil { + params = addTimeout(params, options.Timeout) + } + return params +} + // FileRanges contains a list of file range information for a file. // -// See https://msdn.microsoft.com/en-us/library/azure/dn166984.aspx +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/List-Ranges type FileRanges struct { ContentLength uint64 LastModified string @@ -63,7 +79,7 @@ type FileRanges struct { // FileRange contains range information for a file. // -// See https://msdn.microsoft.com/en-us/library/azure/dn166984.aspx +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/List-Ranges type FileRange struct { Start uint64 `xml:"Start"` End uint64 `xml:"End"` @@ -80,9 +96,13 @@ func (f *File) buildPath() string { // ClearRange releases the specified range of space in a file. // -// See https://msdn.microsoft.com/en-us/library/azure/dn194276.aspx -func (f *File) ClearRange(fileRange FileRange) error { - headers, err := f.modifyRange(nil, fileRange, nil) +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Put-Range +func (f *File) ClearRange(fileRange FileRange, options *FileRequestOptions) error { + var timeout *uint + if options != nil { + timeout = &options.Timeout + } + headers, err := f.modifyRange(nil, fileRange, timeout, nil) if err != nil { return err } @@ -93,41 +113,59 @@ func (f *File) ClearRange(fileRange FileRange) error { // Create creates a new file or replaces an existing one. // -// See https://msdn.microsoft.com/en-us/library/azure/dn194271.aspx -func (f *File) Create(maxSize uint64) error { +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Create-File +func (f *File) Create(maxSize uint64, options *FileRequestOptions) error { if maxSize > oneTB { return fmt.Errorf("max file size is 1TB") } + params := prepareOptions(options) + headers := headersFromStruct(f.Properties) + headers["x-ms-content-length"] = strconv.FormatUint(maxSize, 10) + headers["x-ms-type"] = "file" - extraHeaders := map[string]string{ - "x-ms-content-length": strconv.FormatUint(maxSize, 10), - "x-ms-type": "file", - } - - headers, err := f.fsc.createResource(f.buildPath(), resourceFile, mergeMDIntoExtraHeaders(f.Metadata, extraHeaders)) + outputHeaders, err := f.fsc.createResource(f.buildPath(), resourceFile, params, mergeMDIntoExtraHeaders(f.Metadata, headers), []int{http.StatusCreated}) if err != nil { return err } f.Properties.Length = maxSize - f.updateEtagAndLastModified(headers) + f.updateEtagAndLastModified(outputHeaders) + return nil +} + +// CopyFile operation copied a file/blob from the sourceURL to the path provided. +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/copy-file +func (f *File) CopyFile(sourceURL string, options *FileRequestOptions) error { + extraHeaders := map[string]string{ + "x-ms-type": "file", + "x-ms-copy-source": sourceURL, + } + params := prepareOptions(options) + + headers, err := f.fsc.createResource(f.buildPath(), resourceFile, params, mergeMDIntoExtraHeaders(f.Metadata, extraHeaders), []int{http.StatusAccepted}) + if err != nil { + return err + } + + f.updateEtagLastModifiedAndCopyHeaders(headers) return nil } // Delete immediately removes this file from the storage account. // -// See https://msdn.microsoft.com/en-us/library/azure/dn689085.aspx -func (f *File) Delete() error { - return f.fsc.deleteResource(f.buildPath(), resourceFile) +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Delete-File2 +func (f *File) Delete(options *FileRequestOptions) error { + return f.fsc.deleteResource(f.buildPath(), resourceFile, options) } // DeleteIfExists removes this file if it exists. // -// See https://msdn.microsoft.com/en-us/library/azure/dn689085.aspx -func (f *File) DeleteIfExists() (bool, error) { - resp, err := f.fsc.deleteResourceNoClose(f.buildPath(), resourceFile) +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Delete-File2 +func (f *File) DeleteIfExists(options *FileRequestOptions) (bool, error) { + resp, err := f.fsc.deleteResourceNoClose(f.buildPath(), resourceFile, options) if resp != nil { - defer resp.body.Close() + defer readAndCloseBody(resp.body) if resp.statusCode == http.StatusAccepted || resp.statusCode == http.StatusNotFound { return resp.statusCode == http.StatusAccepted, nil } @@ -135,33 +173,59 @@ func (f *File) DeleteIfExists() (bool, error) { return false, err } +// GetFileOptions includes options for a get file operation +type GetFileOptions struct { + Timeout uint + GetContentMD5 bool +} + +// DownloadToStream operation downloads the file. +// +// See: https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-file +func (f *File) DownloadToStream(options *FileRequestOptions) (io.ReadCloser, error) { + params := prepareOptions(options) + resp, err := f.fsc.getResourceNoClose(f.buildPath(), compNone, resourceFile, params, http.MethodGet, nil) + if err != nil { + return nil, err + } + + if err = checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { + readAndCloseBody(resp.body) + return nil, err + } + return resp.body, nil +} + // DownloadRangeToStream operation downloads the specified range of this file with optional MD5 hash. // // See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-file -func (f *File) DownloadRangeToStream(fileRange FileRange, getContentMD5 bool) (fs FileStream, err error) { - if getContentMD5 && isRangeTooBig(fileRange) { - return fs, fmt.Errorf("must specify a range less than or equal to 4MB when getContentMD5 is true") - } - +func (f *File) DownloadRangeToStream(fileRange FileRange, options *GetFileOptions) (fs FileStream, err error) { extraHeaders := map[string]string{ "Range": fileRange.String(), } - if getContentMD5 == true { - extraHeaders["x-ms-range-get-content-md5"] = "true" + params := url.Values{} + if options != nil { + if options.GetContentMD5 { + if isRangeTooBig(fileRange) { + return fs, fmt.Errorf("must specify a range less than or equal to 4MB when getContentMD5 is true") + } + extraHeaders["x-ms-range-get-content-md5"] = "true" + } + params = addTimeout(params, options.Timeout) } - resp, err := f.fsc.getResourceNoClose(f.buildPath(), compNone, resourceFile, http.MethodGet, extraHeaders) + resp, err := f.fsc.getResourceNoClose(f.buildPath(), compNone, resourceFile, params, http.MethodGet, extraHeaders) if err != nil { return fs, err } if err = checkRespCode(resp.statusCode, []int{http.StatusOK, http.StatusPartialContent}); err != nil { - resp.body.Close() + readAndCloseBody(resp.body) return fs, err } fs.Body = resp.body - if getContentMD5 { + if options != nil && options.GetContentMD5 { fs.ContentMD5 = resp.headers.Get("Content-MD5") } return fs, nil @@ -178,8 +242,10 @@ func (f *File) Exists() (bool, error) { } // FetchAttributes updates metadata and properties for this file. -func (f *File) FetchAttributes() error { - headers, err := f.fsc.getResourceHeaders(f.buildPath(), compNone, resourceFile, http.MethodHead) +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-file-properties +func (f *File) FetchAttributes(options *FileRequestOptions) error { + params := prepareOptions(options) + headers, err := f.fsc.getResourceHeaders(f.buildPath(), compNone, resourceFile, params, http.MethodHead) if err != nil { return err } @@ -199,17 +265,26 @@ func isRangeTooBig(fileRange FileRange) bool { return false } +// ListRangesOptions includes options for a list file ranges operation +type ListRangesOptions struct { + Timeout uint + ListRange *FileRange +} + // ListRanges returns the list of valid ranges for this file. // -// See https://msdn.microsoft.com/en-us/library/azure/dn166984.aspx -func (f *File) ListRanges(listRange *FileRange) (*FileRanges, error) { +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/List-Ranges +func (f *File) ListRanges(options *ListRangesOptions) (*FileRanges, error) { params := url.Values{"comp": {"rangelist"}} // add optional range to list var headers map[string]string - if listRange != nil { - headers = make(map[string]string) - headers["Range"] = listRange.String() + if options != nil { + params = addTimeout(params, options.Timeout) + if options.ListRange != nil { + headers = make(map[string]string) + headers["Range"] = options.ListRange.String() + } } resp, err := f.fsc.listContent(f.buildPath(), params, headers) @@ -221,6 +296,7 @@ func (f *File) ListRanges(listRange *FileRange) (*FileRanges, error) { var cl uint64 cl, err = strconv.ParseUint(resp.headers.Get("x-ms-content-length"), 10, 64) if err != nil { + ioutil.ReadAll(resp.body) return nil, err } @@ -234,7 +310,7 @@ func (f *File) ListRanges(listRange *FileRange) (*FileRanges, error) { } // modifies a range of bytes in this file -func (f *File) modifyRange(bytes io.Reader, fileRange FileRange, contentMD5 *string) (http.Header, error) { +func (f *File) modifyRange(bytes io.Reader, fileRange FileRange, timeout *uint, contentMD5 *string) (http.Header, error) { if err := f.fsc.checkForStorageEmulator(); err != nil { return nil, err } @@ -245,7 +321,12 @@ func (f *File) modifyRange(bytes io.Reader, fileRange FileRange, contentMD5 *str return nil, errors.New("range cannot exceed 4MB in size") } - uri := f.fsc.client.getEndpoint(fileServiceName, f.buildPath(), url.Values{"comp": {"range"}}) + params := url.Values{"comp": {"range"}} + if timeout != nil { + params = addTimeout(params, *timeout) + } + + uri := f.fsc.client.getEndpoint(fileServiceName, f.buildPath(), params) // default to clear write := "clear" @@ -272,7 +353,7 @@ func (f *File) modifyRange(bytes io.Reader, fileRange FileRange, contentMD5 *str if err != nil { return nil, err } - defer resp.body.Close() + defer readAndCloseBody(resp.body) return resp.headers, checkRespCode(resp.statusCode, []int{http.StatusCreated}) } @@ -283,9 +364,9 @@ func (f *File) modifyRange(bytes io.Reader, fileRange FileRange, contentMD5 *str // are case-insensitive so case munging should not matter to other // applications either. // -// See https://msdn.microsoft.com/en-us/library/azure/dn689097.aspx -func (f *File) SetMetadata() error { - headers, err := f.fsc.setResourceHeaders(f.buildPath(), compMetadata, resourceFile, mergeMDIntoExtraHeaders(f.Metadata, nil)) +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Set-File-Metadata +func (f *File) SetMetadata(options *FileRequestOptions) error { + headers, err := f.fsc.setResourceHeaders(f.buildPath(), compMetadata, resourceFile, mergeMDIntoExtraHeaders(f.Metadata, nil), options) if err != nil { return err } @@ -301,9 +382,9 @@ func (f *File) SetMetadata() error { // are case-insensitive so case munging should not matter to other // applications either. // -// See https://msdn.microsoft.com/en-us/library/azure/dn166975.aspx -func (f *File) SetProperties() error { - headers, err := f.fsc.setResourceHeaders(f.buildPath(), compProperties, resourceFile, headersFromStruct(f.Properties)) +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Set-File-Properties +func (f *File) SetProperties(options *FileRequestOptions) error { + headers, err := f.fsc.setResourceHeaders(f.buildPath(), compProperties, resourceFile, headersFromStruct(f.Properties), options) if err != nil { return err } @@ -318,6 +399,14 @@ func (f *File) updateEtagAndLastModified(headers http.Header) { f.Properties.LastModified = headers.Get("Last-Modified") } +// updates Etag, last modified date and x-ms-copy-id +func (f *File) updateEtagLastModifiedAndCopyHeaders(headers http.Header) { + f.Properties.Etag = headers.Get("Etag") + f.Properties.LastModified = headers.Get("Last-Modified") + f.FileCopyProperties.ID = headers.Get("X-Ms-Copy-Id") + f.FileCopyProperties.Status = headers.Get("X-Ms-Copy-Status") +} + // updates file properties from the specified HTTP header func (f *File) updateProperties(header http.Header) { size, err := strconv.ParseUint(header.Get("Content-Length"), 10, 64) @@ -338,19 +427,32 @@ func (f *File) updateProperties(header http.Header) { // This method does not create a publicly accessible URL if the file // is private and this method does not check if the file exists. func (f *File) URL() string { - return f.fsc.client.getEndpoint(fileServiceName, f.buildPath(), url.Values{}) + return f.fsc.client.getEndpoint(fileServiceName, f.buildPath(), nil) } -// WriteRange writes a range of bytes to this file with an optional MD5 hash of the content. -// Note that the length of bytes must match (rangeEnd - rangeStart) + 1 with a maximum size of 4MB. +// WriteRangeOptions includes opptions for a write file range operation +type WriteRangeOptions struct { + Timeout uint + ContentMD5 string +} + +// WriteRange writes a range of bytes to this file with an optional MD5 hash of the content (inside +// options parameter). Note that the length of bytes must match (rangeEnd - rangeStart) + 1 with +// a maximum size of 4MB. // -// See https://msdn.microsoft.com/en-us/library/azure/dn194276.aspx -func (f *File) WriteRange(bytes io.Reader, fileRange FileRange, contentMD5 *string) error { +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Put-Range +func (f *File) WriteRange(bytes io.Reader, fileRange FileRange, options *WriteRangeOptions) error { if bytes == nil { return errors.New("bytes cannot be nil") } + var timeout *uint + var md5 *string + if options != nil { + timeout = &options.Timeout + md5 = &options.ContentMD5 + } - headers, err := f.modifyRange(bytes, fileRange, contentMD5) + headers, err := f.modifyRange(bytes, fileRange, timeout, md5) if err != nil { return err } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/fileserviceclient.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/fileserviceclient.go index 81e094f00..81217bdfa 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/storage/fileserviceclient.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/fileserviceclient.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" "net/url" - "strings" + "strconv" ) // FileServiceClient contains operations for Microsoft Azure File Service. @@ -17,7 +17,7 @@ type FileServiceClient struct { // ListSharesParameters defines the set of customizable parameters to make a // List Shares call. // -// See https://msdn.microsoft.com/en-us/library/azure/dn167009.aspx +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/List-Shares type ListSharesParameters struct { Prefix string Marker string @@ -29,7 +29,7 @@ type ListSharesParameters struct { // ShareListResponse contains the response fields from // ListShares call. // -// See https://msdn.microsoft.com/en-us/library/azure/dn167009.aspx +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/List-Shares type ShareListResponse struct { XMLName xml.Name `xml:"EnumerationResults"` Xmlns string `xml:"xmlns,attr"` @@ -79,10 +79,10 @@ func (p ListSharesParameters) getParameters() url.Values { out.Set("include", p.Include) } if p.MaxResults != 0 { - out.Set("maxresults", fmt.Sprintf("%v", p.MaxResults)) + out.Set("maxresults", strconv.FormatUint(uint64(p.MaxResults), 10)) } if p.Timeout != 0 { - out.Set("timeout", fmt.Sprintf("%v", p.Timeout)) + out.Set("timeout", strconv.FormatUint(uint64(p.Timeout), 10)) } return out @@ -91,15 +91,16 @@ func (p ListSharesParameters) getParameters() url.Values { func (p ListDirsAndFilesParameters) getParameters() url.Values { out := url.Values{} + if p.Prefix != "" { + out.Set("prefix", p.Prefix) + } if p.Marker != "" { out.Set("marker", p.Marker) } if p.MaxResults != 0 { - out.Set("maxresults", fmt.Sprintf("%v", p.MaxResults)) - } - if p.Timeout != 0 { - out.Set("timeout", fmt.Sprintf("%v", p.Timeout)) + out.Set("maxresults", strconv.FormatUint(uint64(p.MaxResults), 10)) } + out = addTimeout(out, p.Timeout) return out } @@ -117,9 +118,9 @@ func getURLInitValues(comp compType, res resourceType) url.Values { } // GetShareReference returns a Share object for the specified share name. -func (f FileServiceClient) GetShareReference(name string) Share { - return Share{ - fsc: &f, +func (f *FileServiceClient) GetShareReference(name string) *Share { + return &Share{ + fsc: f, Name: name, Properties: ShareProperties{ Quota: -1, @@ -130,7 +131,7 @@ func (f FileServiceClient) GetShareReference(name string) Share { // ListShares returns the list of shares in a storage account along with // pagination token and other response details. // -// See https://msdn.microsoft.com/en-us/library/azure/dd179352.aspx +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/list-shares func (f FileServiceClient) ListShares(params ListSharesParameters) (*ShareListResponse, error) { q := mergeParams(params.getParameters(), url.Values{"comp": {"list"}}) @@ -149,6 +150,20 @@ func (f FileServiceClient) ListShares(params ListSharesParameters) (*ShareListRe return &out, err } +// GetServiceProperties gets the properties of your storage account's file service. +// File service does not support logging +// See: https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-file-service-properties +func (f *FileServiceClient) GetServiceProperties() (*ServiceProperties, error) { + return f.client.getServiceProperties(fileServiceName, f.auth) +} + +// SetServiceProperties sets the properties of your storage account's file service. +// File service does not support logging +// See: https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/set-file-service-properties +func (f *FileServiceClient) SetServiceProperties(props ServiceProperties) error { + return f.client.setServiceProperties(props, fileServiceName, f.auth) +} + // retrieves directory or share content func (f FileServiceClient) listContent(path string, params url.Values, extraHeaders map[string]string) (*storageResponse, error) { if err := f.checkForStorageEmulator(); err != nil { @@ -165,7 +180,7 @@ func (f FileServiceClient) listContent(path string, params url.Values, extraHead } if err = checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { - resp.body.Close() + readAndCloseBody(resp.body) return nil, err } @@ -183,7 +198,7 @@ func (f FileServiceClient) resourceExists(path string, res resourceType) (bool, resp, err := f.client.exec(http.MethodHead, uri, headers, nil, f.auth) if resp != nil { - defer resp.body.Close() + defer readAndCloseBody(resp.body) if resp.statusCode == http.StatusOK || resp.statusCode == http.StatusNotFound { return resp.statusCode == http.StatusOK, resp.headers, nil } @@ -192,23 +207,24 @@ func (f FileServiceClient) resourceExists(path string, res resourceType) (bool, } // creates a resource depending on the specified resource type -func (f FileServiceClient) createResource(path string, res resourceType, extraHeaders map[string]string) (http.Header, error) { - resp, err := f.createResourceNoClose(path, res, extraHeaders) +func (f FileServiceClient) createResource(path string, res resourceType, urlParams url.Values, extraHeaders map[string]string, expectedResponseCodes []int) (http.Header, error) { + resp, err := f.createResourceNoClose(path, res, urlParams, extraHeaders) if err != nil { return nil, err } - defer resp.body.Close() - return resp.headers, checkRespCode(resp.statusCode, []int{http.StatusCreated}) + defer readAndCloseBody(resp.body) + return resp.headers, checkRespCode(resp.statusCode, expectedResponseCodes) } // creates a resource depending on the specified resource type, doesn't close the response body -func (f FileServiceClient) createResourceNoClose(path string, res resourceType, extraHeaders map[string]string) (*storageResponse, error) { +func (f FileServiceClient) createResourceNoClose(path string, res resourceType, urlParams url.Values, extraHeaders map[string]string) (*storageResponse, error) { if err := f.checkForStorageEmulator(); err != nil { return nil, err } values := getURLInitValues(compNone, res) - uri := f.client.getEndpoint(fileServiceName, path, values) + combinedParams := mergeParams(values, urlParams) + uri := f.client.getEndpoint(fileServiceName, path, combinedParams) extraHeaders = f.client.protectUserAgent(extraHeaders) headers := mergeHeaders(f.client.getStandardHeaders(), extraHeaders) @@ -216,12 +232,12 @@ func (f FileServiceClient) createResourceNoClose(path string, res resourceType, } // returns HTTP header data for the specified directory or share -func (f FileServiceClient) getResourceHeaders(path string, comp compType, res resourceType, verb string) (http.Header, error) { - resp, err := f.getResourceNoClose(path, comp, res, verb, nil) +func (f FileServiceClient) getResourceHeaders(path string, comp compType, res resourceType, params url.Values, verb string) (http.Header, error) { + resp, err := f.getResourceNoClose(path, comp, res, params, verb, nil) if err != nil { return nil, err } - defer resp.body.Close() + defer readAndCloseBody(resp.body) if err = checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { return nil, err @@ -231,36 +247,35 @@ func (f FileServiceClient) getResourceHeaders(path string, comp compType, res re } // gets the specified resource, doesn't close the response body -func (f FileServiceClient) getResourceNoClose(path string, comp compType, res resourceType, verb string, extraHeaders map[string]string) (*storageResponse, error) { +func (f FileServiceClient) getResourceNoClose(path string, comp compType, res resourceType, params url.Values, verb string, extraHeaders map[string]string) (*storageResponse, error) { if err := f.checkForStorageEmulator(); err != nil { return nil, err } - params := getURLInitValues(comp, res) + params = mergeParams(params, getURLInitValues(comp, res)) uri := f.client.getEndpoint(fileServiceName, path, params) - extraHeaders = f.client.protectUserAgent(extraHeaders) headers := mergeHeaders(f.client.getStandardHeaders(), extraHeaders) return f.client.exec(verb, uri, headers, nil, f.auth) } // deletes the resource and returns the response -func (f FileServiceClient) deleteResource(path string, res resourceType) error { - resp, err := f.deleteResourceNoClose(path, res) +func (f FileServiceClient) deleteResource(path string, res resourceType, options *FileRequestOptions) error { + resp, err := f.deleteResourceNoClose(path, res, options) if err != nil { return err } - defer resp.body.Close() + defer readAndCloseBody(resp.body) return checkRespCode(resp.statusCode, []int{http.StatusAccepted}) } // deletes the resource and returns the response, doesn't close the response body -func (f FileServiceClient) deleteResourceNoClose(path string, res resourceType) (*storageResponse, error) { +func (f FileServiceClient) deleteResourceNoClose(path string, res resourceType, options *FileRequestOptions) (*storageResponse, error) { if err := f.checkForStorageEmulator(); err != nil { return nil, err } - values := getURLInitValues(compNone, res) + values := mergeParams(getURLInitValues(compNone, res), prepareOptions(options)) uri := f.client.getEndpoint(fileServiceName, path, values) return f.client.exec(http.MethodDelete, uri, f.client.getStandardHeaders(), nil, f.auth) } @@ -279,21 +294,13 @@ func mergeMDIntoExtraHeaders(metadata, extraHeaders map[string]string) map[strin return extraHeaders } -// merges extraHeaders into headers and returns headers -func mergeHeaders(headers, extraHeaders map[string]string) map[string]string { - for k, v := range extraHeaders { - headers[k] = v - } - return headers -} - // sets extra header data for the specified resource -func (f FileServiceClient) setResourceHeaders(path string, comp compType, res resourceType, extraHeaders map[string]string) (http.Header, error) { +func (f FileServiceClient) setResourceHeaders(path string, comp compType, res resourceType, extraHeaders map[string]string, options *FileRequestOptions) (http.Header, error) { if err := f.checkForStorageEmulator(); err != nil { return nil, err } - params := getURLInitValues(comp, res) + params := mergeParams(getURLInitValues(comp, res), prepareOptions(options)) uri := f.client.getEndpoint(fileServiceName, path, params) extraHeaders = f.client.protectUserAgent(extraHeaders) headers := mergeHeaders(f.client.getStandardHeaders(), extraHeaders) @@ -302,54 +309,11 @@ func (f FileServiceClient) setResourceHeaders(path string, comp compType, res re if err != nil { return nil, err } - defer resp.body.Close() + defer readAndCloseBody(resp.body) return resp.headers, checkRespCode(resp.statusCode, []int{http.StatusOK}) } -// gets metadata for the specified resource -func (f FileServiceClient) getMetadata(path string, res resourceType) (map[string]string, error) { - if err := f.checkForStorageEmulator(); err != nil { - return nil, err - } - - headers, err := f.getResourceHeaders(path, compMetadata, res, http.MethodGet) - if err != nil { - return nil, err - } - - return getMetadataFromHeaders(headers), nil -} - -// returns a map of custom metadata values from the specified HTTP header -func getMetadataFromHeaders(header http.Header) map[string]string { - metadata := make(map[string]string) - for k, v := range header { - // Can't trust CanonicalHeaderKey() to munge case - // reliably. "_" is allowed in identifiers: - // https://msdn.microsoft.com/en-us/library/azure/dd179414.aspx - // https://msdn.microsoft.com/library/aa664670(VS.71).aspx - // http://tools.ietf.org/html/rfc7230#section-3.2 - // ...but "_" is considered invalid by - // CanonicalMIMEHeaderKey in - // https://golang.org/src/net/textproto/reader.go?s=14615:14659#L542 - // so k can be "X-Ms-Meta-Foo" or "x-ms-meta-foo_bar". - k = strings.ToLower(k) - if len(v) == 0 || !strings.HasPrefix(k, strings.ToLower(userDefinedMetadataHeaderPrefix)) { - continue - } - // metadata["foo"] = content of the last X-Ms-Meta-Foo header - k = k[len(userDefinedMetadataHeaderPrefix):] - metadata[k] = v[len(v)-1] - } - - if len(metadata) == 0 { - return nil - } - - return metadata -} - //checkForStorageEmulator determines if the client is setup for use with //Azure Storage Emulator, and returns a relevant error func (f FileServiceClient) checkForStorageEmulator() error { diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/leaseblob.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/leaseblob.go new file mode 100644 index 000000000..415b74018 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/leaseblob.go @@ -0,0 +1,187 @@ +package storage + +import ( + "errors" + "net/http" + "net/url" + "strconv" + "time" +) + +// lease constants. +const ( + leaseHeaderPrefix = "x-ms-lease-" + headerLeaseID = "x-ms-lease-id" + leaseAction = "x-ms-lease-action" + leaseBreakPeriod = "x-ms-lease-break-period" + leaseDuration = "x-ms-lease-duration" + leaseProposedID = "x-ms-proposed-lease-id" + leaseTime = "x-ms-lease-time" + + acquireLease = "acquire" + renewLease = "renew" + changeLease = "change" + releaseLease = "release" + breakLease = "break" +) + +// leasePut is common PUT code for the various acquire/release/break etc functions. +func (b *Blob) leaseCommonPut(headers map[string]string, expectedStatus int, options *LeaseOptions) (http.Header, error) { + params := url.Values{"comp": {"lease"}} + + if options != nil { + params = addTimeout(params, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := b.Container.bsc.client.getEndpoint(blobServiceName, b.buildPath(), params) + + resp, err := b.Container.bsc.client.exec(http.MethodPut, uri, headers, nil, b.Container.bsc.auth) + if err != nil { + return nil, err + } + defer readAndCloseBody(resp.body) + + if err := checkRespCode(resp.statusCode, []int{expectedStatus}); err != nil { + return nil, err + } + + return resp.headers, nil +} + +// LeaseOptions includes options for all operations regarding leasing blobs +type LeaseOptions struct { + Timeout uint + Origin string `header:"Origin"` + IfMatch string `header:"If-Match"` + IfNoneMatch string `header:"If-None-Match"` + IfModifiedSince *time.Time `header:"If-Modified-Since"` + IfUnmodifiedSince *time.Time `header:"If-Unmodified-Since"` + RequestID string `header:"x-ms-client-request-id"` +} + +// AcquireLease creates a lease for a blob +// returns leaseID acquired +// In API Versions starting on 2012-02-12, the minimum leaseTimeInSeconds is 15, the maximum +// non-infinite leaseTimeInSeconds is 60. To specify an infinite lease, provide the value -1. +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Lease-Blob +func (b *Blob) AcquireLease(leaseTimeInSeconds int, proposedLeaseID string, options *LeaseOptions) (returnedLeaseID string, err error) { + headers := b.Container.bsc.client.getStandardHeaders() + headers[leaseAction] = acquireLease + + if leaseTimeInSeconds == -1 { + // Do nothing, but don't trigger the following clauses. + } else if leaseTimeInSeconds > 60 || b.Container.bsc.client.apiVersion < "2012-02-12" { + leaseTimeInSeconds = 60 + } else if leaseTimeInSeconds < 15 { + leaseTimeInSeconds = 15 + } + + headers[leaseDuration] = strconv.Itoa(leaseTimeInSeconds) + + if proposedLeaseID != "" { + headers[leaseProposedID] = proposedLeaseID + } + + respHeaders, err := b.leaseCommonPut(headers, http.StatusCreated, options) + if err != nil { + return "", err + } + + returnedLeaseID = respHeaders.Get(http.CanonicalHeaderKey(headerLeaseID)) + + if returnedLeaseID != "" { + return returnedLeaseID, nil + } + + return "", errors.New("LeaseID not returned") +} + +// BreakLease breaks the lease for a blob +// Returns the timeout remaining in the lease in seconds +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Lease-Blob +func (b *Blob) BreakLease(options *LeaseOptions) (breakTimeout int, err error) { + headers := b.Container.bsc.client.getStandardHeaders() + headers[leaseAction] = breakLease + return b.breakLeaseCommon(headers, options) +} + +// BreakLeaseWithBreakPeriod breaks the lease for a blob +// breakPeriodInSeconds is used to determine how long until new lease can be created. +// Returns the timeout remaining in the lease in seconds +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Lease-Blob +func (b *Blob) BreakLeaseWithBreakPeriod(breakPeriodInSeconds int, options *LeaseOptions) (breakTimeout int, err error) { + headers := b.Container.bsc.client.getStandardHeaders() + headers[leaseAction] = breakLease + headers[leaseBreakPeriod] = strconv.Itoa(breakPeriodInSeconds) + return b.breakLeaseCommon(headers, options) +} + +// breakLeaseCommon is common code for both version of BreakLease (with and without break period) +func (b *Blob) breakLeaseCommon(headers map[string]string, options *LeaseOptions) (breakTimeout int, err error) { + + respHeaders, err := b.leaseCommonPut(headers, http.StatusAccepted, options) + if err != nil { + return 0, err + } + + breakTimeoutStr := respHeaders.Get(http.CanonicalHeaderKey(leaseTime)) + if breakTimeoutStr != "" { + breakTimeout, err = strconv.Atoi(breakTimeoutStr) + if err != nil { + return 0, err + } + } + + return breakTimeout, nil +} + +// ChangeLease changes a lease ID for a blob +// Returns the new LeaseID acquired +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Lease-Blob +func (b *Blob) ChangeLease(currentLeaseID string, proposedLeaseID string, options *LeaseOptions) (newLeaseID string, err error) { + headers := b.Container.bsc.client.getStandardHeaders() + headers[leaseAction] = changeLease + headers[headerLeaseID] = currentLeaseID + headers[leaseProposedID] = proposedLeaseID + + respHeaders, err := b.leaseCommonPut(headers, http.StatusOK, options) + if err != nil { + return "", err + } + + newLeaseID = respHeaders.Get(http.CanonicalHeaderKey(headerLeaseID)) + if newLeaseID != "" { + return newLeaseID, nil + } + + return "", errors.New("LeaseID not returned") +} + +// ReleaseLease releases the lease for a blob +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Lease-Blob +func (b *Blob) ReleaseLease(currentLeaseID string, options *LeaseOptions) error { + headers := b.Container.bsc.client.getStandardHeaders() + headers[leaseAction] = releaseLease + headers[headerLeaseID] = currentLeaseID + + _, err := b.leaseCommonPut(headers, http.StatusOK, options) + if err != nil { + return err + } + + return nil +} + +// RenewLease renews the lease for a blob as per https://msdn.microsoft.com/en-us/library/azure/ee691972.aspx +func (b *Blob) RenewLease(currentLeaseID string, options *LeaseOptions) error { + headers := b.Container.bsc.client.getStandardHeaders() + headers[leaseAction] = renewLease + headers[headerLeaseID] = currentLeaseID + + _, err := b.leaseCommonPut(headers, http.StatusOK, options) + if err != nil { + return err + } + + return nil +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/message.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/message.go new file mode 100644 index 000000000..3ededcd42 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/message.go @@ -0,0 +1,153 @@ +package storage + +import ( + "encoding/xml" + "fmt" + "net/http" + "net/url" + "strconv" + "time" +) + +// Message represents an Azure message. +type Message struct { + Queue *Queue + Text string `xml:"MessageText"` + ID string `xml:"MessageId"` + Insertion TimeRFC1123 `xml:"InsertionTime"` + Expiration TimeRFC1123 `xml:"ExpirationTime"` + PopReceipt string `xml:"PopReceipt"` + NextVisible TimeRFC1123 `xml:"TimeNextVisible"` + DequeueCount int `xml:"DequeueCount"` +} + +func (m *Message) buildPath() string { + return fmt.Sprintf("%s/%s", m.Queue.buildPathMessages(), m.ID) +} + +// PutMessageOptions is the set of options can be specified for Put Messsage +// operation. A zero struct does not use any preferences for the request. +type PutMessageOptions struct { + Timeout uint + VisibilityTimeout int + MessageTTL int + RequestID string `header:"x-ms-client-request-id"` +} + +// Put operation adds a new message to the back of the message queue. +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Put-Message +func (m *Message) Put(options *PutMessageOptions) error { + query := url.Values{} + headers := m.Queue.qsc.client.getStandardHeaders() + + req := putMessageRequest{MessageText: m.Text} + body, nn, err := xmlMarshal(req) + if err != nil { + return err + } + headers["Content-Length"] = strconv.Itoa(nn) + + if options != nil { + if options.VisibilityTimeout != 0 { + query.Set("visibilitytimeout", strconv.Itoa(options.VisibilityTimeout)) + } + if options.MessageTTL != 0 { + query.Set("messagettl", strconv.Itoa(options.MessageTTL)) + } + query = addTimeout(query, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + + uri := m.Queue.qsc.client.getEndpoint(queueServiceName, m.Queue.buildPathMessages(), query) + resp, err := m.Queue.qsc.client.exec(http.MethodPost, uri, headers, body, m.Queue.qsc.auth) + if err != nil { + return err + } + defer readAndCloseBody(resp.body) + + err = xmlUnmarshal(resp.body, m) + if err != nil { + return err + } + return checkRespCode(resp.statusCode, []int{http.StatusCreated}) +} + +// UpdateMessageOptions is the set of options can be specified for Update Messsage +// operation. A zero struct does not use any preferences for the request. +type UpdateMessageOptions struct { + Timeout uint + VisibilityTimeout int + RequestID string `header:"x-ms-client-request-id"` +} + +// Update operation updates the specified message. +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Update-Message +func (m *Message) Update(options *UpdateMessageOptions) error { + query := url.Values{} + if m.PopReceipt != "" { + query.Set("popreceipt", m.PopReceipt) + } + + headers := m.Queue.qsc.client.getStandardHeaders() + req := putMessageRequest{MessageText: m.Text} + body, nn, err := xmlMarshal(req) + if err != nil { + return err + } + headers["Content-Length"] = strconv.Itoa(nn) + + if options != nil { + if options.VisibilityTimeout != 0 { + query.Set("visibilitytimeout", strconv.Itoa(options.VisibilityTimeout)) + } + query = addTimeout(query, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := m.Queue.qsc.client.getEndpoint(queueServiceName, m.buildPath(), query) + + resp, err := m.Queue.qsc.client.exec(http.MethodPut, uri, headers, body, m.Queue.qsc.auth) + if err != nil { + return err + } + defer readAndCloseBody(resp.body) + + m.PopReceipt = resp.headers.Get("x-ms-popreceipt") + nextTimeStr := resp.headers.Get("x-ms-time-next-visible") + if nextTimeStr != "" { + nextTime, err := time.Parse(time.RFC1123, nextTimeStr) + if err != nil { + return err + } + m.NextVisible = TimeRFC1123(nextTime) + } + + return checkRespCode(resp.statusCode, []int{http.StatusNoContent}) +} + +// Delete operation deletes the specified message. +// +// See https://msdn.microsoft.com/en-us/library/azure/dd179347.aspx +func (m *Message) Delete(options *QueueServiceOptions) error { + params := url.Values{"popreceipt": {m.PopReceipt}} + headers := m.Queue.qsc.client.getStandardHeaders() + + if options != nil { + params = addTimeout(params, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := m.Queue.qsc.client.getEndpoint(queueServiceName, m.buildPath(), params) + + resp, err := m.Queue.qsc.client.exec(http.MethodDelete, uri, headers, nil, m.Queue.qsc.auth) + if err != nil { + return err + } + readAndCloseBody(resp.body) + return checkRespCode(resp.statusCode, []int{http.StatusNoContent}) +} + +type putMessageRequest struct { + XMLName xml.Name `xml:"QueueMessage"` + MessageText string `xml:"MessageText"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/odata.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/odata.go new file mode 100644 index 000000000..41d832e2b --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/odata.go @@ -0,0 +1,33 @@ +package storage + +// MetadataLevel determines if operations should return a paylod, +// and it level of detail. +type MetadataLevel string + +// This consts are meant to help with Odata supported operations +const ( + OdataTypeSuffix = "@odata.type" + + // Types + + OdataBinary = "Edm.Binary" + OdataDateTime = "Edm.DateTime" + OdataGUID = "Edm.Guid" + OdataInt64 = "Edm.Int64" + + // Query options + + OdataFilter = "$filter" + OdataOrderBy = "$orderby" + OdataTop = "$top" + OdataSkip = "$skip" + OdataCount = "$count" + OdataExpand = "$expand" + OdataSelect = "$select" + OdataSearch = "$search" + + EmptyPayload MetadataLevel = "" + NoMetadata MetadataLevel = "application/json;odata=nometadata" + MinimalMetadata MetadataLevel = "application/json;odata=minimalmetadata" + FullMetadata MetadataLevel = "application/json;odata=fullmetadata" +) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/pageblob.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/pageblob.go new file mode 100644 index 000000000..bc5b398d3 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/pageblob.go @@ -0,0 +1,189 @@ +package storage + +import ( + "encoding/xml" + "errors" + "fmt" + "io" + "net/http" + "net/url" + "time" +) + +// GetPageRangesResponse contains the response fields from +// Get Page Ranges call. +// +// See https://msdn.microsoft.com/en-us/library/azure/ee691973.aspx +type GetPageRangesResponse struct { + XMLName xml.Name `xml:"PageList"` + PageList []PageRange `xml:"PageRange"` +} + +// PageRange contains information about a page of a page blob from +// Get Pages Range call. +// +// See https://msdn.microsoft.com/en-us/library/azure/ee691973.aspx +type PageRange struct { + Start int64 `xml:"Start"` + End int64 `xml:"End"` +} + +var ( + errBlobCopyAborted = errors.New("storage: blob copy is aborted") + errBlobCopyIDMismatch = errors.New("storage: blob copy id is a mismatch") +) + +// PutPageOptions includes the options for a put page operation +type PutPageOptions struct { + Timeout uint + LeaseID string `header:"x-ms-lease-id"` + IfSequenceNumberLessThanOrEqualTo *int `header:"x-ms-if-sequence-number-le"` + IfSequenceNumberLessThan *int `header:"x-ms-if-sequence-number-lt"` + IfSequenceNumberEqualTo *int `header:"x-ms-if-sequence-number-eq"` + IfModifiedSince *time.Time `header:"If-Modified-Since"` + IfUnmodifiedSince *time.Time `header:"If-Unmodified-Since"` + IfMatch string `header:"If-Match"` + IfNoneMatch string `header:"If-None-Match"` + RequestID string `header:"x-ms-client-request-id"` +} + +// WriteRange writes a range of pages to a page blob. +// Ranges must be aligned with 512-byte boundaries and chunk must be of size +// multiplies by 512. +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Put-Page +func (b *Blob) WriteRange(blobRange BlobRange, bytes io.Reader, options *PutPageOptions) error { + if bytes == nil { + return errors.New("bytes cannot be nil") + } + return b.modifyRange(blobRange, bytes, options) +} + +// ClearRange clears the given range in a page blob. +// Ranges must be aligned with 512-byte boundaries and chunk must be of size +// multiplies by 512. +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Put-Page +func (b *Blob) ClearRange(blobRange BlobRange, options *PutPageOptions) error { + return b.modifyRange(blobRange, nil, options) +} + +func (b *Blob) modifyRange(blobRange BlobRange, bytes io.Reader, options *PutPageOptions) error { + if blobRange.End < blobRange.Start { + return errors.New("the value for rangeEnd must be greater than or equal to rangeStart") + } + if blobRange.Start%512 != 0 { + return errors.New("the value for rangeStart must be a modulus of 512") + } + if blobRange.End%512 != 511 { + return errors.New("the value for rangeEnd must be a modulus of 511") + } + + params := url.Values{"comp": {"page"}} + + // default to clear + write := "clear" + var cl uint64 + + // if bytes is not nil then this is an update operation + if bytes != nil { + write = "update" + cl = (blobRange.End - blobRange.Start) + 1 + } + + headers := b.Container.bsc.client.getStandardHeaders() + headers["x-ms-blob-type"] = string(BlobTypePage) + headers["x-ms-page-write"] = write + headers["x-ms-range"] = blobRange.String() + headers["Content-Length"] = fmt.Sprintf("%v", cl) + + if options != nil { + params = addTimeout(params, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := b.Container.bsc.client.getEndpoint(blobServiceName, b.buildPath(), params) + + resp, err := b.Container.bsc.client.exec(http.MethodPut, uri, headers, bytes, b.Container.bsc.auth) + if err != nil { + return err + } + readAndCloseBody(resp.body) + + return checkRespCode(resp.statusCode, []int{http.StatusCreated}) +} + +// GetPageRangesOptions includes the options for a get page ranges operation +type GetPageRangesOptions struct { + Timeout uint + Snapshot *time.Time + PreviousSnapshot *time.Time + Range *BlobRange + LeaseID string `header:"x-ms-lease-id"` + RequestID string `header:"x-ms-client-request-id"` +} + +// GetPageRanges returns the list of valid page ranges for a page blob. +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Get-Page-Ranges +func (b *Blob) GetPageRanges(options *GetPageRangesOptions) (GetPageRangesResponse, error) { + params := url.Values{"comp": {"pagelist"}} + headers := b.Container.bsc.client.getStandardHeaders() + + if options != nil { + params = addTimeout(params, options.Timeout) + params = addSnapshot(params, options.Snapshot) + if options.PreviousSnapshot != nil { + params.Add("prevsnapshot", timeRfc1123Formatted(*options.PreviousSnapshot)) + } + if options.Range != nil { + headers["Range"] = options.Range.String() + } + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := b.Container.bsc.client.getEndpoint(blobServiceName, b.buildPath(), params) + + var out GetPageRangesResponse + resp, err := b.Container.bsc.client.exec(http.MethodGet, uri, headers, nil, b.Container.bsc.auth) + if err != nil { + return out, err + } + defer resp.body.Close() + + if err = checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { + return out, err + } + err = xmlUnmarshal(resp.body, &out) + return out, err +} + +// PutPageBlob initializes an empty page blob with specified name and maximum +// size in bytes (size must be aligned to a 512-byte boundary). A page blob must +// be created using this method before writing pages. +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Put-Blob +func (b *Blob) PutPageBlob(options *PutBlobOptions) error { + if b.Properties.ContentLength%512 != 0 { + return errors.New("Content length must be aligned to a 512-byte boundary") + } + + params := url.Values{} + headers := b.Container.bsc.client.getStandardHeaders() + headers["x-ms-blob-type"] = string(BlobTypePage) + headers["x-ms-blob-content-length"] = fmt.Sprintf("%v", b.Properties.ContentLength) + headers["x-ms-blob-sequence-number"] = fmt.Sprintf("%v", b.Properties.SequenceNumber) + headers = mergeHeaders(headers, headersFromStruct(b.Properties)) + headers = b.Container.bsc.client.addMetadataToHeaders(headers, b.Metadata) + + if options != nil { + params = addTimeout(params, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := b.Container.bsc.client.getEndpoint(blobServiceName, b.buildPath(), params) + + resp, err := b.Container.bsc.client.exec(http.MethodPut, uri, headers, nil, b.Container.bsc.auth) + if err != nil { + return err + } + readAndCloseBody(resp.body) + return checkRespCode(resp.statusCode, []int{http.StatusCreated}) +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/queue.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/queue.go index 4dbb67733..c2c7f742c 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/storage/queue.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/queue.go @@ -2,168 +2,139 @@ package storage import ( "encoding/xml" + "errors" "fmt" + "io" "net/http" "net/url" "strconv" - "strings" + "time" ) const ( // casing is per Golang's http.Header canonicalizing the header names. - approximateMessagesCountHeader = "X-Ms-Approximate-Messages-Count" - userDefinedMetadataHeaderPrefix = "X-Ms-Meta-" + approximateMessagesCountHeader = "X-Ms-Approximate-Messages-Count" ) -// QueueServiceClient contains operations for Microsoft Azure Queue Storage -// Service. -type QueueServiceClient struct { - client Client - auth authentication +// QueueAccessPolicy represents each access policy in the queue ACL. +type QueueAccessPolicy struct { + ID string + StartTime time.Time + ExpiryTime time.Time + CanRead bool + CanAdd bool + CanUpdate bool + CanProcess bool } -func pathForQueue(queue string) string { return fmt.Sprintf("/%s", queue) } -func pathForQueueMessages(queue string) string { return fmt.Sprintf("/%s/messages", queue) } -func pathForMessage(queue, name string) string { return fmt.Sprintf("/%s/messages/%s", queue, name) } - -type putMessageRequest struct { - XMLName xml.Name `xml:"QueueMessage"` - MessageText string `xml:"MessageText"` +// QueuePermissions represents the queue ACLs. +type QueuePermissions struct { + AccessPolicies []QueueAccessPolicy } -// PutMessageParameters is the set of options can be specified for Put Messsage -// operation. A zero struct does not use any preferences for the request. -type PutMessageParameters struct { - VisibilityTimeout int - MessageTTL int +// SetQueuePermissionOptions includes options for a set queue permissions operation +type SetQueuePermissionOptions struct { + Timeout uint + RequestID string `header:"x-ms-client-request-id"` } -func (p PutMessageParameters) getParameters() url.Values { - out := url.Values{} - if p.VisibilityTimeout != 0 { - out.Set("visibilitytimeout", strconv.Itoa(p.VisibilityTimeout)) - } - if p.MessageTTL != 0 { - out.Set("messagettl", strconv.Itoa(p.MessageTTL)) - } - return out +// Queue represents an Azure queue. +type Queue struct { + qsc *QueueServiceClient + Name string + Metadata map[string]string + AproxMessageCount uint64 } -// GetMessagesParameters is the set of options can be specified for Get -// Messsages operation. A zero struct does not use any preferences for the -// request. -type GetMessagesParameters struct { - NumOfMessages int - VisibilityTimeout int +func (q *Queue) buildPath() string { + return fmt.Sprintf("/%s", q.Name) } -func (p GetMessagesParameters) getParameters() url.Values { - out := url.Values{} - if p.NumOfMessages != 0 { - out.Set("numofmessages", strconv.Itoa(p.NumOfMessages)) - } - if p.VisibilityTimeout != 0 { - out.Set("visibilitytimeout", strconv.Itoa(p.VisibilityTimeout)) - } - return out +func (q *Queue) buildPathMessages() string { + return fmt.Sprintf("%s/messages", q.buildPath()) } -// PeekMessagesParameters is the set of options can be specified for Peek -// Messsage operation. A zero struct does not use any preferences for the -// request. -type PeekMessagesParameters struct { - NumOfMessages int +// QueueServiceOptions includes options for some queue service operations +type QueueServiceOptions struct { + Timeout uint + RequestID string `header:"x-ms-client-request-id"` } -func (p PeekMessagesParameters) getParameters() url.Values { - out := url.Values{"peekonly": {"true"}} // Required for peek operation - if p.NumOfMessages != 0 { - out.Set("numofmessages", strconv.Itoa(p.NumOfMessages)) - } - return out -} - -// UpdateMessageParameters is the set of options can be specified for Update Messsage -// operation. A zero struct does not use any preferences for the request. -type UpdateMessageParameters struct { - PopReceipt string - VisibilityTimeout int -} - -func (p UpdateMessageParameters) getParameters() url.Values { - out := url.Values{} - if p.PopReceipt != "" { - out.Set("popreceipt", p.PopReceipt) - } - if p.VisibilityTimeout != 0 { - out.Set("visibilitytimeout", strconv.Itoa(p.VisibilityTimeout)) - } - return out -} - -// GetMessagesResponse represents a response returned from Get Messages -// operation. -type GetMessagesResponse struct { - XMLName xml.Name `xml:"QueueMessagesList"` - QueueMessagesList []GetMessageResponse `xml:"QueueMessage"` -} - -// GetMessageResponse represents a QueueMessage object returned from Get -// Messages operation response. -type GetMessageResponse struct { - MessageID string `xml:"MessageId"` - InsertionTime string `xml:"InsertionTime"` - ExpirationTime string `xml:"ExpirationTime"` - PopReceipt string `xml:"PopReceipt"` - TimeNextVisible string `xml:"TimeNextVisible"` - DequeueCount int `xml:"DequeueCount"` - MessageText string `xml:"MessageText"` -} - -// PeekMessagesResponse represents a response returned from Get Messages -// operation. -type PeekMessagesResponse struct { - XMLName xml.Name `xml:"QueueMessagesList"` - QueueMessagesList []PeekMessageResponse `xml:"QueueMessage"` -} - -// PeekMessageResponse represents a QueueMessage object returned from Peek -// Messages operation response. -type PeekMessageResponse struct { - MessageID string `xml:"MessageId"` - InsertionTime string `xml:"InsertionTime"` - ExpirationTime string `xml:"ExpirationTime"` - DequeueCount int `xml:"DequeueCount"` - MessageText string `xml:"MessageText"` -} - -// QueueMetadataResponse represents user defined metadata and queue -// properties on a specific queue. +// Create operation creates a queue under the given account. // -// See https://msdn.microsoft.com/en-us/library/azure/dd179384.aspx -type QueueMetadataResponse struct { - ApproximateMessageCount int - UserDefinedMetadata map[string]string +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Create-Queue4 +func (q *Queue) Create(options *QueueServiceOptions) error { + params := url.Values{} + headers := q.qsc.client.getStandardHeaders() + headers = q.qsc.client.addMetadataToHeaders(headers, q.Metadata) + + if options != nil { + params = addTimeout(params, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := q.qsc.client.getEndpoint(queueServiceName, q.buildPath(), params) + + resp, err := q.qsc.client.exec(http.MethodPut, uri, headers, nil, q.qsc.auth) + if err != nil { + return err + } + readAndCloseBody(resp.body) + return checkRespCode(resp.statusCode, []int{http.StatusCreated}) +} + +// Delete operation permanently deletes the specified queue. +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Delete-Queue3 +func (q *Queue) Delete(options *QueueServiceOptions) error { + params := url.Values{} + headers := q.qsc.client.getStandardHeaders() + + if options != nil { + params = addTimeout(params, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := q.qsc.client.getEndpoint(queueServiceName, q.buildPath(), params) + resp, err := q.qsc.client.exec(http.MethodDelete, uri, headers, nil, q.qsc.auth) + if err != nil { + return err + } + readAndCloseBody(resp.body) + return checkRespCode(resp.statusCode, []int{http.StatusNoContent}) +} + +// Exists returns true if a queue with given name exists. +func (q *Queue) Exists() (bool, error) { + uri := q.qsc.client.getEndpoint(queueServiceName, q.buildPath(), url.Values{"comp": {"metadata"}}) + resp, err := q.qsc.client.exec(http.MethodGet, uri, q.qsc.client.getStandardHeaders(), nil, q.qsc.auth) + if resp != nil { + defer readAndCloseBody(resp.body) + if resp.statusCode == http.StatusOK || resp.statusCode == http.StatusNotFound { + return resp.statusCode == http.StatusOK, nil + } + } + return false, err } // SetMetadata operation sets user-defined metadata on the specified queue. // Metadata is associated with the queue as name-value pairs. // -// See https://msdn.microsoft.com/en-us/library/azure/dd179348.aspx -func (c QueueServiceClient) SetMetadata(name string, metadata map[string]string) error { - uri := c.client.getEndpoint(queueServiceName, pathForQueue(name), url.Values{"comp": []string{"metadata"}}) - metadata = c.client.protectUserAgent(metadata) - headers := c.client.getStandardHeaders() - for k, v := range metadata { - headers[userDefinedMetadataHeaderPrefix+k] = v - } +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Set-Queue-Metadata +func (q *Queue) SetMetadata(options *QueueServiceOptions) error { + params := url.Values{"comp": {"metadata"}} + headers := q.qsc.client.getStandardHeaders() + headers = q.qsc.client.addMetadataToHeaders(headers, q.Metadata) - resp, err := c.client.exec(http.MethodPut, uri, headers, nil, c.auth) + if options != nil { + params = addTimeout(params, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := q.qsc.client.getEndpoint(queueServiceName, q.buildPath(), params) + + resp, err := q.qsc.client.exec(http.MethodPut, uri, headers, nil, q.qsc.auth) if err != nil { return err } - defer resp.body.Close() - + readAndCloseBody(resp.body) return checkRespCode(resp.statusCode, []int{http.StatusNoContent}) } @@ -171,176 +142,286 @@ func (c QueueServiceClient) SetMetadata(name string, metadata map[string]string) // properties on the specified queue. Metadata is associated with // the queue as name-values pairs. // -// See https://msdn.microsoft.com/en-us/library/azure/dd179384.aspx +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Set-Queue-Metadata // // Because the way Golang's http client (and http.Header in particular) // canonicalize header names, the returned metadata names would always // be all lower case. -func (c QueueServiceClient) GetMetadata(name string) (QueueMetadataResponse, error) { - qm := QueueMetadataResponse{} - qm.UserDefinedMetadata = make(map[string]string) - uri := c.client.getEndpoint(queueServiceName, pathForQueue(name), url.Values{"comp": []string{"metadata"}}) - headers := c.client.getStandardHeaders() - resp, err := c.client.exec(http.MethodGet, uri, headers, nil, c.auth) - if err != nil { - return qm, err - } - defer resp.body.Close() +func (q *Queue) GetMetadata(options *QueueServiceOptions) error { + params := url.Values{"comp": {"metadata"}} + headers := q.qsc.client.getStandardHeaders() - for k, v := range resp.headers { - if len(v) != 1 { - return qm, fmt.Errorf("Unexpected number of values (%d) in response header '%s'", len(v), k) - } - - value := v[0] - - if k == approximateMessagesCountHeader { - qm.ApproximateMessageCount, err = strconv.Atoi(value) - if err != nil { - return qm, fmt.Errorf("Unexpected value in response header '%s': '%s' ", k, value) - } - } else if strings.HasPrefix(k, userDefinedMetadataHeaderPrefix) { - name := strings.TrimPrefix(k, userDefinedMetadataHeaderPrefix) - qm.UserDefinedMetadata[strings.ToLower(name)] = value + if options != nil { + params = addTimeout(params, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := q.qsc.client.getEndpoint(queueServiceName, q.buildPath(), url.Values{"comp": {"metadata"}}) + + resp, err := q.qsc.client.exec(http.MethodGet, uri, headers, nil, q.qsc.auth) + if err != nil { + return err + } + defer readAndCloseBody(resp.body) + + if err := checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { + return err + } + + aproxMessagesStr := resp.headers.Get(http.CanonicalHeaderKey(approximateMessagesCountHeader)) + if aproxMessagesStr != "" { + aproxMessages, err := strconv.ParseUint(aproxMessagesStr, 10, 64) + if err != nil { + return err } + q.AproxMessageCount = aproxMessages } - return qm, checkRespCode(resp.statusCode, []int{http.StatusOK}) + q.Metadata = getMetadataFromHeaders(resp.headers) + return nil } -// CreateQueue operation creates a queue under the given account. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd179342.aspx -func (c QueueServiceClient) CreateQueue(name string) error { - uri := c.client.getEndpoint(queueServiceName, pathForQueue(name), url.Values{}) - headers := c.client.getStandardHeaders() - resp, err := c.client.exec(http.MethodPut, uri, headers, nil, c.auth) - if err != nil { - return err +// GetMessageReference returns a message object with the specified text. +func (q *Queue) GetMessageReference(text string) *Message { + return &Message{ + Queue: q, + Text: text, } - defer resp.body.Close() - return checkRespCode(resp.statusCode, []int{http.StatusCreated}) } -// DeleteQueue operation permanently deletes the specified queue. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd179436.aspx -func (c QueueServiceClient) DeleteQueue(name string) error { - uri := c.client.getEndpoint(queueServiceName, pathForQueue(name), url.Values{}) - resp, err := c.client.exec(http.MethodDelete, uri, c.client.getStandardHeaders(), nil, c.auth) - if err != nil { - return err - } - defer resp.body.Close() - return checkRespCode(resp.statusCode, []int{http.StatusNoContent}) +// GetMessagesOptions is the set of options can be specified for Get +// Messsages operation. A zero struct does not use any preferences for the +// request. +type GetMessagesOptions struct { + Timeout uint + NumOfMessages int + VisibilityTimeout int + RequestID string `header:"x-ms-client-request-id"` } -// QueueExists returns true if a queue with given name exists. -func (c QueueServiceClient) QueueExists(name string) (bool, error) { - uri := c.client.getEndpoint(queueServiceName, pathForQueue(name), url.Values{"comp": {"metadata"}}) - resp, err := c.client.exec(http.MethodGet, uri, c.client.getStandardHeaders(), nil, c.auth) - if resp != nil && (resp.statusCode == http.StatusOK || resp.statusCode == http.StatusNotFound) { - return resp.statusCode == http.StatusOK, nil - } - - return false, err -} - -// PutMessage operation adds a new message to the back of the message queue. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd179346.aspx -func (c QueueServiceClient) PutMessage(queue string, message string, params PutMessageParameters) error { - uri := c.client.getEndpoint(queueServiceName, pathForQueueMessages(queue), params.getParameters()) - req := putMessageRequest{MessageText: message} - body, nn, err := xmlMarshal(req) - if err != nil { - return err - } - headers := c.client.getStandardHeaders() - headers["Content-Length"] = strconv.Itoa(nn) - resp, err := c.client.exec(http.MethodPost, uri, headers, body, c.auth) - if err != nil { - return err - } - defer resp.body.Close() - return checkRespCode(resp.statusCode, []int{http.StatusCreated}) -} - -// ClearMessages operation deletes all messages from the specified queue. -// -// See https://msdn.microsoft.com/en-us/library/azure/dd179454.aspx -func (c QueueServiceClient) ClearMessages(queue string) error { - uri := c.client.getEndpoint(queueServiceName, pathForQueueMessages(queue), url.Values{}) - resp, err := c.client.exec(http.MethodDelete, uri, c.client.getStandardHeaders(), nil, c.auth) - if err != nil { - return err - } - defer resp.body.Close() - return checkRespCode(resp.statusCode, []int{http.StatusNoContent}) +type messages struct { + XMLName xml.Name `xml:"QueueMessagesList"` + Messages []Message `xml:"QueueMessage"` } // GetMessages operation retrieves one or more messages from the front of the // queue. // -// See https://msdn.microsoft.com/en-us/library/azure/dd179474.aspx -func (c QueueServiceClient) GetMessages(queue string, params GetMessagesParameters) (GetMessagesResponse, error) { - var r GetMessagesResponse - uri := c.client.getEndpoint(queueServiceName, pathForQueueMessages(queue), params.getParameters()) - resp, err := c.client.exec(http.MethodGet, uri, c.client.getStandardHeaders(), nil, c.auth) - if err != nil { - return r, err +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Get-Messages +func (q *Queue) GetMessages(options *GetMessagesOptions) ([]Message, error) { + query := url.Values{} + headers := q.qsc.client.getStandardHeaders() + + if options != nil { + if options.NumOfMessages != 0 { + query.Set("numofmessages", strconv.Itoa(options.NumOfMessages)) + } + if options.VisibilityTimeout != 0 { + query.Set("visibilitytimeout", strconv.Itoa(options.VisibilityTimeout)) + } + query = addTimeout(query, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) } - defer resp.body.Close() - err = xmlUnmarshal(resp.body, &r) - return r, err + uri := q.qsc.client.getEndpoint(queueServiceName, q.buildPathMessages(), query) + + resp, err := q.qsc.client.exec(http.MethodGet, uri, headers, nil, q.qsc.auth) + if err != nil { + return []Message{}, err + } + defer readAndCloseBody(resp.body) + + var out messages + err = xmlUnmarshal(resp.body, &out) + if err != nil { + return []Message{}, err + } + for i := range out.Messages { + out.Messages[i].Queue = q + } + return out.Messages, err +} + +// PeekMessagesOptions is the set of options can be specified for Peek +// Messsage operation. A zero struct does not use any preferences for the +// request. +type PeekMessagesOptions struct { + Timeout uint + NumOfMessages int + RequestID string `header:"x-ms-client-request-id"` } // PeekMessages retrieves one or more messages from the front of the queue, but // does not alter the visibility of the message. // -// See https://msdn.microsoft.com/en-us/library/azure/dd179472.aspx -func (c QueueServiceClient) PeekMessages(queue string, params PeekMessagesParameters) (PeekMessagesResponse, error) { - var r PeekMessagesResponse - uri := c.client.getEndpoint(queueServiceName, pathForQueueMessages(queue), params.getParameters()) - resp, err := c.client.exec(http.MethodGet, uri, c.client.getStandardHeaders(), nil, c.auth) - if err != nil { - return r, err +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Peek-Messages +func (q *Queue) PeekMessages(options *PeekMessagesOptions) ([]Message, error) { + query := url.Values{"peekonly": {"true"}} // Required for peek operation + headers := q.qsc.client.getStandardHeaders() + + if options != nil { + if options.NumOfMessages != 0 { + query.Set("numofmessages", strconv.Itoa(options.NumOfMessages)) + } + query = addTimeout(query, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) } - defer resp.body.Close() - err = xmlUnmarshal(resp.body, &r) - return r, err + uri := q.qsc.client.getEndpoint(queueServiceName, q.buildPathMessages(), query) + + resp, err := q.qsc.client.exec(http.MethodGet, uri, headers, nil, q.qsc.auth) + if err != nil { + return []Message{}, err + } + defer readAndCloseBody(resp.body) + + var out messages + err = xmlUnmarshal(resp.body, &out) + if err != nil { + return []Message{}, err + } + for i := range out.Messages { + out.Messages[i].Queue = q + } + return out.Messages, err } -// DeleteMessage operation deletes the specified message. +// ClearMessages operation deletes all messages from the specified queue. // -// See https://msdn.microsoft.com/en-us/library/azure/dd179347.aspx -func (c QueueServiceClient) DeleteMessage(queue, messageID, popReceipt string) error { - uri := c.client.getEndpoint(queueServiceName, pathForMessage(queue, messageID), url.Values{ - "popreceipt": {popReceipt}}) - resp, err := c.client.exec(http.MethodDelete, uri, c.client.getStandardHeaders(), nil, c.auth) +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Clear-Messages +func (q *Queue) ClearMessages(options *QueueServiceOptions) error { + params := url.Values{} + headers := q.qsc.client.getStandardHeaders() + + if options != nil { + params = addTimeout(params, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := q.qsc.client.getEndpoint(queueServiceName, q.buildPathMessages(), params) + + resp, err := q.qsc.client.exec(http.MethodDelete, uri, headers, nil, q.qsc.auth) if err != nil { return err } - defer resp.body.Close() + readAndCloseBody(resp.body) return checkRespCode(resp.statusCode, []int{http.StatusNoContent}) } -// UpdateMessage operation deletes the specified message. -// -// See https://msdn.microsoft.com/en-us/library/azure/hh452234.aspx -func (c QueueServiceClient) UpdateMessage(queue string, messageID string, message string, params UpdateMessageParameters) error { - uri := c.client.getEndpoint(queueServiceName, pathForMessage(queue, messageID), params.getParameters()) - req := putMessageRequest{MessageText: message} - body, nn, err := xmlMarshal(req) +// SetPermissions sets up queue permissions +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/set-queue-acl +func (q *Queue) SetPermissions(permissions QueuePermissions, options *SetQueuePermissionOptions) error { + body, length, err := generateQueueACLpayload(permissions.AccessPolicies) if err != nil { return err } - headers := c.client.getStandardHeaders() - headers["Content-Length"] = fmt.Sprintf("%d", nn) - resp, err := c.client.exec(http.MethodPut, uri, headers, body, c.auth) + + params := url.Values{ + "comp": {"acl"}, + } + headers := q.qsc.client.getStandardHeaders() + headers["Content-Length"] = strconv.Itoa(length) + + if options != nil { + params = addTimeout(params, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := q.qsc.client.getEndpoint(queueServiceName, q.buildPath(), params) + resp, err := q.qsc.client.exec(http.MethodPut, uri, headers, body, q.qsc.auth) if err != nil { return err } + defer readAndCloseBody(resp.body) + + if err := checkRespCode(resp.statusCode, []int{http.StatusNoContent}); err != nil { + return errors.New("Unable to set permissions") + } + + return nil +} + +func generateQueueACLpayload(policies []QueueAccessPolicy) (io.Reader, int, error) { + sil := SignedIdentifiers{ + SignedIdentifiers: []SignedIdentifier{}, + } + for _, qapd := range policies { + permission := qapd.generateQueuePermissions() + signedIdentifier := convertAccessPolicyToXMLStructs(qapd.ID, qapd.StartTime, qapd.ExpiryTime, permission) + sil.SignedIdentifiers = append(sil.SignedIdentifiers, signedIdentifier) + } + return xmlMarshal(sil) +} + +func (qapd *QueueAccessPolicy) generateQueuePermissions() (permissions string) { + // generate the permissions string (raup). + // still want the end user API to have bool flags. + permissions = "" + + if qapd.CanRead { + permissions += "r" + } + + if qapd.CanAdd { + permissions += "a" + } + + if qapd.CanUpdate { + permissions += "u" + } + + if qapd.CanProcess { + permissions += "p" + } + + return permissions +} + +// GetQueuePermissionOptions includes options for a get queue permissions operation +type GetQueuePermissionOptions struct { + Timeout uint + RequestID string `header:"x-ms-client-request-id"` +} + +// GetPermissions gets the queue permissions as per https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-queue-acl +// If timeout is 0 then it will not be passed to Azure +func (q *Queue) GetPermissions(options *GetQueuePermissionOptions) (*QueuePermissions, error) { + params := url.Values{ + "comp": {"acl"}, + } + headers := q.qsc.client.getStandardHeaders() + + if options != nil { + params = addTimeout(params, options.Timeout) + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + uri := q.qsc.client.getEndpoint(queueServiceName, q.buildPath(), params) + resp, err := q.qsc.client.exec(http.MethodGet, uri, headers, nil, q.qsc.auth) + if err != nil { + return nil, err + } defer resp.body.Close() - return checkRespCode(resp.statusCode, []int{http.StatusNoContent}) + + var ap AccessPolicy + err = xmlUnmarshal(resp.body, &ap.SignedIdentifiersList) + if err != nil { + return nil, err + } + return buildQueueAccessPolicy(ap, &resp.headers), nil +} + +func buildQueueAccessPolicy(ap AccessPolicy, headers *http.Header) *QueuePermissions { + permissions := QueuePermissions{ + AccessPolicies: []QueueAccessPolicy{}, + } + + for _, policy := range ap.SignedIdentifiersList.SignedIdentifiers { + qapd := QueueAccessPolicy{ + ID: policy.ID, + StartTime: policy.AccessPolicy.StartTime, + ExpiryTime: policy.AccessPolicy.ExpiryTime, + } + qapd.CanRead = updatePermissions(policy.AccessPolicy.Permission, "r") + qapd.CanAdd = updatePermissions(policy.AccessPolicy.Permission, "a") + qapd.CanUpdate = updatePermissions(policy.AccessPolicy.Permission, "u") + qapd.CanProcess = updatePermissions(policy.AccessPolicy.Permission, "p") + + permissions.AccessPolicies = append(permissions.AccessPolicies, qapd) + } + return &permissions } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/queueserviceclient.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/queueserviceclient.go new file mode 100644 index 000000000..19b44941c --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/queueserviceclient.go @@ -0,0 +1,28 @@ +package storage + +// QueueServiceClient contains operations for Microsoft Azure Queue Storage +// Service. +type QueueServiceClient struct { + client Client + auth authentication +} + +// GetServiceProperties gets the properties of your storage account's queue service. +// See: https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-queue-service-properties +func (q *QueueServiceClient) GetServiceProperties() (*ServiceProperties, error) { + return q.client.getServiceProperties(queueServiceName, q.auth) +} + +// SetServiceProperties sets the properties of your storage account's queue service. +// See: https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/set-queue-service-properties +func (q *QueueServiceClient) SetServiceProperties(props ServiceProperties) error { + return q.client.setServiceProperties(props, queueServiceName, q.auth) +} + +// GetQueueReference returns a Container object for the specified queue name. +func (q *QueueServiceClient) GetQueueReference(name string) *Queue { + return &Queue{ + qsc: q, + Name: name, + } +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/share.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/share.go index 8423aedcc..e6a868081 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/storage/share.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/share.go @@ -30,9 +30,15 @@ func (s *Share) buildPath() string { // Create this share under the associated account. // If a share with the same name already exists, the operation fails. // -// See https://msdn.microsoft.com/en-us/library/azure/dn167008.aspx -func (s *Share) Create() error { - headers, err := s.fsc.createResource(s.buildPath(), resourceShare, mergeMDIntoExtraHeaders(s.Metadata, nil)) +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Create-Share +func (s *Share) Create(options *FileRequestOptions) error { + extraheaders := map[string]string{} + if s.Properties.Quota > 0 { + extraheaders["x-ms-share-quota"] = strconv.Itoa(s.Properties.Quota) + } + + params := prepareOptions(options) + headers, err := s.fsc.createResource(s.buildPath(), resourceShare, params, mergeMDIntoExtraHeaders(s.Metadata, extraheaders), []int{http.StatusCreated}) if err != nil { return err } @@ -45,17 +51,23 @@ func (s *Share) Create() error { // it does not exist. Returns true if the share is newly created or false if // the share already exists. // -// See https://msdn.microsoft.com/en-us/library/azure/dn167008.aspx -func (s *Share) CreateIfNotExists() (bool, error) { - resp, err := s.fsc.createResourceNoClose(s.buildPath(), resourceShare, nil) +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Create-Share +func (s *Share) CreateIfNotExists(options *FileRequestOptions) (bool, error) { + extraheaders := map[string]string{} + if s.Properties.Quota > 0 { + extraheaders["x-ms-share-quota"] = strconv.Itoa(s.Properties.Quota) + } + + params := prepareOptions(options) + resp, err := s.fsc.createResourceNoClose(s.buildPath(), resourceShare, params, extraheaders) if resp != nil { - defer resp.body.Close() + defer readAndCloseBody(resp.body) if resp.statusCode == http.StatusCreated || resp.statusCode == http.StatusConflict { if resp.statusCode == http.StatusCreated { s.updateEtagAndLastModified(resp.headers) return true, nil } - return false, s.FetchAttributes() + return false, s.FetchAttributes(nil) } } @@ -66,18 +78,18 @@ func (s *Share) CreateIfNotExists() (bool, error) { // and directories contained within it are later deleted during garbage // collection. If the share does not exist the operation fails // -// See https://msdn.microsoft.com/en-us/library/azure/dn689090.aspx -func (s *Share) Delete() error { - return s.fsc.deleteResource(s.buildPath(), resourceShare) +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Delete-Share +func (s *Share) Delete(options *FileRequestOptions) error { + return s.fsc.deleteResource(s.buildPath(), resourceShare, options) } // DeleteIfExists operation marks this share for deletion if it exists. // -// See https://msdn.microsoft.com/en-us/library/azure/dn689090.aspx -func (s *Share) DeleteIfExists() (bool, error) { - resp, err := s.fsc.deleteResourceNoClose(s.buildPath(), resourceShare) +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Delete-Share +func (s *Share) DeleteIfExists(options *FileRequestOptions) (bool, error) { + resp, err := s.fsc.deleteResourceNoClose(s.buildPath(), resourceShare, options) if resp != nil { - defer resp.body.Close() + defer readAndCloseBody(resp.body) if resp.statusCode == http.StatusAccepted || resp.statusCode == http.StatusNotFound { return resp.statusCode == http.StatusAccepted, nil } @@ -97,8 +109,10 @@ func (s *Share) Exists() (bool, error) { } // FetchAttributes retrieves metadata and properties for this share. -func (s *Share) FetchAttributes() error { - headers, err := s.fsc.getResourceHeaders(s.buildPath(), compNone, resourceShare, http.MethodHead) +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-share-properties +func (s *Share) FetchAttributes(options *FileRequestOptions) error { + params := prepareOptions(options) + headers, err := s.fsc.getResourceHeaders(s.buildPath(), compNone, resourceShare, params, http.MethodHead) if err != nil { return err } @@ -130,9 +144,9 @@ func (s *Share) ServiceClient() *FileServiceClient { // are case-insensitive so case munging should not matter to other // applications either. // -// See https://msdn.microsoft.com/en-us/library/azure/dd179414.aspx -func (s *Share) SetMetadata() error { - headers, err := s.fsc.setResourceHeaders(s.buildPath(), compMetadata, resourceShare, mergeMDIntoExtraHeaders(s.Metadata, nil)) +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/set-share-metadata +func (s *Share) SetMetadata(options *FileRequestOptions) error { + headers, err := s.fsc.setResourceHeaders(s.buildPath(), compMetadata, resourceShare, mergeMDIntoExtraHeaders(s.Metadata, nil), options) if err != nil { return err } @@ -148,15 +162,17 @@ func (s *Share) SetMetadata() error { // are case-insensitive so case munging should not matter to other // applications either. // -// See https://msdn.microsoft.com/en-us/library/azure/mt427368.aspx -func (s *Share) SetProperties() error { - if s.Properties.Quota < 1 || s.Properties.Quota > 5120 { - return fmt.Errorf("invalid value %v for quota, valid values are [1, 5120]", s.Properties.Quota) +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Set-Share-Properties +func (s *Share) SetProperties(options *FileRequestOptions) error { + extraheaders := map[string]string{} + if s.Properties.Quota > 0 { + if s.Properties.Quota > 5120 { + return fmt.Errorf("invalid value %v for quota, valid values are [1, 5120]", s.Properties.Quota) + } + extraheaders["x-ms-share-quota"] = strconv.Itoa(s.Properties.Quota) } - headers, err := s.fsc.setResourceHeaders(s.buildPath(), compProperties, resourceShare, map[string]string{ - "x-ms-share-quota": strconv.Itoa(s.Properties.Quota), - }) + headers, err := s.fsc.setResourceHeaders(s.buildPath(), compProperties, resourceShare, extraheaders, options) if err != nil { return err } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/storageservice.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/storageservice.go new file mode 100644 index 000000000..88700fbc9 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/storageservice.go @@ -0,0 +1,117 @@ +package storage + +import ( + "net/http" + "net/url" + "strconv" +) + +// ServiceProperties represents the storage account service properties +type ServiceProperties struct { + Logging *Logging + HourMetrics *Metrics + MinuteMetrics *Metrics + Cors *Cors +} + +// Logging represents the Azure Analytics Logging settings +type Logging struct { + Version string + Delete bool + Read bool + Write bool + RetentionPolicy *RetentionPolicy +} + +// RetentionPolicy indicates if retention is enabled and for how many days +type RetentionPolicy struct { + Enabled bool + Days *int +} + +// Metrics provide request statistics. +type Metrics struct { + Version string + Enabled bool + IncludeAPIs *bool + RetentionPolicy *RetentionPolicy +} + +// Cors includes all the CORS rules +type Cors struct { + CorsRule []CorsRule +} + +// CorsRule includes all settings for a Cors rule +type CorsRule struct { + AllowedOrigins string + AllowedMethods string + MaxAgeInSeconds int + ExposedHeaders string + AllowedHeaders string +} + +func (c Client) getServiceProperties(service string, auth authentication) (*ServiceProperties, error) { + query := url.Values{ + "restype": {"service"}, + "comp": {"properties"}, + } + uri := c.getEndpoint(service, "", query) + headers := c.getStandardHeaders() + + resp, err := c.exec(http.MethodGet, uri, headers, nil, auth) + if err != nil { + return nil, err + } + defer resp.body.Close() + + if err := checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { + return nil, err + } + + var out ServiceProperties + err = xmlUnmarshal(resp.body, &out) + if err != nil { + return nil, err + } + + return &out, nil +} + +func (c Client) setServiceProperties(props ServiceProperties, service string, auth authentication) error { + query := url.Values{ + "restype": {"service"}, + "comp": {"properties"}, + } + uri := c.getEndpoint(service, "", query) + + // Ideally, StorageServiceProperties would be the output struct + // This is to avoid golint stuttering, while generating the correct XML + type StorageServiceProperties struct { + Logging *Logging + HourMetrics *Metrics + MinuteMetrics *Metrics + Cors *Cors + } + input := StorageServiceProperties{ + Logging: props.Logging, + HourMetrics: props.HourMetrics, + MinuteMetrics: props.MinuteMetrics, + Cors: props.Cors, + } + + body, length, err := xmlMarshal(input) + if err != nil { + return err + } + + headers := c.getStandardHeaders() + headers["Content-Length"] = strconv.Itoa(length) + + resp, err := c.exec(http.MethodPut, uri, headers, body, auth) + if err != nil { + return err + } + readAndCloseBody(resp.body) + return checkRespCode(resp.statusCode, []int{http.StatusAccepted}) +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/table.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/table.go index 5cbc13ff1..4eae3af9d 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/storage/table.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/table.go @@ -5,30 +5,23 @@ import ( "encoding/json" "fmt" "io" + "io/ioutil" "net/http" "net/url" "strconv" + "strings" "time" ) -// TableServiceClient contains operations for Microsoft Azure Table Storage -// Service. -type TableServiceClient struct { - client Client - auth authentication -} - -// AzureTable is the typedef of the Azure Table name -type AzureTable string - const ( - tablesURIPath = "/Tables" + tablesURIPath = "/Tables" + nextTableQueryParameter = "NextTableName" + headerNextPartitionKey = "x-ms-continuation-NextPartitionKey" + headerNextRowKey = "x-ms-continuation-NextRowKey" + nextPartitionKeyQueryParameter = "NextPartitionKey" + nextRowKeyQueryParameter = "NextRowKey" ) -type createTableRequest struct { - TableName string `json:"TableName"` -} - // TableAccessPolicy are used for SETTING table policies type TableAccessPolicy struct { ID string @@ -40,104 +33,146 @@ type TableAccessPolicy struct { CanDelete bool } -func pathForTable(table AzureTable) string { return fmt.Sprintf("%s", table) } - -func (c *TableServiceClient) getStandardHeaders() map[string]string { - return map[string]string{ - "x-ms-version": "2015-02-21", - "x-ms-date": currentTimeRfc1123Formatted(), - "Accept": "application/json;odata=nometadata", - "Accept-Charset": "UTF-8", - "Content-Type": "application/json", - userAgentHeader: c.client.userAgent, - } +// Table represents an Azure table. +type Table struct { + tsc *TableServiceClient + Name string `json:"TableName"` + OdataEditLink string `json:"odata.editLink"` + OdataID string `json:"odata.id"` + OdataMetadata string `json:"odata.metadata"` + OdataType string `json:"odata.type"` } -// QueryTables returns the tables created in the -// *TableServiceClient storage account. -func (c *TableServiceClient) QueryTables() ([]AzureTable, error) { - uri := c.client.getEndpoint(tableServiceName, tablesURIPath, url.Values{}) +// EntityQueryResult contains the response from +// ExecuteQuery and ExecuteQueryNextResults functions. +type EntityQueryResult struct { + OdataMetadata string `json:"odata.metadata"` + Entities []*Entity `json:"value"` + QueryNextLink + table *Table +} - headers := c.getStandardHeaders() - headers["Content-Length"] = "0" +type continuationToken struct { + NextPartitionKey string + NextRowKey string +} - resp, err := c.client.execInternalJSON(http.MethodGet, uri, headers, nil, c.auth) +func (t *Table) buildPath() string { + return fmt.Sprintf("/%s", t.Name) +} + +func (t *Table) buildSpecificPath() string { + return fmt.Sprintf("%s('%s')", tablesURIPath, t.Name) +} + +// Get gets the referenced table. +// See: https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/querying-tables-and-entities +func (t *Table) Get(timeout uint, ml MetadataLevel) error { + if ml == EmptyPayload { + return errEmptyPayload + } + + query := url.Values{ + "timeout": {strconv.FormatUint(uint64(timeout), 10)}, + } + headers := t.tsc.client.getStandardHeaders() + headers[headerAccept] = string(ml) + + uri := t.tsc.client.getEndpoint(tableServiceName, t.buildSpecificPath(), query) + resp, err := t.tsc.client.exec(http.MethodGet, uri, headers, nil, t.tsc.auth) if err != nil { - return nil, err + return err } - defer resp.body.Close() + defer readAndCloseBody(resp.body) - if err := checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { - return nil, err + if err = checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { + return err } - buf := new(bytes.Buffer) - if _, err := buf.ReadFrom(resp.body); err != nil { - return nil, err + respBody, err := ioutil.ReadAll(resp.body) + if err != nil { + return err } - - var respArray queryTablesResponse - if err := json.Unmarshal(buf.Bytes(), &respArray); err != nil { - return nil, err + err = json.Unmarshal(respBody, t) + if err != nil { + return err } - - s := make([]AzureTable, len(respArray.TableName)) - for i, elem := range respArray.TableName { - s[i] = AzureTable(elem.TableName) - } - - return s, nil + return nil } -// CreateTable creates the table given the specific -// name. This function fails if the name is not compliant +// Create creates the referenced table. +// This function fails if the name is not compliant // with the specification or the tables already exists. -func (c *TableServiceClient) CreateTable(table AzureTable) error { - uri := c.client.getEndpoint(tableServiceName, tablesURIPath, url.Values{}) +// ml determines the level of detail of metadata in the operation response, +// or no data at all. +// See https://docs.microsoft.com/rest/api/storageservices/fileservices/create-table +func (t *Table) Create(timeout uint, ml MetadataLevel, options *TableOptions) error { + uri := t.tsc.client.getEndpoint(tableServiceName, tablesURIPath, url.Values{ + "timeout": {strconv.FormatUint(uint64(timeout), 10)}, + }) - headers := c.getStandardHeaders() - - req := createTableRequest{TableName: string(table)} + type createTableRequest struct { + TableName string `json:"TableName"` + } + req := createTableRequest{TableName: t.Name} buf := new(bytes.Buffer) - if err := json.NewEncoder(buf).Encode(req); err != nil { return err } - headers["Content-Length"] = fmt.Sprintf("%d", buf.Len()) - - resp, err := c.client.execInternalJSON(http.MethodPost, uri, headers, buf, c.auth) + headers := t.tsc.client.getStandardHeaders() + headers = addReturnContentHeaders(headers, ml) + headers = addBodyRelatedHeaders(headers, buf.Len()) + headers = options.addToHeaders(headers) + resp, err := t.tsc.client.exec(http.MethodPost, uri, headers, buf, t.tsc.auth) if err != nil { return err } - defer resp.body.Close() + defer readAndCloseBody(resp.body) - if err := checkRespCode(resp.statusCode, []int{http.StatusCreated}); err != nil { - return err + if ml == EmptyPayload { + if err := checkRespCode(resp.statusCode, []int{http.StatusNoContent}); err != nil { + return err + } + } else { + if err := checkRespCode(resp.statusCode, []int{http.StatusCreated}); err != nil { + return err + } + } + + if ml != EmptyPayload { + data, err := ioutil.ReadAll(resp.body) + if err != nil { + return err + } + err = json.Unmarshal(data, t) + if err != nil { + return err + } } return nil } -// DeleteTable deletes the table given the specific -// name. This function fails if the table is not present. -// Be advised: DeleteTable deletes all the entries -// that may be present. -func (c *TableServiceClient) DeleteTable(table AzureTable) error { - uri := c.client.getEndpoint(tableServiceName, tablesURIPath, url.Values{}) - uri += fmt.Sprintf("('%s')", string(table)) +// Delete deletes the referenced table. +// This function fails if the table is not present. +// Be advised: Delete deletes all the entries that may be present. +// See https://docs.microsoft.com/rest/api/storageservices/fileservices/delete-table +func (t *Table) Delete(timeout uint, options *TableOptions) error { + uri := t.tsc.client.getEndpoint(tableServiceName, t.buildSpecificPath(), url.Values{ + "timeout": {strconv.Itoa(int(timeout))}, + }) - headers := c.getStandardHeaders() - - headers["Content-Length"] = "0" - - resp, err := c.client.execInternalJSON(http.MethodDelete, uri, headers, nil, c.auth) + headers := t.tsc.client.getStandardHeaders() + headers = addReturnContentHeaders(headers, EmptyPayload) + headers = options.addToHeaders(headers) + resp, err := t.tsc.client.exec(http.MethodDelete, uri, headers, nil, t.tsc.auth) if err != nil { return err } - defer resp.body.Close() + defer readAndCloseBody(resp.body) if err := checkRespCode(resp.statusCode, []int{http.StatusNoContent}); err != nil { return err @@ -146,28 +181,85 @@ func (c *TableServiceClient) DeleteTable(table AzureTable) error { return nil } -// SetTablePermissions sets up table ACL permissions as per REST details https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Set-Table-ACL -func (c *TableServiceClient) SetTablePermissions(table AzureTable, policies []TableAccessPolicy, timeout uint) (err error) { - params := url.Values{"comp": {"acl"}} +// QueryOptions includes options for a query entities operation. +// Top, filter and select are OData query options. +type QueryOptions struct { + Top uint + Filter string + Select []string + RequestID string +} - if timeout > 0 { - params.Add("timeout", fmt.Sprint(timeout)) +func (options *QueryOptions) getParameters() (url.Values, map[string]string) { + query := url.Values{} + headers := map[string]string{} + if options != nil { + if options.Top > 0 { + query.Add(OdataTop, strconv.FormatUint(uint64(options.Top), 10)) + } + if options.Filter != "" { + query.Add(OdataFilter, options.Filter) + } + if len(options.Select) > 0 { + query.Add(OdataSelect, strings.Join(options.Select, ",")) + } + headers = addToHeaders(headers, "x-ms-client-request-id", options.RequestID) + } + return query, headers +} + +// QueryEntities returns the entities in the table. +// You can use query options defined by the OData Protocol specification. +// +// See: https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/query-entities +func (t *Table) QueryEntities(timeout uint, ml MetadataLevel, options *QueryOptions) (*EntityQueryResult, error) { + if ml == EmptyPayload { + return nil, errEmptyPayload + } + query, headers := options.getParameters() + query = addTimeout(query, timeout) + uri := t.tsc.client.getEndpoint(tableServiceName, t.buildPath(), query) + return t.queryEntities(uri, headers, ml) +} + +// NextResults returns the next page of results +// from a QueryEntities or NextResults operation. +// +// See: https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/query-entities +// See https://docs.microsoft.com/rest/api/storageservices/fileservices/query-timeout-and-pagination +func (eqr *EntityQueryResult) NextResults(options *TableOptions) (*EntityQueryResult, error) { + if eqr == nil { + return nil, errNilPreviousResult + } + if eqr.NextLink == nil { + return nil, errNilNextLink + } + headers := options.addToHeaders(map[string]string{}) + return eqr.table.queryEntities(*eqr.NextLink, headers, eqr.ml) +} + +// SetPermissions sets up table ACL permissions +// See https://docs.microsoft.com/rest/api/storageservices/fileservices/Set-Table-ACL +func (t *Table) SetPermissions(tap []TableAccessPolicy, timeout uint, options *TableOptions) error { + params := url.Values{"comp": {"acl"}, + "timeout": {strconv.Itoa(int(timeout))}, } - uri := c.client.getEndpoint(tableServiceName, string(table), params) - headers := c.client.getStandardHeaders() + uri := t.tsc.client.getEndpoint(tableServiceName, t.Name, params) + headers := t.tsc.client.getStandardHeaders() + headers = options.addToHeaders(headers) - body, length, err := generateTableACLPayload(policies) + body, length, err := generateTableACLPayload(tap) if err != nil { return err } - headers["Content-Length"] = fmt.Sprintf("%v", length) + headers["Content-Length"] = strconv.Itoa(length) - resp, err := c.client.execInternalJSON(http.MethodPut, uri, headers, body, c.auth) + resp, err := t.tsc.client.exec(http.MethodPut, uri, headers, body, t.tsc.auth) if err != nil { return err } - defer resp.body.Close() + defer readAndCloseBody(resp.body) if err := checkRespCode(resp.statusCode, []int{http.StatusNoContent}); err != nil { return err @@ -187,17 +279,18 @@ func generateTableACLPayload(policies []TableAccessPolicy) (io.Reader, int, erro return xmlMarshal(sil) } -// GetTablePermissions gets the table ACL permissions, as per REST details https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-table-acl -func (c *TableServiceClient) GetTablePermissions(table AzureTable, timeout int) (permissionResponse []TableAccessPolicy, err error) { - params := url.Values{"comp": {"acl"}} - - if timeout > 0 { - params.Add("timeout", strconv.Itoa(timeout)) +// GetPermissions gets the table ACL permissions +// See https://docs.microsoft.com/rest/api/storageservices/fileservices/get-table-acl +func (t *Table) GetPermissions(timeout int, options *TableOptions) ([]TableAccessPolicy, error) { + params := url.Values{"comp": {"acl"}, + "timeout": {strconv.Itoa(int(timeout))}, } - uri := c.client.getEndpoint(tableServiceName, string(table), params) - headers := c.client.getStandardHeaders() - resp, err := c.client.execInternalJSON(http.MethodGet, uri, headers, nil, c.auth) + uri := t.tsc.client.getEndpoint(tableServiceName, t.Name, params) + headers := t.tsc.client.getStandardHeaders() + headers = options.addToHeaders(headers) + + resp, err := t.tsc.client.exec(http.MethodGet, uri, headers, nil, t.tsc.auth) if err != nil { return nil, err } @@ -212,12 +305,73 @@ func (c *TableServiceClient) GetTablePermissions(table AzureTable, timeout int) if err != nil { return nil, err } - out := updateTableAccessPolicy(ap) - return out, nil + return updateTableAccessPolicy(ap), nil +} + +func (t *Table) queryEntities(uri string, headers map[string]string, ml MetadataLevel) (*EntityQueryResult, error) { + headers = mergeHeaders(headers, t.tsc.client.getStandardHeaders()) + if ml != EmptyPayload { + headers[headerAccept] = string(ml) + } + + resp, err := t.tsc.client.exec(http.MethodGet, uri, headers, nil, t.tsc.auth) + if err != nil { + return nil, err + } + defer resp.body.Close() + + if err = checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { + return nil, err + } + + data, err := ioutil.ReadAll(resp.body) + if err != nil { + return nil, err + } + var entities EntityQueryResult + err = json.Unmarshal(data, &entities) + if err != nil { + return nil, err + } + + for i := range entities.Entities { + entities.Entities[i].Table = t + } + entities.table = t + + contToken := extractContinuationTokenFromHeaders(resp.headers) + if contToken == nil { + entities.NextLink = nil + } else { + originalURI, err := url.Parse(uri) + if err != nil { + return nil, err + } + v := originalURI.Query() + v.Set(nextPartitionKeyQueryParameter, contToken.NextPartitionKey) + v.Set(nextRowKeyQueryParameter, contToken.NextRowKey) + newURI := t.tsc.client.getEndpoint(tableServiceName, t.buildPath(), v) + entities.NextLink = &newURI + entities.ml = ml + } + + return &entities, nil +} + +func extractContinuationTokenFromHeaders(h http.Header) *continuationToken { + ct := continuationToken{ + NextPartitionKey: h.Get(headerNextPartitionKey), + NextRowKey: h.Get(headerNextRowKey), + } + + if ct.NextPartitionKey != "" && ct.NextRowKey != "" { + return &ct + } + return nil } func updateTableAccessPolicy(ap AccessPolicy) []TableAccessPolicy { - out := []TableAccessPolicy{} + taps := []TableAccessPolicy{} for _, policy := range ap.SignedIdentifiersList.SignedIdentifiers { tap := TableAccessPolicy{ ID: policy.ID, @@ -229,9 +383,9 @@ func updateTableAccessPolicy(ap AccessPolicy) []TableAccessPolicy { tap.CanUpdate = updatePermissions(policy.AccessPolicy.Permission, "u") tap.CanDelete = updatePermissions(policy.AccessPolicy.Permission, "d") - out = append(out, tap) + taps = append(taps, tap) } - return out + return taps } func generateTablePermissions(tap *TableAccessPolicy) (permissions string) { diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/table_batch.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/table_batch.go new file mode 100644 index 000000000..7a0f0915c --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/table_batch.go @@ -0,0 +1,302 @@ +package storage + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "io" + "mime/multipart" + "net/http" + "net/textproto" + "sort" + "strings" + + "github.com/satori/uuid" +) + +// Operation type. Insert, Delete, Replace etc. +type Operation int + +// consts for batch operations. +const ( + InsertOp = Operation(1) + DeleteOp = Operation(2) + ReplaceOp = Operation(3) + MergeOp = Operation(4) + InsertOrReplaceOp = Operation(5) + InsertOrMergeOp = Operation(6) +) + +// BatchEntity used for tracking Entities to operate on and +// whether operations (replace/merge etc) should be forced. +// Wrapper for regular Entity with additional data specific for the entity. +type BatchEntity struct { + *Entity + Force bool + Op Operation +} + +// TableBatch stores all the entities that will be operated on during a batch process. +// Entities can be inserted, replaced or deleted. +type TableBatch struct { + BatchEntitySlice []BatchEntity + + // reference to table we're operating on. + Table *Table +} + +// defaultChangesetHeaders for changeSets +var defaultChangesetHeaders = map[string]string{ + "Accept": "application/json;odata=minimalmetadata", + "Content-Type": "application/json", + "Prefer": "return-no-content", +} + +// NewBatch return new TableBatch for populating. +func (t *Table) NewBatch() *TableBatch { + return &TableBatch{ + Table: t, + } +} + +// InsertEntity adds an entity in preparation for a batch insert. +func (t *TableBatch) InsertEntity(entity *Entity) { + be := BatchEntity{Entity: entity, Force: false, Op: InsertOp} + t.BatchEntitySlice = append(t.BatchEntitySlice, be) +} + +// InsertOrReplaceEntity adds an entity in preparation for a batch insert or replace. +func (t *TableBatch) InsertOrReplaceEntity(entity *Entity, force bool) { + be := BatchEntity{Entity: entity, Force: false, Op: InsertOrReplaceOp} + t.BatchEntitySlice = append(t.BatchEntitySlice, be) +} + +// InsertOrReplaceEntityByForce adds an entity in preparation for a batch insert or replace. Forces regardless of ETag +func (t *TableBatch) InsertOrReplaceEntityByForce(entity *Entity) { + t.InsertOrReplaceEntity(entity, true) +} + +// InsertOrMergeEntity adds an entity in preparation for a batch insert or merge. +func (t *TableBatch) InsertOrMergeEntity(entity *Entity, force bool) { + be := BatchEntity{Entity: entity, Force: false, Op: InsertOrMergeOp} + t.BatchEntitySlice = append(t.BatchEntitySlice, be) +} + +// InsertOrMergeEntityByForce adds an entity in preparation for a batch insert or merge. Forces regardless of ETag +func (t *TableBatch) InsertOrMergeEntityByForce(entity *Entity) { + t.InsertOrMergeEntity(entity, true) +} + +// ReplaceEntity adds an entity in preparation for a batch replace. +func (t *TableBatch) ReplaceEntity(entity *Entity) { + be := BatchEntity{Entity: entity, Force: false, Op: ReplaceOp} + t.BatchEntitySlice = append(t.BatchEntitySlice, be) +} + +// DeleteEntity adds an entity in preparation for a batch delete +func (t *TableBatch) DeleteEntity(entity *Entity, force bool) { + be := BatchEntity{Entity: entity, Force: false, Op: DeleteOp} + t.BatchEntitySlice = append(t.BatchEntitySlice, be) +} + +// DeleteEntityByForce adds an entity in preparation for a batch delete. Forces regardless of ETag +func (t *TableBatch) DeleteEntityByForce(entity *Entity, force bool) { + t.DeleteEntity(entity, true) +} + +// MergeEntity adds an entity in preparation for a batch merge +func (t *TableBatch) MergeEntity(entity *Entity) { + be := BatchEntity{Entity: entity, Force: false, Op: MergeOp} + t.BatchEntitySlice = append(t.BatchEntitySlice, be) +} + +// ExecuteBatch executes many table operations in one request to Azure. +// The operations can be combinations of Insert, Delete, Replace and Merge +// Creates the inner changeset body (various operations, Insert, Delete etc) then creates the outer request packet that encompasses +// the changesets. +// As per document https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/performing-entity-group-transactions +func (t *TableBatch) ExecuteBatch() error { + changesetBoundary := fmt.Sprintf("changeset_%s", uuid.NewV1()) + uri := t.Table.tsc.client.getEndpoint(tableServiceName, "$batch", nil) + changesetBody, err := t.generateChangesetBody(changesetBoundary) + if err != nil { + return err + } + + boundary := fmt.Sprintf("batch_%s", uuid.NewV1()) + body, err := generateBody(changesetBody, changesetBoundary, boundary) + if err != nil { + return err + } + + headers := t.Table.tsc.client.getStandardHeaders() + headers[headerContentType] = fmt.Sprintf("multipart/mixed; boundary=%s", boundary) + + resp, err := t.Table.tsc.client.execBatchOperationJSON(http.MethodPost, uri, headers, bytes.NewReader(body.Bytes()), t.Table.tsc.auth) + if err != nil { + return err + } + defer resp.body.Close() + + if err = checkRespCode(resp.statusCode, []int{http.StatusAccepted}); err != nil { + + // check which batch failed. + operationFailedMessage := t.getFailedOperation(resp.odata.Err.Message.Value) + requestID, date, version := getDebugHeaders(resp.headers) + return AzureStorageServiceError{ + StatusCode: resp.statusCode, + Code: resp.odata.Err.Code, + RequestID: requestID, + Date: date, + APIVersion: version, + Message: operationFailedMessage, + } + } + + return nil +} + +// getFailedOperation parses the original Azure error string and determines which operation failed +// and generates appropriate message. +func (t *TableBatch) getFailedOperation(errorMessage string) string { + // errorMessage consists of "number:string" we just need the number. + sp := strings.Split(errorMessage, ":") + if len(sp) > 1 { + msg := fmt.Sprintf("Element %s in the batch returned an unexpected response code.\n%s", sp[0], errorMessage) + return msg + } + + // cant parse the message, just return the original message to client + return errorMessage +} + +// generateBody generates the complete body for the batch request. +func generateBody(changeSetBody *bytes.Buffer, changesetBoundary string, boundary string) (*bytes.Buffer, error) { + + body := new(bytes.Buffer) + writer := multipart.NewWriter(body) + writer.SetBoundary(boundary) + h := make(textproto.MIMEHeader) + h.Set(headerContentType, fmt.Sprintf("multipart/mixed; boundary=%s\r\n", changesetBoundary)) + batchWriter, err := writer.CreatePart(h) + if err != nil { + return nil, err + } + batchWriter.Write(changeSetBody.Bytes()) + writer.Close() + return body, nil +} + +// generateChangesetBody generates the individual changesets for the various operations within the batch request. +// There is a changeset for Insert, Delete, Merge etc. +func (t *TableBatch) generateChangesetBody(changesetBoundary string) (*bytes.Buffer, error) { + + body := new(bytes.Buffer) + writer := multipart.NewWriter(body) + writer.SetBoundary(changesetBoundary) + + for _, be := range t.BatchEntitySlice { + t.generateEntitySubset(&be, writer) + } + + writer.Close() + return body, nil +} + +// generateVerb generates the HTTP request VERB required for each changeset. +func generateVerb(op Operation) (string, error) { + switch op { + case InsertOp: + return http.MethodPost, nil + case DeleteOp: + return http.MethodDelete, nil + case ReplaceOp, InsertOrReplaceOp: + return http.MethodPut, nil + case MergeOp, InsertOrMergeOp: + return "MERGE", nil + default: + return "", errors.New("Unable to detect operation") + } +} + +// generateQueryPath generates the query path for within the changesets +// For inserts it will just be a table query path (table name) +// but for other operations (modifying an existing entity) then +// the partition/row keys need to be generated. +func (t *TableBatch) generateQueryPath(op Operation, entity *Entity) string { + if op == InsertOp { + return entity.Table.buildPath() + } + return entity.buildPath() +} + +// generateGenericOperationHeaders generates common headers for a given operation. +func generateGenericOperationHeaders(be *BatchEntity) map[string]string { + retval := map[string]string{} + + for k, v := range defaultChangesetHeaders { + retval[k] = v + } + + if be.Op == DeleteOp || be.Op == ReplaceOp || be.Op == MergeOp { + if be.Force || be.Entity.OdataEtag == "" { + retval["If-Match"] = "*" + } else { + retval["If-Match"] = be.Entity.OdataEtag + } + } + + return retval +} + +// generateEntitySubset generates body payload for particular batch entity +func (t *TableBatch) generateEntitySubset(batchEntity *BatchEntity, writer *multipart.Writer) error { + + h := make(textproto.MIMEHeader) + h.Set(headerContentType, "application/http") + h.Set(headerContentTransferEncoding, "binary") + + verb, err := generateVerb(batchEntity.Op) + if err != nil { + return err + } + + genericOpHeadersMap := generateGenericOperationHeaders(batchEntity) + queryPath := t.generateQueryPath(batchEntity.Op, batchEntity.Entity) + uri := t.Table.tsc.client.getEndpoint(tableServiceName, queryPath, nil) + + operationWriter, err := writer.CreatePart(h) + if err != nil { + return err + } + + urlAndVerb := fmt.Sprintf("%s %s HTTP/1.1\r\n", verb, uri) + operationWriter.Write([]byte(urlAndVerb)) + writeHeaders(genericOpHeadersMap, &operationWriter) + operationWriter.Write([]byte("\r\n")) // additional \r\n is needed per changeset separating the "headers" and the body. + + // delete operation doesn't need a body. + if batchEntity.Op != DeleteOp { + //var e Entity = batchEntity.Entity + body, err := json.Marshal(batchEntity.Entity) + if err != nil { + return err + } + operationWriter.Write(body) + } + + return nil +} + +func writeHeaders(h map[string]string, writer *io.Writer) { + // This way it is guaranteed the headers will be written in a sorted order + var keys []string + for k := range h { + keys = append(keys, k) + } + sort.Strings(keys) + for _, k := range keys { + (*writer).Write([]byte(fmt.Sprintf("%s: %s\r\n", k, h[k]))) + } +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/table_entities.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/table_entities.go deleted file mode 100644 index 1758d9f3e..000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/storage/table_entities.go +++ /dev/null @@ -1,345 +0,0 @@ -package storage - -import ( - "bytes" - "encoding/json" - "fmt" - "io" - "net/http" - "net/url" - "reflect" -) - -// Annotating as secure for gas scanning -/* #nosec */ -const ( - partitionKeyNode = "PartitionKey" - rowKeyNode = "RowKey" - tag = "table" - tagIgnore = "-" - continuationTokenPartitionKeyHeader = "X-Ms-Continuation-Nextpartitionkey" - continuationTokenRowHeader = "X-Ms-Continuation-Nextrowkey" - maxTopParameter = 1000 -) - -type queryTablesResponse struct { - TableName []struct { - TableName string `json:"TableName"` - } `json:"value"` -} - -const ( - tableOperationTypeInsert = iota - tableOperationTypeUpdate = iota - tableOperationTypeMerge = iota - tableOperationTypeInsertOrReplace = iota - tableOperationTypeInsertOrMerge = iota -) - -type tableOperation int - -// TableEntity interface specifies -// the functions needed to support -// marshaling and unmarshaling into -// Azure Tables. The struct must only contain -// simple types because Azure Tables do not -// support hierarchy. -type TableEntity interface { - PartitionKey() string - RowKey() string - SetPartitionKey(string) error - SetRowKey(string) error -} - -// ContinuationToken is an opaque (ie not useful to inspect) -// struct that Get... methods can return if there are more -// entries to be returned than the ones already -// returned. Just pass it to the same function to continue -// receiving the remaining entries. -type ContinuationToken struct { - NextPartitionKey string - NextRowKey string -} - -type getTableEntriesResponse struct { - Elements []map[string]interface{} `json:"value"` -} - -// QueryTableEntities queries the specified table and returns the unmarshaled -// entities of type retType. -// top parameter limits the returned entries up to top. Maximum top -// allowed by Azure API is 1000. In case there are more than top entries to be -// returned the function will return a non nil *ContinuationToken. You can call the -// same function again passing the received ContinuationToken as previousContToken -// parameter in order to get the following entries. The query parameter -// is the odata query. To retrieve all the entries pass the empty string. -// The function returns a pointer to a TableEntity slice, the *ContinuationToken -// if there are more entries to be returned and an error in case something went -// wrong. -// -// Example: -// entities, cToken, err = tSvc.QueryTableEntities("table", cToken, reflect.TypeOf(entity), 20, "") -func (c *TableServiceClient) QueryTableEntities(tableName AzureTable, previousContToken *ContinuationToken, retType reflect.Type, top int, query string) ([]TableEntity, *ContinuationToken, error) { - if top > maxTopParameter { - return nil, nil, fmt.Errorf("top accepts at maximum %d elements. Requested %d instead", maxTopParameter, top) - } - - uri := c.client.getEndpoint(tableServiceName, pathForTable(tableName), url.Values{}) - uri += fmt.Sprintf("?$top=%d", top) - if query != "" { - uri += fmt.Sprintf("&$filter=%s", url.QueryEscape(query)) - } - - if previousContToken != nil { - uri += fmt.Sprintf("&NextPartitionKey=%s&NextRowKey=%s", previousContToken.NextPartitionKey, previousContToken.NextRowKey) - } - - headers := c.getStandardHeaders() - - headers["Content-Length"] = "0" - - resp, err := c.client.execInternalJSON(http.MethodGet, uri, headers, nil, c.auth) - - if err != nil { - return nil, nil, err - } - - contToken := extractContinuationTokenFromHeaders(resp.headers) - - defer resp.body.Close() - - if err = checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { - return nil, contToken, err - } - - retEntries, err := deserializeEntity(retType, resp.body) - if err != nil { - return nil, contToken, err - } - - return retEntries, contToken, nil -} - -// InsertEntity inserts an entity in the specified table. -// The function fails if there is an entity with the same -// PartitionKey and RowKey in the table. -func (c *TableServiceClient) InsertEntity(table AzureTable, entity TableEntity) error { - if sc, err := c.execTable(table, entity, false, http.MethodPost); err != nil { - return checkRespCode(sc, []int{http.StatusCreated}) - } - - return nil -} - -func (c *TableServiceClient) execTable(table AzureTable, entity TableEntity, specifyKeysInURL bool, method string) (int, error) { - uri := c.client.getEndpoint(tableServiceName, pathForTable(table), url.Values{}) - if specifyKeysInURL { - uri += fmt.Sprintf("(PartitionKey='%s',RowKey='%s')", url.QueryEscape(entity.PartitionKey()), url.QueryEscape(entity.RowKey())) - } - - headers := c.getStandardHeaders() - - var buf bytes.Buffer - - if err := injectPartitionAndRowKeys(entity, &buf); err != nil { - return 0, err - } - - headers["Content-Length"] = fmt.Sprintf("%d", buf.Len()) - - resp, err := c.client.execInternalJSON(method, uri, headers, &buf, c.auth) - - if err != nil { - return 0, err - } - - defer resp.body.Close() - - return resp.statusCode, nil -} - -// UpdateEntity updates the contents of an entity with the -// one passed as parameter. The function fails if there is no entity -// with the same PartitionKey and RowKey in the table. -func (c *TableServiceClient) UpdateEntity(table AzureTable, entity TableEntity) error { - if sc, err := c.execTable(table, entity, true, http.MethodPut); err != nil { - return checkRespCode(sc, []int{http.StatusNoContent}) - } - return nil -} - -// MergeEntity merges the contents of an entity with the -// one passed as parameter. -// The function fails if there is no entity -// with the same PartitionKey and RowKey in the table. -func (c *TableServiceClient) MergeEntity(table AzureTable, entity TableEntity) error { - if sc, err := c.execTable(table, entity, true, "MERGE"); err != nil { - return checkRespCode(sc, []int{http.StatusNoContent}) - } - return nil -} - -// DeleteEntityWithoutCheck deletes the entity matching by -// PartitionKey and RowKey. There is no check on IfMatch -// parameter so the entity is always deleted. -// The function fails if there is no entity -// with the same PartitionKey and RowKey in the table. -func (c *TableServiceClient) DeleteEntityWithoutCheck(table AzureTable, entity TableEntity) error { - return c.DeleteEntity(table, entity, "*") -} - -// DeleteEntity deletes the entity matching by -// PartitionKey, RowKey and ifMatch field. -// The function fails if there is no entity -// with the same PartitionKey and RowKey in the table or -// the ifMatch is different. -func (c *TableServiceClient) DeleteEntity(table AzureTable, entity TableEntity, ifMatch string) error { - uri := c.client.getEndpoint(tableServiceName, pathForTable(table), url.Values{}) - uri += fmt.Sprintf("(PartitionKey='%s',RowKey='%s')", url.QueryEscape(entity.PartitionKey()), url.QueryEscape(entity.RowKey())) - - headers := c.getStandardHeaders() - - headers["Content-Length"] = "0" - headers["If-Match"] = ifMatch - - resp, err := c.client.execInternalJSON(http.MethodDelete, uri, headers, nil, c.auth) - - if err != nil { - return err - } - defer resp.body.Close() - - if err := checkRespCode(resp.statusCode, []int{http.StatusNoContent}); err != nil { - return err - } - - return nil -} - -// InsertOrReplaceEntity inserts an entity in the specified table -// or replaced the existing one. -func (c *TableServiceClient) InsertOrReplaceEntity(table AzureTable, entity TableEntity) error { - if sc, err := c.execTable(table, entity, true, http.MethodPut); err != nil { - return checkRespCode(sc, []int{http.StatusNoContent}) - } - return nil -} - -// InsertOrMergeEntity inserts an entity in the specified table -// or merges the existing one. -func (c *TableServiceClient) InsertOrMergeEntity(table AzureTable, entity TableEntity) error { - if sc, err := c.execTable(table, entity, true, "MERGE"); err != nil { - return checkRespCode(sc, []int{http.StatusNoContent}) - } - return nil -} - -func injectPartitionAndRowKeys(entity TableEntity, buf *bytes.Buffer) error { - if err := json.NewEncoder(buf).Encode(entity); err != nil { - return err - } - - dec := make(map[string]interface{}) - if err := json.NewDecoder(buf).Decode(&dec); err != nil { - return err - } - - // Inject PartitionKey and RowKey - dec[partitionKeyNode] = entity.PartitionKey() - dec[rowKeyNode] = entity.RowKey() - - // Remove tagged fields - // The tag is defined in the const section - // This is useful to avoid storing the PartitionKey and RowKey twice. - numFields := reflect.ValueOf(entity).Elem().NumField() - for i := 0; i < numFields; i++ { - f := reflect.ValueOf(entity).Elem().Type().Field(i) - - if f.Tag.Get(tag) == tagIgnore { - // we must look for its JSON name in the dictionary - // as the user can rename it using a tag - jsonName := f.Name - if f.Tag.Get("json") != "" { - jsonName = f.Tag.Get("json") - } - delete(dec, jsonName) - } - } - - buf.Reset() - - if err := json.NewEncoder(buf).Encode(&dec); err != nil { - return err - } - - return nil -} - -func deserializeEntity(retType reflect.Type, reader io.Reader) ([]TableEntity, error) { - buf := new(bytes.Buffer) - - var ret getTableEntriesResponse - if err := json.NewDecoder(reader).Decode(&ret); err != nil { - return nil, err - } - - tEntries := make([]TableEntity, len(ret.Elements)) - - for i, entry := range ret.Elements { - - buf.Reset() - if err := json.NewEncoder(buf).Encode(entry); err != nil { - return nil, err - } - - dec := make(map[string]interface{}) - if err := json.NewDecoder(buf).Decode(&dec); err != nil { - return nil, err - } - - var pKey, rKey string - // strip pk and rk - for key, val := range dec { - switch key { - case partitionKeyNode: - pKey = val.(string) - case rowKeyNode: - rKey = val.(string) - } - } - - delete(dec, partitionKeyNode) - delete(dec, rowKeyNode) - - buf.Reset() - if err := json.NewEncoder(buf).Encode(dec); err != nil { - return nil, err - } - - // Create a empty retType instance - tEntries[i] = reflect.New(retType.Elem()).Interface().(TableEntity) - // Popolate it with the values - if err := json.NewDecoder(buf).Decode(&tEntries[i]); err != nil { - return nil, err - } - - // Reset PartitionKey and RowKey - if err := tEntries[i].SetPartitionKey(pKey); err != nil { - return nil, err - } - if err := tEntries[i].SetRowKey(rKey); err != nil { - return nil, err - } - } - - return tEntries, nil -} - -func extractContinuationTokenFromHeaders(h http.Header) *ContinuationToken { - ct := ContinuationToken{h.Get(continuationTokenPartitionKeyHeader), h.Get(continuationTokenRowHeader)} - - if ct.NextPartitionKey != "" && ct.NextRowKey != "" { - return &ct - } - return nil -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/tableserviceclient.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/tableserviceclient.go new file mode 100644 index 000000000..895dcfded --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/tableserviceclient.go @@ -0,0 +1,190 @@ +package storage + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "net/http" + "net/url" + "strconv" +) + +const ( + headerAccept = "Accept" + headerEtag = "Etag" + headerPrefer = "Prefer" + headerXmsContinuation = "x-ms-Continuation-NextTableName" +) + +// TableServiceClient contains operations for Microsoft Azure Table Storage +// Service. +type TableServiceClient struct { + client Client + auth authentication +} + +// TableOptions includes options for some table operations +type TableOptions struct { + RequestID string +} + +func (options *TableOptions) addToHeaders(h map[string]string) map[string]string { + if options != nil { + h = addToHeaders(h, "x-ms-client-request-id", options.RequestID) + } + return h +} + +// QueryNextLink includes information for getting the next page of +// results in query operations +type QueryNextLink struct { + NextLink *string + ml MetadataLevel +} + +// GetServiceProperties gets the properties of your storage account's table service. +// See: https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-table-service-properties +func (t *TableServiceClient) GetServiceProperties() (*ServiceProperties, error) { + return t.client.getServiceProperties(tableServiceName, t.auth) +} + +// SetServiceProperties sets the properties of your storage account's table service. +// See: https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/set-table-service-properties +func (t *TableServiceClient) SetServiceProperties(props ServiceProperties) error { + return t.client.setServiceProperties(props, tableServiceName, t.auth) +} + +// GetTableReference returns a Table object for the specified table name. +func (t *TableServiceClient) GetTableReference(name string) *Table { + return &Table{ + tsc: t, + Name: name, + } +} + +// QueryTablesOptions includes options for some table operations +type QueryTablesOptions struct { + Top uint + Filter string + RequestID string +} + +func (options *QueryTablesOptions) getParameters() (url.Values, map[string]string) { + query := url.Values{} + headers := map[string]string{} + if options != nil { + if options.Top > 0 { + query.Add(OdataTop, strconv.FormatUint(uint64(options.Top), 10)) + } + if options.Filter != "" { + query.Add(OdataFilter, options.Filter) + } + headers = addToHeaders(headers, "x-ms-client-request-id", options.RequestID) + } + return query, headers +} + +// QueryTables returns the tables in the storage account. +// You can use query options defined by the OData Protocol specification. +// +// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/query-tables +func (t *TableServiceClient) QueryTables(ml MetadataLevel, options *QueryTablesOptions) (*TableQueryResult, error) { + query, headers := options.getParameters() + uri := t.client.getEndpoint(tableServiceName, tablesURIPath, query) + return t.queryTables(uri, headers, ml) +} + +// NextResults returns the next page of results +// from a QueryTables or a NextResults operation. +// +// See https://docs.microsoft.com/rest/api/storageservices/fileservices/query-tables +// See https://docs.microsoft.com/rest/api/storageservices/fileservices/query-timeout-and-pagination +func (tqr *TableQueryResult) NextResults(options *TableOptions) (*TableQueryResult, error) { + if tqr == nil { + return nil, errNilPreviousResult + } + if tqr.NextLink == nil { + return nil, errNilNextLink + } + headers := options.addToHeaders(map[string]string{}) + + return tqr.tsc.queryTables(*tqr.NextLink, headers, tqr.ml) +} + +// TableQueryResult contains the response from +// QueryTables and QueryTablesNextResults functions. +type TableQueryResult struct { + OdataMetadata string `json:"odata.metadata"` + Tables []Table `json:"value"` + QueryNextLink + tsc *TableServiceClient +} + +func (t *TableServiceClient) queryTables(uri string, headers map[string]string, ml MetadataLevel) (*TableQueryResult, error) { + if ml == EmptyPayload { + return nil, errEmptyPayload + } + headers = mergeHeaders(headers, t.client.getStandardHeaders()) + headers[headerAccept] = string(ml) + + resp, err := t.client.exec(http.MethodGet, uri, headers, nil, t.auth) + if err != nil { + return nil, err + } + defer resp.body.Close() + + if err := checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { + return nil, err + } + + respBody, err := ioutil.ReadAll(resp.body) + if err != nil { + return nil, err + } + var out TableQueryResult + err = json.Unmarshal(respBody, &out) + if err != nil { + return nil, err + } + + for i := range out.Tables { + out.Tables[i].tsc = t + } + out.tsc = t + + nextLink := resp.headers.Get(http.CanonicalHeaderKey(headerXmsContinuation)) + if nextLink == "" { + out.NextLink = nil + } else { + originalURI, err := url.Parse(uri) + if err != nil { + return nil, err + } + v := originalURI.Query() + v.Set(nextTableQueryParameter, nextLink) + newURI := t.client.getEndpoint(tableServiceName, tablesURIPath, v) + out.NextLink = &newURI + out.ml = ml + } + + return &out, nil +} + +func addBodyRelatedHeaders(h map[string]string, length int) map[string]string { + h[headerContentType] = "application/json" + h[headerContentLength] = fmt.Sprintf("%v", length) + h[headerAcceptCharset] = "UTF-8" + return h +} + +func addReturnContentHeaders(h map[string]string, ml MetadataLevel) map[string]string { + if ml != EmptyPayload { + h[headerPrefer] = "return-content" + h[headerAccept] = string(ml) + } else { + h[headerPrefer] = "return-no-content" + // From API version 2015-12-11 onwards, Accept header is required + h[headerAccept] = string(NoMetadata) + } + return h +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/util.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/util.go index 57ca1b6d9..8a902be2f 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/storage/util.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/util.go @@ -12,9 +12,15 @@ import ( "net/http" "net/url" "reflect" + "strconv" + "strings" "time" ) +var ( + fixedTime = time.Date(2050, time.December, 20, 21, 55, 0, 0, time.FixedZone("GMT", -6)) +) + func (c Client) computeHmac256(message string) string { h := hmac.New(sha256.New, c.accountKey) h.Write([]byte(message)) @@ -76,10 +82,118 @@ func headersFromStruct(v interface{}) map[string]string { value := reflect.ValueOf(v) for i := 0; i < value.NumField(); i++ { key := value.Type().Field(i).Tag.Get("header") - val := value.Field(i).String() - if key != "" && val != "" { - headers[key] = val + if key != "" { + reflectedValue := reflect.Indirect(value.Field(i)) + var val string + if reflectedValue.IsValid() { + switch reflectedValue.Type() { + case reflect.TypeOf(fixedTime): + val = timeRfc1123Formatted(reflectedValue.Interface().(time.Time)) + case reflect.TypeOf(uint64(0)), reflect.TypeOf(uint(0)): + val = strconv.FormatUint(reflectedValue.Uint(), 10) + case reflect.TypeOf(int(0)): + val = strconv.FormatInt(reflectedValue.Int(), 10) + default: + val = reflectedValue.String() + } + } + if val != "" { + headers[key] = val + } } } return headers } + +// merges extraHeaders into headers and returns headers +func mergeHeaders(headers, extraHeaders map[string]string) map[string]string { + for k, v := range extraHeaders { + headers[k] = v + } + return headers +} + +func addToHeaders(h map[string]string, key, value string) map[string]string { + if value != "" { + h[key] = value + } + return h +} + +func addTimeToHeaders(h map[string]string, key string, value *time.Time) map[string]string { + if value != nil { + h = addToHeaders(h, key, timeRfc1123Formatted(*value)) + } + return h +} + +func addTimeout(params url.Values, timeout uint) url.Values { + if timeout > 0 { + params.Add("timeout", fmt.Sprintf("%v", timeout)) + } + return params +} + +func addSnapshot(params url.Values, snapshot *time.Time) url.Values { + if snapshot != nil { + params.Add("snapshot", timeRfc1123Formatted(*snapshot)) + } + return params +} + +func getTimeFromHeaders(h http.Header, key string) (*time.Time, error) { + var out time.Time + var err error + outStr := h.Get(key) + if outStr != "" { + out, err = time.Parse(time.RFC1123, outStr) + if err != nil { + return nil, err + } + } + return &out, nil +} + +// TimeRFC1123 is an alias for time.Time needed for custom Unmarshalling +type TimeRFC1123 time.Time + +// UnmarshalXML is a custom unmarshaller that overrides the default time unmarshal which uses a different time layout. +func (t *TimeRFC1123) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + var value string + d.DecodeElement(&value, &start) + parse, err := time.Parse(time.RFC1123, value) + if err != nil { + return err + } + *t = TimeRFC1123(parse) + return nil +} + +// returns a map of custom metadata values from the specified HTTP header +func getMetadataFromHeaders(header http.Header) map[string]string { + metadata := make(map[string]string) + for k, v := range header { + // Can't trust CanonicalHeaderKey() to munge case + // reliably. "_" is allowed in identifiers: + // https://msdn.microsoft.com/en-us/library/azure/dd179414.aspx + // https://msdn.microsoft.com/library/aa664670(VS.71).aspx + // http://tools.ietf.org/html/rfc7230#section-3.2 + // ...but "_" is considered invalid by + // CanonicalMIMEHeaderKey in + // https://golang.org/src/net/textproto/reader.go?s=14615:14659#L542 + // so k can be "X-Ms-Meta-Lol" or "x-ms-meta-lol_rofl". + k = strings.ToLower(k) + if len(v) == 0 || !strings.HasPrefix(k, strings.ToLower(userDefinedMetadataHeaderPrefix)) { + continue + } + // metadata["lol"] = content of the last X-Ms-Meta-Lol header + k = k[len(userDefinedMetadataHeaderPrefix):] + metadata[k] = v[len(v)-1] + } + + if len(metadata) == 0 { + return nil + } + + return metadata +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/version.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/version.go index 575eb1429..a23fff1e2 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/storage/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/version.go @@ -1,5 +1,5 @@ package storage var ( - sdkVersion = "8.1.0-beta" + sdkVersion = "10.0.2" ) diff --git a/vendor/github.com/Azure/go-autorest/autorest/version.go b/vendor/github.com/Azure/go-autorest/autorest/version.go index e325f4ce2..7a0bf9c9f 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/version.go +++ b/vendor/github.com/Azure/go-autorest/autorest/version.go @@ -2,28 +2,22 @@ package autorest import ( "fmt" - "strings" - "sync" ) const ( - major = 7 - minor = 3 - patch = 1 - tag = "" + major = "7" + minor = "3" + patch = "0" + tag = "" + semVerFormat = "%s.%s.%s%s" ) -var versionLock sync.Once var version string // Version returns the semantic version (see http://semver.org). func Version() string { - versionLock.Do(func() { - version = fmt.Sprintf("v%d.%d.%d", major, minor, patch) - - if trimmed := strings.TrimPrefix(tag, "-"); trimmed != "" { - version = fmt.Sprintf("%s-%s", version, trimmed) - } - }) + if version == "" { + version = fmt.Sprintf(semVerFormat, major, minor, patch, tag) + } return version } diff --git a/vendor/vendor.json b/vendor/vendor.json index 2aafd3f8b..9381f6179 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -21,261 +21,236 @@ "revisionTime": "2016-08-11T22:04:02Z" }, { - "checksumSHA1": "N92Zji40JkCHAnsCNHTP4iKPz88=", - "comment": "v2.1.1-beta-8-gca4d906", + "checksumSHA1": "cmMpbgzcc+qBJOOO80ZmgLdij5I=", "path": "github.com/Azure/azure-sdk-for-go/arm/cdn", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { - "checksumSHA1": "xOt4xQmO/KFcJYjQ678DL5ynub4=", - "comment": "v2.1.1-beta-8-gca4d906", + "checksumSHA1": "QxOnuHvy3RS17v4Pxrr3WU8apAI=", "path": "github.com/Azure/azure-sdk-for-go/arm/compute", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { - "checksumSHA1": "JaUx70JMD/d/AwSed7dZAboFfZs=", - "comment": "v2.1.1-beta-8-gca4d906", + "checksumSHA1": "tW9QCHXgrANyNEHcUvfzd1kh0hU=", "path": "github.com/Azure/azure-sdk-for-go/arm/containerregistry", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { - "checksumSHA1": "G4hj0/ClTgXCDjKupxZ0Ii1VWtI=", - "comment": "v2.1.1-beta-8-gca4d906", + "checksumSHA1": "nuAV092jQX2A0GvMvP1xy/I+ef8=", "path": "github.com/Azure/azure-sdk-for-go/arm/containerservice", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { - "checksumSHA1": "iAZi+Mh1Tivk3bdBbAEz+bd5nPg=", + "checksumSHA1": "Kr6/gY3LrNiOxMfDBCfBvBvenYw=", "path": "github.com/Azure/azure-sdk-for-go/arm/disk", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { - "checksumSHA1": "ro1i9qoJcSgbWgV7D93wXhBwoL8=", - "comment": "v2.1.1-beta-8-gca4d906", + "checksumSHA1": "eautqQaMqPwrTLVl81qpTSVtxI8=", "path": "github.com/Azure/azure-sdk-for-go/arm/eventhub", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { - "checksumSHA1": "t/W6hTKBQzHfV1vXxqprTGZYeSI=", - "comment": "v2.1.1-beta-8-gca4d906", + "checksumSHA1": "o702lrErInKg0A2sBGKfH8aB8WY=", "path": "github.com/Azure/azure-sdk-for-go/arm/keyvault", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { - "checksumSHA1": "ZT+e2iMSXAsKCuJ3BNYpOzDaSmk=", - "comment": "v2.1.1-beta-8-gca4d906", + "checksumSHA1": "HMu0WrEHVs+wqyjsTzXxRsEJimI=", "path": "github.com/Azure/azure-sdk-for-go/arm/network", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { - "checksumSHA1": "AC1CTs+pQQncMAaEOSkiO8uMjng=", - "comment": "v2.1.1-beta-8-gca4d906", + "checksumSHA1": "OqQXkmRm/77KtQZqQ0QVMb+Ioxw=", "path": "github.com/Azure/azure-sdk-for-go/arm/redis", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { - "checksumSHA1": "A7vV2JtR1aTZrQNWqjQdR5Dssh4=", - "comment": "v2.1.1-beta-8-gca4d906", + "checksumSHA1": "iJ8ZV+uhUAtNn91pkKjfIY0z+44=", "path": "github.com/Azure/azure-sdk-for-go/arm/resources/resources", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { - "checksumSHA1": "8Sa2kkdH3tdZ7kvyTR3l6fTJ66I=", - "comment": "v2.1.1-beta-8-gca4d906", + "checksumSHA1": "pmG7yonuaXa3DIeY78Ih/ESwTCk=", "path": "github.com/Azure/azure-sdk-for-go/arm/scheduler", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { - "checksumSHA1": "UgfDDACkeEz/Tn7fUQ+ofCm4kcI=", + "checksumSHA1": "JT/V4xIXcR8WeHjbzcG5WtvC85M=", "path": "github.com/Azure/azure-sdk-for-go/arm/servicebus", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { - "checksumSHA1": "xt50hkmkQR7XZOSWZGOaZZvsmxE=", + "checksumSHA1": "qdGeszEMNPwve1mAMxLlPZFmsyo=", "path": "github.com/Azure/azure-sdk-for-go/arm/sql", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { - "checksumSHA1": "m1KzBritgIsQ+s4tAlBGz02iIKo=", - "comment": "v2.1.1-beta-8-gca4d906", + "checksumSHA1": "QiYT2buD7yqmgxfl/ESn8yJmQTY=", "path": "github.com/Azure/azure-sdk-for-go/arm/storage", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { - "checksumSHA1": "tRas0uLjthfwj+9OiGzVKs1br6g=", + "checksumSHA1": "C4DNtCaEFdo/LyqtGdNj1C0F8Io=", "path": "github.com/Azure/azure-sdk-for-go/arm/trafficmanager", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { - "checksumSHA1": "JUEQrLvmfuxKwX/s89mFnzg7jc0=", - "comment": "v2.1.1-beta-8-gca4d906", + "checksumSHA1": "MwIV/0YiHMjGAvuk4N4iwXpgSz0=", "path": "github.com/Azure/azure-sdk-for-go/management", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { "checksumSHA1": "BiKKFwRpXzrRxa2odOMYAZZ5xU8=", - "comment": "v2.1.1-beta-8-gca4d906", "path": "github.com/Azure/azure-sdk-for-go/management/affinitygroup", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { "checksumSHA1": "HfjyhRfmKBsVgWLTOfWVcxe8Z88=", - "comment": "v2.1.1-beta-8-gca4d906", "path": "github.com/Azure/azure-sdk-for-go/management/hostedservice", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { "checksumSHA1": "4otMhU6xZ41HfmiGZFYtV93GdcI=", - "comment": "v2.1.1-beta-8-gca4d906", "path": "github.com/Azure/azure-sdk-for-go/management/location", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { "checksumSHA1": "hxivwm3D13cqFGOlOS3q8HD7DN0=", - "comment": "v2.1.1-beta-8-gca4d906", "path": "github.com/Azure/azure-sdk-for-go/management/networksecuritygroup", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { "checksumSHA1": "XzrPv8SWFBYdh5oie+NGysqnLIM=", - "comment": "v2.1.1-beta-8-gca4d906", "path": "github.com/Azure/azure-sdk-for-go/management/osimage", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { "checksumSHA1": "aTvFD5aYYXC1bLaVMlHWJImkHDg=", - "comment": "v2.1.1-beta-8-gca4d906", "path": "github.com/Azure/azure-sdk-for-go/management/sql", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { "checksumSHA1": "YoAhDE0X6hSFuPpXbpfqcTC0Zvw=", - "comment": "v2.1.1-beta-8-gca4d906", "path": "github.com/Azure/azure-sdk-for-go/management/storageservice", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { "checksumSHA1": "6xEiZL4a9rr5YbnY0RdzuzhEF1Q=", - "comment": "v2.1.1-beta-8-gca4d906", "path": "github.com/Azure/azure-sdk-for-go/management/virtualmachine", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { "checksumSHA1": "xcBM3zQtfcE3VHNBACJJGEesCBI=", - "comment": "v2.1.1-beta-8-gca4d906", "path": "github.com/Azure/azure-sdk-for-go/management/virtualmachinedisk", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { "checksumSHA1": "0bfdkDZ2JFV7bol6GQFfC0g+lP4=", - "comment": "v2.1.1-beta-8-gca4d906", "path": "github.com/Azure/azure-sdk-for-go/management/virtualmachineimage", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { "checksumSHA1": "IhjDqm84VDVSIoHyiGvUzuljG3s=", - "comment": "v2.1.1-beta-8-gca4d906", "path": "github.com/Azure/azure-sdk-for-go/management/virtualnetwork", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { "checksumSHA1": "Tb6BY70kI9ZclWIjjMhGzkdJbn0=", - "comment": "v2.1.1-beta-8-gca4d906", "path": "github.com/Azure/azure-sdk-for-go/management/vmutils", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { - "checksumSHA1": "tnwIjZc1ZOFuilMWKptLnhEURls=", - "comment": "v2.1.1-beta-8-gca4d906", + "checksumSHA1": "kaK7epAI09FJJHMAoVUKAkTD73E=", "path": "github.com/Azure/azure-sdk-for-go/storage", - "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813", - "revisionTime": "2017-03-02T00:14:02Z", - "version": "v8.1.0-beta", - "versionExact": "v8.1.0-beta" + "revision": "5841475edc7c8725d79885d635aa8956f97fdf0e", + "revisionTime": "2017-05-10T22:14:13Z", + "version": "v10.0.2-beta", + "versionExact": "v10.0.2-beta" }, { "checksumSHA1": "23FJUX+AInYeEM2hoUMvYZtXZd4=", @@ -290,11 +265,11 @@ "revisionTime": "2016-06-22T17:32:16Z" }, { - "checksumSHA1": "U2+FgaMOPEFg/yHLD5RbiXI1cq4=", + "checksumSHA1": "+sxS3YEvxf1VxlRskIdXFRWq9rY=", "comment": "v7.0.5", "path": "github.com/Azure/go-autorest/autorest", - "revision": "a2fdd780c9a50455cecd249b00bdc3eb73a78e31", - "revisionTime": "2017-04-06T20:28:05Z", + "revision": "ec5f4903f77ed9927ac95b19ab8e44ada64c1356", + "revisionTime": "2017-02-15T19:58:14Z", "version": "v7.3.1", "versionExact": "v7.3.1" }, @@ -302,8 +277,8 @@ "checksumSHA1": "ghrnc4vZv6q8zzeakZnrS8CGFhE=", "comment": "v7.0.5", "path": "github.com/Azure/go-autorest/autorest/azure", - "revision": "a2fdd780c9a50455cecd249b00bdc3eb73a78e31", - "revisionTime": "2017-04-06T20:28:05Z", + "revision": "ec5f4903f77ed9927ac95b19ab8e44ada64c1356", + "revisionTime": "2017-02-15T19:58:14Z", "version": "v7.3.1", "versionExact": "v7.3.1" }, @@ -311,8 +286,8 @@ "checksumSHA1": "q9Qz8PAxK5FTOZwgYKe5Lj38u4c=", "comment": "v7.0.5", "path": "github.com/Azure/go-autorest/autorest/date", - "revision": "a2fdd780c9a50455cecd249b00bdc3eb73a78e31", - "revisionTime": "2017-04-06T20:28:05Z", + "revision": "ec5f4903f77ed9927ac95b19ab8e44ada64c1356", + "revisionTime": "2017-02-15T19:58:14Z", "version": "v7.3.1", "versionExact": "v7.3.1" }, @@ -320,16 +295,16 @@ "checksumSHA1": "Ev8qCsbFjDlMlX0N2tYAhYQFpUc=", "comment": "v7.0.5", "path": "github.com/Azure/go-autorest/autorest/to", - "revision": "a2fdd780c9a50455cecd249b00bdc3eb73a78e31", - "revisionTime": "2017-04-06T20:28:05Z", + "revision": "ec5f4903f77ed9927ac95b19ab8e44ada64c1356", + "revisionTime": "2017-02-15T19:58:14Z", "version": "v7.3.1", "versionExact": "v7.3.1" }, { "checksumSHA1": "oBixceM+55gdk47iff8DSEIh3po=", "path": "github.com/Azure/go-autorest/autorest/validation", - "revision": "a2fdd780c9a50455cecd249b00bdc3eb73a78e31", - "revisionTime": "2017-04-06T20:28:05Z", + "revision": "ec5f4903f77ed9927ac95b19ab8e44ada64c1356", + "revisionTime": "2017-02-15T19:58:14Z", "version": "v7.3.1", "versionExact": "v7.3.1" }, diff --git a/website/source/docs/providers/azurerm/r/container_registry.html.markdown b/website/source/docs/providers/azurerm/r/container_registry.html.markdown index d72132f1e..159a20b61 100644 --- a/website/source/docs/providers/azurerm/r/container_registry.html.markdown +++ b/website/source/docs/providers/azurerm/r/container_registry.html.markdown @@ -33,6 +33,7 @@ resource "azurerm_container_registry" "test" { resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" admin_enabled = true + sku = "Basic" storage_account { name = "${azurerm_storage_account.test.name}" @@ -57,6 +58,8 @@ The following arguments are supported: * `storage_account` - (Required) A Storage Account block as documented below - which must be located in the same data center as the Container Registry. +* `sku` - (Required) The SKU name of the the container registry. `Basic` is the only acceptable value at this time. + * `tags` - (Optional) A mapping of tags to assign to the resource. `storage_account` supports the following: