[WIP] arm/disk implementation
This commit is contained in:
parent
0a07c14377
commit
2df44e0779
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/Azure/azure-sdk-for-go/arm/compute"
|
"github.com/Azure/azure-sdk-for-go/arm/compute"
|
||||||
"github.com/Azure/azure-sdk-for-go/arm/containerregistry"
|
"github.com/Azure/azure-sdk-for-go/arm/containerregistry"
|
||||||
"github.com/Azure/azure-sdk-for-go/arm/containerservice"
|
"github.com/Azure/azure-sdk-for-go/arm/containerservice"
|
||||||
|
"github.com/Azure/azure-sdk-for-go/arm/disk"
|
||||||
"github.com/Azure/azure-sdk-for-go/arm/eventhub"
|
"github.com/Azure/azure-sdk-for-go/arm/eventhub"
|
||||||
"github.com/Azure/azure-sdk-for-go/arm/keyvault"
|
"github.com/Azure/azure-sdk-for-go/arm/keyvault"
|
||||||
"github.com/Azure/azure-sdk-for-go/arm/network"
|
"github.com/Azure/azure-sdk-for-go/arm/network"
|
||||||
|
@ -25,7 +26,6 @@ import (
|
||||||
"github.com/Azure/go-autorest/autorest/azure"
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
riviera "github.com/jen20/riviera/azure"
|
riviera "github.com/jen20/riviera/azure"
|
||||||
"github.com/Azure/azure-sdk-for-go/arm/disk"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ArmClient contains the handles to all the specific Azure Resource Manager
|
// ArmClient contains the handles to all the specific Azure Resource Manager
|
||||||
|
@ -248,6 +248,12 @@ func (c *Config) getArmClient() (*ArmClient, error) {
|
||||||
csc.Sender = autorest.CreateSender(withRequestLogging())
|
csc.Sender = autorest.CreateSender(withRequestLogging())
|
||||||
client.containerServicesClient = csc
|
client.containerServicesClient = csc
|
||||||
|
|
||||||
|
dkc := disk.NewDisksClientWithBaseURI(endpoint, c.SubscriptionID)
|
||||||
|
setUserAgent(&dkc.Client)
|
||||||
|
dkc.Authorizer = spt
|
||||||
|
dkc.Sender = autorest.CreateSender(withRequestLogging())
|
||||||
|
client.diskClient = dkc
|
||||||
|
|
||||||
ehc := eventhub.NewEventHubsClientWithBaseURI(endpoint, c.SubscriptionID)
|
ehc := eventhub.NewEventHubsClientWithBaseURI(endpoint, c.SubscriptionID)
|
||||||
setUserAgent(&ehc.Client)
|
setUserAgent(&ehc.Client)
|
||||||
ehc.Authorizer = spt
|
ehc.Authorizer = spt
|
||||||
|
|
|
@ -9,20 +9,20 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAccAzureRMDisk_importEmpty(t *testing.T) {
|
func TestAccAzureRMDisk_importEmpty(t *testing.T) {
|
||||||
runTestAzureRMDisk_import(t, "azurerm_disk.test", testAccAzureRMDisk_emptyDisk)
|
runTestAzureRMDisk_import(t, "azurerm_disk.test", testAccAzureRMDisk_empty)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccAzureRMDisk_importBlob(t *testing.T) {
|
/*func TestAccAzureRMDisk_importBlob(t *testing.T) {
|
||||||
runTestAzureRMDisk_import(t, "azurerm_disk.test", testAccAzureRMDisk_blob)
|
runTestAzureRMDisk_import(t, "azurerm_disk.test", testAccAzureRMDisk_blob)
|
||||||
}
|
}*/
|
||||||
|
|
||||||
func runTestAzureRMDisk_import(t *testing.T, resourceName string, configSource string) {
|
func runTestAzureRMDisk_import(t *testing.T, resourceName string, configSource string) {
|
||||||
ri := acctest.RandInt()
|
ri := acctest.RandInt()
|
||||||
config := fmt.Sprintf(configSource, ri, ri, ri)
|
config := fmt.Sprintf(configSource, ri, ri)
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t)},
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testCheckAzureRMDiskDestroy,
|
CheckDestroy: testCheckAzureRMDiskDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
|
@ -30,10 +30,10 @@ func runTestAzureRMDisk_import(t *testing.T, resourceName string, configSource s
|
||||||
},
|
},
|
||||||
|
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
ResourceName: resourceName,
|
ResourceName: resourceName,
|
||||||
ImportState: true,
|
ImportState: true,
|
||||||
ImportStateVerify: true,
|
ImportStateVerify: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,8 @@ func Provider() terraform.ResourceProvider {
|
||||||
"azurerm_container_registry": resourceArmContainerRegistry(),
|
"azurerm_container_registry": resourceArmContainerRegistry(),
|
||||||
"azurerm_container_service": resourceArmContainerService(),
|
"azurerm_container_service": resourceArmContainerService(),
|
||||||
|
|
||||||
|
"azurerm_disk": resourceArmDisk(),
|
||||||
|
|
||||||
"azurerm_eventhub": resourceArmEventHub(),
|
"azurerm_eventhub": resourceArmEventHub(),
|
||||||
"azurerm_eventhub_authorization_rule": resourceArmEventHubAuthorizationRule(),
|
"azurerm_eventhub_authorization_rule": resourceArmEventHubAuthorizationRule(),
|
||||||
"azurerm_eventhub_consumer_group": resourceArmEventHubConsumerGroup(),
|
"azurerm_eventhub_consumer_group": resourceArmEventHubConsumerGroup(),
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package azurerm
|
package azurerm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/Azure/azure-sdk-for-go/arm/disk"
|
"github.com/Azure/azure-sdk-for-go/arm/disk"
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
"github.com/hashicorp/terraform/helper/validation"
|
"github.com/hashicorp/terraform/helper/validation"
|
||||||
"fmt"
|
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func resourceArmDisk() *schema.Resource {
|
func resourceArmDisk() *schema.Resource {
|
||||||
|
@ -22,7 +22,7 @@ func resourceArmDisk() *schema.Resource {
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"name": {
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
|
@ -36,7 +36,7 @@ func resourceArmDisk() *schema.Resource {
|
||||||
},
|
},
|
||||||
|
|
||||||
"storage_account_type": {
|
"storage_account_type": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ValidateFunc: validation.StringInSlice([]string{
|
ValidateFunc: validation.StringInSlice([]string{
|
||||||
string(disk.PremiumLRS),
|
string(disk.PremiumLRS),
|
||||||
|
@ -45,7 +45,7 @@ func resourceArmDisk() *schema.Resource {
|
||||||
},
|
},
|
||||||
|
|
||||||
"create_option": {
|
"create_option": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ValidateFunc: validation.StringInSlice([]string{
|
ValidateFunc: validation.StringInSlice([]string{
|
||||||
string(disk.Import),
|
string(disk.Import),
|
||||||
|
@ -60,7 +60,7 @@ func resourceArmDisk() *schema.Resource {
|
||||||
},
|
},
|
||||||
|
|
||||||
"os_type": {
|
"os_type": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ValidateFunc: validation.StringInSlice([]string{
|
ValidateFunc: validation.StringInSlice([]string{
|
||||||
string(disk.Windows),
|
string(disk.Windows),
|
||||||
|
@ -69,9 +69,8 @@ func resourceArmDisk() *schema.Resource {
|
||||||
},
|
},
|
||||||
|
|
||||||
"disk_size_gb": {
|
"disk_size_gb": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Required: true,
|
||||||
Computed: true,
|
|
||||||
ValidateFunc: validateDiskSizeGB,
|
ValidateFunc: validateDiskSizeGB,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -101,7 +100,7 @@ func resourceArmDiskCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
tags := d.Get("tags").(map[string]interface{})
|
tags := d.Get("tags").(map[string]interface{})
|
||||||
expandedTags := expandTags(tags)
|
expandedTags := expandTags(tags)
|
||||||
|
|
||||||
createDisk := &disk.Model {
|
createDisk := disk.Model{
|
||||||
Name: &name,
|
Name: &name,
|
||||||
Location: &location,
|
Location: &location,
|
||||||
Tags: expandedTags,
|
Tags: expandedTags,
|
||||||
|
@ -109,25 +108,27 @@ func resourceArmDiskCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
|
|
||||||
storageAccountType := d.Get("storage_account_type").(string)
|
storageAccountType := d.Get("storage_account_type").(string)
|
||||||
osType := d.Get("os_type").(string)
|
osType := d.Get("os_type").(string)
|
||||||
diskSize := d.Get("disk_size_db").(int)
|
|
||||||
|
|
||||||
createDisk.Properties = &disk.Properties {
|
createDisk.Properties = &disk.Properties{
|
||||||
AccountType: &storageAccountType,
|
AccountType: disk.StorageAccountTypes(storageAccountType),
|
||||||
OsType: &osType,
|
OsType: disk.OperatingSystemTypes(osType),
|
||||||
DiskSizeGB: &diskSize,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if v := d.Get("disk_size_gb"); v != nil {
|
||||||
|
diskSize := int32(v.(int))
|
||||||
|
createDisk.Properties.DiskSizeGB = &diskSize
|
||||||
|
}
|
||||||
createOption := d.Get("create_option").(string)
|
createOption := d.Get("create_option").(string)
|
||||||
|
|
||||||
creationData := &disk.CreationData{
|
creationData := &disk.CreationData{
|
||||||
CreateOption: disk.CreateOption(createOption),
|
CreateOption: disk.CreateOption(createOption),
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.EqualFold(createOption, disk.Import) {
|
if strings.EqualFold(createOption, string(disk.Import)) {
|
||||||
if vhdUri := d.Get("vhd_uri").(string); vhdUri != "" {
|
if vhdUri := d.Get("vhd_uri").(string); vhdUri != "" {
|
||||||
creationData.SourceURI = vhdUri;
|
creationData.SourceURI = &vhdUri
|
||||||
} else {
|
} else {
|
||||||
return nil, fmt.Errorf("[ERROR] vhd_uri must be specified when create_option is `%s`", disk.Import)
|
return fmt.Errorf("[ERROR] vhd_uri must be specified when create_option is `%s`", disk.Import)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +140,7 @@ func resourceArmDiskCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
read, err := diskClient.Get(resGroup, name)
|
read, err := diskClient.Get(resGroup, name)
|
||||||
if err != nil{
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if read.ID == nil {
|
if read.ID == nil {
|
||||||
|
@ -222,10 +223,10 @@ func resourceArmDiskDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
|
|
||||||
func flattenAzureRmDiskProperties(properties *disk.Properties) (map[string]interface{}, error) {
|
func flattenAzureRmDiskProperties(properties *disk.Properties) (map[string]interface{}, error) {
|
||||||
result := make(map[string]interface{})
|
result := make(map[string]interface{})
|
||||||
result["storage_account_type"] = *properties.AccountType
|
result["storage_account_type"] = string(properties.AccountType)
|
||||||
result["disk_size_gb"] = *properties.DiskSizeGB
|
result["disk_size_gb"] = *properties.DiskSizeGB
|
||||||
if properties.OsType != nil {
|
if properties.OsType != "" {
|
||||||
result["os_type"] = *properties.OsType
|
result["os_type"] = string(properties.OsType)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
@ -233,10 +234,10 @@ func flattenAzureRmDiskProperties(properties *disk.Properties) (map[string]inter
|
||||||
|
|
||||||
func flattenAzureRmDiskCreationData(creationData *disk.CreationData) (map[string]interface{}, error) {
|
func flattenAzureRmDiskCreationData(creationData *disk.CreationData) (map[string]interface{}, error) {
|
||||||
result := make(map[string]interface{})
|
result := make(map[string]interface{})
|
||||||
result["create_option"] = *creationData.CreateOption
|
result["create_option"] = string(creationData.CreateOption)
|
||||||
if creationData.SourceURI != nil {
|
if creationData.SourceURI != nil {
|
||||||
result["vhd_uri"] = *creationData.SourceURI
|
result["vhd_uri"] = *creationData.SourceURI
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1,105 @@
|
||||||
package azurerm
|
package azurerm
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/Azure/azure-sdk-for-go/arm/disk"
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
|
"github.com/hashicorp/terraform/terraform"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAccAzureRMDisk_empty(t *testing.T) {
|
||||||
|
var d disk.Model
|
||||||
|
ri := acctest.RandInt()
|
||||||
|
config := fmt.Sprintf(testAccAzureRMDisk_empty, ri, ri)
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testCheckAzureRMDiskDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
{
|
||||||
|
Config: config,
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testCheckAzureRMDiskExists("azurerm_disk.test", &d),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func testCheckAzureRMDiskExists(name string, d *disk.Model) resource.TestCheckFunc {
|
||||||
|
return func(s *terraform.State) error {
|
||||||
|
rs, ok := s.RootModule().Resources[name]
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("Not found: %s", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
dName := rs.Primary.Attributes["name"]
|
||||||
|
resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"]
|
||||||
|
if !hasResourceGroup {
|
||||||
|
return fmt.Errorf("Bad: no resource group found in state for disk: %s", dName)
|
||||||
|
}
|
||||||
|
|
||||||
|
conn := testAccProvider.Meta().(*ArmClient).diskClient
|
||||||
|
|
||||||
|
resp, err := conn.Get(resourceGroup, dName)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Bad: Get on diskClient: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode == http.StatusNotFound {
|
||||||
|
return fmt.Errorf("Bad: VirtualMachine %q (resource group %q) does not exist", dName, resourceGroup)
|
||||||
|
}
|
||||||
|
|
||||||
|
*d = resp
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func testCheckAzureRMDiskDestroy(s *terraform.State) error {
|
||||||
|
conn := testAccProvider.Meta().(*ArmClient).diskClient
|
||||||
|
|
||||||
|
for _, rs := range s.RootModule().Resources {
|
||||||
|
if rs.Type != "azurerm_disk" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
name := rs.Primary.Attributes["name"]
|
||||||
|
resourceGroup := rs.Primary.Attributes["resource_group_name"]
|
||||||
|
|
||||||
|
resp, err := conn.Get(resourceGroup, name)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusNotFound {
|
||||||
|
return fmt.Errorf("Disk still exists: \n%#v", resp.Properties)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var testAccAzureRMDisk_empty = `
|
||||||
|
resource "azurerm_resource_group" "test" {
|
||||||
|
name = "acctestRG-%d"
|
||||||
|
location = "West US 2"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "azurerm_disk" "test" {
|
||||||
|
name = "acctestd-%d"
|
||||||
|
location = "West US 2"
|
||||||
|
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||||
|
storage_account_type = "Standard_LRS"
|
||||||
|
create_option = "Empty"
|
||||||
|
disk_size_gb = "20"
|
||||||
|
|
||||||
|
tags {
|
||||||
|
environment = "acctest"
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
|
|
@ -0,0 +1,421 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ImagesClient is the the Compute Management Client.
|
||||||
|
type ImagesClient struct {
|
||||||
|
ManagementClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewImagesClient creates an instance of the ImagesClient client.
|
||||||
|
func NewImagesClient(subscriptionID string) ImagesClient {
|
||||||
|
return NewImagesClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewImagesClientWithBaseURI creates an instance of the ImagesClient client.
|
||||||
|
func NewImagesClientWithBaseURI(baseURI string, subscriptionID string) ImagesClient {
|
||||||
|
return ImagesClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdate create or update an image. 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. 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) {
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := client.CreateOrUpdatePreparer(resourceGroupName, imageName, parameters, cancel)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.CreateOrUpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = resp
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "CreateOrUpdate", resp, "Failure sending request")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.CreateOrUpdateResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "CreateOrUpdate", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||||
|
func (client ImagesClient) CreateOrUpdatePreparer(resourceGroupName string, imageName string, parameters Image, cancel <-chan struct{}) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"imageName": autorest.Encode("path", imageName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": client.APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsJSON(),
|
||||||
|
autorest.AsPut(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", pathParameters),
|
||||||
|
autorest.WithJSON(parameters),
|
||||||
|
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 ImagesClient) 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 ImagesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete deletes an Image. 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. 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")
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.DeleteSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = resp
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "Delete", resp, "Failure sending request")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.DeleteResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "Delete", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePreparer prepares the Delete request.
|
||||||
|
func (client ImagesClient) DeletePreparer(resourceGroupName string, imageName string, cancel <-chan struct{}) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"imageName": autorest.Encode("path", imageName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": client.APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsDelete(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", 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 ImagesClient) 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 ImagesClient) 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 an image.
|
||||||
|
//
|
||||||
|
// resourceGroupName is the name of the resource group. imageName is the name
|
||||||
|
// of the image. expand is the expand expression to apply on the operation.
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client ImagesClient) GetPreparer(resourceGroupName string, imageName string, expand string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"imageName": autorest.Encode("path", imageName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": client.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.Compute/images/{imageName}", 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 ImagesClient) 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 ImagesClient) GetResponder(resp *http.Response) (result Image, 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 the list of Images in the subscription. Use nextLink property in
|
||||||
|
// the response to get the next page of Images. Do this till nextLink is not
|
||||||
|
// null to fetch all the Images.
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "List", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPreparer prepares the List request.
|
||||||
|
func (client ImagesClient) ListPreparer() (*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.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images", 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 ImagesClient) 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 ImagesClient) ListResponder(resp *http.Response) (result ImageListResult, 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 ImagesClient) ListNextResults(lastResults ImageListResult) (result ImageListResult, err error) {
|
||||||
|
req, err := lastResults.ImageListResultPreparer()
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "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, "compute.ImagesClient", "List", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "List", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroup gets the list of images under a resource group.
|
||||||
|
//
|
||||||
|
// resourceGroupName is the name of the resource group.
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListByResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "ListByResourceGroup", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
|
||||||
|
func (client ImagesClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": client.APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images", 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 ImagesClient) 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 ImagesClient) ListByResourceGroupResponder(resp *http.Response) (result ImageListResult, 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 ImagesClient) ListByResourceGroupNextResults(lastResults ImageListResult) (result ImageListResult, err error) {
|
||||||
|
req, err := lastResults.ImageListResultPreparer()
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "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, "compute.ImagesClient", "ListByResourceGroup", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListByResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "ListByResourceGroup", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
// Package disk implements the Azure ARM Disk service API version
|
||||||
|
// 2016-04-30-preview.
|
||||||
|
//
|
||||||
|
// The Disk Resource Provider Client.
|
||||||
|
package disk
|
||||||
|
|
||||||
|
// 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ManagementClient is the base client for Disk.
|
||||||
|
type ManagementClient struct {
|
||||||
|
autorest.Client
|
||||||
|
BaseURI string
|
||||||
|
APIVersion string
|
||||||
|
SubscriptionID string
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates an instance of the ManagementClient client.
|
||||||
|
func New(subscriptionID string) ManagementClient {
|
||||||
|
return NewWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewWithBaseURI creates an instance of the ManagementClient client.
|
||||||
|
func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient {
|
||||||
|
return ManagementClient{
|
||||||
|
Client: autorest.NewClientWithUserAgent(UserAgent()),
|
||||||
|
BaseURI: baseURI,
|
||||||
|
APIVersion: APIVersion,
|
||||||
|
SubscriptionID: subscriptionID,
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,638 @@
|
||||||
|
package disk
|
||||||
|
|
||||||
|
// 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DisksClient is the the Disk Resource Provider Client.
|
||||||
|
type DisksClient struct {
|
||||||
|
ManagementClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewDisksClient creates an instance of the DisksClient client.
|
||||||
|
func NewDisksClient(subscriptionID string) DisksClient {
|
||||||
|
return NewDisksClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewDisksClientWithBaseURI creates an instance of the DisksClient client.
|
||||||
|
func NewDisksClientWithBaseURI(baseURI string, subscriptionID string) DisksClient {
|
||||||
|
return DisksClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdate creates or updates a disk. 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. 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) {
|
||||||
|
if err := validation.Validate([]validation.Validation{
|
||||||
|
{TargetValue: diskParameter,
|
||||||
|
Constraints: []validation.Constraint{{Target: "diskParameter.Properties", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "diskParameter.Properties.CreationData", Name: validation.Null, Rule: true,
|
||||||
|
Chain: []validation.Constraint{{Target: "diskParameter.Properties.CreationData.ImageReference", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "diskParameter.Properties.CreationData.ImageReference.ID", Name: validation.Null, Rule: true, Chain: nil}}},
|
||||||
|
}},
|
||||||
|
{Target: "diskParameter.Properties.EncryptionSettings", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "diskParameter.Properties.EncryptionSettings.DiskEncryptionKey", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "diskParameter.Properties.EncryptionSettings.DiskEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
{Target: "diskParameter.Properties.EncryptionSettings.DiskEncryptionKey.SecretURL", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
}},
|
||||||
|
{Target: "diskParameter.Properties.EncryptionSettings.KeyEncryptionKey", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "diskParameter.Properties.EncryptionSettings.KeyEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
{Target: "diskParameter.Properties.EncryptionSettings.KeyEncryptionKey.KeyURL", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
}}}}}); err != nil {
|
||||||
|
return result, validation.NewErrorWithValidationError(err, "disk.DisksClient", "CreateOrUpdate")
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := client.CreateOrUpdatePreparer(resourceGroupName, diskName, diskParameter, cancel)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "disk.DisksClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.CreateOrUpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = resp
|
||||||
|
return result, autorest.NewErrorWithError(err, "disk.DisksClient", "CreateOrUpdate", resp, "Failure sending request")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.CreateOrUpdateResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "disk.DisksClient", "CreateOrUpdate", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||||
|
func (client DisksClient) CreateOrUpdatePreparer(resourceGroupName string, diskName string, diskParameter Model, cancel <-chan struct{}) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"diskName": autorest.Encode("path", diskName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": client.APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsJSON(),
|
||||||
|
autorest.AsPut(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", pathParameters),
|
||||||
|
autorest.WithJSON(diskParameter),
|
||||||
|
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 DisksClient) 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 DisksClient) CreateOrUpdateResponder(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
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete deletes a disk. 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. 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")
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.DeleteSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = resp
|
||||||
|
return result, autorest.NewErrorWithError(err, "disk.DisksClient", "Delete", resp, "Failure sending request")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.DeleteResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "disk.DisksClient", "Delete", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePreparer prepares the Delete request.
|
||||||
|
func (client DisksClient) DeletePreparer(resourceGroupName string, diskName string, cancel <-chan struct{}) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"diskName": autorest.Encode("path", diskName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": client.APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsDelete(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", 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 DisksClient) 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 DisksClient) 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 information about a disk.
|
||||||
|
//
|
||||||
|
// 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) 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")
|
||||||
|
}
|
||||||
|
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "disk.DisksClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client DisksClient) GetPreparer(resourceGroupName string, diskName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"diskName": autorest.Encode("path", diskName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": client.APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", 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 DisksClient) 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 DisksClient) GetResponder(resp *http.Response) (result Model, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GrantAccess grants access to a disk. 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. 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) {
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := client.GrantAccessPreparer(resourceGroupName, diskName, grantAccessData, cancel)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "disk.DisksClient", "GrantAccess", nil, "Failure preparing request")
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GrantAccessSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = resp
|
||||||
|
return result, autorest.NewErrorWithError(err, "disk.DisksClient", "GrantAccess", resp, "Failure sending request")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GrantAccessResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "disk.DisksClient", "GrantAccess", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GrantAccessPreparer prepares the GrantAccess request.
|
||||||
|
func (client DisksClient) GrantAccessPreparer(resourceGroupName string, diskName string, grantAccessData GrantAccessData, cancel <-chan struct{}) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"diskName": autorest.Encode("path", diskName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": client.APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsJSON(),
|
||||||
|
autorest.AsPost(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess", pathParameters),
|
||||||
|
autorest.WithJSON(grantAccessData),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare(&http.Request{Cancel: cancel})
|
||||||
|
}
|
||||||
|
|
||||||
|
// GrantAccessSender sends the GrantAccess request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client DisksClient) GrantAccessSender(req *http.Request) (*http.Response, error) {
|
||||||
|
return autorest.SendWithSender(client,
|
||||||
|
req,
|
||||||
|
azure.DoPollForAsynchronous(client.PollingDelay))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// List lists all the disks under a subscription.
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "disk.DisksClient", "List", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPreparer prepares the List request.
|
||||||
|
func (client DisksClient) ListPreparer() (*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.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks", 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 DisksClient) 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 DisksClient) ListResponder(resp *http.Response) (result ListType, 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 DisksClient) ListNextResults(lastResults ListType) (result ListType, err error) {
|
||||||
|
req, err := lastResults.ListTypePreparer()
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "disk.DisksClient", "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, "disk.DisksClient", "List", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "disk.DisksClient", "List", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroup lists all the disks under a resource group.
|
||||||
|
//
|
||||||
|
// resourceGroupName is the name of the resource group.
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListByResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "disk.DisksClient", "ListByResourceGroup", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
|
||||||
|
func (client DisksClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": client.APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks", 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 DisksClient) 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 DisksClient) ListByResourceGroupResponder(resp *http.Response) (result ListType, 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 DisksClient) ListByResourceGroupNextResults(lastResults ListType) (result ListType, err error) {
|
||||||
|
req, err := lastResults.ListTypePreparer()
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "disk.DisksClient", "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, "disk.DisksClient", "ListByResourceGroup", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListByResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "disk.DisksClient", "ListByResourceGroup", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// RevokeAccess revokes access to a disk. 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. 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")
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.RevokeAccessSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = resp
|
||||||
|
return result, autorest.NewErrorWithError(err, "disk.DisksClient", "RevokeAccess", resp, "Failure sending request")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.RevokeAccessResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "disk.DisksClient", "RevokeAccess", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// RevokeAccessPreparer prepares the RevokeAccess request.
|
||||||
|
func (client DisksClient) RevokeAccessPreparer(resourceGroupName string, diskName string, cancel <-chan struct{}) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"diskName": autorest.Encode("path", diskName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare(&http.Request{Cancel: cancel})
|
||||||
|
}
|
||||||
|
|
||||||
|
// RevokeAccessSender sends the RevokeAccess request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client DisksClient) RevokeAccessSender(req *http.Request) (*http.Response, error) {
|
||||||
|
return autorest.SendWithSender(client,
|
||||||
|
req,
|
||||||
|
azure.DoPollForAsynchronous(client.PollingDelay))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update updates (patches) a disk. 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. 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")
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.UpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = resp
|
||||||
|
return result, autorest.NewErrorWithError(err, "disk.DisksClient", "Update", resp, "Failure sending request")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.UpdateResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "disk.DisksClient", "Update", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatePreparer prepares the Update request.
|
||||||
|
func (client DisksClient) UpdatePreparer(resourceGroupName string, diskName string, diskParameter UpdateType, cancel <-chan struct{}) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"diskName": autorest.Encode("path", diskName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": client.APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsJSON(),
|
||||||
|
autorest.AsPatch(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", pathParameters),
|
||||||
|
autorest.WithJSON(diskParameter),
|
||||||
|
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 DisksClient) 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 DisksClient) UpdateResponder(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
|
||||||
|
}
|
|
@ -0,0 +1,278 @@
|
||||||
|
package disk
|
||||||
|
|
||||||
|
// 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/date"
|
||||||
|
"github.com/Azure/go-autorest/autorest/to"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AccessLevel enumerates the values for access level.
|
||||||
|
type AccessLevel string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// None specifies the none state for access level.
|
||||||
|
None AccessLevel = "None"
|
||||||
|
// Read specifies the read state for access level.
|
||||||
|
Read AccessLevel = "Read"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CreateOption enumerates the values for create option.
|
||||||
|
type CreateOption string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Attach specifies the attach state for create option.
|
||||||
|
Attach CreateOption = "Attach"
|
||||||
|
// Copy specifies the copy state for create option.
|
||||||
|
Copy CreateOption = "Copy"
|
||||||
|
// Empty specifies the empty state for create option.
|
||||||
|
Empty CreateOption = "Empty"
|
||||||
|
// FromImage specifies the from image state for create option.
|
||||||
|
FromImage CreateOption = "FromImage"
|
||||||
|
// Import specifies the import state for create option.
|
||||||
|
Import CreateOption = "Import"
|
||||||
|
// Restore specifies the restore state for create option.
|
||||||
|
Restore CreateOption = "Restore"
|
||||||
|
)
|
||||||
|
|
||||||
|
// OperatingSystemTypes enumerates the values for operating system types.
|
||||||
|
type OperatingSystemTypes string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Linux specifies the linux state for operating system types.
|
||||||
|
Linux OperatingSystemTypes = "Linux"
|
||||||
|
// Windows specifies the windows state for operating system types.
|
||||||
|
Windows OperatingSystemTypes = "Windows"
|
||||||
|
)
|
||||||
|
|
||||||
|
// StorageAccountTypes enumerates the values for storage account types.
|
||||||
|
type StorageAccountTypes string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// PremiumLRS specifies the premium lrs state for storage account types.
|
||||||
|
PremiumLRS StorageAccountTypes = "Premium_LRS"
|
||||||
|
// StandardLRS specifies the standard lrs state for storage account types.
|
||||||
|
StandardLRS StorageAccountTypes = "Standard_LRS"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AccessURI is a disk access SAS uri.
|
||||||
|
type AccessURI struct {
|
||||||
|
autorest.Response `json:"-"`
|
||||||
|
*AccessURIOutput `json:"properties,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AccessURIOutput is azure properties, including output.
|
||||||
|
type AccessURIOutput struct {
|
||||||
|
*AccessURIRaw `json:"output,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AccessURIRaw is this object gets 'bubbled up' through flattening.
|
||||||
|
type AccessURIRaw struct {
|
||||||
|
AccessSAS *string `json:"accessSAS,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// APIError is api error.
|
||||||
|
type APIError struct {
|
||||||
|
Details *[]APIErrorBase `json:"details,omitempty"`
|
||||||
|
Innererror *InnerError `json:"innererror,omitempty"`
|
||||||
|
Code *string `json:"code,omitempty"`
|
||||||
|
Target *string `json:"target,omitempty"`
|
||||||
|
Message *string `json:"message,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// APIErrorBase is api error base.
|
||||||
|
type APIErrorBase struct {
|
||||||
|
Code *string `json:"code,omitempty"`
|
||||||
|
Target *string `json:"target,omitempty"`
|
||||||
|
Message *string `json:"message,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreationData is data used when creating a disk.
|
||||||
|
type CreationData struct {
|
||||||
|
CreateOption CreateOption `json:"createOption,omitempty"`
|
||||||
|
StorageAccountID *string `json:"storageAccountId,omitempty"`
|
||||||
|
ImageReference *ImageDiskReference `json:"imageReference,omitempty"`
|
||||||
|
SourceURI *string `json:"sourceUri,omitempty"`
|
||||||
|
SourceResourceID *string `json:"sourceResourceId,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// EncryptionSettings is encryption settings for disk or snapshot
|
||||||
|
type EncryptionSettings struct {
|
||||||
|
Enabled *bool `json:"enabled,omitempty"`
|
||||||
|
DiskEncryptionKey *KeyVaultAndSecretReference `json:"diskEncryptionKey,omitempty"`
|
||||||
|
KeyEncryptionKey *KeyVaultAndKeyReference `json:"keyEncryptionKey,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GrantAccessData is data used for requesting a SAS.
|
||||||
|
type GrantAccessData struct {
|
||||||
|
Access AccessLevel `json:"access,omitempty"`
|
||||||
|
DurationInSeconds *int32 `json:"durationInSeconds,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ImageDiskReference is the source image used for creating the disk.
|
||||||
|
type ImageDiskReference struct {
|
||||||
|
ID *string `json:"id,omitempty"`
|
||||||
|
Lun *int32 `json:"lun,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// InnerError is inner error details.
|
||||||
|
type InnerError struct {
|
||||||
|
Exceptiontype *string `json:"exceptiontype,omitempty"`
|
||||||
|
Errordetail *string `json:"errordetail,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyVaultAndKeyReference is key Vault Key Url and vault id of KeK, KeK is
|
||||||
|
// optional and when provided is used to unwrap the encryptionKey
|
||||||
|
type KeyVaultAndKeyReference struct {
|
||||||
|
SourceVault *SourceVault `json:"sourceVault,omitempty"`
|
||||||
|
KeyURL *string `json:"keyUrl,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyVaultAndSecretReference is key Vault Secret Url and vault id of the
|
||||||
|
// encryption key
|
||||||
|
type KeyVaultAndSecretReference struct {
|
||||||
|
SourceVault *SourceVault `json:"sourceVault,omitempty"`
|
||||||
|
SecretURL *string `json:"secretUrl,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListType is the List Disks operation response.
|
||||||
|
type ListType struct {
|
||||||
|
autorest.Response `json:"-"`
|
||||||
|
Value *[]Model `json:"value,omitempty"`
|
||||||
|
NextLink *string `json:"nextLink,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListTypePreparer prepares a request to retrieve the next set of results. It returns
|
||||||
|
// nil if no more results exist.
|
||||||
|
func (client ListType) ListTypePreparer() (*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)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Model is disk resource.
|
||||||
|
type Model 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"`
|
||||||
|
*Properties `json:"properties,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperationStatusResponse is operation status response
|
||||||
|
type OperationStatusResponse struct {
|
||||||
|
autorest.Response `json:"-"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Status *string `json:"status,omitempty"`
|
||||||
|
StartTime *date.Time `json:"startTime,omitempty"`
|
||||||
|
EndTime *date.Time `json:"endTime,omitempty"`
|
||||||
|
Error *APIError `json:"error,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Properties is disk resource properties.
|
||||||
|
type Properties struct {
|
||||||
|
AccountType StorageAccountTypes `json:"accountType,omitempty"`
|
||||||
|
TimeCreated *date.Time `json:"timeCreated,omitempty"`
|
||||||
|
OsType OperatingSystemTypes `json:"osType,omitempty"`
|
||||||
|
CreationData *CreationData `json:"creationData,omitempty"`
|
||||||
|
DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
|
||||||
|
EncryptionSettings *EncryptionSettings `json:"encryptionSettings,omitempty"`
|
||||||
|
OwnerID *string `json:"ownerId,omitempty"`
|
||||||
|
ProvisioningState *string `json:"provisioningState,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resource is the Resource model 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"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResourceUpdate is the Resource model definition.
|
||||||
|
type ResourceUpdate struct {
|
||||||
|
Tags *map[string]*string `json:"tags,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Snapshot is snapshot resource.
|
||||||
|
type Snapshot 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"`
|
||||||
|
*Properties `json:"properties,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SnapshotList is the List Snapshots operation response.
|
||||||
|
type SnapshotList struct {
|
||||||
|
autorest.Response `json:"-"`
|
||||||
|
Value *[]Snapshot `json:"value,omitempty"`
|
||||||
|
NextLink *string `json:"nextLink,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SnapshotListPreparer prepares a request to retrieve the next set of results. It returns
|
||||||
|
// nil if no more results exist.
|
||||||
|
func (client SnapshotList) SnapshotListPreparer() (*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)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SnapshotUpdate is snapshot update resource.
|
||||||
|
type SnapshotUpdate struct {
|
||||||
|
Tags *map[string]*string `json:"tags,omitempty"`
|
||||||
|
*UpdateProperties `json:"properties,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SourceVault is the vault id is an Azure Resource Manager Resoure id in the
|
||||||
|
// form
|
||||||
|
// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}
|
||||||
|
type SourceVault struct {
|
||||||
|
ID *string `json:"id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateProperties is disk resource update properties.
|
||||||
|
type UpdateProperties struct {
|
||||||
|
AccountType StorageAccountTypes `json:"accountType,omitempty"`
|
||||||
|
OsType OperatingSystemTypes `json:"osType,omitempty"`
|
||||||
|
CreationData *CreationData `json:"creationData,omitempty"`
|
||||||
|
DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
|
||||||
|
EncryptionSettings *EncryptionSettings `json:"encryptionSettings,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateType is disk update resource.
|
||||||
|
type UpdateType struct {
|
||||||
|
Tags *map[string]*string `json:"tags,omitempty"`
|
||||||
|
*UpdateProperties `json:"properties,omitempty"`
|
||||||
|
}
|
|
@ -0,0 +1,643 @@
|
||||||
|
package disk
|
||||||
|
|
||||||
|
// 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SnapshotsClient is the the Disk Resource Provider Client.
|
||||||
|
type SnapshotsClient struct {
|
||||||
|
ManagementClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSnapshotsClient creates an instance of the SnapshotsClient client.
|
||||||
|
func NewSnapshotsClient(subscriptionID string) SnapshotsClient {
|
||||||
|
return NewSnapshotsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSnapshotsClientWithBaseURI creates an instance of the SnapshotsClient
|
||||||
|
// client.
|
||||||
|
func NewSnapshotsClientWithBaseURI(baseURI string, subscriptionID string) SnapshotsClient {
|
||||||
|
return SnapshotsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdate creates or updates a snapshot. 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. 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) {
|
||||||
|
if err := validation.Validate([]validation.Validation{
|
||||||
|
{TargetValue: snapshot,
|
||||||
|
Constraints: []validation.Constraint{{Target: "snapshot.Properties", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "snapshot.Properties.CreationData", Name: validation.Null, Rule: true,
|
||||||
|
Chain: []validation.Constraint{{Target: "snapshot.Properties.CreationData.ImageReference", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "snapshot.Properties.CreationData.ImageReference.ID", Name: validation.Null, Rule: true, Chain: nil}}},
|
||||||
|
}},
|
||||||
|
{Target: "snapshot.Properties.EncryptionSettings", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "snapshot.Properties.EncryptionSettings.DiskEncryptionKey", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "snapshot.Properties.EncryptionSettings.DiskEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
{Target: "snapshot.Properties.EncryptionSettings.DiskEncryptionKey.SecretURL", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
}},
|
||||||
|
{Target: "snapshot.Properties.EncryptionSettings.KeyEncryptionKey", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "snapshot.Properties.EncryptionSettings.KeyEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
{Target: "snapshot.Properties.EncryptionSettings.KeyEncryptionKey.KeyURL", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
}}}}}); err != nil {
|
||||||
|
return result, validation.NewErrorWithValidationError(err, "disk.SnapshotsClient", "CreateOrUpdate")
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := client.CreateOrUpdatePreparer(resourceGroupName, snapshotName, snapshot, cancel)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.CreateOrUpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = resp
|
||||||
|
return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "CreateOrUpdate", resp, "Failure sending request")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.CreateOrUpdateResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "CreateOrUpdate", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||||
|
func (client SnapshotsClient) CreateOrUpdatePreparer(resourceGroupName string, snapshotName string, snapshot Snapshot, cancel <-chan struct{}) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"snapshotName": autorest.Encode("path", snapshotName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": client.APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsJSON(),
|
||||||
|
autorest.AsPut(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", pathParameters),
|
||||||
|
autorest.WithJSON(snapshot),
|
||||||
|
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 SnapshotsClient) 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 SnapshotsClient) CreateOrUpdateResponder(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
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete deletes a snapshot. 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. 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")
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.DeleteSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = resp
|
||||||
|
return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Delete", resp, "Failure sending request")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.DeleteResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Delete", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePreparer prepares the Delete request.
|
||||||
|
func (client SnapshotsClient) DeletePreparer(resourceGroupName string, snapshotName string, cancel <-chan struct{}) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"snapshotName": autorest.Encode("path", snapshotName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": client.APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsDelete(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", 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 SnapshotsClient) 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 SnapshotsClient) 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 information about a snapshot.
|
||||||
|
//
|
||||||
|
// 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) 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")
|
||||||
|
}
|
||||||
|
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client SnapshotsClient) GetPreparer(resourceGroupName string, snapshotName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"snapshotName": autorest.Encode("path", snapshotName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": client.APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", 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 SnapshotsClient) 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 SnapshotsClient) GetResponder(resp *http.Response) (result Snapshot, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GrantAccess grants access to a snapshot. 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. snapshotName is the
|
||||||
|
// 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) {
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := client.GrantAccessPreparer(resourceGroupName, snapshotName, grantAccessData, cancel)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "GrantAccess", nil, "Failure preparing request")
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GrantAccessSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = resp
|
||||||
|
return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "GrantAccess", resp, "Failure sending request")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GrantAccessResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "GrantAccess", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GrantAccessPreparer prepares the GrantAccess request.
|
||||||
|
func (client SnapshotsClient) GrantAccessPreparer(resourceGroupName string, snapshotName string, grantAccessData GrantAccessData, cancel <-chan struct{}) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"snapshotName": autorest.Encode("path", snapshotName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": client.APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsJSON(),
|
||||||
|
autorest.AsPost(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess", pathParameters),
|
||||||
|
autorest.WithJSON(grantAccessData),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare(&http.Request{Cancel: cancel})
|
||||||
|
}
|
||||||
|
|
||||||
|
// GrantAccessSender sends the GrantAccess request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client SnapshotsClient) GrantAccessSender(req *http.Request) (*http.Response, error) {
|
||||||
|
return autorest.SendWithSender(client,
|
||||||
|
req,
|
||||||
|
azure.DoPollForAsynchronous(client.PollingDelay))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// List lists snapshots under a subscription.
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "List", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPreparer prepares the List request.
|
||||||
|
func (client SnapshotsClient) ListPreparer() (*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.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots", 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 SnapshotsClient) 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 SnapshotsClient) ListResponder(resp *http.Response) (result SnapshotList, 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 SnapshotsClient) ListNextResults(lastResults SnapshotList) (result SnapshotList, err error) {
|
||||||
|
req, err := lastResults.SnapshotListPreparer()
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "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, "disk.SnapshotsClient", "List", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "List", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroup lists snapshots under a resource group.
|
||||||
|
//
|
||||||
|
// resourceGroupName is the name of the resource group.
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListByResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "ListByResourceGroup", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
|
||||||
|
func (client SnapshotsClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": client.APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots", 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 SnapshotsClient) 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 SnapshotsClient) ListByResourceGroupResponder(resp *http.Response) (result SnapshotList, 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 SnapshotsClient) ListByResourceGroupNextResults(lastResults SnapshotList) (result SnapshotList, err error) {
|
||||||
|
req, err := lastResults.SnapshotListPreparer()
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "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, "disk.SnapshotsClient", "ListByResourceGroup", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListByResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "ListByResourceGroup", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// RevokeAccess revokes access to a snapshot. 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. 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")
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.RevokeAccessSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = resp
|
||||||
|
return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "RevokeAccess", resp, "Failure sending request")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.RevokeAccessResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "RevokeAccess", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// RevokeAccessPreparer prepares the RevokeAccess request.
|
||||||
|
func (client SnapshotsClient) RevokeAccessPreparer(resourceGroupName string, snapshotName string, cancel <-chan struct{}) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"snapshotName": autorest.Encode("path", snapshotName),
|
||||||
|
"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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare(&http.Request{Cancel: cancel})
|
||||||
|
}
|
||||||
|
|
||||||
|
// RevokeAccessSender sends the RevokeAccess request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client SnapshotsClient) RevokeAccessSender(req *http.Request) (*http.Response, error) {
|
||||||
|
return autorest.SendWithSender(client,
|
||||||
|
req,
|
||||||
|
azure.DoPollForAsynchronous(client.PollingDelay))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update updates (patches) a snapshot. 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. snapshotName is the
|
||||||
|
// 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")
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.UpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = resp
|
||||||
|
return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Update", resp, "Failure sending request")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.UpdateResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Update", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatePreparer prepares the Update request.
|
||||||
|
func (client SnapshotsClient) UpdatePreparer(resourceGroupName string, snapshotName string, snapshot SnapshotUpdate, cancel <-chan struct{}) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"snapshotName": autorest.Encode("path", snapshotName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": client.APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsJSON(),
|
||||||
|
autorest.AsPatch(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", pathParameters),
|
||||||
|
autorest.WithJSON(snapshot),
|
||||||
|
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 SnapshotsClient) 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 SnapshotsClient) UpdateResponder(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
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
package disk
|
||||||
|
|
||||||
|
// 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 (
|
||||||
|
"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
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
Loading…
Reference in New Issue