diff --git a/azurerm/config.go b/azurerm/config.go index 663699b9dd89..902869d59e3e 100644 --- a/azurerm/config.go +++ b/azurerm/config.go @@ -38,6 +38,7 @@ import ( "github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2017-12-01/postgresql" "github.com/Azure/azure-sdk-for-go/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement" "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization" + "github.com/Azure/azure-sdk-for-go/services/preview/devspaces/mgmt/2018-06-01-preview/devspaces" "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" "github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2018-03-01/insights" "github.com/Azure/azure-sdk-for-go/services/preview/msi/mgmt/2015-08-31-preview/msi" @@ -61,6 +62,7 @@ import ( "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage" "github.com/Azure/azure-sdk-for-go/services/trafficmanager/mgmt/2017-05-01/trafficmanager" "github.com/Azure/azure-sdk-for-go/services/web/mgmt/2018-02-01/web" + mainStorage "github.com/Azure/azure-sdk-for-go/storage" "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/adal" @@ -162,6 +164,9 @@ type ArmClient struct { devTestVirtualMachinesClient dtl.VirtualMachinesClient devTestVirtualNetworksClient dtl.VirtualNetworksClient + // DevSpace + devSpaceControllerClient devspaces.ControllersClient + // Databases mysqlConfigurationsClient mysql.ConfigurationsClient mysqlDatabasesClient mysql.DatabasesClient @@ -507,6 +512,7 @@ func getArmClient(c *authentication.Config) (*ArmClient, error) { client.registerDatabases(endpoint, c.SubscriptionID, auth, sender) client.registerDataLakeStoreClients(endpoint, c.SubscriptionID, auth) client.registerDeviceClients(endpoint, c.SubscriptionID, auth) + client.registerDevSpaceClients(endpoint, c.SubscriptionID, auth) client.registerDevTestClients(endpoint, c.SubscriptionID, auth) client.registerDNSClients(endpoint, c.SubscriptionID, auth) client.registerEventGridClients(endpoint, c.SubscriptionID, auth) @@ -835,6 +841,12 @@ func (c *ArmClient) registerDevTestClients(endpoint, subscriptionId string, auth c.devTestVirtualNetworksClient = devTestVirtualNetworksClient } +func (c *ArmClient) registerDevSpaceClients(endpoint, subscriptionId string, auth autorest.Authorizer) { + controllersClient := devspaces.NewControllersClientWithBaseURI(endpoint, subscriptionId) + c.configureClient(&controllersClient.Client, auth) + c.devSpaceControllerClient = controllersClient +} + func (c *ArmClient) registerDNSClients(endpoint, subscriptionId string, auth autorest.Authorizer) { dn := dns.NewRecordSetsClientWithBaseURI(endpoint, subscriptionId) c.configureClient(&dn.Client, auth) diff --git a/azurerm/helpers/validate/devspace.go b/azurerm/helpers/validate/devspace.go new file mode 100644 index 000000000000..a21e933be1d1 --- /dev/null +++ b/azurerm/helpers/validate/devspace.go @@ -0,0 +1,26 @@ +package validate + +import ( + "regexp" + + "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/helper/validation" +) + +func DevSpaceName() schema.SchemaValidateFunc { + return func(i interface{}, k string) (s []string, es []error) { + // Length should be between 3 and 31. + if s, es = validation.StringLenBetween(3, 31)(i, k); len(es) > 0 { + return s, es + } + + // Naming rule. + regexStr := "^[a-zA-Z0-9](-?[a-zA-Z0-9])*$" + errMsg := "DevSpace name can only include alphanumeric characters, hyphens." + if s, es = validation.StringMatch(regexp.MustCompile(regexStr), errMsg)(i, k); len(es) > 0 { + return s, es + } + + return s, es + } +} diff --git a/azurerm/helpers/validate/devspace_test.go b/azurerm/helpers/validate/devspace_test.go new file mode 100644 index 000000000000..f0f0ef630322 --- /dev/null +++ b/azurerm/helpers/validate/devspace_test.go @@ -0,0 +1,31 @@ +package validate + +import "testing" + +func TestValidateDevSpaceName(t *testing.T) { + validNames := []string{ + "valid-name", + "valid02-name", + "validName1", + } + for _, v := range validNames { + _, errors := DevSpaceName()(v, "valid") + if len(errors) != 0 { + t.Fatalf("%q should be a valid DevSpace Name: %q", v, errors) + } + } + + invalidNames := []string{ + "invalid!", + "!@£", + "-invalid", + "double-hyphen--invalid", + "invalid_name", + } + for _, v := range invalidNames { + _, errors := DevSpaceName()(v, "invalid") + if len(errors) == 0 { + t.Fatalf("%q should be an invalid DevSpace Name", v) + } + } +} diff --git a/azurerm/provider.go b/azurerm/provider.go index b62ebce691bb..68d904721f95 100644 --- a/azurerm/provider.go +++ b/azurerm/provider.go @@ -164,6 +164,7 @@ func Provider() terraform.ResourceProvider { "azurerm_data_lake_store": resourceArmDataLakeStore(), "azurerm_data_lake_store_file": resourceArmDataLakeStoreFile(), "azurerm_data_lake_store_firewall_rule": resourceArmDataLakeStoreFirewallRule(), + "azurerm_devspace_controller": resourceArmDevSpaceController(), "azurerm_dev_test_lab": resourceArmDevTestLab(), "azurerm_dev_test_policy": resourceArmDevTestPolicy(), "azurerm_dev_test_linux_virtual_machine": resourceArmDevTestLinuxVirtualMachine(), diff --git a/azurerm/resource_arm_devspace_controller.go b/azurerm/resource_arm_devspace_controller.go new file mode 100644 index 000000000000..03da69161158 --- /dev/null +++ b/azurerm/resource_arm_devspace_controller.go @@ -0,0 +1,271 @@ +package azurerm + +import ( + "fmt" + "log" + + "github.com/Azure/azure-sdk-for-go/services/preview/devspaces/mgmt/2018-06-01-preview/devspaces" + "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func resourceArmDevSpaceController() *schema.Resource { + return &schema.Resource{ + Create: resourceArmDevSpaceControllerCreate, + Read: resourceArmDevSpaceControllerRead, + Update: resourceArmDevSpaceControllerUpdate, + Delete: resourceArmDevSpaceControllerDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.DevSpaceName(), + }, + + "location": locationSchema(), + + "resource_group_name": resourceGroupNameSchema(), + + "sku": { + Type: schema.TypeList, + Required: true, + ForceNew: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + "S1", + }, false), + }, + "tier": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + string(devspaces.Standard), + }, false), + }, + }, + }, + }, + + "host_suffix": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.NoZeroValues, + }, + + "target_container_host_resource_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: azure.ValidateResourceID, + }, + + "target_container_host_credentials_base64": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Sensitive: true, + ValidateFunc: validation.NoZeroValues, + }, + + "tags": tagsSchema(), + + "data_plane_fqdn": { + Type: schema.TypeString, + Computed: true, + }, + }, + } +} + +func resourceArmDevSpaceControllerCreate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).devSpaceControllerClient + ctx := meta.(*ArmClient).StopContext + + log.Printf("[INFO] preparing arguments for DevSpace Controller creation") + + name := d.Get("name").(string) + location := azureRMNormalizeLocation(d.Get("location").(string)) + resGroupName := d.Get("resource_group_name").(string) + tags := d.Get("tags").(map[string]interface{}) + + sku := expandDevSpaceControllerSku(d) + + hostSuffix := d.Get("host_suffix").(string) + tarCHResId := d.Get("target_container_host_resource_id").(string) + tarCHCredBase64 := d.Get("target_container_host_credentials_base64").(string) + + controller := devspaces.Controller{ + Location: &location, + Tags: expandTags(tags), + Sku: sku, + ControllerProperties: &devspaces.ControllerProperties{ + HostSuffix: &hostSuffix, + TargetContainerHostResourceID: &tarCHResId, + TargetContainerHostCredentialsBase64: &tarCHCredBase64, + }, + } + + future, err := client.Create(ctx, resGroupName, name, controller) + if err != nil { + return fmt.Errorf("Error creating DevSpace Controller %q (Resource Group %q): %+v", name, resGroupName, err) + } + + if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("Error waiting for creation of DevSpace Controller %q (Resource Group %q): %+v", name, resGroupName, err) + } + + result, err := client.Get(ctx, resGroupName, name) + if err != nil { + return fmt.Errorf("Error retrieving DevSpace %q (Resource Group %q): %+v", name, resGroupName, err) + } + + if result.ID == nil { + return fmt.Errorf("Cannot read DevSpace Controller %q (Resource Group %q) ID", name, resGroupName) + } + d.SetId(*result.ID) + + return resourceArmDevSpaceControllerRead(d, meta) +} + +func resourceArmDevSpaceControllerRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).devSpaceControllerClient + ctx := meta.(*ArmClient).StopContext + + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + resGroupName := id.ResourceGroup + name := id.Path["controllers"] + + result, err := client.Get(ctx, resGroupName, name) + if err != nil { + if utils.ResponseWasNotFound(result.Response) { + log.Printf("[DEBUG] DevSpace Controller %q was not found in Resource Group %q - removing from state!", name, resGroupName) + d.SetId("") + return nil + } + + return fmt.Errorf("Error making Read request on DevSpace Controller Lab %q (Resource Group %q): %+v", name, resGroupName, err) + } + + d.Set("name", result.Name) + d.Set("resource_group_name", resGroupName) + if location := result.Location; location != nil { + d.Set("location", azureRMNormalizeLocation(*location)) + } + + d.Set("sku", flattenDevSpaceControllerSku(result.Sku)) + + if props := result.ControllerProperties; props != nil { + if props.HostSuffix != nil { + d.Set("host_suffix", props.HostSuffix) + } + + if props.DataPlaneFqdn != nil { + d.Set("data_plane_fqdn", props.DataPlaneFqdn) + } + + if props.TargetContainerHostResourceID != nil { + d.Set("target_container_host_resource_id", props.TargetContainerHostResourceID) + } + } + + flattenAndSetTags(d, result.Tags) + + return nil +} + +func resourceArmDevSpaceControllerUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).devSpaceControllerClient + ctx := meta.(*ArmClient).StopContext + + log.Printf("[INFO] preparing arguments for DevSpace Controller updating") + + name := d.Get("name").(string) + resGroupName := d.Get("resource_group_name").(string) + tags := d.Get("tags").(map[string]interface{}) + + params := devspaces.ControllerUpdateParameters{ + Tags: expandTags(tags), + } + + result, err := client.Update(ctx, resGroupName, name, params) + if err != nil { + return fmt.Errorf("Error updating DevSpace Controller %q (Resource Group %q): %+v", name, resGroupName, err) + } + + if result.ID == nil { + return fmt.Errorf("Cannot read DevSpace Controller %q (Resource Group %q) ID", name, resGroupName) + } + d.SetId(*result.ID) + + return resourceArmDevSpaceControllerRead(d, meta) +} + +func resourceArmDevSpaceControllerDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).devSpaceControllerClient + ctx := meta.(*ArmClient).StopContext + + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + resGroupName := id.ResourceGroup + name := id.Path["controllers"] + + future, err := client.Delete(ctx, resGroupName, name) + if err != nil { + return fmt.Errorf("Error deleting DevSpace Controller %q (Resource Group %q): %+v", name, resGroupName, err) + } + + if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("Error waiting for the deletion of DevSpace Controller %q (Resource Group %q): %+v", name, resGroupName, err) + } + + return nil +} + +func expandDevSpaceControllerSku(d *schema.ResourceData) *devspaces.Sku { + if _, ok := d.GetOk("sku"); !ok { + return nil + } + + skuConfigs := d.Get("sku").([]interface{}) + skuConfig := skuConfigs[0].(map[string]interface{}) + skuName := skuConfig["name"].(string) + skuTier := devspaces.SkuTier(skuConfig["tier"].(string)) + + return &devspaces.Sku{ + Name: &skuName, + Tier: skuTier, + } +} + +func flattenDevSpaceControllerSku(skuObj *devspaces.Sku) []interface{} { + if skuObj == nil { + return []interface{}{} + } + + skuConfig := make(map[string]interface{}, 0) + skuConfig["name"] = *skuObj.Name + skuConfig["tier"] = skuObj.Tier + + return []interface{}{skuConfig} +} diff --git a/azurerm/resource_arm_devspace_controller_test.go b/azurerm/resource_arm_devspace_controller_test.go new file mode 100644 index 000000000000..96c54dbb3e94 --- /dev/null +++ b/azurerm/resource_arm_devspace_controller_test.go @@ -0,0 +1,144 @@ +package azurerm + +import ( + "fmt" + "log" + "net/http" + "os" + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/terraform" +) + +func TestAccAzureRMDevSpaceController_basic(t *testing.T) { + resourceName := "azurerm_devspace_controller.test" + rInt := acctest.RandInt() + location := testLocation() + clientId := os.Getenv("ARM_CLIENT_ID") + clientSecret := os.Getenv("ARM_CLIENT_SECRET") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMDevSpaceControllerDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMDevSpaceController_basic(rInt, location, clientId, clientSecret), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMDevSpaceControllerExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "sku.#", "1"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + ), + }, + }, + }) +} + +func testCheckAzureRMDevSpaceControllerExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + // Ensure we have enough information in state to look up in API + rs, ok := s.RootModule().Resources[name] + if !ok { + return fmt.Errorf("Not found: %s", name) + } + + ctrlName := rs.Primary.Attributes["name"] + resGroupName, hasReseGroup := rs.Primary.Attributes["resource_group_name"] + if !hasReseGroup { + return fmt.Errorf("Bad: no resource group found in state for DevSpace Controller: %s", ctrlName) + } + + client := testAccProvider.Meta().(*ArmClient).devSpaceControllerClient + ctx := testAccProvider.Meta().(*ArmClient).StopContext + result, err := client.Get(ctx, resGroupName, ctrlName) + + if err == nil { + return nil + } + + if result.StatusCode == http.StatusNotFound { + return fmt.Errorf("Bad: DevSpace Controller %q (Resource Group: %q) does not exist", ctrlName, resGroupName) + } + + return fmt.Errorf("Bad: Get devSpaceControllerClient: %+v", err) + } +} + +func testCheckAzureRMDevSpaceControllerDestroy(s *terraform.State) error { + client := testAccProvider.Meta().(*ArmClient).devSpaceControllerClient + ctx := testAccProvider.Meta().(*ArmClient).StopContext + + for _, rs := range s.RootModule().Resources { + if rs.Type != "azurerm_devspace_controller" { + continue + } + + log.Printf("[WARN] azurerm_devspace_controller still exists in state file.") + + ctrlName := rs.Primary.Attributes["name"] + resGroupName := rs.Primary.Attributes["resource_group_name"] + + result, err := client.Get(ctx, resGroupName, ctrlName) + + if err == nil { + return fmt.Errorf("DevSpace Controller still exists:\n%#v", result) + } + + if result.StatusCode != http.StatusNotFound { + return err + } + } + + return nil +} + +func testAccAzureRMDevSpaceController_basic(rInt int, location string, clientId string, clientSecret string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_kubernetes_cluster" "test" { + name = "acctestaks%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + dns_prefix = "acctestaks1" + + linux_profile { + admin_username = "acctestuser1" + ssh_key { + key_data = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+L2NxRIfQ781rxV6Iq5jSav6b2Q8z5KiseOlvKA/RF2wqU0UPYqQviQhLmW6THTpmrv/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+5N2Ta6UYH3lsDf9R9wTP2K/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+7HTcWfdu0qQqPWY5ujyMw/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt terraform@demo.tld" + } + } + + agent_pool_profile { + name = "default" + count = "1" + vm_size = "Standard_DS2_v2" + } + + service_principal { + client_id = "%s" + client_secret = "%s" + } +} + +resource "azurerm_devspace_controller" test { + name = "acctestdsc%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + name = "S1" + tier = "Standard" + } + + host_suffix = "suffix" + target_container_host_resource_id = "${azurerm_kubernetes_cluster.test.id}" + target_container_host_credentials_base64 = "${base64encode(azurerm_kubernetes_cluster.test.kube_config_raw)}" +} +`, rInt, location, rInt, clientId, clientSecret, rInt) +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/devspaces/mgmt/2018-06-01-preview/devspaces/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/devspaces/mgmt/2018-06-01-preview/devspaces/client.go new file mode 100644 index 000000000000..ee2fccaf0732 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/devspaces/mgmt/2018-06-01-preview/devspaces/client.go @@ -0,0 +1,51 @@ +// Package devspaces implements the Azure ARM Devspaces service API version 2018-06-01-preview. +// +// Dev Spaces Client +package devspaces + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Devspaces + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Devspaces. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/devspaces/mgmt/2018-06-01-preview/devspaces/controllers.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/devspaces/mgmt/2018-06-01-preview/devspaces/controllers.go new file mode 100644 index 000000000000..dba3f15747a9 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/devspaces/mgmt/2018-06-01-preview/devspaces/controllers.go @@ -0,0 +1,643 @@ +package devspaces + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ControllersClient is the dev Spaces Client +type ControllersClient struct { + BaseClient +} + +// NewControllersClient creates an instance of the ControllersClient client. +func NewControllersClient(subscriptionID string) ControllersClient { + return NewControllersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewControllersClientWithBaseURI creates an instance of the ControllersClient client. +func NewControllersClientWithBaseURI(baseURI string, subscriptionID string) ControllersClient { + return ControllersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates an Azure Dev Spaces Controller with the specified create parameters. +// Parameters: +// resourceGroupName - resource group to which the resource belongs. +// name - name of the resource. +// controller - controller create parameters. +func (client ControllersClient) Create(ctx context.Context, resourceGroupName string, name string, controller Controller) (result ControllersCreateFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: name, + Constraints: []validation.Constraint{{Target: "name", Name: validation.MaxLength, Rule: 31, Chain: nil}, + {Target: "name", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "name", Name: validation.Pattern, Rule: `^[a-zA-Z0-9](-?[a-zA-Z0-9])*$`, Chain: nil}}}, + {TargetValue: controller, + Constraints: []validation.Constraint{{Target: "controller.ControllerProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "controller.ControllerProperties.HostSuffix", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "controller.ControllerProperties.TargetContainerHostResourceID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "controller.ControllerProperties.TargetContainerHostCredentialsBase64", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "controller.Sku", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "controller.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("devspaces.ControllersClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, name, controller) + if err != nil { + err = autorest.NewErrorWithError(err, "devspaces.ControllersClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "devspaces.ControllersClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ControllersClient) CreatePreparer(ctx context.Context, resourceGroupName string, name string, controller Controller) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevSpaces/controllers/{name}", pathParameters), + autorest.WithJSON(controller), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ControllersClient) CreateSender(req *http.Request) (future ControllersCreateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ControllersClient) CreateResponder(resp *http.Response) (result Controller, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing Azure Dev Spaces Controller. +// Parameters: +// resourceGroupName - resource group to which the resource belongs. +// name - name of the resource. +func (client ControllersClient) Delete(ctx context.Context, resourceGroupName string, name string) (result ControllersDeleteFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: name, + Constraints: []validation.Constraint{{Target: "name", Name: validation.MaxLength, Rule: 31, Chain: nil}, + {Target: "name", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "name", Name: validation.Pattern, Rule: `^[a-zA-Z0-9](-?[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("devspaces.ControllersClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, name) + if err != nil { + err = autorest.NewErrorWithError(err, "devspaces.ControllersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "devspaces.ControllersClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ControllersClient) DeletePreparer(ctx context.Context, resourceGroupName string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevSpaces/controllers/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ControllersClient) DeleteSender(req *http.Request) (future ControllersDeleteFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ControllersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the properties for an Azure Dev Spaces Controller. +// Parameters: +// resourceGroupName - resource group to which the resource belongs. +// name - name of the resource. +func (client ControllersClient) Get(ctx context.Context, resourceGroupName string, name string) (result Controller, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: name, + Constraints: []validation.Constraint{{Target: "name", Name: validation.MaxLength, Rule: 31, Chain: nil}, + {Target: "name", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "name", Name: validation.Pattern, Rule: `^[a-zA-Z0-9](-?[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("devspaces.ControllersClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, name) + if err != nil { + err = autorest.NewErrorWithError(err, "devspaces.ControllersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devspaces.ControllersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devspaces.ControllersClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ControllersClient) GetPreparer(ctx context.Context, resourceGroupName string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevSpaces/controllers/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ControllersClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ControllersClient) GetResponder(resp *http.Response) (result Controller, 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 lists all the Azure Dev Spaces Controllers with their properties in the subscription. +func (client ControllersClient) List(ctx context.Context) (result ControllerListPage, err error) { + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "devspaces.ControllersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.cl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devspaces.ControllersClient", "List", resp, "Failure sending request") + return + } + + result.cl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devspaces.ControllersClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ControllersClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DevSpaces/controllers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ControllersClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ControllersClient) ListResponder(resp *http.Response) (result ControllerList, 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 ControllersClient) listNextResults(lastResults ControllerList) (result ControllerList, err error) { + req, err := lastResults.controllerListPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devspaces.ControllersClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devspaces.ControllersClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devspaces.ControllersClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ControllersClient) ListComplete(ctx context.Context) (result ControllerListIterator, err error) { + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup lists all the Azure Dev Spaces Controllers with their properties in the specified resource group +// and subscription. +// Parameters: +// resourceGroupName - resource group to which the resource belongs. +func (client ControllersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ControllerListPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("devspaces.ControllersClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "devspaces.ControllersClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.cl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devspaces.ControllersClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.cl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devspaces.ControllersClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ControllersClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevSpaces/controllers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ControllersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ControllersClient) ListByResourceGroupResponder(resp *http.Response) (result ControllerList, 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 ControllersClient) listByResourceGroupNextResults(lastResults ControllerList) (result ControllerList, err error) { + req, err := lastResults.controllerListPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devspaces.ControllersClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devspaces.ControllersClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devspaces.ControllersClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ControllersClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ControllerListIterator, err error) { + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListConnectionDetails lists connection details for the underlying container resources of an Azure Dev Spaces +// Controller. +// Parameters: +// resourceGroupName - resource group to which the resource belongs. +// name - name of the resource. +func (client ControllersClient) ListConnectionDetails(ctx context.Context, resourceGroupName string, name string) (result ControllerConnectionDetailsList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: name, + Constraints: []validation.Constraint{{Target: "name", Name: validation.MaxLength, Rule: 31, Chain: nil}, + {Target: "name", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "name", Name: validation.Pattern, Rule: `^[a-zA-Z0-9](-?[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("devspaces.ControllersClient", "ListConnectionDetails", err.Error()) + } + + req, err := client.ListConnectionDetailsPreparer(ctx, resourceGroupName, name) + if err != nil { + err = autorest.NewErrorWithError(err, "devspaces.ControllersClient", "ListConnectionDetails", nil, "Failure preparing request") + return + } + + resp, err := client.ListConnectionDetailsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devspaces.ControllersClient", "ListConnectionDetails", resp, "Failure sending request") + return + } + + result, err = client.ListConnectionDetailsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devspaces.ControllersClient", "ListConnectionDetails", resp, "Failure responding to request") + } + + return +} + +// ListConnectionDetailsPreparer prepares the ListConnectionDetails request. +func (client ControllersClient) ListConnectionDetailsPreparer(ctx context.Context, resourceGroupName string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevSpaces/controllers/{name}/listConnectionDetails", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListConnectionDetailsSender sends the ListConnectionDetails request. The method will close the +// http.Response Body if it receives an error. +func (client ControllersClient) ListConnectionDetailsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListConnectionDetailsResponder handles the response to the ListConnectionDetails request. The method always +// closes the http.Response Body. +func (client ControllersClient) ListConnectionDetailsResponder(resp *http.Response) (result ControllerConnectionDetailsList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates the properties of an existing Azure Dev Spaces Controller with the specified update parameters. +// Parameters: +// resourceGroupName - resource group to which the resource belongs. +// name - name of the resource. +func (client ControllersClient) Update(ctx context.Context, resourceGroupName string, name string, controllerUpdateParameters ControllerUpdateParameters) (result Controller, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: name, + Constraints: []validation.Constraint{{Target: "name", Name: validation.MaxLength, Rule: 31, Chain: nil}, + {Target: "name", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "name", Name: validation.Pattern, Rule: `^[a-zA-Z0-9](-?[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("devspaces.ControllersClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, name, controllerUpdateParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "devspaces.ControllersClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devspaces.ControllersClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devspaces.ControllersClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ControllersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, name string, controllerUpdateParameters ControllerUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevSpaces/controllers/{name}", pathParameters), + autorest.WithJSON(controllerUpdateParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ControllersClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ControllersClient) UpdateResponder(resp *http.Response) (result Controller, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/devspaces/mgmt/2018-06-01-preview/devspaces/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/devspaces/mgmt/2018-06-01-preview/devspaces/models.go new file mode 100644 index 000000000000..33603b57a44a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/devspaces/mgmt/2018-06-01-preview/devspaces/models.go @@ -0,0 +1,750 @@ +package devspaces + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/to" + "net/http" +) + +// InstanceType enumerates the values for instance type. +type InstanceType string + +const ( + // InstanceTypeKubernetes ... + InstanceTypeKubernetes InstanceType = "Kubernetes" + // InstanceTypeOrchestratorSpecificConnectionDetails ... + InstanceTypeOrchestratorSpecificConnectionDetails InstanceType = "OrchestratorSpecificConnectionDetails" +) + +// PossibleInstanceTypeValues returns an array of possible values for the InstanceType const type. +func PossibleInstanceTypeValues() []InstanceType { + return []InstanceType{InstanceTypeKubernetes, InstanceTypeOrchestratorSpecificConnectionDetails} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // Canceled ... + Canceled ProvisioningState = "Canceled" + // Creating ... + Creating ProvisioningState = "Creating" + // Deleting ... + Deleting ProvisioningState = "Deleting" + // Failed ... + Failed ProvisioningState = "Failed" + // Succeeded ... + Succeeded ProvisioningState = "Succeeded" + // Updating ... + Updating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{Canceled, Creating, Deleting, Failed, Succeeded, Updating} +} + +// SkuTier enumerates the values for sku tier. +type SkuTier string + +const ( + // Standard ... + Standard SkuTier = "Standard" +) + +// PossibleSkuTierValues returns an array of possible values for the SkuTier const type. +func PossibleSkuTierValues() []SkuTier { + return []SkuTier{Standard} +} + +// Controller ... +type Controller struct { + autorest.Response `json:"-"` + *ControllerProperties `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + // Tags - Tags for the Azure resource. + Tags map[string]*string `json:"tags"` + // Location - Region where the Azure resource is located. + Location *string `json:"location,omitempty"` + // ID - Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - The name of the resource. + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Controller. +func (c Controller) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.ControllerProperties != nil { + objectMap["properties"] = c.ControllerProperties + } + if c.Sku != nil { + objectMap["sku"] = c.Sku + } + if c.Tags != nil { + objectMap["tags"] = c.Tags + } + if c.Location != nil { + objectMap["location"] = c.Location + } + if c.ID != nil { + objectMap["id"] = c.ID + } + if c.Name != nil { + objectMap["name"] = c.Name + } + if c.Type != nil { + objectMap["type"] = c.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Controller struct. +func (c *Controller) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var controllerProperties ControllerProperties + err = json.Unmarshal(*v, &controllerProperties) + if err != nil { + return err + } + c.ControllerProperties = &controllerProperties + } + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + c.Sku = &sku + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + c.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + c.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + } + } + + return nil +} + +// ControllerConnectionDetails ... +type ControllerConnectionDetails struct { + // AuthKey - Authentication key for communicating with services. + AuthKey *string `json:"authKey,omitempty"` + // WorkspaceStorageAccountName - Workspace storage account name. + WorkspaceStorageAccountName *string `json:"workspaceStorageAccountName,omitempty"` + // WorkspaceStorageSasToken - Workspace storage account SAS token. + WorkspaceStorageSasToken *string `json:"workspaceStorageSasToken,omitempty"` + OrchestratorSpecificConnectionDetails BasicOrchestratorSpecificConnectionDetails `json:"orchestratorSpecificConnectionDetails,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for ControllerConnectionDetails struct. +func (ccd *ControllerConnectionDetails) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "authKey": + if v != nil { + var authKey string + err = json.Unmarshal(*v, &authKey) + if err != nil { + return err + } + ccd.AuthKey = &authKey + } + case "workspaceStorageAccountName": + if v != nil { + var workspaceStorageAccountName string + err = json.Unmarshal(*v, &workspaceStorageAccountName) + if err != nil { + return err + } + ccd.WorkspaceStorageAccountName = &workspaceStorageAccountName + } + case "workspaceStorageSasToken": + if v != nil { + var workspaceStorageSasToken string + err = json.Unmarshal(*v, &workspaceStorageSasToken) + if err != nil { + return err + } + ccd.WorkspaceStorageSasToken = &workspaceStorageSasToken + } + case "orchestratorSpecificConnectionDetails": + if v != nil { + orchestratorSpecificConnectionDetails, err := unmarshalBasicOrchestratorSpecificConnectionDetails(*v) + if err != nil { + return err + } + ccd.OrchestratorSpecificConnectionDetails = orchestratorSpecificConnectionDetails + } + } + } + + return nil +} + +// ControllerConnectionDetailsList ... +type ControllerConnectionDetailsList struct { + autorest.Response `json:"-"` + // ConnectionDetailsList - List of Azure Dev Spaces Controller connection details. + ConnectionDetailsList *[]ControllerConnectionDetails `json:"connectionDetailsList,omitempty"` +} + +// ControllerList ... +type ControllerList struct { + autorest.Response `json:"-"` + // Value - List of Azure Dev Spaces Controllers. + Value *[]Controller `json:"value,omitempty"` + // NextLink - The URI that can be used to request the next page for list of Azure Dev Spaces Controllers. + NextLink *string `json:"nextLink,omitempty"` +} + +// ControllerListIterator provides access to a complete listing of Controller values. +type ControllerListIterator struct { + i int + page ControllerListPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ControllerListIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ControllerListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ControllerListIterator) Response() ControllerList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ControllerListIterator) Value() Controller { + if !iter.page.NotDone() { + return Controller{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (cl ControllerList) IsEmpty() bool { + return cl.Value == nil || len(*cl.Value) == 0 +} + +// controllerListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (cl ControllerList) controllerListPreparer() (*http.Request, error) { + if cl.NextLink == nil || len(to.String(cl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(cl.NextLink))) +} + +// ControllerListPage contains a page of Controller values. +type ControllerListPage struct { + fn func(ControllerList) (ControllerList, error) + cl ControllerList +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ControllerListPage) Next() error { + next, err := page.fn(page.cl) + if err != nil { + return err + } + page.cl = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ControllerListPage) NotDone() bool { + return !page.cl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ControllerListPage) Response() ControllerList { + return page.cl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ControllerListPage) Values() []Controller { + if page.cl.IsEmpty() { + return nil + } + return *page.cl.Value +} + +// ControllerProperties ... +type ControllerProperties struct { + // ProvisioningState - Provisioning state of the Azure Dev Spaces Controller. Possible values include: 'Succeeded', 'Failed', 'Canceled', 'Updating', 'Creating', 'Deleting' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // HostSuffix - DNS suffix for public endpoints running in the Azure Dev Spaces Controller. + HostSuffix *string `json:"hostSuffix,omitempty"` + // DataPlaneFqdn - DNS name for accessing DataPlane services + DataPlaneFqdn *string `json:"dataPlaneFqdn,omitempty"` + // TargetContainerHostResourceID - Resource ID of the target container host + TargetContainerHostResourceID *string `json:"targetContainerHostResourceId,omitempty"` + // TargetContainerHostCredentialsBase64 - Credentials of the target container host (base64). + TargetContainerHostCredentialsBase64 *string `json:"targetContainerHostCredentialsBase64,omitempty"` +} + +// ControllersCreateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ControllersCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ControllersCreateFuture) Result(client ControllersClient) (c Controller, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "devspaces.ControllersCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("devspaces.ControllersCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { + c, err = client.CreateResponder(c.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "devspaces.ControllersCreateFuture", "Result", c.Response.Response, "Failure responding to request") + } + } + return +} + +// ControllersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ControllersDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ControllersDeleteFuture) Result(client ControllersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "devspaces.ControllersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("devspaces.ControllersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ControllerUpdateParameters parameters for updating an Azure Dev Spaces Controller. +type ControllerUpdateParameters struct { + // Tags - Tags for the Azure Dev Spaces Controller. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ControllerUpdateParameters. +func (cup ControllerUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cup.Tags != nil { + objectMap["tags"] = cup.Tags + } + return json.Marshal(objectMap) +} + +// ErrorDetails ... +type ErrorDetails struct { + // Code - Status code for the error. + Code *string `json:"code,omitempty"` + // Message - Error message describing the error in detail. + Message *string `json:"message,omitempty"` + // Target - The target of the particular error. + Target *string `json:"target,omitempty"` +} + +// ErrorResponse error response indicates that the service is not able to process the incoming request. The reason +// is provided in the error message. +type ErrorResponse struct { + // Error - The details of the error. + Error *ErrorDetails `json:"error,omitempty"` +} + +// KubernetesConnectionDetails ... +type KubernetesConnectionDetails struct { + // KubeConfig - Gets the kubeconfig for the cluster. + KubeConfig *string `json:"kubeConfig,omitempty"` + // InstanceType - Possible values include: 'InstanceTypeOrchestratorSpecificConnectionDetails', 'InstanceTypeKubernetes' + InstanceType InstanceType `json:"instanceType,omitempty"` +} + +// MarshalJSON is the custom marshaler for KubernetesConnectionDetails. +func (kcd KubernetesConnectionDetails) MarshalJSON() ([]byte, error) { + kcd.InstanceType = InstanceTypeKubernetes + objectMap := make(map[string]interface{}) + if kcd.KubeConfig != nil { + objectMap["kubeConfig"] = kcd.KubeConfig + } + if kcd.InstanceType != "" { + objectMap["instanceType"] = kcd.InstanceType + } + return json.Marshal(objectMap) +} + +// AsKubernetesConnectionDetails is the BasicOrchestratorSpecificConnectionDetails implementation for KubernetesConnectionDetails. +func (kcd KubernetesConnectionDetails) AsKubernetesConnectionDetails() (*KubernetesConnectionDetails, bool) { + return &kcd, true +} + +// AsOrchestratorSpecificConnectionDetails is the BasicOrchestratorSpecificConnectionDetails implementation for KubernetesConnectionDetails. +func (kcd KubernetesConnectionDetails) AsOrchestratorSpecificConnectionDetails() (*OrchestratorSpecificConnectionDetails, bool) { + return nil, false +} + +// AsBasicOrchestratorSpecificConnectionDetails is the BasicOrchestratorSpecificConnectionDetails implementation for KubernetesConnectionDetails. +func (kcd KubernetesConnectionDetails) AsBasicOrchestratorSpecificConnectionDetails() (BasicOrchestratorSpecificConnectionDetails, bool) { + return &kcd, true +} + +// BasicOrchestratorSpecificConnectionDetails ... +type BasicOrchestratorSpecificConnectionDetails interface { + AsKubernetesConnectionDetails() (*KubernetesConnectionDetails, bool) + AsOrchestratorSpecificConnectionDetails() (*OrchestratorSpecificConnectionDetails, bool) +} + +// OrchestratorSpecificConnectionDetails ... +type OrchestratorSpecificConnectionDetails struct { + // InstanceType - Possible values include: 'InstanceTypeOrchestratorSpecificConnectionDetails', 'InstanceTypeKubernetes' + InstanceType InstanceType `json:"instanceType,omitempty"` +} + +func unmarshalBasicOrchestratorSpecificConnectionDetails(body []byte) (BasicOrchestratorSpecificConnectionDetails, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["instanceType"] { + case string(InstanceTypeKubernetes): + var kcd KubernetesConnectionDetails + err := json.Unmarshal(body, &kcd) + return kcd, err + default: + var oscd OrchestratorSpecificConnectionDetails + err := json.Unmarshal(body, &oscd) + return oscd, err + } +} +func unmarshalBasicOrchestratorSpecificConnectionDetailsArray(body []byte) ([]BasicOrchestratorSpecificConnectionDetails, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + oscdArray := make([]BasicOrchestratorSpecificConnectionDetails, len(rawMessages)) + + for index, rawMessage := range rawMessages { + oscd, err := unmarshalBasicOrchestratorSpecificConnectionDetails(*rawMessage) + if err != nil { + return nil, err + } + oscdArray[index] = oscd + } + return oscdArray, nil +} + +// MarshalJSON is the custom marshaler for OrchestratorSpecificConnectionDetails. +func (oscd OrchestratorSpecificConnectionDetails) MarshalJSON() ([]byte, error) { + oscd.InstanceType = InstanceTypeOrchestratorSpecificConnectionDetails + objectMap := make(map[string]interface{}) + if oscd.InstanceType != "" { + objectMap["instanceType"] = oscd.InstanceType + } + return json.Marshal(objectMap) +} + +// AsKubernetesConnectionDetails is the BasicOrchestratorSpecificConnectionDetails implementation for OrchestratorSpecificConnectionDetails. +func (oscd OrchestratorSpecificConnectionDetails) AsKubernetesConnectionDetails() (*KubernetesConnectionDetails, bool) { + return nil, false +} + +// AsOrchestratorSpecificConnectionDetails is the BasicOrchestratorSpecificConnectionDetails implementation for OrchestratorSpecificConnectionDetails. +func (oscd OrchestratorSpecificConnectionDetails) AsOrchestratorSpecificConnectionDetails() (*OrchestratorSpecificConnectionDetails, bool) { + return &oscd, true +} + +// AsBasicOrchestratorSpecificConnectionDetails is the BasicOrchestratorSpecificConnectionDetails implementation for OrchestratorSpecificConnectionDetails. +func (oscd OrchestratorSpecificConnectionDetails) AsBasicOrchestratorSpecificConnectionDetails() (BasicOrchestratorSpecificConnectionDetails, bool) { + return &oscd, true +} + +// Resource an Azure resource. +type Resource struct { + // ID - Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - The name of the resource. + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// ResourceProviderOperationDefinition ... +type ResourceProviderOperationDefinition struct { + // Name - Resource provider operation name. + Name *string `json:"name,omitempty"` + Display *ResourceProviderOperationDisplay `json:"display,omitempty"` +} + +// ResourceProviderOperationDisplay ... +type ResourceProviderOperationDisplay struct { + // Provider - Name of the resource provider. + Provider *string `json:"provider,omitempty"` + // Resource - Name of the resource type. + Resource *string `json:"resource,omitempty"` + // Operation - Name of the resource provider operation. + Operation *string `json:"operation,omitempty"` + // Description - Description of the resource provider operation. + Description *string `json:"description,omitempty"` +} + +// ResourceProviderOperationList ... +type ResourceProviderOperationList struct { + autorest.Response `json:"-"` + // Value - Resource provider operations list. + Value *[]ResourceProviderOperationDefinition `json:"value,omitempty"` + // NextLink - The URI that can be used to request the next page for list of Azure operations. + NextLink *string `json:"nextLink,omitempty"` +} + +// ResourceProviderOperationListIterator provides access to a complete listing of +// ResourceProviderOperationDefinition values. +type ResourceProviderOperationListIterator struct { + i int + page ResourceProviderOperationListPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ResourceProviderOperationListIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ResourceProviderOperationListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ResourceProviderOperationListIterator) Response() ResourceProviderOperationList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ResourceProviderOperationListIterator) Value() ResourceProviderOperationDefinition { + if !iter.page.NotDone() { + return ResourceProviderOperationDefinition{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (rpol ResourceProviderOperationList) IsEmpty() bool { + return rpol.Value == nil || len(*rpol.Value) == 0 +} + +// resourceProviderOperationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rpol ResourceProviderOperationList) resourceProviderOperationListPreparer() (*http.Request, error) { + if rpol.NextLink == nil || len(to.String(rpol.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rpol.NextLink))) +} + +// ResourceProviderOperationListPage contains a page of ResourceProviderOperationDefinition values. +type ResourceProviderOperationListPage struct { + fn func(ResourceProviderOperationList) (ResourceProviderOperationList, error) + rpol ResourceProviderOperationList +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ResourceProviderOperationListPage) Next() error { + next, err := page.fn(page.rpol) + if err != nil { + return err + } + page.rpol = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ResourceProviderOperationListPage) NotDone() bool { + return !page.rpol.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ResourceProviderOperationListPage) Response() ResourceProviderOperationList { + return page.rpol +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ResourceProviderOperationListPage) Values() []ResourceProviderOperationDefinition { + if page.rpol.IsEmpty() { + return nil + } + return *page.rpol.Value +} + +// Sku model representing SKU for Azure Dev Spaces Controller. +type Sku struct { + // Name - The name of the SKU for Azure Dev Spaces Controller. + Name *string `json:"name,omitempty"` + // Tier - The tier of the SKU for Azure Dev Spaces Controller. Possible values include: 'Standard' + Tier SkuTier `json:"tier,omitempty"` +} + +// TrackedResource the resource model definition for a ARM tracked top level resource. +type TrackedResource struct { + // Tags - Tags for the Azure resource. + Tags map[string]*string `json:"tags"` + // Location - Region where the Azure resource is located. + Location *string `json:"location,omitempty"` + // ID - Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - The name of the resource. + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + if tr.ID != nil { + objectMap["id"] = tr.ID + } + if tr.Name != nil { + objectMap["name"] = tr.Name + } + if tr.Type != nil { + objectMap["type"] = tr.Type + } + return json.Marshal(objectMap) +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/devspaces/mgmt/2018-06-01-preview/devspaces/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/devspaces/mgmt/2018-06-01-preview/devspaces/operations.go new file mode 100644 index 000000000000..baa7963ae1ae --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/devspaces/mgmt/2018-06-01-preview/devspaces/operations.go @@ -0,0 +1,126 @@ +package devspaces + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OperationsClient is the dev Spaces Client +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all the supported operations by the Microsoft.DevSpaces resource provider along with their description. +func (client OperationsClient) List(ctx context.Context) (result ResourceProviderOperationListPage, err error) { + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "devspaces.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.rpol.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devspaces.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.rpol, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devspaces.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.DevSpaces/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result ResourceProviderOperationList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(lastResults ResourceProviderOperationList) (result ResourceProviderOperationList, err error) { + req, err := lastResults.resourceProviderOperationListPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devspaces.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devspaces.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devspaces.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result ResourceProviderOperationListIterator, err error) { + result.page, err = client.List(ctx) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/devspaces/mgmt/2018-06-01-preview/devspaces/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/devspaces/mgmt/2018-06-01-preview/devspaces/version.go new file mode 100644 index 000000000000..4185bde52c4e --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/devspaces/mgmt/2018-06-01-preview/devspaces/version.go @@ -0,0 +1,30 @@ +package devspaces + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " devspaces/2018-06-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/vendor/vendor.json b/vendor/vendor.json index f4221aa2cb82..230e6872b37f 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -218,6 +218,14 @@ "version": "v21.3.0", "versionExact": "v21.3.0" }, + { + "checksumSHA1": "wGW3tQ2ARxHa8qNWfNY0yiqWEmU=", + "path": "github.com/Azure/azure-sdk-for-go/services/preview/devspaces/mgmt/2018-06-01-preview/devspaces", + "revision": "da91af54816b4cf72949c225a2d0980f51fab01b", + "revisionTime": "2018-10-19T17:11:53Z", + "version": "v21.3.0", + "versionExact": "v21.3.0" + }, { "checksumSHA1": "P5j/WdC8zYfnoyr7VSyPjvozy4Q=", "path": "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns", diff --git a/website/azurerm.erb b/website/azurerm.erb index 10f0e8b33f65..a2418b22da82 100644 --- a/website/azurerm.erb +++ b/website/azurerm.erb @@ -561,6 +561,17 @@ + > + DevSpace Resources + + + > Dev Test Resources